wechatpay-apiv3 / wechatpay-java

微信支付 APIv3 的官方 Java Library
Apache License 2.0
923 stars 206 forks source link

jsapi支付时,仅能支付第一单,然后应用卡死,不能再接受新单子。 #140

Closed TaoWolf closed 1 year ago

TaoWolf commented 1 year ago

错误描述

image 请看图,不管是在controller中,还是在main的测试中,都是第一次运行后就一直卡死了,这是什么原因?

重现bug的步骤

使用官方的示例,就会卡死。 // 使用自动更新平台证书的RSA配置 // 一个商户号只能初始化一个配置,否则会因为重复的下载任务报错 public static volatile RSAAutoCertificateConfig config = null;

public static void main(String[] args) {
    if(null==config){
        config = new RSAAutoCertificateConfig.Builder()
                .merchantId(merchantId)
                .privateKeyFromPath(privateKeyPath)
                .merchantSerialNumber(merchantSerialNumber)
                .apiV3Key(apiV3key)
                .build();
    }
    SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddHHmmss");
    String dateStr = sdf.format(new Date());
    Random random = new Random();
    String randomStr = String.valueOf(random.nextInt(100000000));
    String tradeNo = dateStr + randomStr;
    PrepayRequest request = new PrepayRequest();

// Config config = // new RSAConfig.Builder() // .merchantId(merchantId) // .privateKeyFromPath(privateKeyPath) // .merchantSerialNumber(merchantSerialNumber) // .wechatPayCertificatesFromPath(wechatPayCertificatePath) // .build(); Amount amount = new Amount(); amount.setTotal(1); request.setAmount(amount); request.setAppid(appId); request.setMchid(merchantId); request.setDescription("测试商品标题"); request.setNotifyUrl("https://notify_url"); request.setOutTradeNo(tradeNo); Payer payer = new Payer(); payer.setOpenid("ot-te509zuM1DDrToQR0eQgYV-Bk"); request.setPayer(payer); //wx2523244954655625ca2beb60eb1feb0000 JsapiServiceExtension serviceExt = new JsapiServiceExtension.Builder().config(config).build(); // response包含了调起支付所需的所有参数,可直接用于前端调起支付 PrepayWithRequestPaymentResponse responsePre = serviceExt.prepayWithRequestPayment(request); System.err.println(responsePre); }

预期行为

使用一次后卡死。

导致错误的代码片段

No response

操作系统

windows11/CentOS8

Java 版本

8

wechatpay-java 版本

0.2.6

其他信息

No response

TaoWolf commented 1 year ago

已经看到文档中的提醒,感谢!