|
@@ -92,7 +92,7 @@ class CloudVodView(View):
|
|
|
elif operation == 'payOK':
|
|
|
return self.do_pay_ok()
|
|
|
elif operation == 'payError':
|
|
|
- return self.do_pay_ok()
|
|
|
+ return self.do_pay_error()
|
|
|
else:
|
|
|
token = request_dict.get('token', None)
|
|
|
# 设备主键uid
|
|
@@ -113,24 +113,188 @@ class CloudVodView(View):
|
|
|
else:
|
|
|
return response.json(414)
|
|
|
|
|
|
- def do_pay_ok(self):
|
|
|
+ def do_pay_error(self):
|
|
|
response = HttpResponse()
|
|
|
response.status_code = 200
|
|
|
+ # response.content = '''
|
|
|
+ # <!DOCTYPE html>
|
|
|
+ # <html lang="en">
|
|
|
+ # <head>
|
|
|
+ # <meta charset="UTF-8">
|
|
|
+ # <title>Title</title>
|
|
|
+ # </head>
|
|
|
+ # <body>
|
|
|
+ # <div class="content"
|
|
|
+ # style="text-align:center;overflow: hidden;padding:20% 10% 10% 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;min-height: 300px">
|
|
|
+ # <span style="padding: 10px 20px; font-size: 48px;background-color: #EB6F5A;border-radius:4px;color:#fff;">付款失败</span>
|
|
|
+ # </div>
|
|
|
+ # </body>
|
|
|
+ # </html>
|
|
|
+ # '''
|
|
|
+ response.content = '''
|
|
|
+ <!DOCTYPE html>
|
|
|
+<html>
|
|
|
+<head>
|
|
|
+ <title>拦截跳转实现通信</title>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport"
|
|
|
+ content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
|
|
+ <script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.12.4/jquery.js"></script>
|
|
|
+
|
|
|
+ <style type="text/css">
|
|
|
+ .btn {
|
|
|
+ background-color: #aaa;
|
|
|
+ height: 40px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ color: #444444;
|
|
|
+ text-decoration: none;
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #response {
|
|
|
+ background: #eeeeee;
|
|
|
+ word-wrap: break-word;
|
|
|
+ display: block;
|
|
|
+ outline: 1px solid #ccc;
|
|
|
+ padding: 5px;
|
|
|
+ margin: 5px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+</head>
|
|
|
+<body>
|
|
|
+<p style="color: red">嵌入页区域</p>
|
|
|
+<p>以拦截跳转链接的方式实现</p>
|
|
|
+<input type="text" id="loginInputID">
|
|
|
+<button class="btn" id="login">发起APP登录</button>
|
|
|
+<input type="text" id="shareInputID">
|
|
|
+<button class="btn" id="share">发起社交化分享</button>
|
|
|
+
|
|
|
+<pre id="response"></pre>
|
|
|
+<script>
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示响应信息
|
|
|
+ * @param response 响应信心
|
|
|
+ */
|
|
|
+ function showResponse(response) {
|
|
|
+ $('#response').text(response);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ $(function () {
|
|
|
+ $('#login').click(function () {
|
|
|
+ let loginInputVal = $('#loginInputID').val()
|
|
|
+ alert(loginInputVal)
|
|
|
+ window.location = loginInputVal;
|
|
|
+ //window.location = 'app://login?account=13011112222&password=123456';
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#share').click(function () {
|
|
|
+ let shareInputVal = $('#shareInputID').val()
|
|
|
+ alert(shareInputVal)
|
|
|
+ window.location = shareInputVal
|
|
|
+ //window.location = 'app://share?title=分享的标题&desc=分享的描述'
|
|
|
+ });
|
|
|
+ });
|
|
|
+</script>
|
|
|
+</body>
|
|
|
+</html>
|
|
|
+
|
|
|
+ '''
|
|
|
+ return response
|
|
|
+
|
|
|
+ def do_pay_ok(self):
|
|
|
+ response = HttpResponse()
|
|
|
+ # response.status_code = 200
|
|
|
+ # response.content = '''
|
|
|
+ # <!DOCTYPE html>
|
|
|
+ # <html lang="en">
|
|
|
+ # <head>
|
|
|
+ # <meta charset="UTF-8">
|
|
|
+ # <title>Title</title>
|
|
|
+ # </head>
|
|
|
+ # <body>
|
|
|
+ # <div class="content"
|
|
|
+ # style="text-align:center;overflow: hidden;padding:20% 10% 10% 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;min-height: 300px">
|
|
|
+ # <span style="padding: 10px 20px; font-size: 48px;background-color: #EB6F5A;border-radius:4px;color:#fff;">付款成功</span>
|
|
|
+ # </div>
|
|
|
+ # </body>
|
|
|
+ # </html>
|
|
|
+ # '''
|
|
|
response.content = '''
|
|
|
- <!DOCTYPE html>
|
|
|
- <html lang="en">
|
|
|
- <head>
|
|
|
- <meta charset="UTF-8">
|
|
|
- <title>Title</title>
|
|
|
- </head>
|
|
|
- <body>
|
|
|
- <div class="content"
|
|
|
- style="text-align:center;overflow: hidden;padding:20% 10% 10% 10%;margin:0 10%;background-color: #fff;box-shadow:0 4px 20px rgba(0,0,0,0.1);word-break: break-all;min-height: 300px">
|
|
|
- <span style="padding: 10px 20px; font-size: 48px;background-color: #EB6F5A;border-radius:4px;color:#fff;">付款成功</span>
|
|
|
- </div>
|
|
|
- </body>
|
|
|
- </html>
|
|
|
- '''
|
|
|
+ <!DOCTYPE html>
|
|
|
+ <html>
|
|
|
+ <head>
|
|
|
+ <title>拦截跳转实现通信</title>
|
|
|
+ <meta charset="UTF-8">
|
|
|
+ <meta name="viewport"
|
|
|
+ content="width=device-width,initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=no"/>
|
|
|
+ <script type="text/javascript" src="https://cdn.staticfile.org/jquery/1.12.4/jquery.js"></script>
|
|
|
+
|
|
|
+ <style type="text/css">
|
|
|
+ .btn {
|
|
|
+ background-color: #aaa;
|
|
|
+ height: 40px;
|
|
|
+ display: flex;
|
|
|
+ justify-content: center;
|
|
|
+ align-items: center;
|
|
|
+ color: #444444;
|
|
|
+ text-decoration: none;
|
|
|
+ margin-top: 10px;
|
|
|
+ }
|
|
|
+
|
|
|
+ #response {
|
|
|
+ background: #eeeeee;
|
|
|
+ word-wrap: break-word;
|
|
|
+ display: block;
|
|
|
+ outline: 1px solid #ccc;
|
|
|
+ padding: 5px;
|
|
|
+ margin: 5px;
|
|
|
+ }
|
|
|
+ </style>
|
|
|
+ </head>
|
|
|
+ <body>
|
|
|
+ <p style="color: red">嵌入页区域</p>
|
|
|
+ <p>以拦截跳转链接的方式实现</p>
|
|
|
+ <input type="text" id="loginInputID">
|
|
|
+ <button class="btn" id="login">发起APP登录</button>
|
|
|
+ <input type="text" id="shareInputID">
|
|
|
+ <button class="btn" id="share">发起社交化分享</button>
|
|
|
+
|
|
|
+ <pre id="response"></pre>
|
|
|
+ <script>
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 显示响应信息
|
|
|
+ * @param response 响应信心
|
|
|
+ */
|
|
|
+ function showResponse(response) {
|
|
|
+ $('#response').text(response);
|
|
|
+ return response;
|
|
|
+ }
|
|
|
+
|
|
|
+ $(function () {
|
|
|
+ $('#login').click(function () {
|
|
|
+ let loginInputVal = $('#loginInputID').val()
|
|
|
+ alert(loginInputVal)
|
|
|
+ window.location = loginInputVal;
|
|
|
+ //window.location = 'app://login?account=13011112222&password=123456';
|
|
|
+ });
|
|
|
+
|
|
|
+ $('#share').click(function () {
|
|
|
+ let shareInputVal = $('#shareInputID').val()
|
|
|
+ alert(shareInputVal)
|
|
|
+ window.location = shareInputVal
|
|
|
+ //window.location = 'app://share?title=分享的标题&desc=分享的描述'
|
|
|
+ });
|
|
|
+ });
|
|
|
+ </script>
|
|
|
+ </body>
|
|
|
+ </html>
|
|
|
+
|
|
|
+ '''
|
|
|
return response
|
|
|
|
|
|
# next
|
|
@@ -343,6 +507,8 @@ class CloudVodView(View):
|
|
|
PayerID = request_dict.get('PayerID', None)
|
|
|
orderID = request_dict.get('orderID', None)
|
|
|
if not paymentId or not PayerID or not orderID:
|
|
|
+ red_url = "{SERVER_DOMAIN}cloudVod/payError".format(SERVER_DOMAIN=SERVER_DOMAIN)
|
|
|
+ return HttpResponseRedirect(red_url)
|
|
|
return response.json(444, 'paymentId,PayerID,orderID')
|
|
|
paypalrestsdk.configure({
|
|
|
"mode": "sandbox", # sandbox or live
|
|
@@ -354,6 +520,8 @@ class CloudVodView(View):
|
|
|
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.error) # Error Hash
|
|
|
return response.json(10, payment.error)
|
|
|
print("Payment execute successfully")
|