Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

微信支付支持仿真测试环境 #119

Closed
fivesmallq opened this issue Jan 8, 2017 · 12 comments
Closed

微信支付支持仿真测试环境 #119

fivesmallq opened this issue Jan 8, 2017 · 12 comments

Comments

@fivesmallq
Copy link

目前代码中使用的都是真实的url,微信支付本身支持设置仿真测试环境,

图1为微信支付仿真测试系统(后简称仿真系统)的简化原理图。仿真系统的API协议与正式API完全相同(API接口文档)。商户开发者只需将正式API的调用URL增加一层sandboxnew路径,即可对接到仿真系统。
例如,刷卡支付URL:https://api.mch.weixin.qq.com/pay/micropay
变更为:https://api.mch.weixin.qq.com/sandboxnew/pay/micropay。

https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_1

https://github.com/Wechat-Group/weixin-java-tools/blob/develop/weixin-java-mp/src/main/java/me/chanjar/weixin/mp/api/impl/WxMpPayServiceImpl.java#L41

public class WxMpPayServiceImpl implements WxMpPayService {

  private static final String PAY_BASE_URL = "https://api.mch.weixin.qq.com";
  private static final String[] TRADE_TYPES = new String[]{"JSAPI", "NATIVE", "APP"};
  private static final String[] REFUND_ACCOUNT = new String[]{"REFUND_SOURCE_RECHARGE_FUNDS", "REFUND_SOURCE_UNSETTLED_FUNDS"};
  private final Logger log = LoggerFactory.getLogger(this.getClass());
  private WxMpService wxMpService;

这个地方写死了,提供一个对外的set方法?还是可以在配置文件中设置。

@binarywang
Copy link
Owner

binarywang commented Jan 8, 2017

感谢提醒,我的初步想法是可以在configstorage里增加一个开关的属性设置,然后修改对应代码,就可以自由切换两种环境了

@binarywang
Copy link
Owner

@fivesmallq 大概研究了下文档,也尝试改下代码,发现这个沙箱环境还真是事儿挺多,调用之前的接口一直给我报 “验证签名失败, 请调用getsignkey生成沙箱密钥”,不知道你使用这个环境有什么经验可以分享的吗?

@fivesmallq
Copy link
Author

fivesmallq commented Jan 9, 2017

@binarywang
sorry,刚才出去办事了。 刚看了下文档,签名是固定的

仿真系统与生产环境完全独立,包括存储层。商户在仿真系统所做的所有交易(如下单、支付、查询)均为无资金流的假数据,即:用户无需真实扣款,商户也不会有资金入账。

验收仿真测试系统的API验签密钥为: ABCDEFGHIJKLMNOPQRSTUVWXYZ123456

https://pay.weixin.qq.com/wiki/doc/api/jsapi.php?chapter=23_1

@binarywang
Copy link
Owner

这个我知道,我都试过了,总是抱那个错误,最新代码已经提交了,你可以帮忙看看,如果看出什么问题来的话,可以提出来。

@binarywang
Copy link
Owner

binarywang commented Jan 9, 2017

另外问一句,你知道他这个环境是什么时候开始有的吗?文档都没有标注,而且以前确实都没听说过

@fivesmallq
Copy link
Author

@binarywang 我回到这里了。 245bec7#commitcomment-20403270

@binarywang
Copy link
Owner

而且我还发现个别接口在这个仿真测试环境中并没有对应的实现,直接报的就是404,如交易保障的那个

@binarywang
Copy link
Owner

所以我就在怀疑了,这根本就是个半成品,根本没法使用的玩意

@fivesmallq
Copy link
Author

:( 你这么说我也怀疑不可用。。。

@binarywang
Copy link
Owner

不管怎样,代码就先加上了,以后万一他们弄好了再根据需要启用。

@fivesmallq
Copy link
Author

恩。。那我先关issues了。。

@izee
Copy link

izee commented May 9, 2017

建议所有API的url地址都可以通过set覆盖,以免出现API地址变动时,不能快速应对

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants