微信小程序开发 |
您所在的位置:网站首页 › 微信小程序取消订单多久退款 › 微信小程序开发 |
之前有写过详细的微信支付功能:微信支付 我们使用weixin-java-pay的jar包等,配置上的流程同微信支付,可以看上面的文章。 退款使用的WxPayService类的refundV3方法。使用该方法需要在微信支付配置的基础上加上:apiclient_key.pem 证书文件、 apiclient_cert.pem证书文件、apiV3 秘钥值的配置 1、下载API证书,并放到程序的指定位置 2、在yml配置文件中定义 wechat: appid: secret: # 商户 mchId: # 秘钥 mchKey: apiV3Key: # p12证书的位置,可以指定绝对路径,也可以指定类路径(以classpath:开头) keyPath: classpath:apiclient_cert.p12 privateKeyPath: classpath:apiclient_key.pem privateCertPath: classpath:apiclient_cert.pem #JSAPI--公众号支付 NATIVE--原生扫码支付 APP--app支付 tradeType: JSAPI notifyUrl: #支付回调方法地址 refundNotifyUrl: #退款回调方法地址3、在原有的WxProperties和WxConfig中对WxPayService配置的内容中进行新增内容。 WxProperties: WxConfig:【这里的setNotifyUrl的地址是支付回调的地址】 Controller层调用: 在调用退款方法中使用此句设置了退款回调方法的地址; request.setNotifyUrl(this.wxPayService.getConfig().getPayScoreNotifyUrl());//回调地址不论是支付回调还是退款回调,都需要把访问地址映射到公网中才可以测试和使用。 回调方法如下: Controller: /** * 微信退款结果回调 * @param * @throws Exception */ @PostMapping("/refundNotify") void refundNotify(@RequestBody String xmlData) throws Exception{ wxPayOrderApi.refundNotify(xmlData); }实现层代码: /** * 微信退款结果回调 * @param xmlData * @throws Exception */ @Override @Transactional(rollbackFor = Exception.class) public void refundNotify(@RequestBody String xmlData) throws Exception { //SignatureHeader signatureHeader = this.getSignatureHeader(timestamp, nonce, serial, signature); final WxPayRefundNotifyV3Result notifyResult = this.wxPayService.parseRefundNotifyV3Result(xmlData,null); if (null != notifyResult && notifyResult.getResult().getRefundStatus().equals("SUCCESS")) { System.out.println("微信退款结果回调结果==============>:" + notifyResult.getResult());//TODO 删除 //逻辑代码,修改微信支付订单状态以及其他操作 } } }使用wxPayService.parseRefundNotifyV3Result方法,自行查看源码 记:一开始退款使用的是refund方法,如下: |
今日新闻 |
点击排行 |
|
推荐新闻 |
图片新闻 |
|
专题文章 |
CopyRight 2018-2019 实验室设备网 版权所有 win10的实时保护怎么永久关闭 |