|
@@ -70,6 +70,7 @@ class Paypal:
|
|
|
billing_plan.activate() # 激活
|
|
|
plan_id = billing_plan.id
|
|
|
else:
|
|
|
+ print(billing_plan.error)
|
|
|
return False
|
|
|
|
|
|
now_time = int(time.time())
|
|
@@ -92,7 +93,6 @@ class Paypal:
|
|
|
if billing_agreement.create():
|
|
|
for link in billing_agreement.links:
|
|
|
if link.rel == "approval_url":
|
|
|
- print("-------------------")
|
|
|
return {"plan_id": plan_id, "url": link.href}
|
|
|
else:
|
|
|
print(billing_agreement.error)
|
|
@@ -118,22 +118,26 @@ class PaypalCycleNotify(View):
|
|
|
elif operation == 'paypalCycleNotify': # paypal 周期付款回调
|
|
|
return self.do_paypal_webhook_notify(request_dict, response)
|
|
|
def do_paypal_cycle_return(self, request_dict, response):
|
|
|
- paymentId = request_dict.get('paymentId', None)
|
|
|
- PayerID = request_dict.get('PayerID', None)
|
|
|
lang = request_dict.get('lang', 'en')
|
|
|
token = request_dict.get('token',None)
|
|
|
paypalrestsdk.configure(PAYPAL_CRD)
|
|
|
billing_agreement = paypalrestsdk.BillingAgreement()
|
|
|
- billing_agreement_response = billing_agreement.execute("EC-93848356GS252673L")
|
|
|
+ billing_agreement_response = billing_agreement.execute(token)
|
|
|
if billing_agreement_response.error:
|
|
|
- return False
|
|
|
+ print(billing_agreement_response.error)
|
|
|
+ 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)
|
|
|
|
|
|
orderID = billing_agreement_response.description
|
|
|
agreement_id = billing_agreement_response.id
|
|
|
+ promotion_rule_id = ''
|
|
|
try:
|
|
|
order_qs = Order_Model.objects.filter(orderID=orderID, status=0)
|
|
|
|
|
|
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)
|
|
@@ -151,7 +155,11 @@ class PaypalCycleNotify(View):
|
|
|
values("day", "bucket_id", "bucket__storeDay", "expire")
|
|
|
bucketId = smqs[0]['bucket_id']
|
|
|
if not smqs.exists():
|
|
|
- return response.json(173)
|
|
|
+ print("not smqs")
|
|
|
+ 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)
|
|
|
# ##
|
|
|
ubqs = UID_Bucket.objects.filter(uid=UID).values("id", "bucket_id", "bucket__storeDay", "bucket__region",
|
|
|
"endTime", "use_status")
|
|
@@ -163,7 +171,6 @@ class PaypalCycleNotify(View):
|
|
|
nowTime = int(time.time())
|
|
|
promotion = PromotionRuleModel.objects.filter(status=1, startTime__lte=nowTime,
|
|
|
endTime__gte=nowTime).values('id','ruleConfig')
|
|
|
- promotion_rule_id = ''
|
|
|
if promotion.exists():
|
|
|
promotion_rule_id = promotion[0]['id']
|
|
|
expire = expire * 2
|
|
@@ -217,7 +224,7 @@ class PaypalCycleNotify(View):
|
|
|
'Dear customer,you already subscribed the cloud storage package successfully for device ' + UID + ' on ' + time.strftime(
|
|
|
"%b %dth,%Y", time.localtime())]
|
|
|
|
|
|
- CloudStorage.CloudStorageView.do_vod_msg_Notice(UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
|
+ CloudStorage.CloudStorageView.do_vod_msg_Notice(self, UID, channel, userid, lang, sys_msg_text_list, 'SMS_219738485')
|
|
|
|
|
|
# return response.json(0)
|
|
|
red_url = "{SERVER_DOMAIN_SSL}web/paid2/success.html".format(SERVER_DOMAIN_SSL=SERVER_DOMAIN_SSL)
|