dever 6 anos atrás
pai
commit
a816dd0067
2 arquivos alterados com 19 adições e 8 exclusões
  1. 4 2
      doc/apidoc.php
  2. 15 6
      main/src/Journal.php

+ 4 - 2
doc/apidoc.php

@@ -846,17 +846,18 @@
  */
 
 /**
- * @api {get} wonderful/main/?l=journal.buy_action 发起微信支付
+ * @api {get} wonderful/main/?l=journal.buy_action 发起支付
  * @apiVersion 1.0.0
  * @apiName journal.buy_action
  * @apiGroup Journal
  *
- * @apiDescription 发起微信支付
+ * @apiDescription 发起支付:请注意,如果是苹果支付,请在发起苹果支付之后,将苹果返回的验证数据,传入该接口
  *
  * @apiParam {String} signature signature
  * @apiParam {String} journal_id 小刊id
  * @apiParam {String} buy_id 购买本数id
  * @apiParam {String} source_signature 分享人的signature,scene参数中的source_signature,用完请删除该参数。
+ * @apiParam {String} receipt 当header中的source_type为ios时,请传入该参数,参数的值为苹果支付后返回的参数,即可发起支付验证。
 *
  * @apiSuccess {Object[]} pay 微信支付返回的数据
  * @apiSuccess {String}   pay.time 服务器时间戳
@@ -864,6 +865,7 @@
  * @apiSuccess {String}   pay.prepay_id 统一下单接口返回的 prepay_id 参数值,通过'prepay_id=' + prepay_id 拼装成package
  * @apiSuccess {String}   pay.sign_type 签名算法
  * @apiSuccess {String}   pay.sign 签名
+ * @apiSuccess {String}   pay.yes 苹果支付时显示改参数,1为支付成功2为支付失败
  */
 
 /**

+ 15 - 6
main/src/Journal.php

@@ -498,13 +498,18 @@ class Journal extends Core
 
         $source_type = Dever::input('source_type');
 
-        if ($source_type == 'ios' || $source_type == 'android') {
-            $method = 'app';
-            if ($source_type == 'ios') {
-                $order_data['system'] = 3;
-            } else {
-                $order_data['system'] = 4;
+        if ($source_type == 'ios') {
+            $method = 'apple';
+            $order_data['system'] = 3;
+            $account_id = 3;
+            # 使用苹果内购支付
+            $receipt = Dever::input('receipt');
+            if (!$receipt) {
+                Dever::alert('苹果内购支付失败,没有receipt参数');
             }
+        } elseif ($source_type == 'android') {
+            $method = 'app';
+            $order_data['system'] = 4;
             $account_id = 3;
         } else {
             $method = 'applet';
@@ -562,6 +567,10 @@ class Journal extends Core
             'order_id' => $order_id,
         );
 
+        if ($method == 'apple') {
+            $param['other'] = $receipt;
+        }
+
         $this->data['pay'] = Dever::load('pay/api.' . $method, $param);
 
         if ($order_data['system'] == 1) {