收藏
回答

服务商请求分账接口?

ProfitSharingComponent profitSharingComponent = getSpProfitSharingComponent(wxApiV3PubKey);
CreateOrderRequest createOrderRequest = new CreateOrderRequest();
createOrderRequest.setAppid(config.getSpAppId());
createOrderRequest.setTransactionId(wxSubledgerVO.getWXPAYID());
createOrderRequest.setOutOrderNo(wxSubledgerVO.getPAYORDERID());
createOrderRequest.setSubAppid(wxSubledgerVO.getAPPID());
createOrderRequest.setSubMchid(bsPos.getMCHID());
JSONArray jsonArray = buildReceivers(wxSubledgerVO);
List receivers = JSONUtil.toList(jsonArray, CreateOrderReceiver.class);
createOrderRequest.setReceivers(receivers);
createOrderRequest.setUnfreezeUnsplit(true);
OrdersEntity ordersEntity = profitSharingComponent.createOrder(createOrderRequest);


public static ProfitSharingComponent getSpProfitSharingComponent(Config wxApiV3PubKey) {
    return new ProfitSharingComponent.Builder().config(wxApiV3PubKey).build();
}


@Bean("wxApiV3PubKey")
public Config getConfig() {
    return new RSAPublicKeyConfig.Builder()
            .merchantId(this.spMchId) //微信支付的商户号
            .privateKeyFromPath(this.privateKeyPath) // 商户API证书私钥的存放路径
            .publicKeyFromPath(this.pubKeyPath) //微信支付公钥的存放路径
            .publicKeyId(this.pubKeyId) //微信支付公钥ID
            .merchantSerialNumber(this.mchSerialNo) //商户API证书序列号
            .apiV3Key(this.apiV3Key) //APIv3密钥
            .build();
}



接口返回错误:

[{

"code": "SIGN_ERROR",

"detail": {

"detail": {

"issue": "sign not match"

},

"field": "signature",

"location": "authorization",

"sign_information": {

"method": "POST",

"sign_message_length": 428,

"truncated_sign_message": "POST\n/v3/profitsharing/orders\n1758793006\nJsak1h7GydhlpdBcYJGnqElXt1S1hkI3\n{\"sub_mc\n",

"url": "/v3/profitsharing/orders"

}

},

"message": "错误的签名,验签失败"

}]HttpRequest[{

"http_method": "POST",

"url": "https://api.mch.weixin.qq.com/v3/profitsharing/orders",

"uri": "https://api.mch.weixin.qq.com/v3/profitsharing/orders",

"headers": {

"headers": {

"Authorization": "WECHATPAY2-SHA256-RSA2048 mchid=\"******\",nonce_str=\"Jsak1h7GydhlpdBcYJGnqElXt1S1hkI3\",timestamp=\"1758793006\",serial_no=\"---我留空了----\",signature=\"JMqFfZitQVO0PZeU5BRYOFQ1Peyu5fK+QeRW7mxkT88DubROuw1AfkYIMxvVRU9AMYdNz2w6RlzlgHBy0hisni6ngnk/BXjOhdRyIwvkcH4DHqtWL7AaNSzuLKIfWSBrMtNkZynaO2kQpNwHPVugUCAy9Rhw2P+iNB23e+JkU2XhJ1RMg8AhBJHoD0COBvMG9+euqUok0SYzK8HV8GFb5gTpAReeyVu4iY1sx/dvU6oqCo26a+EjZZjsvpmC6mG8lonrjdT4D0/R18Kz02Fj8m9iFbUyrT5aAdSyhsb5QnKE/7g+lr2dEkl9pWsZmGcwGLeoVhNIS5cH6Ga4oQ0vNg==\"",

"Accept": "application/json",

"User-Agent": "WechatPay-Java/0.2.15 (Windows 11/10.0) Java/1.8.0_321 Credential/WechatPay2Credential Validator/WechatPay2Validator okhttp3/null",

"Content-Type": "application/json",

"Wechatpay-Serial": "---我留空了----"

}

},

"body": {

"body": "{\"sub_mchid\":\"****\",\"appid\":\"****\",\"sub_appid\":\"****\",\"transaction_id\":\"****\",\"out_order_no\":\"****\",\"receivers\":[{\"type\":\"PERSONAL_SUB_OPENID\",\"account\":\"---我留空了----\",\"amount\":100,\"description\":\"分账来源为-****的订单\"}],\"unfreeze_unsplit\":true}"

}

}]


最后一次编辑于  2025-09-26
回答关注问题邀请回答
收藏

1 个回答

  • Memory (私信不回复)
    Memory (私信不回复)
    2025-09-25

    是你的问题,不是接口的问题

    2025-09-25
    有用
    回复 8
    • tax
      tax
      发表于移动端
      2025-09-25
      发现了,明天解决,哈哈哈
      2025-09-25
      回复
    • tax
      tax
      2025-09-26
      啥问题,我还是没有找到,昨天以为是参数不对,结果还是 签名错误。我使用的都是官方自己的服务
      2025-09-26
      回复
    • tax
      tax
      发表于移动端
      2025-09-26
      已经解决了哦,本地不管怎么样都会返回签名错误,需要发布正式环境调用,就没问题了
      2025-09-26
      回复
    • Memory (私信不回复)
      Memory (私信不回复)
      2025-09-26回复tax
      你是win和Linux的区别吧
      2025-09-26
      回复
    • tax
      tax
      2025-09-26回复Memory (私信不回复)
      如何看出来的,,, 我本地是win,我发布到linux服务器上调用就好了
      2025-09-26
      回复
    查看更多(3)
登录 后发表内容