瀏覽代碼

认证订阅打印日志

linhaohong 1 年之前
父節點
當前提交
70c25a85e2
共有 1 個文件被更改,包括 8 次插入2 次删除
  1. 8 2
      Controller/InAppPurchaseController.py

+ 8 - 2
Controller/InAppPurchaseController.py

@@ -64,6 +64,8 @@ class InAppPurchaseView(View):
         uid = request_dict.get('uid', None)
         lang = request_dict.get('lang', 'en')
         channel = request_dict.get('channel', None)
+        logger = logging.getLogger('apple_pay')
+        logger.info(f"认证交易receipt:{receipt}")
 
         if not all([receipt, uid, channel]):
             return response.json(444)
@@ -140,8 +142,8 @@ class InAppPurchaseView(View):
                 transaction_subscription = client.get_all_subscription_statuses(transaction_id)
                 if transaction_subscription.data:
                     for subscription in transaction_subscription.data[0].lastTransactions:
-                        if int(subscription.status) != 2 or int(subscription.status) != 5:
-                            return response.json(10048)
+                        if str(subscription.status) == "Status.ACTIVE":
+                            return response.json(10048, f"订阅状态为 {subscription.status} ")
 
             pay_type = PAY_TYPE_IN_APP_PURCHASE
             now_time = int(time.time())
@@ -346,6 +348,10 @@ class InAppPurchaseView(View):
 
                 return HttpResponse(status=200)
 
+            else:
+                logger.info('App Store服务器通知不是post请求')
+                return HttpResponse(status=400)
+
         except Exception as e:
             logger.info('App Store服务器通知异常:{}'.
                         format('error_line:{}, error_msg:{}'.format(e.__traceback__.tb_lineno, repr(e))))