Commit b6d5296f authored by Boxiang Sun's avatar Boxiang Sun

slapos_subscription_request: Generate QRCode base on the code_url which returned by Wechat

parent 3c54323f
# inspired by Pack_generateCode128BarcodeImage in sanef-evl project
return context.Base_generateBarcodeImage('qrcode', code_url)
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="PythonScript" module="Products.PythonScripts.PythonScript"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>Script_magic</string> </key>
<value> <int>3</int> </value>
</item>
<item>
<key> <string>_bind_names</string> </key>
<value>
<object>
<klass>
<global name="NameAssignments" module="Shared.DC.Scripts.Bindings"/>
</klass>
<tuple/>
<state>
<dictionary>
<item>
<key> <string>_asgns</string> </key>
<value>
<dictionary>
<item>
<key> <string>name_container</string> </key>
<value> <string>container</string> </value>
</item>
<item>
<key> <string>name_context</string> </key>
<value> <string>context</string> </value>
</item>
<item>
<key> <string>name_m_self</string> </key>
<value> <string>script</string> </value>
</item>
<item>
<key> <string>name_subpath</string> </key>
<value> <string>traverse_subpath</string> </value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</state>
</object>
</value>
</item>
<item>
<key> <string>_params</string> </key>
<value> <string>code_url</string> </value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>Base_generateWechatQRCodeFromCodeURL</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
...@@ -3,27 +3,20 @@ from DateTime import DateTime ...@@ -3,27 +3,20 @@ from DateTime import DateTime
if REQUEST is not None: if REQUEST is not None:
raise Unauthorized raise Unauthorized
# You always needs a user here # You always needs a user here
person, person_is_new = context.SubscriptionRequest_createUser(email, user_input_dict['name']) person, person_is_new = context.SubscriptionRequest_createUser(email, user_input_dict['name'])
web_site = context.getWebSiteValue() web_site = context.getWebSiteValue()
# Check if user is already exist, otherwise redirect to ask confirmation
# order.js seems use SubscriptionRequestModule_requestSubscriptionProxy abused... # if payment mode not selected, ask user to confirm and select one.
# In the first time, order.js call SubscriptionRequestModule_requestSubscriptionProxy if not payment_mode:
# which the "payment_mode" is not selected yet.
# which will use payzen by default
# we should always let user confirm and select payment mode
if confirmation_required:
# if confirmation_required and not person_is_new:
base_url = web_site.absolute_url() base_url = web_site.absolute_url()
return context.REQUEST.RESPONSE.redirect( return context.REQUEST.RESPONSE.redirect(
"%s/#order_confirmation?name=%s&email=%s&amount=%s&subscription_reference=%s" % ( "%s/#order_confirmation?name=%s&email=%s&amount=%s&subscription_reference=%s" % (
base_url, base_url,
person.getTitle(), person.getTitle(),
person.getDefaultEmailText(), email,
user_input_dict["amount"], user_input_dict["amount"],
subscription_reference)) subscription_reference))
...@@ -53,10 +46,11 @@ if batch_mode: ...@@ -53,10 +46,11 @@ if batch_mode:
if payment_mode == "wechat": if payment_mode == "wechat":
portal = context.getPortalObject() portal = context.getPortalObject()
code_url = portal.Base_getWechatCodeURL(subscription_request.getId(), payment.PaymentTransaction_getTotalPayablePrice(), user_input_dict["amount"]) code_url = portal.Base_getWechatCodeURL(subscription_request.getId(), payment.PaymentTransaction_getTotalPayablePrice(), user_input_dict["amount"])
code_url = "weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00"
web_site = context.getWebSiteValue() web_site = context.getWebSiteValue()
base_url = web_site.absolute_url() base_url = web_site.absolute_url()
return context.REQUEST.RESPONSE.redirect( return context.REQUEST.RESPONSE.redirect(
"%s/#wechat_payment?amount=%s" % (base_url, user_input_dict["amount"])) "%s/#wechat_payment?amount=%s&code_url=%s" % (base_url, user_input_dict["amount"], code_url))
def wrapRedirectWithShadow(payment_transaction, web_site): def wrapRedirectWithShadow(payment_transaction, web_site):
return payment_transaction.PaymentTransaction_redirectToManualPayzenPayment(web_site) return payment_transaction.PaymentTransaction_redirectToManualPayzenPayment(web_site)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment