Эх сурвалжийг харах

修改记录钩子订阅行为

lang 3 жил өмнө
parent
commit
970519fdca

+ 5 - 6
Controller/PaymentCycle.py

@@ -340,7 +340,6 @@ class PaypalCycleNotify(View):
                 'resource_type': json_obj.get('resource_type'),
                 'event_type': 1,
                 'summary': summary,
-                'agreement_id': billing_agreement_id,
                 'trade_no': paypal_transaction_id,
                 'resource': json_agreement_str,
                 'created_time': int(time.time()),
@@ -359,6 +358,7 @@ class PaypalCycleNotify(View):
 
             agreement_id = paypal_body.get('billing_agreement_id')
             billing_agreement = paypalrestsdk.BillingAgreement.find(agreement_id)
+            logger.info(type(billing_agreement))
             # 记录钩子日志
             PaypalWebHookEventInsert = {
                 'webhook_event_id': json_obj.get('id'),
@@ -531,7 +531,7 @@ class PaypalCycleNotify(View):
             event_type = json_obj.get('event_type')
             summary = json_obj.get('summary')
             resource_type = json_obj.get('resource_type')
-            billing_agreement_id = paypal_body.get('billing_agreement_id')
+            billing_agreement_id = paypal_body.get('id')
             paypal_transaction_id = paypal_body.get('id')
             amount = paypal_body.get('amount')
 
@@ -558,10 +558,9 @@ class PaypalCycleNotify(View):
 
             PaypalWebHookEventInsert = {
                 'webhook_event_id': json_obj.get('id'),
-                'resource_type': json_obj.get('resource_type'),
-                'event_type': 1,
+                'resource_type': resource_type,
+                'event_type': event_type_code,
                 'summary': summary,
-                'agreement_id': billing_agreement_id,
                 'trade_no': paypal_transaction_id,
                 'resource': json_agreement_str,
                 'created_time': int(time.time()),
@@ -584,7 +583,7 @@ class PaypalCycleNotify(View):
             PaypalWebHookEventInsert = {
                 'webhook_event_id': json_obj.get('id'),
                 'resource_type': json_obj.get('resource_type'),
-                'event_type': 1,
+                'event_type': event_type_code,
                 'summary': summary,
                 'agreement_id': billing_agreement_id,
                 'trade_no': paypal_transaction_id,