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}"
}
}]

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