|
@@ -10,8 +10,8 @@ from django.db.models import Q, F
|
|
|
from django.http import HttpResponseRedirect, HttpResponse
|
|
|
from django.views.generic.base import View
|
|
|
|
|
|
-from Ansjer.config import PAYPAL_CRD, SERVER_DOMAIN_SSL, PAYPAL_WEB_HOOK_ID, PAYPAL_WEB_HOOK_ID_TWO, CONFIG_INFO, \
|
|
|
- CONFIG_US, CONFIG_EUR, VSEES_PAYPAL_WEB_HOOK_ID, VSEES_PAYPAL_WEB_HOOK_ID_TWO
|
|
|
+from Ansjer.config import PAYPAL_CRD, SERVER_DOMAIN_SSL, PAYPAL_WEB_HOOK_ID, CONFIG_INFO, \
|
|
|
+ CONFIG_US, CONFIG_EUR
|
|
|
from Controller import CloudStorage
|
|
|
from Model.models import PayCycleConfigModel, Store_Meal, UID_Bucket, PromotionRuleModel, \
|
|
|
Unused_Uid_Meal, Device_Info, CouponModel, Order_Model, PaypalWebHookEvent, CountryModel, AiService
|
|
@@ -390,10 +390,7 @@ class PaypalCycleNotify(View):
|
|
|
agreement_id = paypal_body.get('billing_agreement_id')
|
|
|
paypal_transaction_id = paypal_body.get('id')
|
|
|
amount = paypal_body.get('amount')
|
|
|
- if 'transaction_fee' in paypal_body:
|
|
|
- fee = paypal_body['transaction_fee']['value']
|
|
|
- else:
|
|
|
- fee = 0
|
|
|
+ fee = paypal_body['transaction_fee']['value'] if 'transaction_fee' in paypal_body else 0
|
|
|
PaypalWebHookEventInsert = {
|
|
|
'webhook_event_id': json_obj.get('id'),
|
|
|
'resource_type': json_obj.get('resource_type'),
|
|
@@ -410,14 +407,14 @@ class PaypalCycleNotify(View):
|
|
|
if resource_type == 'sale' and paypal_body.get('state') == 'completed':
|
|
|
paypalrestsdk.configure(PAYPAL_CRD['Zosi'])
|
|
|
response = paypalrestsdk.WebhookEvent.verify(
|
|
|
- transmission_id, transmission_time, PAYPAL_WEB_HOOK_ID, json_agreement_str, cert_url,
|
|
|
- transmission_sig, auth_algo)
|
|
|
+ transmission_id, transmission_time, PAYPAL_WEB_HOOK_ID['Zosi']['paypalCycleNotify'],
|
|
|
+ json_agreement_str, cert_url, transmission_sig, auth_algo)
|
|
|
app_type = 1
|
|
|
if not response:
|
|
|
paypalrestsdk.configure(PAYPAL_CRD['Vsees'])
|
|
|
response = paypalrestsdk.WebhookEvent.verify(
|
|
|
- transmission_id, transmission_time, VSEES_PAYPAL_WEB_HOOK_ID, json_agreement_str, cert_url,
|
|
|
- transmission_sig, auth_algo)
|
|
|
+ transmission_id, transmission_time, PAYPAL_WEB_HOOK_ID['Vsees']['paypalCycleNotify'],
|
|
|
+ json_agreement_str, cert_url, transmission_sig, auth_algo)
|
|
|
if not response:
|
|
|
PAY_LOGGER.info('PayPal周期扣款失败---签名验证失败')
|
|
|
return HttpResponse('Fail', status=500)
|
|
@@ -722,15 +719,15 @@ class PaypalCycleNotify(View):
|
|
|
# self.get_plan_desc('P-4CG284532S612303METMEINY')
|
|
|
paypalrestsdk.configure(PAYPAL_CRD['Zosi'])
|
|
|
response = paypalrestsdk.WebhookEvent.verify(
|
|
|
- transmission_id, transmission_time, PAYPAL_WEB_HOOK_ID_TWO, json_agreement_str, cert_url,
|
|
|
- transmission_sig, auth_algo)
|
|
|
+ transmission_id, transmission_time, PAYPAL_WEB_HOOK_ID['Zosi']['subscriptionBreakNotify'],
|
|
|
+ json_agreement_str, cert_url, transmission_sig, auth_algo)
|
|
|
logger.info('----验证签名----')
|
|
|
logger.info(response)
|
|
|
if not response:
|
|
|
paypalrestsdk.configure(PAYPAL_CRD['Vsees'])
|
|
|
response = paypalrestsdk.WebhookEvent.verify(
|
|
|
- transmission_id, transmission_time, VSEES_PAYPAL_WEB_HOOK_ID_TWO, json_agreement_str, cert_url,
|
|
|
- transmission_sig, auth_algo)
|
|
|
+ transmission_id, transmission_time, PAYPAL_WEB_HOOK_ID['Vsees']['subscriptionBreakNotify'],
|
|
|
+ json_agreement_str, cert_url, transmission_sig, auth_algo)
|
|
|
logger.info('----验证签名----')
|
|
|
logger.info(response)
|
|
|
if not response:
|