Commit 9f23588d authored by Boxiang Sun's avatar Boxiang Sun

erp5_wechat_secure_payment: Improve the UNITTEST mode support

The current implementation now supports to the quering call with UNNITTEST mode
parent 24a321e2
...@@ -122,7 +122,18 @@ class WechatService(XMLObject): ...@@ -122,7 +122,18 @@ class WechatService(XMLObject):
if self.getWechatMode() == "SANDBOX": if self.getWechatMode() == "SANDBOX":
key = self.getSandboxKey() key = self.getSandboxKey()
elif self.getWechatMode() == "UNITTEST": elif self.getWechatMode() == "UNITTEST":
return {"result_code": 'SUCCESS', "code_url": 'weixin://wxpay/bizpayurl?pr=AAAAA'} # this function will get call twice
# one for submit the payment request to wechat
# one for query the payment status to wechat
# trade_state is returned by quering
# and put it in the returned value from payment request has no harm
return {
"result_code": 'SUCCESS',
"code_url": 'weixin://wxpay/bizpayurl?pr=AAAAA',
"trade_state": 'SUCCESS',
"total_fee": '18800',
"fee_type": 'CNY',
}
else: else:
key = self.getServiceApiKey() key = self.getServiceApiKey()
nonce_str = self.generateRandomStr() nonce_str = self.generateRandomStr()
...@@ -254,7 +265,11 @@ class WechatService(XMLObject): ...@@ -254,7 +265,11 @@ class WechatService(XMLObject):
'In Navigate', error=False) 'In Navigate', error=False)
portal = self.getPortalObject() portal = self.getPortalObject()
base_url = wechat_dict.pop('base_url', '%s/#wechat_payment' % portal.absolute_url())
if self.getWechatMode() == "UNITTEST":
base_url = wechat_dict.pop('base_url', '%s/#wechat_payment_test' % portal.absolute_url())
else:
base_url = wechat_dict.pop('base_url', '%s/#wechat_payment' % portal.absolute_url())
return self.REQUEST.RESPONSE.redirect( return self.REQUEST.RESPONSE.redirect(
"%s?trade_no=%s&price=%s&payment_url=%s" % ( "%s?trade_no=%s&price=%s&payment_url=%s" % (
......
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