如何解决微信支付中出现【appid和openid不匹配】问题?
@ApiOperation(value = "预支付")
@PostMapping("/wxAppletPay")
public WxPayUnifiedOrderV3Result.JsapiResult wxAppletPay(PayRequestDTO weChatPayRequest) throws Exception {
WxPayConfig wxConfig = this.getWxConfig();
System.out.println(wxConfig.getAppId()+"appid"+weChatPayRequest.getOpenId()+"openid");
WxPayServiceImpl wxPayServiceApacheHttp = new WxPayServiceImpl();
wxPayServiceApacheHttp.setConfig(this.getWxConfig());
WxPayUnifiedOrderV3Request request = new WxPayUnifiedOrderV3Request();
WxPayUnifiedOrderV3Request.Amount amount = new WxPayUnifiedOrderV3Request.Amount();
amount.setCurrency("CNY").setTotal(weChatPayRequest.getTotalFee().multiply(new BigDecimal(100)).intValue());
WxPayUnifiedOrderV3Request.Payer payer = new WxPayUnifiedOrderV3Request.Payer();
payer.setOpenid(weChatPayRequest.getOpenId());
WxPayUnifiedOrderV3Request.SceneInfo sceneInfo = new WxPayUnifiedOrderV3Request.SceneInfo();
sceneInfo.setPayerClientIp("127.0.0.1");
request.setAmount(amount).setPayer(payer).setOutTradeNo(weChatPayRequest.getOrderNo())
.setSceneInfo(sceneInfo).setDescription(weChatPayRequest.getBody()).setNotifyUrl("http://ling.l2.ttut.cc/app/wxzf/notify/order");
WxPayUnifiedOrderV3Result result = wxPayServiceApacheHttp.unifiedOrderV3(TradeTypeEnum.JSAPI, request);
//WxPayConfig wxConfig =getWxConfig();
String privateKeyPath = wxConfig.getPrivateKeyPath();
PrivateKey privateKey =getPrivateKey(privateKeyPath);
WxPayUnifiedOrderV3Result.JsapiResult payInfo = result.getPayInfo(TradeTypeEnum.JSAPI, wxConfig.getAppId(), wxConfig.getMchId(), privateKey);
return payInfo;
}
这是代码 appid是小程序的appid openid是小程序的openid