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
c1799cde
Commit
c1799cde
authored
Sep 27, 2019
by
Boxiang Sun
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
slapos_wechat: Add Wechat payment support
parent
406cb85e
Changes
20
Show whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
945 additions
and
0 deletions
+945
-0
master/bt5/slapos_wechat/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.py
...plateItem/portal_components/extension.erp5.WechatUtils.py
+258
-0
master/bt5/slapos_wechat/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.xml
...lateItem/portal_components/extension.erp5.WechatUtils.xml
+124
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat.xml
...os_wechat/SkinTemplateItem/portal_skins/slapos_wechat.xml
+47
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_generateWechatQRCodeFromCodeURL.py
...ins/slapos_wechat/Base_generateWechatQRCodeFromCodeURL.py
+2
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_generateWechatQRCodeFromCodeURL.xml
...ns/slapos_wechat/Base_generateWechatQRCodeFromCodeURL.xml
+62
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_getWechatCodeURL.xml
...Item/portal_skins/slapos_wechat/Base_getWechatCodeURL.xml
+28
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_queryWechatOrderStatusByTradeNo.py
...ins/slapos_wechat/Base_queryWechatOrderStatusByTradeNo.py
+4
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_queryWechatOrderStatusByTradeNo.xml
...ns/slapos_wechat/Base_queryWechatOrderStatusByTradeNo.xml
+62
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_receiveWechatPaymentNotify.xml
...l_skins/slapos_wechat/Base_receiveWechatPaymentNotify.xml
+28
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_getWechatPaymentConfiguration.py
...s/slapos_wechat/ERP5Site_getWechatPaymentConfiguration.py
+1
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_getWechatPaymentConfiguration.xml
.../slapos_wechat/ERP5Site_getWechatPaymentConfiguration.xml
+62
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_receiveWechatPaymentCallback.py
...ns/slapos_wechat/ERP5Site_receiveWechatPaymentCallback.py
+16
-0
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_receiveWechatPaymentCallback.xml
...s/slapos_wechat/ERP5Site_receiveWechatPaymentCallback.xml
+62
-0
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testERP5WechatSecurePayment.py
...ortal_components/test.erp5.testERP5WechatSecurePayment.py
+60
-0
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testERP5WechatSecurePayment.xml
...rtal_components/test.erp5.testERP5WechatSecurePayment.xml
+124
-0
master/bt5/slapos_wechat/bt/template_extension_id_list
master/bt5/slapos_wechat/bt/template_extension_id_list
+1
-0
master/bt5/slapos_wechat/bt/template_format_version
master/bt5/slapos_wechat/bt/template_format_version
+1
-0
master/bt5/slapos_wechat/bt/template_skin_id_list
master/bt5/slapos_wechat/bt/template_skin_id_list
+1
-0
master/bt5/slapos_wechat/bt/template_test_id_list
master/bt5/slapos_wechat/bt/template_test_id_list
+1
-0
master/bt5/slapos_wechat/bt/title
master/bt5/slapos_wechat/bt/title
+1
-0
No files found.
master/bt5/slapos_wechat/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.py
0 → 100644
View file @
c1799cde
import
random
,
string
,
hashlib
,
urllib2
,
socket
from
urlparse
import
urlparse
try
:
import
xml.etree.cElementTree
as
ET
except
ImportError
:
import
xml.etree.ElementTree
as
ET
class
WechatException
(
Exception
):
def
__init__
(
self
,
msg
):
super
(
WechatException
,
self
).
__init__
(
msg
)
# UFDODER_URL = "https://api.mch.weixin.qq.com/sandboxnew/pay/unifiedorder" # Wechat unified order API
UFDODER_URL
=
"https://api.mch.weixin.qq.com/pay/unifiedorder"
# Wechat unified order API
QUERY_URL
=
"https://api.mch.weixin.qq.com/pay/orderquery"
def
generateRandomStr
(
random_length
=
24
):
alpha_num
=
string
.
ascii_letters
+
string
.
digits
random_str
=
''
.
join
(
random
.
choice
(
alpha_num
)
for
i
in
range
(
random_length
))
return
random_str
def
calculateSign
(
dict_content
,
key
):
# Calculate the sign according to the data_dict
# The rule was defined by Wechat (Wrote in Chinese):
# https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=4_3
# 1. Sort it by dict order
params_list
=
sorted
(
dict_content
.
items
(),
key
=
lambda
e
:
e
[
0
],
reverse
=
False
)
# 2. Concatenate the list to a string
params_str
=
"&"
.
join
(
u"{}={}"
.
format
(
k
,
v
)
for
k
,
v
in
params_list
)
# 3. Add trade key in the end
params_str
=
params_str
+
'&key='
+
key
md5
=
hashlib
.
md5
()
# Use MD5 mode
md5
.
update
(
params_str
.
encode
(
'utf-8'
))
sign
=
md5
.
hexdigest
().
upper
()
return
sign
def
convert_xml_to_dict
(
xml_content
):
'''
The XML returned by Wechat is like:
<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[OK]]></return_msg>
<appid><![CDATA[wx2421b1c4370ec43b]]></appid>
<mch_id><![CDATA[10000100]]></mch_id>
<nonce_str><![CDATA[IITRi8Iabbblz1Jc]]></nonce_str>
<openid><![CDATA[oUpF8uMuAJO_M2pxb1Q9zNjWeS6o]]></openid>
<sign><![CDATA[7921E432F65EB8ED0CE9755F0E86D72F]]></sign>
<result_code><![CDATA[SUCCESS]]></result_code>
<prepay_id><![CDATA[wx201411101639507cbf6ffd8b0779950874]]></prepay_id>
<trade_type><![CDATA[JSAPI]]></trade_type>
</xml>
'''
try
:
t
=
ET
.
XML
(
xml_content
)
except
ET
.
ParseError
:
return
{}
else
:
dict_content
=
dict
([(
child
.
tag
,
child
.
text
)
for
child
in
t
])
return
dict_content
def
convert_dict_to_xml
(
dict_content
):
xml
=
''
for
key
,
value
in
dict_content
.
items
():
xml
+=
'<{0}>{1}</{0}>'
.
format
(
key
,
value
)
xml
=
'<xml>{0}</xml>'
.
format
(
xml
)
return
xml
def
getSandboxKey
(
self
):
SANDBOX_KEY_URL
=
"https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey"
wechat_account_configuration
=
self
.
ERP5Site_getWechatPaymentConfiguration
()
params
=
{}
params
[
'mch_id'
]
=
wechat_account_configuration
[
'MCH_ID'
]
params
[
'nonce_str'
]
=
generateRandomStr
()
params
[
'sign'
]
=
calculateSign
(
params
,
wechat_account_configuration
[
'API_KEY'
])
# construct XML str
request_xml_str
=
'<xml>'
for
key
,
value
in
params
.
items
():
if
isinstance
(
value
,
basestring
):
request_xml_str
=
'%s<%s><![CDATA[%s]]></%s>'
%
(
request_xml_str
,
key
,
value
,
key
,
)
else
:
request_xml_str
=
'%s<%s>%s</%s>'
%
(
request_xml_str
,
key
,
value
,
key
,
)
request_xml_str
=
'%s</xml>'
%
request_xml_str
result
=
urllib2
.
Request
(
SANDBOX_KEY_URL
,
data
=
request_xml_str
)
result_data
=
urllib2
.
urlopen
(
result
)
result_read
=
result_data
.
read
()
result_dict_content
=
convert_xml_to_dict
(
result_read
)
return_code
=
result_dict_content
.
get
(
'return_code'
,
''
)
if
return_code
==
"SUCCESS"
:
result_msg
=
result_dict_content
[
'return_msg'
]
if
result_msg
==
"ok"
:
sandbox_signkey
=
result_dict_content
[
'sandbox_signkey'
]
return
sandbox_signkey
raise
Exception
(
result_dict_content
[
'result_msg'
].
encode
(
'utf-8'
))
raise
Exception
(
"Get sanbox key failed: "
+
str
(
result_dict_content
))
def
getWechatQRCodeURL
(
self
,
order_id
,
price
,
amount
):
portal
=
self
.
getPortalObject
()
base_url
=
portal
.
absolute_url
()
NOTIFY_URL
=
base_url
+
"/ERP5Site_receiveWechatPaymentCallback"
# Wechat payment callback method
wechat_account_configuration
=
self
.
ERP5Site_getWechatPaymentConfiguration
()
appid
=
wechat_account_configuration
[
'APP_ID'
]
mch_id
=
wechat_account_configuration
[
'MCH_ID'
]
key
=
wechat_account_configuration
[
'API_KEY'
]
# This is for sandbox test
# key = getSandboxKey() # API_KEY
nonce_str
=
generateRandomStr
()
result
=
urlparse
(
base_url
)
spbill_create_ip
=
socket
.
gethostbyname
(
result
.
netloc
)
notify_url
=
NOTIFY_URL
trade_type
=
"NATIVE"
# Construct parameter for calling the Wechat payment URL
params
=
{}
params
[
'appid'
]
=
appid
params
[
'mch_id'
]
=
mch_id
params
[
'nonce_str'
]
=
nonce_str
params
[
'out_trade_no'
]
=
order_id
.
encode
(
'utf-8'
)
# This is for sandbox test, sandbox need the total_fee equal to 101 exactly
# params['total_fee'] = 101 # int(-(price * 100)) # unit is Fen, 1 CNY = 100 Fen
# params['total_fee'] = int(-(price * 100)) # unit is Fen, 1 CNY(RMB) = 100 Fen
params
[
'total_fee'
]
=
1
#int(-(price * 100)) # unit is Fen, 1 CNY = 100 Fen
params
[
'spbill_create_ip'
]
=
spbill_create_ip
params
[
'notify_url'
]
=
notify_url
params
[
'body'
]
=
"Rapid Space Virtual Machine"
.
encode
(
'utf-8'
)
params
[
'trade_type'
]
=
trade_type
# generate signature
params
[
'sign'
]
=
calculateSign
(
params
,
key
)
# construct XML str
request_xml_str
=
'<xml>'
for
key
,
value
in
params
.
items
():
if
isinstance
(
value
,
basestring
):
request_xml_str
=
'%s<%s><![CDATA[%s]]></%s>'
%
(
request_xml_str
,
key
,
value
,
key
,
)
else
:
request_xml_str
=
'%s<%s>%s</%s>'
%
(
request_xml_str
,
key
,
value
,
key
,
)
request_xml_str
=
'%s</xml>'
%
request_xml_str
# send data
result
=
urllib2
.
Request
(
UFDODER_URL
,
data
=
request_xml_str
)
result_data
=
urllib2
.
urlopen
(
result
)
result_read
=
result_data
.
read
()
result_dict_content
=
convert_xml_to_dict
(
result_read
)
return_code
=
result_dict_content
[
'return_code'
]
if
return_code
==
"SUCCESS"
:
result_code
=
result_dict_content
[
'result_code'
]
if
result_code
==
"SUCCESS"
:
code_url
=
result_dict_content
[
'code_url'
]
return
code_url
else
:
raise
Exception
(
"Error description: {0}"
.
format
(
result_dict_content
.
get
(
"err_code_des"
)))
else
:
raise
Exception
(
"Error description: {0}"
.
format
(
result_dict_content
.
get
(
"return_msg"
)))
def
receiveWechatPaymentNotify
(
self
,
request
,
*
args
,
**
kwargs
):
'''
Receive the asychonized callback send by Wechat after user pay the order.
Wechat will give us something like:
<xml>
<appid><![CDATA[wx6509f6e240dfae50]]></appid>
<bank_type><![CDATA[CFT]]></bank_type>
<cash_fee><![CDATA[1]]></cash_fee>
<fee_type><![CDATA[CNY]]></fee_type>
<is_subscribe><![CDATA[N]]></is_subscribe>
<mch_id><![CDATA[14323929292]]></mch_id>
<nonce_str><![CDATA[aCJv0SAwKY5Cxfi34mtCEM5SdNKexuXgnW]]></nonce_str>
<openid><![CDATA[oHWl5w5M34hYM-ox2mn6Xatse7yCTs]]></openid>
<out_trade_no><![CDATA[aHQDJyacUSGC]]></out_trade_no>
<result_code><![CDATA[SUCCESS]]></result_code>
<return_code><![CDATA[SUCCESS]]></return_code>
<sign><![CDATA[C4F8B5B17A3E6203491A3B790A1D87ECEA]]></sign>
<time_end><![CDATA[201712114144230]]></time_end>
<total_fee>1</total_fee>
<trade_type><![CDATA[NATIVE]]></trade_type>
<transaction_id><![CDATA[4200000031201712112434025551875]]></transaction_id>
</xml>
'''
wechat_account_configuration
=
self
.
ERP5Site_getWechatPaymentConfiguration
()
params
=
convert_xml_to_dict
(
request
.
body
)
if
params
.
get
(
"return_code"
)
==
"SUCCESS"
:
# Connection is ok
sign
=
params
.
pop
(
'sign'
)
recalcualted_sign
=
calculateSign
(
params
,
wechat_account_configuration
[
'API_KEY'
])
if
recalcualted_sign
==
sign
:
if
params
.
get
(
"result_code"
,
None
)
==
"SUCCESS"
:
# payment is ok
# order number
# out_trade_no = params.get("out_trade_no")
# Wechat payment order ID
# This is what we should use when we search the order in the wechat
# transaction_id = params.get("out_trade_no")
# Save the wechat payment order ID in somewhere.
# We recevied the payment...
# Process something
# XXX: display the page the payment received.
# container.REQUEST.RESPONSE.redirect("%s/#wechat_payment_confirmed")
# We must tell Wechat we received the response. Otherwise wechat will keep send it within 24 hours
# xml_str = convert_dict_to_xml({"return_code": "SUCCESS"})
# return container.REQUEST.RESPONSE(xml_str)
return
'''
<xml>
<return_code><![CDATA[SUCCESS]]></return_code>
<return_msg><![CDATA[OK]]></return_msg>
</xml>
'''
else
:
print
(
"{0}:{1}"
.
format
(
params
.
get
(
"err_code"
),
params
.
get
(
"err_code_des"
)))
else
:
# Error information
print
(
params
.
get
(
"return_msg"
).
encode
(
"utf-8"
))
def
queryWechatOrderStatus
(
self
,
dict_content
):
'''
query url: https://api.mch.weixin.qq.com/pay/orderquery
documentation(Chinese): https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_2
The dict_content atleast should contains one of following:
- 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
"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"
)
wechat_account_configuration
=
self
.
ERP5Site_getWechatPaymentConfiguration
()
params
=
{
"appid"
:
wechat_account_configuration
[
'APP_ID'
],
"mch_id"
:
wechat_account_configuration
[
'MCH_ID'
],
"nonce_str"
:
generateRandomStr
(),
# "transaction_id": dict_content.get("transaction_id", ""),
"out_trade_no"
:
dict_content
.
get
(
"out_trade_no"
,
""
),
}
sign
=
calculateSign
(
params
,
wechat_account_configuration
[
'API_KEY'
])
params
[
"sign"
]
=
sign
xml_str
=
convert_dict_to_xml
(
params
)
result
=
urllib2
.
Request
(
QUERY_URL
,
data
=
xml_str
)
result_data
=
urllib2
.
urlopen
(
result
)
result_read
=
result_data
.
read
()
result_dict_content
=
convert_xml_to_dict
(
result_read
)
return_code
=
result_dict_content
[
'return_code'
]
if
return_code
==
"SUCCESS"
:
result_code
=
result_dict_content
[
'result_code'
]
if
result_code
==
"SUCCESS"
:
return
result_dict_content
[
'trade_state'
]
else
:
raise
Exception
(
"Error description: {0}"
.
format
(
result_dict_content
.
get
(
"err_code_des"
)))
else
:
raise
Exception
(
"Error description: {0}"
.
format
(
result_dict_content
.
get
(
"return_msg"
)))
\ No newline at end of file
master/bt5/slapos_wechat/ExtensionTemplateItem/portal_components/extension.erp5.WechatUtils.xml
0 → 100644
View file @
c1799cde
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Extension Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
WechatUtils
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
extension.erp5.WechatUtils
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Extension Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat.xml
0 → 100644
View file @
c1799cde
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Folder"
module=
"OFS.Folder"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_local_properties
</string>
</key>
<value>
<tuple>
<dictionary>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
business_template_skin_layer_priority
</string>
</value>
</item>
<item>
<key>
<string>
type
</string>
</key>
<value>
<string>
float
</string>
</value>
</item>
</dictionary>
</tuple>
</value>
</item>
<item>
<key>
<string>
_objects
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
business_template_skin_layer_priority
</string>
</key>
<value>
<float>
60.0
</float>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
slapos_wechat
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_generateWechatQRCodeFromCodeURL.py
0 → 100644
View file @
c1799cde
# inspired by Pack_generateCode128BarcodeImage in sanef-evl project
return
context
.
Base_generateBarcodeImage
(
'qrcode'
,
code_url
)
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_generateWechatQRCodeFromCodeURL.xml
0 → 100644
View file @
c1799cde
<?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>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_getWechatCodeURL.xml
0 → 100644
View file @
c1799cde
<?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>
getWechatQRCodeURL
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
WechatUtils
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_getWechatCodeURL
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_queryWechatOrderStatusByTradeNo.py
0 → 100644
View file @
c1799cde
if
not
trade_no
:
raise
Exception
(
"Unknown trade number"
)
return
context
.
Base_queryWechatOrderStatus
({
'out_trade_no'
:
trade_no
})
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_queryWechatOrderStatusByTradeNo.xml
0 → 100644
View file @
c1799cde
<?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=None
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_queryWechatOrderStatusByTradeNo
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/Base_receiveWechatPaymentNotify.xml
0 → 100644
View file @
c1799cde
<?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>
receiveWechatPaymentNotify
</string>
</value>
</item>
<item>
<key>
<string>
_module
</string>
</key>
<value>
<string>
WechatUtils
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
Base_receiveWechatPaymentNotify
</string>
</value>
</item>
<item>
<key>
<string>
title
</string>
</key>
<value>
<string></string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_getWechatPaymentConfiguration.py
0 → 100644
View file @
c1799cde
return
{}
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_getWechatPaymentConfiguration.xml
0 → 100644
View file @
c1799cde
<?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></string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_getWechatPaymentConfiguration
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_receiveWechatPaymentCallback.py
0 → 100644
View file @
c1799cde
# 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
raise
Exception
(
request
)
# 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
()
print
response
return
printed
master/bt5/slapos_wechat/SkinTemplateItem/portal_skins/slapos_wechat/ERP5Site_receiveWechatPaymentCallback.xml
0 → 100644
View file @
c1799cde
<?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>
**kw
</string>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
ERP5Site_receiveWechatPaymentCallback
</string>
</value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testERP5WechatSecurePayment.py
0 → 100644
View file @
c1799cde
##############################################################################
#
# Copyright (c) 2002-2011 Nexedi SA and Contributors. All Rights Reserved.
#
# WARNING: This program as such is intended to be used by professional
# programmers who take the whole responsibility of assessing all potential
# consequences resulting from its eventual inadequacies and bugs
# End users who are looking for a ready-to-use solution with commercial
# guarantees and support are strongly advised to contract a Free Software
# Service Company
#
# This program is Free Software; you can redistribute it and/or
# modify it under the terms of the GNU General Public License
# as published by the Free Software Foundation; either version 2
# of the License, or (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#
##############################################################################
from
Products.ERP5Type.tests.ERP5TypeTestCase
import
ERP5TypeTestCase
class
TestERP5WechatSecurePayment
(
ERP5TypeTestCase
):
"""
An ERP5 Wechat Secure Payment test case
"""
def
getTitle
(
self
):
return
"ERP5 Wechat Secure Payment"
def
afterSetUp
(
self
):
pass
def
test_submit_wechat_order
(
self
):
self
.
portal
=
self
.
getPortalObject
()
# '20190925-226AD' is the trade number which submitted to the wechat server manually
# Use this to check our query function
# TODO:
# - Move wechat urls to slapos_vifib/ERP5Site_getWechatPaymentConfiguration.py
# - Add fake urls in slapos_subscription_request/ERP5Site_getWechatPaymentConfiguration.py
# Mock the wechat call
# return_code = self.portal.Base_getWechatCodeURL('23456789-AAAAA', 1, 1)
# self.assertEqual(return_code[:14], 'weixin://wxpay/')
def
test_query_wechat_order
(
self
):
self
.
portal
=
self
.
getPortalObject
()
# '20190925-226AD' is the trade number which submitted to the wechat server manually
# Use this to check our query function
return_code
=
self
.
portal
.
Base_queryWechatOrderStatusByTradeNo
(
trade_no
=
'20190925-226AD'
)
self
.
assertEqual
(
return_code
,
'SUCCESS'
)
master/bt5/slapos_wechat/TestTemplateItem/portal_components/test.erp5.testERP5WechatSecurePayment.xml
0 → 100644
View file @
c1799cde
<?xml version="1.0"?>
<ZopeData>
<record
id=
"1"
aka=
"AAAAAAAAAAE="
>
<pickle>
<global
name=
"Test Component"
module=
"erp5.portal_type"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
_recorded_property_dict
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAI=
</string>
</persistent>
</value>
</item>
<item>
<key>
<string>
default_reference
</string>
</key>
<value>
<string>
testERP5WechatSecurePayment
</string>
</value>
</item>
<item>
<key>
<string>
description
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
id
</string>
</key>
<value>
<string>
test.erp5.testERP5WechatSecurePayment
</string>
</value>
</item>
<item>
<key>
<string>
portal_type
</string>
</key>
<value>
<string>
Test Component
</string>
</value>
</item>
<item>
<key>
<string>
sid
</string>
</key>
<value>
<none/>
</value>
</item>
<item>
<key>
<string>
text_content_error_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
text_content_warning_message
</string>
</key>
<value>
<tuple/>
</value>
</item>
<item>
<key>
<string>
version
</string>
</key>
<value>
<string>
erp5
</string>
</value>
</item>
<item>
<key>
<string>
workflow_history
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAM=
</string>
</persistent>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"2"
aka=
"AAAAAAAAAAI="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary/>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"3"
aka=
"AAAAAAAAAAM="
>
<pickle>
<global
name=
"PersistentMapping"
module=
"Persistence.mapping"
/>
</pickle>
<pickle>
<dictionary>
<item>
<key>
<string>
data
</string>
</key>
<value>
<dictionary>
<item>
<key>
<string>
component_validation_workflow
</string>
</key>
<value>
<persistent>
<string
encoding=
"base64"
>
AAAAAAAAAAQ=
</string>
</persistent>
</value>
</item>
</dictionary>
</value>
</item>
</dictionary>
</pickle>
</record>
<record
id=
"4"
aka=
"AAAAAAAAAAQ="
>
<pickle>
<global
name=
"WorkflowHistoryList"
module=
"Products.ERP5Type.patches.WorkflowTool"
/>
</pickle>
<pickle>
<tuple>
<none/>
<list>
<dictionary>
<item>
<key>
<string>
action
</string>
</key>
<value>
<string>
validate
</string>
</value>
</item>
<item>
<key>
<string>
validation_state
</string>
</key>
<value>
<string>
validated
</string>
</value>
</item>
</dictionary>
</list>
<none/>
</tuple>
</pickle>
</record>
</ZopeData>
master/bt5/slapos_wechat/bt/template_extension_id_list
0 → 100644
View file @
c1799cde
extension.erp5.WechatUtils
\ No newline at end of file
master/bt5/slapos_wechat/bt/template_format_version
0 → 100644
View file @
c1799cde
1
\ No newline at end of file
master/bt5/slapos_wechat/bt/template_skin_id_list
0 → 100644
View file @
c1799cde
slapos_wechat
\ No newline at end of file
master/bt5/slapos_wechat/bt/template_test_id_list
0 → 100644
View file @
c1799cde
test.erp5.testERP5WechatSecurePayment
\ No newline at end of file
master/bt5/slapos_wechat/bt/title
0 → 100644
View file @
c1799cde
slapos_wechat
\ No newline at end of file
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