Commit f31ecd78 authored by Rafael Monnerat's avatar Rafael Monnerat

erp5_wechat_secure_payment: Optinally, let the user configure spbill_create_ip

   Whenever used via activity nodes, it is not possible to discover IP of the server via portal absolute url.
parent 5cf92181
...@@ -118,7 +118,6 @@ class WechatService(XMLObject): ...@@ -118,7 +118,6 @@ class WechatService(XMLObject):
def callWechatApi(self, URL, wechat_dict): def callWechatApi(self, URL, wechat_dict):
portal = self.getPortalObject() portal = self.getPortalObject()
base_url = portal.absolute_url()
wechat_url = self.getLinkUrlString() wechat_url = self.getLinkUrlString()
if self.getWechatMode() == "SANDBOX": if self.getWechatMode() == "SANDBOX":
key = self.getSandboxKey() key = self.getSandboxKey()
...@@ -128,8 +127,13 @@ class WechatService(XMLObject): ...@@ -128,8 +127,13 @@ class WechatService(XMLObject):
key = self.getServiceApiKey() key = self.getServiceApiKey()
nonce_str = self.generateRandomStr() 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) result = urlparse(base_url)
spbill_create_ip = socket.gethostbyname(result.netloc) 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 # Construct parameter for calling the Wechat payment URL
wechat_dict['appid'] = self.getServiceAppid() 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 @@ ...@@ -99,6 +99,7 @@
<string>my_reference</string> <string>my_reference</string>
<string>my_wechat_mode</string> <string>my_wechat_mode</string>
<string>my_service_mch_id</string> <string>my_service_mch_id</string>
<string>my_wechat_spbill_create_ip</string>
</list> </list>
</value> </value>
</item> </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