Browse Source

修复paypal异步回调失败问题

lang 3 years ago
parent
commit
42d993f3f3
1 changed files with 6 additions and 3 deletions
  1. 6 3
      Controller/PaymentCycle.py

+ 6 - 3
Controller/PaymentCycle.py

@@ -319,7 +319,8 @@ class PaypalCycleNotify(View):
                                                  "userID__userID","uid_bucket_id",
                                                  "userID__username",'plan_id','addTime','desc','payType','currency','commodity_type','updTime')
                     nowTime = int(time.time())
-                    if order_list[0]['userID__userID'] + 9200 > nowTime:  #避免续费订单重复支付
+                    if order_list[0]['addTime'] + 9200 > nowTime:  #避免续费订单重复支付
+                        logger.info('-----------------------paypal重复异步回调')
                         return HttpResponse('success')
 
                     userid = order_list[0]['userID__userID']
@@ -426,6 +427,8 @@ class PaypalCycleNotify(View):
                         return HttpResponse('success')
                 except Exception as e:
                     print(e)
+                    logger.info('-----------------------paypal异步回调失败')
+                    logger.info(e)
                     return HttpResponse('fail')
         return HttpResponse('fail')
 
@@ -433,10 +436,10 @@ class PaypalCycleNotify(View):
     def do_test(self, request_dict, request, response):
         paypalrestsdk.configure(PAYPAL_CRD)
         billing_agreement = paypalrestsdk.BillingAgreement
-        billing_agreement = billing_agreement.find("I-HT38K76XPMGJ")
+        billing_agreement = billing_agreement.find("I-17SRPP7TS71U")
         print("Got Billing Agreement Details for Billing Agreement[%s]" % (
             billing_agreement.id))
-        exit()
+        exit(billing_agreement)
         #normal_pay
         # json_str = '{"id":"WH-8SU832847J141682K-0FF265943E8692615","event_version":"1.0","create_time":"2022-01-10T06:31:49.863Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 0.02 USD","resource":{"amount":{"total":"0.02","currency":"USD","details":{"subtotal":"0.02"}},"payment_mode":"INSTANT_TRANSFER","create_time":"2022-01-10T06:31:45Z","transaction_fee":{"currency":"USD","value":"0.02"},"parent_payment":"PAYID-MHN5E5Y1RH70069CT417990V","update_time":"2022-01-10T06:31:45Z","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","application_context":{"related_qualifiers":[{"id":"0FJ93448LU7282046","type":"CART"}]},"protection_eligibility":"ELIGIBLE","links":[{"method":"GET","rel":"self","href":"https://api.sandbox.paypal.com/v1/payments/sale/6N498138TH641260G"},{"method":"POST","rel":"refund","href":"https://api.sandbox.paypal.com/v1/payments/sale/6N498138TH641260G/refund"},{"method":"GET","rel":"parent_payment","href":"https://api.sandbox.paypal.com/v1/payments/payment/PAYID-MHN5E5Y1RH70069CT417990V"}],"id":"6N498138TH641260G","state":"completed","invoice_number":""},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-8SU832847J141682K-0FF265943E8692615","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-8SU832847J141682K-0FF265943E8692615/resend","rel":"resend","method":"POST"}]}'
         json_agreement_str = '{"id":"WH-9BE23393R5338163R-48P08088YL173821A","event_version":"1.0","create_time":"2022-01-10T10:27:42.925Z","resource_type":"sale","event_type":"PAYMENT.SALE.COMPLETED","summary":"Payment completed for $ 0.02 USD","resource":{"billing_agreement_id":"I-K8PCK2NJC6N6","amount":{"total":"0.02","currency":"USD","details":{"subtotal":"0.02"}},"payment_mode":"INSTANT_TRANSFER","update_time":"2022-01-10T10:27:19Z","create_time":"2022-01-10T10:27:19Z","protection_eligibility_type":"ITEM_NOT_RECEIVED_ELIGIBLE,UNAUTHORIZED_PAYMENT_ELIGIBLE","transaction_fee":{"currency":"USD","value":"0.02"},"protection_eligibility":"ELIGIBLE","links":[{"method":"GET","rel":"self","href":"https://api.sandbox.paypal.com/v1/payments/sale/4H259512Y67055105"},{"method":"POST","rel":"refund","href":"https://api.sandbox.paypal.com/v1/payments/sale/4H259512Y67055105/refund"}],"id":"4H259512Y67055105","state":"completed","invoice_number":""},"links":[{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-9BE23393R5338163R-48P08088YL173821A","rel":"self","method":"GET"},{"href":"https://api.sandbox.paypal.com/v1/notifications/webhooks-events/WH-9BE23393R5338163R-48P08088YL173821A/resend","rel":"resend","method":"POST"}]}'