Jelajahi Sumber

增加苹果内购

15954078560 2 tahun lalu
induk
melakukan
be22b43f18
2 mengubah file dengan 21 tambahan dan 12 penghapusan
  1. 14 12
      application/api/controller/Money.php
  2. 7 0
      application/api/controller/User.php

+ 14 - 12
application/api/controller/Money.php

@@ -319,7 +319,7 @@ class Money extends Common
     }
 
     // 内购支付回调
-    public function result() {
+    public function iosresult() {
         //苹果内购的验证收据
         $receipt_data = input('apple_receipt', '', 'trim');
         $order_no = input('order_no', '', 'trim');
@@ -346,7 +346,7 @@ class Money extends Common
         }
 
         // 验证支付状态
-        $result = $this->validate_apple_pay($receipt_data, $vipConfigInfo['bundle_id']);
+        $result = $this->validate_apple_pay($receipt_data);
         if (!$result['status']) {
             // 验证不通过
             //error_log(print_r($result, 1), 3, './result.txt');
@@ -356,7 +356,8 @@ class Money extends Common
         $count = count($result['data']['receipt']['in_app']);
         $use_count = $count - 1;
         //p($apple_id);p($result['data']['receipt']['in_app'][$use_count]['product_id']);die;
-        if ($result['data']['receipt']['in_app'][$use_count]['product_id'] != 'com.lnkj.authentication.3') {
+//        if ($result['data']['receipt']['in_app'][$use_count]['product_id'] != 'com.lnkj.authentication.3') {
+        if ($result['data']['receipt']['in_app'][$use_count]['product_id'] != $vipConfigInfo['product_id']) {
             $this->error('非法请求,请立刻停止');
         }
 
@@ -401,7 +402,7 @@ class Money extends Common
      * @param string $receipt_data 付款后凭证
      * @return array                验证是否成功
      */
-    function validate_apple_pay($receipt_data = '', $bundle_id = '') {
+    function validate_apple_pay($receipt_data = '') {
         // 验证参数
         if (strlen($receipt_data) < 20) {
             $result = array(
@@ -420,17 +421,17 @@ class Money extends Common
         }
 
         // 如果是沙盒数据 则验证沙盒模式 21008;正式数据 21007
-        if ($data['status'] == '21007') {
-            // 请求验证
-            $html = $this->curl($receipt_data, 1);
-            $data = json_decode($html, true);
-            $data['sandbox'] = '1';
-        }
+//        if ($data['status'] == '21007') {
+//            // 请求验证
+//            $html = $this->curl($receipt_data, 1);
+//            $data = json_decode($html, true);
+//            $data['sandbox'] = '1';
+//        }
         if (isset($_GET['debug'])) {
             exit(json_encode($data));
         }
 //        if ($data['receipt']['bundle_id'] != 'com.liuniukeji.mayivideo') {
-        if ($data['receipt']['bundle_id'] != $bundle_id) {
+        if ($data['receipt']['bundle_id'] != 'com.nuoruiyang.fate') {
             $result = array(
                 'status' => false,
                 'message' => '非法请求',
@@ -475,7 +476,8 @@ class Money extends Common
         $url_buy = "https://buy.itunes.apple.com/verifyReceipt";
         $url_sandbox = "https://sandbox.itunes.apple.com/verifyReceipt";
 
-        if ($sandbox > 0) {
+//        if ($sandbox > 0) {
+        if (config('site.ios_pay_sandbox') > 0) {
             $url = $url_buy;
         } else {
             $url = $url_sandbox;

+ 7 - 0
application/api/controller/User.php

@@ -1641,6 +1641,13 @@ class User extends Api
         $this->success('钻石', $list);
     }
 
+    //iOS钻石列表
+    public function getdiamondios() {
+        $list = Db::name('diamond_ios')->order('weigh', 'asc')->select();
+
+        $this->success('钻石', $list);
+    }
+
     //钻石支付有眼缘
     public function diamondpayfate() {
         $fate_user_id = $this->request->request('fate_user_id'); // 被眼缘用户ID