收藏
回答

调用API退款报错:For input string: "PUB",如何处理?

private void initWXPayService() {
    File file = new File(this.getClass().getResource("/").getPath());
    String path = file.getPath();
    RSAConfig config = new RSAConfig.Builder()
            .merchantId(Configure.getMch_id())
            .merchantSerialNumber(Configure.getMerchantSerialNumber())
            .privateKeyFromPath(path + "/wxpaycert/apiclient_key.pem")
            .wechatPayCertificatesFromPath(
                    path + "/wxpaycert/apiclient_cert.pem",
                    path + "/wxpaycert/apiclient_platform_cert.pem")
            .build();


    service = new com.wechat.pay.java.service.refund.RefundService.Builder().config(config).build();
}

CreateRequest requestRefund = new CreateRequest();

AmountReq amountReq = new AmountReq();
//订单总金额: 单位 分
amountReq.setTotal(totalPrice.multiply(new BigDecimal("100")).longValue());
//退款金额: 单位 分
amountReq.setRefund(refundPrice.multiply(new BigDecimal("100")).longValue());
//人民币
amountReq.setCurrency("CNY");

requestRefund.setAmount(amountReq);
requestRefund.setOutTradeNo(outTradeNo);
requestRefund.setOutRefundNo(outRefundNo);

//发送退款请求:这里直接抛出异常: java.lang.NumberFormatException: For input string: "PUB"

Refund refund = service.create(requestRefund);


回答关注问题邀请回答
收藏

1 个回答

  • Memory (私信不回复)
    Memory (私信不回复)
    05-30

    验证签名需要用到平台证书或微信支付公钥,你给的不对

    05-30
    有用
    回复 1
    • 一林
      一林
      06-19
      嗯。证书不能用了,该用公钥了。
      06-19
      回复
登录 后发表内容