- wechatpay-guzzle-middleware 报错提示 class找不到
<?php declare (strict_types = 1); namespace app\wechat\extend; use GuzzleHttp\Client; use GuzzleHttp\HandlerStack; use WechatPay\GuzzleMiddleware\Util\PemUtil; use WechatPay\GuzzleMiddleware\WechatPayMiddleware; class WechatPay { public function place($data) { $merchantKey=PemUtil::loadPrivateKey(app()->getRootPath().$this->merchantPrivateKey); $merchantCert=PemUtil::loadCertificate(app()->getRootPath().$this->wechatpayCertificate); $wechatpayMiddleware=WechatPayMiddleware::builder() ->withMerchant($this->merchantId,$this->merchantSerialNumber,$merchantKey) ->withWechatPay([$merchantCert]) ->build(); $stack=HandlerStack::create(); $stack->push($wechatpayMiddleware); $client=new Client(['handler'=>$stack]); try { // $resp = $client->request('GET', 'https://api.mch.weixin.qq.com/v3/...', [ // 注意替换为实际URL // 'headers' => [ 'Accept' => 'application/json' ] // ]); // // echo $resp->getStatusCode().' '.$resp->getReasonPhrase()."\n"; // echo $resp->getBody()."\n"; $data['appid']=$this->APPID; $data['mchid']=$this->merchantId; $data=json_encode($data); $resp = $client->request('POST', $this->place_url, [ 'json' => $data, 'headers' => [ 'Accept' => 'application/json' ] ]); $res['statusCode']=$resp->getStatusCode(); $res['reasonPhrase']=$resp->getReasonPhrase(); $res['body']=$resp->getBody(); return $res; } catch (\RangeException $e) { // 进行错误处理 echo $e->getMessage()."\n"; if ($e->hasResponse()) { echo $e->getResponse()->getStatusCode().' '.$e->getResponse()->getReasonPhrase()."\n"; echo $e->getResponse()->getBody(); } return; } } } #0 [0]Error in WechatPay.php line 26Class 'WechatPay\GuzzleMiddleware\Util\PemUtil' not found报错class找不到,这个问题怎么解决,使用的是thinkphp6
2021-04-23 - 如何解决微信小程序登录,服务端解密有几率报错-41003的问题?
我搜索过社区中,查看了其他很多人的解决方案,一直没有找到解决方法,我是用户信息和手机号一起获取,是这个方向不能实现吗? 前台代码: 授权登陆 js代码: login: function (res) { var that=this; wx.login({ success: function (e) { var code = encodeURIComponent(e.code); wx.getUserInfo({ lang: "zh_CN", success: function (result) { var encryptedData= encodeURIComponent(res.detail.encryptedData); var iv=encodeURIComponent(res.detail.iv); console.log(res.detail.iv) wx.request({ url: 'xxxxxxxx', data: { code: code, encryptedData:encryptedData, iv:iv, distribution:that.data.distribution }, header: { "Content-Type": "application/x-www-form-urlencoded" }, method: "post", success: function (res) {} }) } }) } }) // console.log(res) }, 后台php代码: $post = $_POST; $code = urldecode($post['code']); $encryptedData = urldecode($post['encryptedData']); $iv = urldecode($post['iv']); // $phone = $post['phone']; // $sendCode = $post['sendCode']; $verifyUrl = "https://api.weixin.qq.com/sns/jscode2session?appid=" . $this->APPID . "&secret=" . $this->secret . "&js_code=" . $code . "&grant_type=authorization_code"; $verify = $this->curl($verifyUrl); $verify1 = json_decode($verify, true); $errCode = $this->decryptData($encryptedData, $iv, $verify1['session_key'], $data); 偶尔会出现-41003错误
2020-12-18 - 使用postman 测试微信支付回调地址,后台接收不到数据,应该怎么使用postman测试回调地址?
后台代码: $receipt = file_get_contents("php://input"); if ($receipt == null) { $receipt = $GLOBALS['HTTP_RAW_POST_DATA']; } postman截图 [图片]
2020-11-14