收藏
回答

Authorization不合法

微信支付接入 还没发起支付就一直报这个错误 我也是按照文档一步一步配置的 有没有懂php的高手看一下

public function showSign($url)
{
    $time = time();
    $str = md5(rand(0000,9999));
    $sign = $this->getsSign('POST\n'.$url.'\n'.$time.'\n'.$str.'\n\n');
    $nonce_str = md5(rand(0000,9999));
    $timestamp = time();
    $acc = 'WECHATPAY2-SHA256-RSA2048'.' mchid='.C('JSAPI.mchid').',nonce_str='.$nonce_str.',timestamp='.$timestamp.',serial_no='.C('JSAPI.cert').',signature='.$sign;
    return $acc;
}

private function getsSign($content){
    $key = file_get_contents('./Public/Files/private_key.pem');
    openssl_sign($content, $signature, $key, "sha256WithRSAEncryption");
    openssl_free_key($key);
    $sign = base64_encode($signature);
    return $sign;
}
返回结果,我打印了下3个参数
string(53) "https://api.mch.weixin.qq.com/v3/profitsharing/orders"

array(5) {
  ["appid"] => string(18) "wx*********"
  ["transaction_id"] => string(18) "G21091709464426319"
  ["out_order_no"] => string(14) "P1631931559113"
  ["unfreeze_unsplit"] => bool(true)
  ["receivers"] => array(4) {
    ["type"] => string(11) "MERCHANT_ID"
    ["account"] => string(28) "o1rM_6QTKa*******dsqfVIDZEcs"
    ["amount"] => int(1)
    ["description"] => string(18) "分账测试给123"
  }
}

string(512) "WECHATPAY2-SHA256-RSA2048 mchid=*******,nonce_str=5a7f963e5e0504740c3a6b10bb6d4fa5,timestamp=1631931559,serial_no=702CD70A857D93513638D8EB6D4FF2D53B042321,signature=mt3q4YkAIQJO873h7RbLrhDAgN2Y/8Uzia6lOxF2Qyo9v20GAoU+x7+C0CYKktM16/12wBWjseFyLjYITPcqh5sCiSOwIX/dL4dDABQSDrTLv/0kktceT7XAW+Fb0YXJQ91eyI+CUvMjuJezISjwFqjOiXSdwuMwe2Br8X8+CicgnEogEc4XIn3ieBk2dtS36H3i5V5Yd5Ilr7KBUqyeQ91m8Px/YH36ENxlWk/30Yqd9L7GJHrrndE2cB2iUWq0QVkaCXqP1mZCsncwoIxEuDWaoI9mRquIKz1jBwEQOxCW1pcfDogbFPCNfsOwhtWXvGB/SYk4sr6gglAei3su0A=="

string(56) "{"code":"SIGN_ERROR","message":"Authorization不合法"}"
回答关注问题邀请回答
收藏

1 个回答

登录 后发表内容