- 按照java sdk快速开始文档中的代码和配置,执行报错。
代码如下: [图片] 报错信息如下: 16:11:38.893 DEBUG com.wechat.pay.java.core.auth.WechatPay2Credential - authorization message[POST /v3/pay/transactions/native 1735027898 lWZl2cyaxLtAl8gfwmT2k0KKgoXZ2YwG {"appid":"有值,"mchid":"有值","description":"测试商品标题","out_trade_no":"111111111","notify_url":"***********************","amount":{"total":10}} ] 16:11:38.917 DEBUG com.wechat.pay.java.core.auth.WechatPay2Credential - The generated request signature information is[mchid="有值",nonce_str="有值",timestamp="有值",serial_no="有值",signature="有值"] Exception in thread "main" java.lang.NullPointerException at com.wechat.pay.java.core.util.PemUtil.getSerialNumber(PemUtil.java:231) at com.wechat.pay.java.core.cipher.AbstractVerifier.getSerialNumber(AbstractVerifier.java:138) at com.wechat.pay.java.core.auth.WechatPay2Validator.getSerialNumber(WechatPay2Validator.java:66) at com.wechat.pay.java.core.http.AbstractHttpClient.getWechatPaySerial(AbstractHttpClient.java:137) at com.wechat.pay.java.core.http.AbstractHttpClient.execute(AbstractHttpClient.java:43) at com.wechat.pay.java.service.payments.nativepay.NativePayService.prepay(NativePayService.java:164) at WxPayQuickStart.main(WxPayQuickStart.java:48)
2024-12-24 - 获取沙箱环境的sandbox_signkey成功。但是代入统一下单接口就失败了。
使用沙箱环境开发NATIVE支付接口。 第一步使用正式的密钥key生成正式的sign。 第二步使用sign和mch_id获取sandbox_signkey Map<String, String> params = new HashMap<String, String>(); params.put("mch_id", this.getMchID()); params.put("nonce_str", WXPayUtil.generateNonceStr()); String signSX = WXPayUtil.generateSignature(params, this.getKey()); params.put("sign", signSX); String strXML = wxPay.requestWithoutCert("https://api.mch.weixin.qq.com/sandboxnew/pay/getsignkey", params, this.getHttpConnectTimeoutMs(), this.getHttpReadTimeoutMs()); Map<String, String> result = WXPayUtil.xmlToMap(strXML); System.out.println("retrieveSandboxSignKey:" + result); if ("SUCCESS".equals(result.get("return_code"))) { return result.get("sandbox_signkey"); } 得到sandbox_signkey之后。替换正式的密钥key.然后调用统一下单接口。 data.put("sign", WXPayUtil.generateSignature(params, iWxPayConfig.getKey())); System.out.println("发起微信支付下单接口, request={}"+ data.toString()); Map<String, String> response = wxpay.unifiedOrder(data); 返回 response={}{return_msg=沙箱验证签名失败,请确认沙箱签名key是否正确(通过getsignkey调用生成), return_code=FAIL}
2019-04-01