【记】微信支付服务器证书更换通知的验证流程

原文: 【记】微信支付服务器证书更换通知的验证流程

【重要】微信支付服务器证书更换通知,请开发人员验证以免影响交易

尊敬的微信支付商户&服务商:

       因微信支付HTTPS服务器证书的根CA证书将于2018年8月23日到期失效,微信支付计划于2018年5月29日, 更换服务器证书。

       新的服务器证书由权威机构(DigiCert) 签发, 如果你的服务器上没有部署DigiCert的根CA证书,将导致你的下单、退款等功能无法正常使用。请开发人员务必尽快完成证书验证及安装,详细流程可参考《微信支付HTTPS服务器证书验证指引》

 

调用微信支付沙箱环境的API接口验证时,服务器一直返回  远程服务器返回错误: (400) 错误的请求。

 

解决办法:

Post请求时需要带上商户证书!

商户证书下载:微信商户平台(pay.weixin.qq.com)-->账户中心-->账户设置-->API安全-->证书下载

 

 

posted on 2018-12-14 13:13 NET未来之路 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/lonelyxmas/p/10118863.html

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
使用微信支付服务需要在服务器端进行处理,以下是使用Java语言编写的微信支付服务器端代码示例: 1. 引入SDK ```java // 引入微信支付SDK import com.github.wxpay.sdk.WXPay; import com.github.wxpay.sdk.WXPayConstants; import com.github.wxpay.sdk.WXPayUtil; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; import java.util.HashMap; import java.util.Map; ``` 2. 初始化配置 ```java @Service public class WxPayService { // 从配置文件中读取微信支付参数 @Value("${wxpay.appId}") private String appId; @Value("${wxpay.mchId}") private String mchId; @Value("${wxpay.key}") private String key; @Value("${wxpay.notifyUrl}") private String notifyUrl; // 微信支付客户端 private WXPay wxPay; @PostConstruct public void init() throws Exception { Map<String, String> config = new HashMap<>(); config.put("appid", appId); config.put("mch_id", mchId); config.put("key", key); config.put("notify_url", notifyUrl); config.put("trade_type", "APP"); wxPay = new WXPay(config, WXPayConstants.SignType.MD5); } // 下单接口 public Map<String, String> unifiedOrder(String body, String outTradeNo, String totalFee, String spbillCreateIp) throws Exception { Map<String, String> data = new HashMap<>(); data.put("body", body); data.put("out_trade_no", outTradeNo); data.put("total_fee", totalFee); data.put("spbill_create_ip", spbillCreateIp); Map<String, String> resp = wxPay.unifiedOrder(data); if ("SUCCESS".equals(resp.get("return_code")) && "SUCCESS".equals(resp.get("result_code"))) { String prepayId = resp.get("prepay_id"); Map<String, String> signData = new HashMap<>(); signData.put("appid", appId); signData.put("partnerid", mchId); signData.put("prepayid", prepayId); signData.put("package", "Sign=WXPay"); signData.put("noncestr", WXPayUtil.generateNonceStr()); signData.put("timestamp", String.valueOf(System.currentTimeMillis() / 1000)); String sign = WXPayUtil.generateSignature(signData, key); Map<String, String> payParams = new HashMap<>(); payParams.put("appid", appId); payParams.put("partnerid", mchId); payParams.put("prepayid", prepayId); payParams.put("package", "Sign=WXPay"); payParams.put("noncestr", signData.get("noncestr")); payParams.put("timestamp", signData.get("timestamp")); payParams.put("sign", sign); return payParams; } else { String errorCode = resp.get("err_code"); String errorMsg = resp.get("err_code_des"); throw new Exception(errorMsg); } } // 支付结果回调接口 public void notify(Map<String, String> notifyData) throws Exception { if (wxPay.isPayResultNotifySignatureValid(notifyData)) { String outTradeNo = notifyData.get("out_trade_no"); String transactionId = notifyData.get("transaction_id"); // 处理订单支付结果 // ... Map<String, String> resp = new HashMap<>(); resp.put("return_code", "SUCCESS"); resp.put("return_msg", "OK"); wxPay.fillResponseData(resp); String xml = WXPayUtil.mapToXml(resp); response.getWriter().write(xml); } else { throw new Exception("签名验证失败"); } } } ``` 以上代码示例中,`WxPayService`是一个服务类,其中`unifiedOrder`方法用于统一下单,`notify`方法用于处理支付结果回调。在`init`方法中,初始化微信支付客户端时,从配置文件中读取微信支付参数。 在`notify`方法中,需要验证微信支付回调的签名,如果验证通过,则处理订单支付结果。在处理完成后,需要向微信支付服务器返回一个XML格式的响应,以通知微信支付服务器已经处理完成。 以上就是使用Java语言编写的微信支付服务器端代码示例,你可以根据自己的具体需求进行修改。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值