https://github.com/wechatpay-apiv3/wechatpay-guzzle-middleware/pull/18 这个0侵入的加/解密方案,可以尝试下。 use WechatPay\GuzzleMiddleware\Util\SensitiveInfoCodec as Codec; // Codec默认为加密模式,实例后直接当方法用即可 $encryptor = new Codec(PemUtil::loadCertificate('/downloaded/public.pem')); // POST 语法糖 $resp = $client->post('/v3/applyment4sub/applyment/', [ 'json' => [ 'business_code' => 'APL_98761234', 'contact_info' => [ 'contact_name' => $encryptor('窃格瓦拉'), 'contact_id_number' => $encryptor('45012119841227000X'), 'mobile_phone' => $encryptor('12345678901'), 'contact_email' => $encryptor('noop@real.world'), ], //... ], 'headers' => [ // 命令行获取证书序列号 // openssl x509 -in /downloaded/public.pem -noout -serial | awk -F= '{print $2}' 'Wechatpay-Serial' => 'must be the serial number via the downloaded pem file of `/v3/certificates`', 'Accept' => 'application/json', ], ]);
服务商特约商户进件提交申请单密文加密错误错误信息: {"code""PARAM_ERROR","message""请确认待处理的消息是否为加密后的密文"} 看到特约商户更新了文档之后,我采用的是最新的API-v3接口规则 请求头如下(证书序列号是微信支付平台序列号): array("Content-Type: application/json","Accept:application/json","User-Agent:".$_SERVER['HTTP_USER_AGENT'],"Authorization:"$this->authorization,"Wechatpay-Serial:"$this->cert_sn) 验签如下(验签使用的是商户平台私钥): $url_parts = parse_url($url); $canonical_url = ($url_parts['path'] . (!empty($url_parts['query'])) ? "?${url_parts['query']}" : "")); $message = strtoupper($http_method).'\n'.canonical_url.'\n'. $timestamp.'\n'. $nonce.'\n'. $body.'\n'; $pri_key_string = file_get_contents($this->apiclient_key); $pri_key = openssl_get_privatekey($pri_key_string); if(!openssl_sign(message, raw_sign, pri_key, 'sha256WithRSAEncryption')){ throw new WxPayException('make sign failed:'.PHP_EOL); } $sign = base64_encode($raw_sign); 加密敏感信息(使用微信支付平台公钥): $pub_key_string = file_get_contents($this->cert_path); $pub_key = openssl_get_publickey($pub_key_string); $encrypted = ''; if(openssl_public_encrypt($str,$encrypted,$pub_key,OPENSSL_PKCS1_OAEP_PADDING)){ return base64_encode($encrypted); } 麻烦看一下是什么问题,官方给的错误信息没有明确指出是哪个字段加密出错,现在找不到处理的办法了。
2020-06-02别慌,按照官方帮助文档 -> 微信支付商户自查违规记录/申诉指引 查询下,按要求提供资料申诉即可。
微信商户涉及交易异常?啥也没做,就被微信限制了提款权限。只能收钱不能提现? [图片]
2020-06-02https://github.com/wechatpay-apiv3/wechatpay-guzzle-middleware/pull/16 已0侵入解决图片上传问题,不用再花精力拼接body体了,用法见 commit 说明。 use WechatPay\GuzzleMiddleware\Util\MediaUtil; // 实例化一个媒体文件流,注意文件后缀名需符合接口要求 $media = new MediaUtil('/your/file/path/with.extension'); // POST 语法糖 $resp = $client->post('merchant/media/upload', [ 'body' => $media->getStream(), 'headers' => [ 'Accept' => 'application/json', 'content-type' => $media->getContentType(), ] ]);
wechatpay-guzzle-middleware如何上传图片?如何使用这个sdk上传图片。我是用如下代码,无法通过验签 $wechatPayMiddleware = WechatPayMiddleware::builder() ->withMerchant(CommonData::MCH_ID, CommonData::SERIAL_NUMBER, CommonData::getPrivateKey()) ->withWechatPay([ CommonData::getCertificate() ]) // 可传入多个微信支付平台证书,参数类型为array ->withValidator(new NoValidator()) ->build(); // 将WechatPayMiddleware添加到Guzzle的HandlerStack中 $stack = HandlerStack::create(); $stack->push($wechatPayMiddleware, 'wechatpay'); // 创建Guzzle HTTP Client时,将HandlerStack传入 $client = new \GuzzleHttp\Client(['handler' => $stack, 'verify' => false]); $url = 'https://xxx.com/'.$object; // 接下来,正常使用Guzzle发起API请求,WechatPayMiddleware会自动地处理签名和验签 $resp = $client->request('POST', CommonData::URL . $this->getUri(), [ 'headers' => [ 'Accept' => 'application/json' ], 'multipart' => [ [ 'name'=>'file', 'contents'=>fopen($url, 'r') ], [ 'name'=>'meta', 'contents'=>json_encode([ 'filename'=>basename($url), 'sha256'=>hash('sha256', (new Oss())->downloadFile('hic-image', $object)), ]) ] ], ]); $result = json_decode($resp->getBody()->getContents(), true);
2020-06-01