Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
S
slapos.core
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Boxiang Sun
slapos.core
Commits
9b2eb2f9
Commit
9b2eb2f9
authored
Sep 25, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_subscription_request: Add wechat payment simulation pages
parent
3bd5249c
Changes
10
Hide whitespace changes
Inline
Side-by-side
Showing
10 changed files
with
205 additions
and
8 deletions
+205
-8
master/bt5/slapos_subscription_request/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.py
...plateItem/portal_components/extension.erp5.WechatUtils.py
+19
-4
master/bt5/slapos_subscription_request/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.xml
...lateItem/portal_components/extension.erp5.WechatUtils.xml
+3
-2
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_WechatPaymentSimulation.py
...apos_subscription_request/Base_WechatPaymentSimulation.py
+12
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_WechatPaymentSimulation.xml
...pos_subscription_request/Base_WechatPaymentSimulation.xml
+70
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_finishThePayment.xml
...ins/slapos_subscription_request/Base_finishThePayment.xml
+28
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_generateWechatQRCodeFromCodeURL.py
...scription_request/Base_generateWechatQRCodeFromCodeURL.py
+1
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_generateWechatQRCodeFromCodeURL.xml
...cription_request/Base_generateWechatQRCodeFromCodeURL.xml
+1
-1
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_redirectWechatPaymentSuccessPage.py
...cription_request/Base_redirectWechatPaymentSuccessPage.py
+13
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_redirectWechatPaymentSuccessPage.xml
...ription_request/Base_redirectWechatPaymentSuccessPage.xml
+58
-0
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
...est/SubscriptionRequestModule_requestSubscriptionProxy.py
+0
-1
No files found.
master/bt5/slapos_subscription_request/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.py
View file @
9b2eb2f9
...
...
@@ -9,8 +9,20 @@ class WechatException(Exception):
super
(
WechatException
,
self
).
__init__
(
msg
)
# RapidSpace Wechat acocunt configuration
APP_ID
=
""
# Wechat public account appid
class
Single
(
object
):
_instance
=
None
PAYMENT_DONE
=
False
def
__new__
(
cls
,
*
args
,
**
kw
):
if
cls
.
_instance
is
None
:
cls
.
_instance
=
object
.
__new__
(
cls
,
*
args
,
**
kw
)
return
cls
.
_instance
def
__init__
(
self
):
pass
def
finishThePayment
(
self
):
self
.
APP_ID
=
"XXX"
APP_ID
=
"wxadebca31430703b0"
# Wechat public account appid
MCH_ID
=
""
# Wechat merchant account ID
API_KEY
=
""
# Wechat merchant platform(pay.weixin.qq.com) -->账户设置 -->API安全 -->密钥设置
...
...
@@ -125,7 +137,7 @@ def getWechatQRCodeURL(self, order_id, price, amount):
result_code
=
result_dict_content
[
'result_code'
]
if
result_code
==
"SUCCESS"
:
code_url
=
result_dict_content
[
'code_url'
]
return
code_url
return
"weixin://wxpay/bizpayurl/up?pr=NwY5Mz9&groupid=00"
else
:
print
(
"Error description: {0}"
.
format
(
result_dict_content
.
get
(
"err_code_des"
)))
else
:
...
...
@@ -190,6 +202,8 @@ def queryWechatOrderStatus(self, dict_content):
- transaction_id (str): wechat order number, use this in higher priority, it will return in the payment notify callback
- out_trade_no(str): The order ID used inside ERP5, less than 32 characters, digits, alphabets, and "_-|*@", unique in ERP5
'''
if
APP_ID
==
"XXX"
:
return
"SUCCESS"
if
"transaction_id"
not
in
dict_content
and
"out_trade_no"
not
in
dict_content
:
raise
WechatException
(
"transaction_id or out_trade_no is needed for query the Wechat Order"
)
...
...
@@ -204,7 +218,8 @@ def queryWechatOrderStatus(self, dict_content):
sign
=
calculateSign
(
params
,
API_KEY
)
params
[
"sign"
]
=
sign
# xml_str = convert_dict_to_xml(params)
return
"SUCCESS"
return
None
# return "SUCCESS"
# result = urllib2.Request(QUERY_URL, data=xml_str)
# result_data = urllib2.urlopen(result)
# result_read = result_data.read()
...
...
master/bt5/slapos_subscription_request/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.xml
View file @
9b2eb2f9
...
...
@@ -46,8 +46,9 @@
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple>
<string>
W: 15, 0: Cannot decode using encoding "ascii", unexpected byte at position 63 (invalid-encoded-data)
</string>
<string>
W: 86, 2: Unreachable code (unreachable)
</string>
<string>
W: 27, 0: Cannot decode using encoding "ascii", unexpected byte at position 63 (invalid-encoded-data)
</string>
<string>
W: 98, 2: Unreachable code (unreachable)
</string>
<string>
W:139, 6: Unused variable \'code_url\' (unused-variable)
</string>
</tuple>
</value>
</item>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_WechatPaymentSimulation.py
0 → 100644
View file @
9b2eb2f9
web_site
=
context
.
getWebSiteValue
()
base_url
=
web_site
.
absolute_url
()
# portal = context.getPortalObject()
# subscription_request = portal.subscription_request_module.get(trade_no)
context
.
Base_finishThePayment
()
# if not subscription_request:
# raise Exception("Order not found")
# subscription_request.confirmed()
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
"%s/gadget_rapid_page_order_wechat_simulation_confirm.html/"
%
base_url
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_WechatPaymentSimulation.xml
0 → 100644
View file @
9b2eb2f9
<?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>
trade_no
</string>
</value>
</item>
<item>
<key>
<string>
_proxy_roles
</string>
</key>
<value>
<tuple>
<string>
Anonymous
</string>
</tuple>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_WechatPaymentSimulation
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_finishThePayment.xml
0 → 100644
View file @
9b2eb2f9
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"ExternalMethod"
module=
"Products.ExternalMethod.ExternalMethod"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_function
</string>
</key>
<value>
<string>
finishThePayment
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
WechatUtils
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_finishThePayment
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_generateWechatQRCodeFromCodeURL.py
View file @
9b2eb2f9
# inspired by Pack_generateCode128BarcodeImage in sanef-evl project
code_url
=
code_url
+
"&trade_no="
+
trade_no
return
context
.
Base_generateBarcodeImage
(
'qrcode'
,
code_url
)
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_generateWechatQRCodeFromCodeURL.xml
View file @
9b2eb2f9
...
...
@@ -50,7 +50,7 @@
</item>
<item>
<key>
<string>
_params
</string>
</key>
<value>
<string>
code_url
</string>
</value>
<value>
<string>
code_url
, trade_no
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
...
...
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_redirectWechatPaymentSuccessPage.py
0 → 100644
View file @
9b2eb2f9
# Example code:
# Import a standard function, and get the HTML request and response objects.
from
Products.PythonScripts.standard
import
html_quote
request
=
container
.
REQUEST
response
=
request
.
response
# Return a string identifying this script.
print
"This is the"
,
script
.
meta_type
,
'"%s"'
%
script
.
getId
(),
if
script
.
title
:
print
"(%s)"
%
html_quote
(
script
.
title
),
print
"in"
,
container
.
absolute_url
()
return
printed
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/Base_redirectWechatPaymentSuccessPage.xml
0 → 100644
View file @
9b2eb2f9
<?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>
id
</string>
</key>
<value>
<string>
Base_redirectWechatPaymentSuccessPage
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_subscription_request/SkinTemplateItem/portal_skins/slapos_subscription_request/SubscriptionRequestModule_requestSubscriptionProxy.py
View file @
9b2eb2f9
...
...
@@ -46,7 +46,6 @@ if batch_mode:
if
payment_mode
==
"wechat"
:
portal
=
context
.
getPortalObject
()
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
()
base_url
=
web_site
.
absolute_url
()
return
context
.
REQUEST
.
RESPONSE
.
redirect
(
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment