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):
if self.getWechatMode() == "SANDBOX":
key = self.getSandboxKey()
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:
key = self.getServiceApiKey()
nonce_str = self.generateRandomStr()
......@@ -254,6 +265,10 @@ class WechatService(XMLObject):
'In Navigate', error=False)
portal = self.getPortalObject()
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(
......
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