收藏
回答

V3版本RefundService 调用退款接口,返回签名失败,怎么解决?

    com.github.wechatpay-apiv3
    wechatpay-java
    0.2.17


创建订单成功,
支付成功,
创建退款申请失败,报签名错误
refundService.create(request);


日志

httpResponseBody[{"code":"SIGN_ERROR","detail":{"detail":{"issue":"sign not match"},"field":"signature","location":"authorization","sign_information":{"method":"POST","sign_message_length":336,"truncated_sign_message":"POST\n/v3/refund/domestic/refunds\n1752115499\nKYsfbzRKGJbbNy2U4y3oxGeEs6RyxqqA\n{\"transa\n","url":"/v3/refund/domestic/refunds"}},"message":"错误的签名,验签失败"}] HttpRequest[{"http_method":"POST","url":"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds","uri":"https://api.mch.weixin.qq.com/v3/refund/domestic/refunds","headers":{"headers":{"Authorization":"WECHATPAY2-SHA256-RSA2048 mchid=\"1721962xxx\",nonce_str=\"KYsfbzRKGJbbNy2U4y3oxGeEs6RyxqqA\",timestamp=\"1752115499\",serial_no=\"3E57089EE74F863C2FBF2B9B0065FE8102D959C1\",signature=\"Ec8n5unkQ4TTBigVsd1Mepb1Dx+OZPhDIQNb52vr0OsDsnb7pJiCq+VmvCvkxJ/0iV+8lSOcW5MftOdw8IqsHTF62inPVCI2TefdggV6/cRe/MXDcqUeXUGymVjGj8eyAFqxzBacbkhOvh5Q8nmo3b8bRXokKeSrAMCJFyDXJLDVXreAGMXaTKXoaymfqb4R+0N+nGkfva+8SUNWFnVNICU60u+KEfrWtrYHdSjSB63zYaQv9MFpPocfKC27bNqU6uptUdlGTB1tMKdyLehnPoyOFHQ28fLcxFEJZh4fOrQulNQZ8FtwfgnFA3LS2a+47DW8MoqhUrT1UnV/SUKIgg==\"","Accept":"application/json","User-Agent":"WechatPay-Java/0.2.17 (Windows 11/10.0) Java/1.8.0_391 Credential/WechatPay2Credential Validator/WechatPay2Validator okhttp3/null","Content-Type":"application/json","Wechatpay-Serial":"PUB_KEY_ID_0117219628512025xxxxxxxxdddd003000"}},"body":{"body":"{\"transaction_id\":\"4200002748202507106725999438\",\"out_trade_no\":\"21105024433165108042\",\"out_refund_no\":\"21154995022488767916\",\"notify_url\":\"https://163hk45580mx.vicp.fun/api/applet/refundNotify/without_token\",\"amount\":{\"refund\":1,\"total\":1,\"currency\":\"CNY\"}}"}}]


调用的sdk方法,是RefundService的构建方式不对吗?》

public Config rasPublicKetConfig(){
        if(config == null){
            config = new RSAPublicKeyConfig.Builder()
                    .merchantId(wxPayProperties.getMerchantId())
                    .privateKeyFromPath(getFilePath(wxPayProperties.getPrivateKeyPath()))
                    .publicKeyFromPath(getFilePath(wxPayProperties.getPublicKeyPath()))
                    .publicKeyId(wxPayProperties.getPublicKeyId())
                    .merchantSerialNumber(wxPayProperties.getMerchantSerialNumber())
                    .apiV3Key(wxPayProperties.getApiV3Key())
                    .build();
        }
        return config;
    }
refundService =  new RefundService.Builder().config(rasPublicKetConfig()).build();



最后一次编辑于  2025-07-10
回答关注问题邀请回答
收藏
登录 后发表内容