Commit f64940ab authored by Rafael Monnerat's avatar Rafael Monnerat

slapos_wechat_secure_payment: Extend Wechat implement so we can test it

See merge request !1480
parents 93f1017d 23ddbe61
......@@ -118,16 +118,22 @@ class WechatService(XMLObject):
def callWechatApi(self, URL, wechat_dict):
portal = self.getPortalObject()
base_url = portal.absolute_url()
wechat_url = self.getLinkUrlString()
if self.getWechatMode() == "SANDBOX":
key = self.getSandboxKey()
elif self.getWechatMode() == "UNITTEST":
return {"result_code": 'SUCCESS', "code_url": 'weixin://wxpay/bizpayurl?pr=AAAAA'}
else:
key = self.getServiceApiKey()
nonce_str = self.generateRandomStr()
wechat_spbill_create_ip = self.getWechatSpbillCreateIp()
if not wechat_spbill_create_ip:
base_url = portal.absolute_url()
result = urlparse(base_url)
spbill_create_ip = socket.gethostbyname(result.netloc)
else:
spbill_create_ip = socket.gethostbyname(wechat_spbill_create_ip)
# Construct parameter for calling the Wechat payment URL
wechat_dict['appid'] = self.getServiceAppid()
......
<?xml version="1.0"?>
<ZopeData>
<record id="1" aka="AAAAAAAAAAE=">
<pickle>
<global name="Standard Property" module="erp5.portal_type"/>
</pickle>
<pickle>
<dictionary>
<item>
<key> <string>categories</string> </key>
<value>
<tuple>
<string>elementary_type/string</string>
</tuple>
</value>
</item>
<item>
<key> <string>description</string> </key>
<value>
<none/>
</value>
</item>
<item>
<key> <string>id</string> </key>
<value> <string>wechat_spbill_create_ip_property</string> </value>
</item>
<item>
<key> <string>portal_type</string> </key>
<value> <string>Standard Property</string> </value>
</item>
<item>
<key> <string>title</string> </key>
<value> <string>wechat_mode</string> </value>
</item>
</dictionary>
</pickle>
</record>
</ZopeData>
......@@ -99,6 +99,7 @@
<string>my_reference</string>
<string>my_wechat_mode</string>
<string>my_service_mch_id</string>
<string>my_wechat_spbill_create_ip</string>
</list>
</value>
</item>
......
......@@ -243,6 +243,10 @@
<string>PRODUCTION</string>
<string>PRODUCTION</string>
</tuple>
<tuple>
<string>UNITTEST</string>
<string>UNITTEST</string>
</tuple>
</list>
</value>
</item>
......
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