Преглед на файлове

修改paypal自动续费钩子响应失败回调
添加paypal钩子响应日志

lang преди 3 години
родител
ревизия
15fbf02839
променени са 2 файла, в които са добавени 18 реда и са изтрити 12 реда
  1. 13 12
      Controller/PaymentCycle.py
  2. 5 0
      Service/TemplateService.py

+ 13 - 12
Controller/PaymentCycle.py

@@ -174,17 +174,16 @@ class PaypalCycleNotify(View):
         order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
                                      "userID__userID",
                                      "userID__username", 'coupon_id')
+        if not orderID:
+            print("not orderID")
+            red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+            if lang != 'cn':
+                red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+            return HttpResponseRedirect(red_url)
+        UID = order_list[0]['UID']
         try:
-            if not orderID:
-                print("not orderID")
-                red_url = "{SERVER_DOMAIN_SSL}web/paid2/fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
-                if lang != 'cn':
-                    red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_fail.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
-                return HttpResponseRedirect(red_url)
-
             userid = order_list[0]['userID__userID']
             username = order_list[0]['userID__username']
-            UID = order_list[0]['UID']
             channel = order_list[0]['channel']
             rank = order_list[0]['rank']
             smqs = Store_Meal.objects.filter(id=rank). \
@@ -271,10 +270,12 @@ class PaypalCycleNotify(View):
                 red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
                 if lang != 'cn':
                     red_url = "{SERVER_DOMAIN_SSL}web/paid2/en_success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
+                logger.info('{UID}成功开通paypal自动续费:----'.format(UID=UID))
                 return HttpResponseRedirect(red_url)
         except Exception as e:
             print(repr(e))
             logger.info('do_paypal_cycle_return支付失败:----')
+            logger.info('{UID}开通paypal自动续费失败'.format(UID=UID))
             logger.info("错误行数:{errLine}".format(errLine=e.__traceback__.tb_lineno))
             logger.info(repr(e))
             if order_qs:
@@ -345,7 +346,7 @@ class PaypalCycleNotify(View):
                     oldOrderID = billing_agreement.description
                     order_qs = Order_Model.objects.filter(orderID=oldOrderID, status=1)
                     if not order_qs:
-                        return HttpResponse('fail')
+                        return HttpResponse('fail', status=500)
                     order_list = order_qs.values("UID", "channel", "commodity_code", "rank", "isSelectDiscounts",
                                                  "userID__userID","uid_bucket_id",
                                                  "userID__username",'plan_id','addTime','desc','payType','currency','commodity_type','updTime')
@@ -365,7 +366,7 @@ class PaypalCycleNotify(View):
                         values("day", "bucket_id", "bucket__storeDay", "expire")
                     bucketId = smqs[0]['bucket_id']
                     if not smqs.exists():
-                        return HttpResponse('fail')
+                        return HttpResponse('fail', status=500)
                     # ##
                     ubqs = UID_Bucket.objects.filter(uid=UID).values("id", "bucket_id", "bucket__storeDay",
                                                                      "bucket__region",
@@ -458,7 +459,7 @@ class PaypalCycleNotify(View):
                             }
                         ]
                         billing_agreement.replace(billing_agreement_update_attributes)
-
+                        logger.info('{UID}成功续费paypal:----'.format(UID=UID))
                         return HttpResponse('success')
                 except Exception as e:
                     print(e)
@@ -467,7 +468,7 @@ class PaypalCycleNotify(View):
                     logger.info('do_paypal_webhook_notify支付失败:----')
                     logger.info("错误行数:{errLine}".format(errLine=e.__traceback__.tb_lineno))
                     logger.info(repr(e))
-                    return HttpResponse('fail')
+                    return HttpResponse('fail', status=500)
         return HttpResponse('fail')
 
 

+ 5 - 0
Service/TemplateService.py

@@ -85,6 +85,11 @@ class TemplateService:
             'Cloudsum/userappversion',
             'Cloudsum/usercount',
             'Cloudsum/usercloud',
+            'paymentCycle/queryPayCycle',
+            'paymentCycle/cancelPayCycle',
+            'payCycle/paypalCycleNotify',
+            'payCycle/paypalCycleReturn',
+            'payCycle/test',
         ]
         return apiList