我已經將v2版本的服務商支付跑起來了。
目前嘗試改造v3版,依托于v2已經在傳遞的是sub_openid
在PayClient中將v3的普通商戶的接口常量替換為服務商api接口。
改造了對應服務商的參數。
原版:
public function pay(string $type, string $appid, string $outTradeNo, string $total, string $description, string $attach, array $payer = [])
{
$totalFee = (int)bcmul($total, '100');
$data = [
'appid' => $appid,
'mchid' => $this->app['config']['v3_payment']['mchid'],
'out_trade_no' => $outTradeNo,
'attach' => $attach,
'description' => $description,
'notify_url' => $this->app['config']['v3_payment']['notify_url'],
'amount' => [
'total' => $totalFee,
'currency' => 'CNY'
],
];
改造后
public function pay(string $type, string $appid, string $outTradeNo, string $total, string $description, string $attach, array $payer = [])
{
$totalFee = (int)bcmul($total, '100');
$data = [
'sp_appid' => $appid,
'sp_mchid' => $this->app['config']['v3_payment']['mchid'],
'sub_mchid' => $this->app['config']['v3_payment']['sub_mch_id'],
'out_trade_no' => $outTradeNo,
'attach' => $attach,
'description' => $description,
'notify_url' => $this->app['config']['v3_payment']['notify_url'],
'amount' => [
'total' => $totalFee,
'currency' => 'CNY'
],
];
其中sub_mch_id已經在V3WechatPay中增加了對應的參數。
實際在小程序中調用的時候提示“請求中含有未在API文檔中定義的參數”
我也一一反復對比了微信官方文檔和easywechat的官方文檔。感覺我這里的改造應該沒有問題啊。
麻煩請各位指點一下,是哪里出的問題。