|
@@ -395,7 +395,7 @@ class PaypalCycleNotify(View):
|
|
|
PaypalWebHookEventInsert['agreement_desc'] = repr(billing_agreement)
|
|
|
PaypalWebHookEventInsert['agreement_id'] = agreement_id
|
|
|
PaypalWebHookEventInsert['orderID'] = billing_agreement.description
|
|
|
- PaypalWebHookEvent.objects.create(**PaypalWebHookEventInsert)
|
|
|
+ paypal_webhook_event_qs = PaypalWebHookEvent.objects.create(**PaypalWebHookEventInsert)
|
|
|
|
|
|
# 查询订单数据
|
|
|
order_id = billing_agreement.description
|
|
@@ -410,9 +410,6 @@ class PaypalCycleNotify(View):
|
|
|
PAY_LOGGER.info('PayPal周期扣款失败---根据order_id查询订单数据不存在')
|
|
|
return HttpResponse('fail', status=500)
|
|
|
|
|
|
- # 更新PayPal交易号
|
|
|
- order_qs.update(trade_no=paypal_transaction_id)
|
|
|
-
|
|
|
# 判断用户地区是否跟服务器地区匹配
|
|
|
uid = order_qs[0]['UID']
|
|
|
country_id = order_qs[0]['userID__region_country']
|
|
@@ -422,7 +419,7 @@ class PaypalCycleNotify(View):
|
|
|
UID = order_qs[0]['UID']
|
|
|
# PayPal周期扣款首次扣款
|
|
|
if billing_agreement.agreement_details.cycles_completed == '0':
|
|
|
- order_qs.update(status=1, updTime=nowTime)
|
|
|
+ order_qs.update(status=1, trade_no=paypal_transaction_id, updTime=nowTime)
|
|
|
PAY_LOGGER.info('{} PayPal周期扣款首次扣款成功'.format(UID))
|
|
|
return HttpResponse('success')
|
|
|
|
|
@@ -527,7 +524,11 @@ class PaypalCycleNotify(View):
|
|
|
}
|
|
|
}
|
|
|
]
|
|
|
- billing_agreement.replace(billing_agreement_update_attributes)
|
|
|
+ update_status = billing_agreement.replace(billing_agreement_update_attributes)
|
|
|
+
|
|
|
+ # 记录新订单号和更新状态
|
|
|
+ PaypalWebHookEvent.objects.filter(id=paypal_webhook_event_qs.id).update(newOrderID=orderID,
|
|
|
+ update_status=update_status)
|
|
|
PAY_LOGGER.info('{} PayPal周期扣款成功'.format(UID))
|
|
|
return HttpResponse('success')
|
|
|
except Exception as e:
|