收藏
回答

新版代金券创建

最新代金券创建的时候没有签名字段,是不需要传了么?

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

3 个回答

  • 左边
    左边
    2020-07-21
    //获取私钥
    public function getPrivateKey()
    {
        //绝对路径 $this->apiclient_cert
        $this->apiclient_cert = file_get_contents($this->apiclient_cert);//获取私钥
    }
    
    /**
     * 生成签名
     */
    protected function getSign()
    {
        $url_parts = parse_url($this->url);  //链接
        $canonical_url = ($url_parts['path'] . (!empty($url_parts['query']) ? "?${url_parts['query']}" : ""));
        $this->timestamp = time();
        $this->nonce_str = createKey(); //随机字符串
        $message =
            "POST\n" .
            $canonical_url . "\n" .
            $this->timestamp . "\n" .
            $this->nonce_str . "\n" .
            $this->body . "\n";
        $this->getPrivateKey();  //生成私钥
        openssl_sign($message, $raw_sign, $this->apiclient_cert, 'sha256WithRSAEncryption');
        $this->sign = base64_encode($raw_sign);
    }
    raw_sign 这个参数是什么意思提示Authorization不合法因为签名没有生成
    
    
    2020-07-21
    有用
    回复 1
    • 左边
      左边
      2020-07-21
      项目php版本为5.4.45
      2020-07-21
      回复
  • 微信支付技术助手8
    微信支付技术助手8
    2020-07-20

    https://wechatpay-api.gitbook.io/wechatpay-api-v3/你好,V3签名参考这篇文档。

    2020-07-20
    有用
    回复 2
  • 北望沣渭
    北望沣渭
    2020-07-20

    是说V3版代金券创建吗?V3版签名是在请求头HEADER,请求体是纯数据。

    2020-07-20
    有用
    回复 1
    • 左边
      左边
      2020-07-21
      官方的代码没有注释,是V3的代金券,签名的$raw_sign这个参数是什么意思
      2020-07-21
      回复
登录 后发表内容
问题标签