收藏
回答

微信官方php-sdk,收付通普通支付。按照readme写的,报错,签名错误?

v3/pay/partner/transactions/jsapi

$resp = $instance
    ->chain($this->api['transactions'])
    ->post([
        'json' => [
            'sp_appid'=>$this->config['sp_appid'],
            'sp_mchid'=>$this->config['sp_mchid'],
            'sub_mchid'=>$param['sub_mchid'],
            'description'=>$param['description'],
            'out_trade_no'=>$param['out_trade_no'],
            'notify_url'=>$this->notify,
            'settle_info'=>[
                'profit_sharing'=>true,// 分账
            ],
            'amount'=>[
                'total'=>$param['total']*100,
                'currency'=>'CNY',
            ],
            'payer'=>[
                'sp_openid'=>$param['sp_openid'],// 用户微信openid
            ],
        ],
    ]);

// 这里就会报错了 
Client error: `POST https://api.mch.weixin.qq.com/v3/pay/partner/transactions/jsapi` resulted in a `401 Unauthorized` 
response: {"code":"SIGN_ERROR","message":"签名错误"} 401 Unauthorized {"code":"SIGN_ERROR","message":"签名错误"} #0 
/www/wwwroot/laiketui/vendor/guzzlehttp/guzzle/src/Middleware.php(69): 
GuzzleHttp\Exception\RequestException::create() #1 /www/wwwroot/laiketui/vendor/guzzlehttp/promises/src/Promise.php(204): 
GuzzleHttp\Middleware::GuzzleHttp\{closure}()

官方sdk,例子 ,有啥缺失的吗,需要传 Authorization??sdk里生成 Authorization 的方法是哪个?
回答关注问题邀请回答
收藏

1 个回答

  • Memory
    Memory
    06-04

    初始化参数都是黑的,猜不到问题

    06-04
    有用
    回复
登录 后发表内容