├── .gitignore ├── .travis.yml ├── README.md ├── composer.json ├── phpunit.xml └── src ├── Hardywen └── Wxpay │ ├── Facades │ └── Wxpay.php │ ├── JsApi │ └── JsApi.php │ ├── Wxpay.php │ ├── WxpayServiceProvider.php │ └── lib │ ├── Common.php │ ├── Notify.php │ └── UnifiedOrder.php ├── config └── config.php └── views └── pay.blade.php /.gitignore: -------------------------------------------------------------------------------- 1 | /vendor 2 | composer.phar 3 | composer.lock 4 | .DS_Store 5 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: php 2 | 3 | php: 4 | - 5.4 5 | - 5.5 6 | - 5.6 7 | - hhvm 8 | 9 | before_script: 10 | - travis_retry composer self-update 11 | - travis_retry composer install --prefer-source --no-interaction --dev 12 | 13 | script: phpunit 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # wxpay 2 | 自用 3 | WeiXin Payment 4 | 5 | ##更新 6 | 1. 增加参数call_back_url ,同步回调地址。 7 | 8 | ###微信支付的配置要点:请留心注意本部分内容,因为这很可能是你遇到的大坑。 9 | 1.网页授权(设置错误会出现redirect_url参数错误的错误) 10 | 这个网页授权需要登录微信公众平台,点击左侧菜单“开发者中心”,在右侧“权限列表”中找到“网页账号”,点击最右侧的修改,把测试的网址写进去,不要加http。 11 | 12 | 2.支付授权目录(设置不对会无法发起js支付,因为没有权限,错误为:“getBrandWCPayRequest:fail_no permission to execute” 13 | ) 14 | 设置好授权目录即可。 15 | 16 | 17 | ###Install 18 | 19 | 1. 修改composer.json文件,加入```"hardywen/wxpay": "dev-master"``` 20 | ```json 21 | "require": { 22 | "hardywen/wxpay": "dev-master" 23 | } 24 | ``` 25 | 26 | 2. 修改app/config/app.php 27 | ```php 28 | 'providers' => array( 29 | 'Hardywen\Wxpay\WxpayServiceProvider' 30 | ) 31 | 32 | 33 | 'aliases' => array( 34 | 'Wxpay' => 'Hardywen\Wxpay\Facades\WxpayFacade' 35 | ) 36 | ``` 37 | 38 | 3. 运行```composer update ```命令 39 | 4. 运行```php artisan config:publish hardywen/wxpay``` 40 | 5. 如有必要修改支付页面,运行```php artisan view:publish hardywen/wxpay``` 41 | 42 | 43 | ###Usage 44 | 45 | 支付调用 46 | ```php 47 | $config = array( 48 | 'body'=>'', 49 | 'total_fee' =>'', 50 | ... 51 | ); 52 | Wxpay::instance('jsApi')->setConfig($config)->pay(); 53 | ``` 54 | 55 | 支付回调 56 | 57 | ```php 58 | $wxpay = Wxpay::instance('jsApi'); 59 | $notify = $wxpay->verifyNotify(); //验证回调 60 | 61 | if($notify){ 62 | //业务逻辑 63 | 64 | return 'success'; 65 | }else{ 66 | 67 | //业务逻辑 68 | 69 | 70 | return 'fail'; 71 | } 72 | 73 | ``` 74 | 75 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "hardywen/wxpay", 3 | "description": "微信支付 微信js支付 Weixin weixinPay", 4 | "keywords": ["PHP","laravel","Laravel 4", "WeixinPay"], 5 | "license": "MIT", 6 | "authors": [ 7 | { 8 | "name": "HardyWen", 9 | "email": "hardy.wen@foxmail.com" 10 | } 11 | ], 12 | "require": { 13 | "php": ">=5.4.0", 14 | "illuminate/support": "4.2.*" 15 | }, 16 | "autoload": { 17 | "psr-0": { 18 | "Hardywen\\Wxpay": "src/" 19 | } 20 | }, 21 | "minimum-stability": "stable" 22 | } 23 | -------------------------------------------------------------------------------- /phpunit.xml: -------------------------------------------------------------------------------- 1 | 2 | 13 | 14 | 15 | ./tests/ 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /src/Hardywen/Wxpay/Facades/Wxpay.php: -------------------------------------------------------------------------------- 1 | '', 16 | 'total_fee' => '', 17 | 'out_trade_no' => '', 18 | 'sub_mch_id' => '', 19 | 'device_info' => '', 20 | 'attach' => '', 21 | 'time_start' => '', 22 | 'time_expire' => '', 23 | 'goods_tag' => '', 24 | 'product_id' => '', 25 | ]; 26 | var $url = "https://api.mch.weixin.qq.com/pay/unifiedorder"; 27 | var $code;//code码,用以获取openid 28 | var $openid;//用户的openid 29 | var $parameters;//jsApi参数,格式为json 30 | var $prepay_id;//使用统一支付接口得到的预支付id 31 | var $curl_timeout;//curl超时时间 32 | 33 | function __construct($config) 34 | { 35 | $this->wxpay_config = $this->wxpay_config = array_merge($this->wxpay_config,$config); 36 | 37 | //设置curl超时时间 38 | $this->curl_timeout = $this->wxpay_config['curl_timeout']; 39 | 40 | } 41 | 42 | function setConfig($config){ 43 | 44 | $this->wxpay_config = array_merge($this->wxpay_config,$config); 45 | 46 | return $this; 47 | } 48 | 49 | 50 | function pay(){ 51 | 52 | $jsApiParameters = $this->getOpenid()->jsApiParameters(); 53 | $return_url = $this->wxpay_config['call_back_url']; 54 | return View::make('wxpay::pay',compact('jsApiParameters','return_url'))->render(); 55 | } 56 | 57 | function verifyNotify(){ 58 | 59 | $notify = $this->checkSign(); 60 | 61 | if($this->wxpay_config['log']){ 62 | $data = json_encode($this->getData()); 63 | 64 | \Log::info("===============WeiXin pay notify result==============:$notify. Data:$data"); 65 | } 66 | 67 | return $notify; 68 | 69 | } 70 | 71 | function jsApiParameters(){ 72 | 73 | $this->setParameter("openid", $this->openid);//商品描述 74 | $this->setParameter("notify_url", $this->wxpay_config['notify_url']);//通知地址 75 | $this->setParameter("trade_type", "JSAPI");//交易类型 76 | 77 | //订单相关 78 | $this->setParameter("body", $this->wxpay_config['body']);//商品描述 79 | 80 | $this->setParameter("out_trade_no", $this->wxpay_config['out_trade_no']);//商户订单号 81 | $this->setParameter("total_fee", $this->wxpay_config['total_fee']);//总金额 82 | 83 | //非必填参数,商户可根据实际情况选填 84 | $this->setParameter("sub_mch_id",$this->wxpay_config['sub_mch_id']);//子商户号 85 | $this->setParameter("device_info",$this->wxpay_config['device_info']);//设备号 86 | $this->setParameter("attach",$this->wxpay_config['attach']);//附加数据 87 | $this->setParameter("time_start",$this->wxpay_config['time_start']);//交易起始时间 88 | $this->setParameter("time_expire",$this->wxpay_config['time_expire']);//交易结束时间 89 | $this->setParameter("goods_tag",$this->wxpay_config['goods_tag']);//商品标记 90 | $this->setParameter("product_id",$this->wxpay_config['product_id']);//商品ID 91 | 92 | $prepay_id = $this->getPrepayId(); 93 | 94 | $this->setPrepayId($prepay_id); 95 | 96 | $jsApiParameters = $this->getParameters(); 97 | //echo $jsApiParameters;exit; 98 | return $jsApiParameters; 99 | } 100 | 101 | 102 | /** 103 | * 作用:生成可以获得code的url 104 | */ 105 | function createOauthUrlForCode($redirectUrl) 106 | { 107 | if($redirectUrl === ''){ 108 | $redirectUrl = \Request::url(); 109 | } 110 | $urlObj["appid"] = $this->wxpay_config['appid']; 111 | $urlObj["redirect_uri"] = "$redirectUrl"; 112 | $urlObj["response_type"] = "code"; 113 | $urlObj["scope"] = "snsapi_base"; 114 | $urlObj["state"] = "STATE"."#wechat_redirect"; 115 | $bizString = $this->formatBizQueryParaMap($urlObj, false); 116 | return "https://open.weixin.qq.com/connect/oauth2/authorize?".$bizString; 117 | } 118 | 119 | /** 120 | * 作用:生成可以获得openid的url 121 | */ 122 | function createOauthUrlForOpenid() 123 | { 124 | $urlObj["appid"] = $this->wxpay_config['appid']; 125 | $urlObj["secret"] = $this->wxpay_config['app_secret']; 126 | $urlObj["code"] = $this->code; 127 | $urlObj["grant_type"] = "authorization_code"; 128 | $bizString = $this->formatBizQueryParaMap($urlObj, false); 129 | return "https://api.weixin.qq.com/sns/oauth2/access_token?".$bizString; 130 | } 131 | 132 | 133 | /** 134 | * 作用:通过curl向微信提交code,以获取openid 135 | */ 136 | function getOpenid() 137 | { 138 | if (!isset($_GET['code'])) 139 | { 140 | //触发微信返回code码 141 | $url = $this->createOauthUrlForCode($this->wxpay_config['js_api_call_url']); 142 | Header("Location: $url"); exit; 143 | }else 144 | { 145 | //获取code码,以获取openid 146 | $code = $_GET['code']; 147 | $this->setCode($code); 148 | } 149 | 150 | $url = $this->createOauthUrlForOpenid(); 151 | //初始化curl 152 | $ch = curl_init(); 153 | //设置超时 154 | curl_setopt($ch, CURLOPT_TIMEOUT, $this->curl_timeout); 155 | curl_setopt($ch, CURLOPT_URL, $url); 156 | curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); 157 | curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); 158 | curl_setopt($ch, CURLOPT_HEADER, FALSE); 159 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 160 | //运行curl,结果以jason形式返回 161 | $res = curl_exec($ch); 162 | curl_close($ch); 163 | 164 | $data = json_decode($res,true); 165 | 166 | if(array_key_exists('errcode',$data)){ 167 | throw new \Exception($data['errcode'] . '-' . $data['errmsg']); 168 | } 169 | 170 | $this->openid = $data["openid"]; 171 | 172 | return $this; 173 | } 174 | 175 | /** 176 | * 作用:设置prepay_id 177 | */ 178 | function setPrepayId($prepayId) 179 | { 180 | $this->prepay_id = $prepayId; 181 | } 182 | 183 | /** 184 | * 作用:设置code 185 | */ 186 | function setCode($code_) 187 | { 188 | $this->code = $code_; 189 | } 190 | 191 | /** 192 | * 作用:设置jsApi的参数 193 | */ 194 | public function getParameters() 195 | { 196 | $jsApiObj["appId"] = $this->wxpay_config['appid']; 197 | $timeStamp = time(); 198 | $jsApiObj["timeStamp"] = "$timeStamp"; 199 | $jsApiObj["nonceStr"] = $this->createNonceStr(); 200 | $jsApiObj["package"] = "prepay_id=$this->prepay_id"; 201 | $jsApiObj["signType"] = "MD5"; 202 | 203 | $jsApiObj["paySign"] = $this->getSign($jsApiObj); 204 | 205 | $this->parameters = json_encode($jsApiObj); 206 | 207 | return $this->parameters; 208 | } 209 | 210 | 211 | 212 | } 213 | -------------------------------------------------------------------------------- /src/Hardywen/Wxpay/Wxpay.php: -------------------------------------------------------------------------------- 1 | config = $config; 11 | } 12 | 13 | public function instance($type){ 14 | 15 | switch($type){ 16 | case 'jsApi': 17 | return new JsApi($this->config); 18 | break; 19 | default: 20 | return false; 21 | break; 22 | } 23 | } 24 | 25 | } -------------------------------------------------------------------------------- /src/Hardywen/Wxpay/WxpayServiceProvider.php: -------------------------------------------------------------------------------- 1 | package('hardywen/wxpay'); 23 | } 24 | 25 | /** 26 | * Register the service provider. 27 | * 28 | * @return void 29 | */ 30 | public function register() 31 | { 32 | $app = $this->app; 33 | $app['wxpay'] = $app->share(function ($app) { 34 | return new Wxpay($app['config']->get('wxpay::config')); 35 | }); 36 | } 37 | 38 | /** 39 | * Get the services provided by the provider. 40 | * 41 | * @return array 42 | */ 43 | public function provides() 44 | { 45 | return array('wxpay'); 46 | } 47 | 48 | } 49 | -------------------------------------------------------------------------------- /src/Hardywen/Wxpay/lib/Common.php: -------------------------------------------------------------------------------- 1 | $v) 43 | { 44 | if($urlencode) 45 | { 46 | $v = urlencode($v); 47 | } 48 | //$buff .= strtolower($k) . "=" . $v . "&"; 49 | $buff .= $k . "=" . $v . "&"; 50 | } 51 | $reqPar = ''; 52 | if (strlen($buff) > 0) 53 | { 54 | $reqPar = substr($buff, 0, strlen($buff)-1); 55 | } 56 | return $reqPar; 57 | } 58 | 59 | /** 60 | * 作用:生成签名 61 | */ 62 | public function getSign($Obj) 63 | { 64 | foreach ($Obj as $k => $v) 65 | { 66 | $Parameters[$k] = $v; 67 | } 68 | //签名步骤一:按字典序排序参数 69 | ksort($Parameters); 70 | $String = $this->formatBizQueryParaMap($Parameters, false); 71 | //echo '【string1】'.$String.'
'; 72 | //签名步骤二:在string后加入KEY 73 | $String = $String."&key=".$this->wxpay_config['key']; 74 | //echo "【string2】".$String."
"; 75 | //签名步骤三:MD5加密 76 | $String = md5($String); 77 | //echo "【string3】 ".$String."
"; 78 | //签名步骤四:所有字符转为大写 79 | $result_ = strtoupper($String); 80 | //echo "【result】 ".$result_."
"; 81 | return $result_; 82 | } 83 | 84 | /** 85 | * 作用:array转xml 86 | */ 87 | function arrayToXml($arr) 88 | { 89 | $xml = ""; 90 | foreach ($arr as $key=>$val) 91 | { 92 | if (is_numeric($val)) 93 | { 94 | $xml.="<".$key.">".$val.""; 95 | 96 | } 97 | else 98 | $xml.="<".$key.">"; 99 | } 100 | $xml.=""; 101 | return $xml; 102 | } 103 | 104 | /** 105 | * 作用:将xml转为array 106 | */ 107 | public function xmlToArray($xml) 108 | { 109 | //禁止引用外部xml实体 110 | $disableLibxmlEntityLoader = libxml_disable_entity_loader(true); 111 | 112 | //将XML转为array 113 | $array_data = json_decode(json_encode(simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA)), true); 114 | 115 | libxml_disable_entity_loader($disableLibxmlEntityLoader); 116 | 117 | return $array_data; 118 | } 119 | 120 | /** 121 | * 作用:以post方式提交xml到对应的接口url 122 | */ 123 | public function postXmlCurl($xml,$url,$second=30) 124 | { 125 | //初始化curl 126 | $ch = curl_init(); 127 | //设置超时 128 | curl_setopt($ch, CURLOPT_TIMEOUT, $second); 129 | //这里设置代理,如果有的话 130 | //curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8'); 131 | //curl_setopt($ch,CURLOPT_PROXYPORT, 8080); 132 | curl_setopt($ch,CURLOPT_URL, $url); 133 | curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); 134 | curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); 135 | //设置header 136 | curl_setopt($ch, CURLOPT_HEADER, FALSE); 137 | //要求结果为字符串且输出到屏幕上 138 | curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); 139 | //post提交方式 140 | curl_setopt($ch, CURLOPT_POST, TRUE); 141 | curl_setopt($ch, CURLOPT_POSTFIELDS, $xml); 142 | //运行curl 143 | $data = curl_exec($ch); 144 | //返回结果 145 | if($data) 146 | { 147 | curl_close($ch); 148 | return $data; 149 | } 150 | else 151 | { 152 | $error = curl_errno($ch); 153 | echo "curl出错,错误码:$error"."
"; 154 | echo "错误原因查询
"; 155 | curl_close($ch); 156 | return false; 157 | } 158 | } 159 | 160 | /** 161 | * 作用:使用证书,以post方式提交xml到对应的接口url 162 | */ 163 | function postXmlSSLCurl($xml,$url,$second=30) 164 | { 165 | $ch = curl_init(); 166 | //超时时间 167 | curl_setopt($ch,CURLOPT_TIMEOUT,$second); 168 | //这里设置代理,如果有的话 169 | //curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8'); 170 | //curl_setopt($ch,CURLOPT_PROXYPORT, 8080); 171 | curl_setopt($ch,CURLOPT_URL, $url); 172 | curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE); 173 | curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE); 174 | //设置header 175 | curl_setopt($ch,CURLOPT_HEADER,FALSE); 176 | //要求结果为字符串且输出到屏幕上 177 | curl_setopt($ch,CURLOPT_RETURNTRANSFER,TRUE); 178 | //设置证书 179 | //使用证书:cert 与 key 分别属于两个.pem文件 180 | //默认格式为PEM,可以注释 181 | curl_setopt($ch,CURLOPT_SSLCERTTYPE,'PEM'); 182 | curl_setopt($ch,CURLOPT_SSLCERT, $this->wxpay_config['sslcert_path']); 183 | //默认格式为PEM,可以注释 184 | curl_setopt($ch,CURLOPT_SSLKEYTYPE,'PEM'); 185 | curl_setopt($ch,CURLOPT_SSLKEY, $this->wxpay_config['sslkey_path']); 186 | //post提交方式 187 | curl_setopt($ch,CURLOPT_POST, true); 188 | curl_setopt($ch,CURLOPT_POSTFIELDS,$xml); 189 | $data = curl_exec($ch); 190 | //返回结果 191 | if($data){ 192 | curl_close($ch); 193 | return $data; 194 | } 195 | else { 196 | $error = curl_errno($ch); 197 | echo "curl出错,错误码:$error"."
"; 198 | echo "错误原因查询
"; 199 | curl_close($ch); 200 | return false; 201 | } 202 | } 203 | 204 | /** 205 | * 作用:打印数组 206 | */ 207 | function printErr($wording='',$err='') 208 | { 209 | print_r('
');
210 | 		echo $wording."
"; 211 | var_dump($err); 212 | print_r('
'); 213 | } 214 | 215 | 216 | } 217 | -------------------------------------------------------------------------------- /src/Hardywen/Wxpay/lib/Notify.php: -------------------------------------------------------------------------------- 1 | data = $this->xmlToArray($xml); 15 | } 16 | 17 | 18 | function checkSign() 19 | { 20 | $tmpData = $this->saveData($GLOBALS['HTTP_RAW_POST_DATA']); 21 | 22 | unset($tmpData['sign']); 23 | 24 | $sign = $this->getSign($tmpData);//本地签名 25 | if ($this->data['sign'] == $sign) { 26 | return TRUE; 27 | } 28 | return FALSE; 29 | } 30 | 31 | /** 32 | * 获取微信的请求数据 33 | */ 34 | function getData() 35 | { 36 | return $this->data; 37 | } 38 | 39 | /** 40 | * 设置返回微信的xml数据 41 | */ 42 | function setReturnParameter($parameter, $parameterValue) 43 | { 44 | $this->returnParameters[$this->trimString($parameter)] = $this->trimString($parameterValue); 45 | } 46 | 47 | /** 48 | * 将xml数据返回微信 49 | */ 50 | function returnXml() 51 | { 52 | $returnXml = $this->arrayToXml($this->returnParameters); 53 | return $returnXml; 54 | } 55 | } -------------------------------------------------------------------------------- /src/Hardywen/Wxpay/lib/UnifiedOrder.php: -------------------------------------------------------------------------------- 1 | parameters["out_trade_no"] == null) 21 | { 22 | throw new \Exception("缺少统一支付接口必填参数out_trade_no!"."
"); 23 | }elseif($this->parameters["body"] == null){ 24 | throw new \Exception("缺少统一支付接口必填参数body!"."
"); 25 | }elseif ($this->parameters["total_fee"] == null ) { 26 | throw new \Exception("缺少统一支付接口必填参数total_fee!"."
"); 27 | }elseif ($this->parameters["notify_url"] == null) { 28 | throw new \Exception("缺少统一支付接口必填参数notify_url!"."
"); 29 | }elseif ($this->parameters["trade_type"] == null) { 30 | throw new \Exception("缺少统一支付接口必填参数trade_type!"."
"); 31 | }elseif ($this->parameters["trade_type"] == "JSAPI" && 32 | $this->parameters["openid"] == NULL){ 33 | throw new \Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"."
"); 34 | } 35 | $this->parameters["appid"] = $this->wxpay_config['appid'];//公众账号ID 36 | $this->parameters["mch_id"] = isset($this->wxpay_config['mch_id']) ? $this->wxpay_config['mch_id'] : $this->wxpay_config['mchid'];//商户号 37 | $this->parameters["spbill_create_ip"] = $_SERVER['REMOTE_ADDR'];//终端ip 38 | $this->parameters["nonce_str"] = $this->createNonceStr();//随机字符串 39 | $this->parameters["sign"] = $this->getSign($this->parameters);//签名 40 | return $this->arrayToXml($this->parameters); 41 | }catch (Exception $e) 42 | { 43 | dd($e); 44 | } 45 | } 46 | 47 | 48 | /** 49 | * 作用:设置请求参数 50 | */ 51 | function setParameter($parameter, $parameterValue) 52 | { 53 | if($parameterValue !== '') 54 | $this->parameters[$this->trimString($parameter)] = $this->trimString($parameterValue); 55 | } 56 | 57 | 58 | /** 59 | * 作用:post请求xml 60 | */ 61 | function postXml() 62 | { 63 | $xml = $this->createXml(); 64 | $this->response = $this->postXmlCurl($xml,$this->url,$this->curl_timeout); 65 | return $this->response; 66 | } 67 | 68 | /** 69 | * 作用:使用证书post请求xml 70 | */ 71 | function postXmlSSL() 72 | { 73 | $xml = $this->createXml(); 74 | $this->response = $this->postXmlSSLCurl($xml,$this->url,$this->curl_timeout); 75 | return $this->response; 76 | } 77 | 78 | /** 79 | * 作用:获取结果,默认不使用证书 80 | */ 81 | function getResult() 82 | { 83 | $this->postXml(); 84 | $this->result = $this->xmlToArray($this->response); 85 | return $this->result; 86 | } 87 | 88 | /** 89 | * 获取prepay_id 90 | */ 91 | function getPrepayId() 92 | { 93 | $this->postXml(); 94 | $this->result = $this->xmlToArray($this->response); 95 | $prepay_id = $this->result["prepay_id"]; 96 | return $prepay_id; 97 | } 98 | 99 | } -------------------------------------------------------------------------------- /src/config/config.php: -------------------------------------------------------------------------------- 1 | '', //必填 8 | 9 | 10 | //受理商ID,身份标识 11 | 'mch_id' => '',//必填 12 | 13 | 14 | //商户支付密钥Key。审核通过后,在微信发送的邮件中查看 15 | 'key' => '',//必填 16 | 17 | 18 | //JSAPI接口中获取openid,审核后在公众平台开启开发模式后可查看 19 | 'app_secret' => '',//必填 20 | 21 | 22 | //=======【JSAPI路径设置】=================================== 23 | //获取access_token过程中的跳转uri,通过跳转将code传入jsapi支付页面 24 | 'js_api_call_url' => '', 25 | 26 | 27 | //=======【证书路径设置】===================================== 28 | //证书路径,注意应该填写绝对路径 29 | 'sslcert_path' => '', 30 | 31 | 'sslkey_path' => '', 32 | 33 | 34 | //=======【异步通知url设置】=================================== 35 | //异步通知url,商户根据实际开发过程设定 36 | 'notify_url' => '',//必填 37 | 38 | 39 | //=======【同步回调url】============================== 40 | //同步回调地址,即支付完成后跳回的地址 41 | 'call_back_url' => '',//必填 42 | 43 | 44 | 45 | //=======【curl超时设置】=================================== 46 | //本例程通过curl使用HTTP POST方法,此处可修改其超时时间,默认为30秒 47 | 'curl_timeout' => 30, 48 | 49 | //是否记录日志 50 | 'log' => true, 51 | ); -------------------------------------------------------------------------------- /src/views/pay.blade.php: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 微信安全支付 6 | 51 | 52 | 53 | 54 | 55 | 56 | --------------------------------------------------------------------------------