thinkphp5.0中小程序支付报 ERROR_GATEWAY: Get Wechat API Error:
- 环境:
lamp
+ 小程序 +thinkPHP5.0
- 使用的是
yansongda/pay 2.9.3
扩展包做的支付 - 报错如下:
- 日志如下:
代码如下:
protected $config = [ 'miniapp_id' => '***', 'mch_id' => '**', // 商户号 'key' => '**', // 支付秘钥 'notify_url' => 'http://requestbin.net/r/1005cpc1', 'log' => [ // optional 'file' => '', 'level' => 'debug', // 建议生产环境等级调整为 info,开发环境为 debug 'type' => 'single', // optional, 可选 daily. 'max_file' => 30, // optional, 当 type 为 daily 时有效,默认 30 天 ], 'http' => [ // optional 'timeout' => 5.0, 'connect_timeout' => 5.0, ], 'mode' => 'dev', // optional, dev/hk;当为 `hk` 时,为香港 gateway。 ]; ... $order = [ 'out_trade_no' => $orderId, 'total_fee' => '1', // **单位:分** 'body' => 'test body', 'openid' => $openid['openid'] ]; $pay = Pay::wechat($this->config); $result = $pay->miniapp($order); return json($result);
商户号和支付秘钥没有问题, 求大佬指教下该怎么解决
终于解决了, 是因为
$config
中的mode
问题, 这里应该设置normal