代码如下:
报错信息如下:
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)
getSerialNumber空指针,你前面怎么定义的?下面这部分内容没看到你截出来
/** 商户号 */ public static String merchantId = "190000****"; /** 商户API私钥路径 */ public static String privateKeyPath = "/Users/yourname/your/path/apiclient_key.pem"; /** 商户证书序列号 */ public static String merchantSerialNumber = "5157F09EFDC096DE15EBE81A47057A72********"; /** 商户APIV3密钥 */ public static String apiV3Key = "...";