收藏
回答

微信支付验签失败?

$url_parts = parse_url($url);
$canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));

$message = $http_method . "\n" .
    $canonical_url . "\n" .
    $timestamp . "\n" .
    $nonce . "\n" .
    $body . "\n";

openssl_sign($message, $raw_sign, $mch_private_key, 'sha256WithRSAEncryption');
$sign = base64_encode($raw_sign);

$schema = 'WECHATPAY2-SHA256-RSA2048 ';
$token = sprintf('mchid="%s",nonce_str="%s",timestamp="%d",serial_no="%s",signature="%s"',
    $merchant_id, $nonce, $timestamp, $serial_no, $sign);
return $token;



$url = "https://api.mch.weixin.qq.com/v3/certificates";
$timestamp = time();
$nonce = $this->nonce_str();
$body = '';
$sign = $this->sign($url, 'GET', $timestamp, $nonce, $body, $this->getPrivateKey($this->private_key), $this->mch_id,
    $this->serial_no);

$header = [
    'Authorization: WECHATPAY2-SHA256-RSA2048 ' . $sign,
    'Accept:application/json',
    'User-Agent:' . $this->mch_id,
];
Log::info('提现问题', $header);
$result = $this->curl($url, '', $header, 'GET');
$result = json_decode($result, true);


回答关注问题邀请回答
收藏

1 个回答

  • 支付社区运营
    支付社区运营
    11-26

    还请提供一下验签失败返回的具体错误信息

    11-26
    有用
    回复
登录 后发表内容