yansongda / pay

可能是我用过的最优雅的 Alipay/WeChat/Douyin/Unipay/江苏银行 的支付 SDK 扩展包了
http://pay.yansongda.cn
MIT License
5.01k stars 1.03k forks source link

微信公众号支付服务商模式下出现错误 "请求中含有未在API文档中定义的参数" #854

Closed andy236726493 closed 11 months ago

andy236726493 commented 11 months ago

包版本号

V3.5.0

问题描述

微信公众号支付,服务商模式出现错误 "请求中含有未在API文档中定义的参数"(单商户支付是可以的)

你的代码

config : 'test' => [ // 必填-商户号,服务商模式下为服务商商户号 'mch_id' => '1575503*21', // 选填-v2商户私钥 'mch_secret_key_v2' => 'be9ee1a1f7d2c0530f5ef2139e13624038', // 必填-商户秘钥 'mch_secret_key' => 'be9ee1a1f7d2c0530f5efb9e2133624038', // 必填-商户私钥 字符串或路径 'mch_secret_cert' => BASE_PATH . '/config/wechat/payconfig/service/apiclient_key.pem', // 必填-商户公钥证书路径 'mch_public_cert_path' => BASE_PATH . '/config/wechat/payconfig/service/apiclient_cert.pem', // 必填 'notify_url' => env('APP_URL') . "/api/wechat/pay/notify/elwjoerpmb", // 选填-公众号 的 app_id 'mp_app_id' => 'wxffc212312341c766c5', // 选填-小程序 的 app_id 'mini_app_id' => '', // 选填-app 的 app_id 'app_id' => '', // 选填-合单 app_id 'combine_app_id' => '', // 选填-合单商户号 'combine_mch_id' => '', // 选填-服务商模式下,子公众号 的 app_id 'sub_mp_app_id' => '', // 选填-服务商模式下,子 app 的 app_id 'sub_app_id' => '', // 选填-服务商模式下,子小程序 的 app_id 'sub_mini_app_id' => '', // 选填-服务商模式下,子商户id 'sub_mch_id' => '1635421451', // 选填-微信公钥证书路径, optional,强烈建议 php-fpm 模式下配置此参数 'wechat_public_cert_path' => [ '' => '', ], // 选填-默认为正常模式。可选为: MODE_NORMAL, MODE_SERVICE 'mode' => Pay::MODE_SERVICE, ],

代码; public function index() { try { $add_data = [ '_config' => 'test', // 多租户 'out_trade_no' => ( string ) time(), 'description' => 'test', 'settle_info' => ["profit_sharing" => true], 'amount' => [ 'total' => 1, ], 'payer' => [ 'openid' => 'odver***-nvKbQTvZrc', ],

       ];
       $res = $this->pay->wechat()->mp($add_data);
       var_dump($res);
       return [$res];
   }catch (\Throwable $e){
       var_dump($e->getMessage());
       return [$e->getMessage()];
   }

}

报错详情

微信统一下单出现错误 "请求中含有未在API文档中定义的参数"

sdk 日志

nginx/apache 日志

涉及到 异步通知、同步通知 的问题,请贴出来

yansongda commented 11 months ago

日志?

andy236726493 commented 11 months ago

日志 打不开啊

andyzhu @.***

 

------------------ 原始邮件 ------------------ 发件人: "yansongda/pay" @.>; 发送时间: 2023年9月25日(星期一) 中午11:00 @.>; @.**@.>; 主题: Re: [yansongda/pay] 微信公众号支付服务商模式下出现错误 "请求中含有未在API文档中定义的参数" (Issue #854)

日志?

— Reply to this email directly, view it on GitHub, or unsubscribe. You are receiving this because you authored the thread.Message ID: @.***>

yansongda commented 11 months ago

对着微信官方文档看看哪些参数多传了

andy236726493 commented 11 months ago

$pay->wechat()->mp( $params );这样写日志没有生成 加了 ['_force' => true], log才会生成了, $pay->wechat( array_merge($config, ['_force' => true]) )->mp( $params ); 从日志里看 是detail":{"location":null,"value":["/body/payer/openid",openid 我检查了,没有错啊