|
@@ -16,7 +16,7 @@ from django.views.generic.base import View
|
|
|
from Ansjer.config import OSS_STS_ACCESS_KEY, OSS_STS_ACCESS_SECRET, OSS_ROLE_ARN, SERVER_DOMAIN, PAYPAL_CRD, \
|
|
|
CONFIG_INFO, CONFIG_CN
|
|
|
from Model.models import Device_Info, Order_Model, Store_Meal, OssCrdModel, UID_Bucket, StsCrdModel, \
|
|
|
- VodBucketModel, UidSetModel, AiService
|
|
|
+ VodBucketModel, UidSetModel, AiService, LogModel
|
|
|
from Object.AliPayObject import AliPayObject
|
|
|
from Object.ResponseObject import ResponseObject
|
|
|
from Object.TokenObject import TokenObject
|
|
@@ -52,7 +52,7 @@ class CloudVodView(View):
|
|
|
return self.do_getSts(request_dict, ip, response)
|
|
|
# 付款完成
|
|
|
elif operation == 'payExecute':
|
|
|
- return self.do_paypal_execute(request_dict, response)
|
|
|
+ return self.do_paypal_execute(request, request_dict, response)
|
|
|
elif operation == 'payOK':
|
|
|
return self.do_pay_ok()
|
|
|
elif operation == 'payError':
|
|
@@ -397,7 +397,7 @@ class CloudVodView(View):
|
|
|
return HttpResponse(json.dumps(res, ensure_ascii=False),
|
|
|
content_type="application/json,charset=utf-8")
|
|
|
|
|
|
- def do_paypal_execute(self, request_dict, response):
|
|
|
+ def do_paypal_execute(self, request, request_dict, response):
|
|
|
paymentId = request_dict.get('paymentId', None)
|
|
|
PayerID = request_dict.get('PayerID', None)
|
|
|
orderID = request_dict.get('orderID', None)
|
|
@@ -407,13 +407,10 @@ class CloudVodView(View):
|
|
|
paypalrestsdk.configure(PAYPAL_CRD)
|
|
|
# ID of the payment. This ID is provided when creating payment.
|
|
|
payment = paypalrestsdk.Payment.find(paymentId)
|
|
|
- print(payment)
|
|
|
payres = payment.execute({"payer_id": PayerID})
|
|
|
- print(payres)
|
|
|
if not payres:
|
|
|
red_url = "{SERVER_DOMAIN}cloudVod/payError".format(SERVER_DOMAIN=SERVER_DOMAIN)
|
|
|
return HttpResponseRedirect(red_url)
|
|
|
- print("Payment execute successfully")
|
|
|
order_qs = Order_Model.objects.filter(orderID=orderID)
|
|
|
nowTime = int(time.time())
|
|
|
order_qs.update(status=1, updTime=nowTime)
|
|
@@ -450,10 +447,18 @@ class CloudVodView(View):
|
|
|
OssCrdModel.objects.filter(uid=UID, channel=channel).delete()
|
|
|
# 新增模式
|
|
|
else:
|
|
|
- print('create')
|
|
|
UID_Bucket.objects.create(uid=UID, channel=channel,
|
|
|
bucket_id=bucketId, endTime=nowTime + addTime)
|
|
|
- # return response.json(0)
|
|
|
+ log = {
|
|
|
+ 'ip': CommonService.get_ip_address(request),
|
|
|
+ 'user_id': 1,
|
|
|
+ 'status': 200,
|
|
|
+ 'time': nowTime,
|
|
|
+ 'content': json.dumps(request_dict),
|
|
|
+ 'url': 'cloudVod/payExecute',
|
|
|
+ 'operation': '订单{}回调成功'.format(orderID)
|
|
|
+ }
|
|
|
+ LogModel.objects.create(**log)
|
|
|
red_url = "{SERVER_DOMAIN}cloudVod/payOK".format(SERVER_DOMAIN=SERVER_DOMAIN)
|
|
|
return HttpResponseRedirect(red_url)
|
|
|
|