微信平台收付通(分账)-请求分账接口一直报错:请求参数错误。
严格按照文档要求的参数,严格按照官方提供PHP版本SDK,
已经添加分账接收方,已经添加合单支付标识。
为啥还一直报参数错误,我应该怎么排查错误
PHP代码如下:
public function profitsharing($params){
try {
$requestData = [
'sub_mchid' => '1709441164',
'transaction_id' => '4343102484202503116409408407',
'out_order_no' => '4343102484202503116409408407',
'receivers' => [
[
'type' => 'MERCHANT_ID',
'receiver_account' => '1704664915',
'amount' => 3,
'description' => '测试分账'
]
],
'finish' => false
];
$debug = json_encode($requestData, JSON_UNESCAPED_UNICODE);
Log::debug('分账请求原始数据:'.$debug );
$headers = [
'Wechatpay-Serial' => config('pay.wechatpay.platform_serial_no'),
'Accept' => 'application/json',
'Content-Type' => 'application/json'
];
$response = $this->wechatPayClient
->chain('v3/ecommerce/profitsharing/orders')
->post([
'json' => $requestData,
'headers' => $headers,
'verify' => false
]);
return json_decode((string)$response->getBody(), true);
} catch (\Throwable $e) {
$errorInfo = [
'message' => $e->getMessage(),
'code' => $e->getCode()
];
if ($e instanceof RequestException && $e->hasResponse()) {
$response = $e->getResponse();
$errorInfo['status_code'] = $response->getStatusCode();
$errorInfo['headers'] = $response->getHeaders();
$errorInfo['response'] = (string)$response->getBody();
}
Log::error('分账异常详情', $errorInfo);
throw new Exception('分账请求失败: '.$e->getMessage());
}
}
apipost测试返回结果如下:
[2025-03-11T11:40:19+08:00][debug] 分账请求原始数据:{"sub_mchid":"1709441164","transaction_id":"4343102484202503116409408407","out_order_no":"4343102484202503116409408407","receivers":[{"type":"MERCHANT_ID","receiver_account":"1704664915","amount":6,"description":"测试分账"}],"finish":false}
[2025-03-11T11:40:19+08:00][error] 分账异常详情
[2025-03-11T11:40:19+08:00][error] [0]分账请求失败: Client error: `POST https:
{"code":"PARAM_ERROR","message":"请求参数错误"}
APPID呢?
请求分账文档:微信分配的公众账号ID是选填,但实际是这个appid是必填项,感谢!
appid 选填 string(32)
【微信分配的公众账号ID】微信分配的公众账号ID
因为文档写的选填,之前添加了后来请求接口报参数错误,又去掉后请求接口还是报参数参数。刚刚我又添加了appid。请求接口成功返回: { "status": 1000, "msg": "", "data": { "order_id": "30001909912025031183873449929", "out_order_no": "4343102484202503116409408407", "receivers": [ { "amount": 3, "description": "测试分账", "detail_id": "36001909912025031119786248039", "finish_time": "2025-03-11T13:24:54+08:00", "receiver_account": "1704664915", "receiver_mchid": "1704664915", "result": "SUCCESS", "type": "MERCHANT_ID" } ], "status": "FINISHED", "sub_mchid": "1709441164", "transaction_id": "4343102484202503116409408407" }, "refresh_ticket": "" }