ImageVerifierCode 换一换
格式:DOCX , 页数:6 ,大小:16.22KB ,
资源ID:8482655      下载积分:3 金币
快捷下载
登录下载
邮箱/手机:
温馨提示:
快捷下载时,用户名和密码都是您填写的邮箱或者手机号,方便查询和重复下载(系统自动生成)。 如填写123,账号就是123,密码也是123。
特别说明:
请自助下载,系统不会自动发送文件的哦; 如果您已付费,想二次下载,请登录后访问:我的下载记录
支付方式: 支付宝    微信支付   
验证码:   换一换

加入VIP,免费下载
 

温馨提示:由于个人手机设置不同,如果发现不能下载,请复制以下地址【https://www.bdocx.com/down/8482655.html】到电脑端继续下载(重复下载不扣费)。

已注册用户请登录:
账号:
密码:
验证码:   换一换
  忘记密码?
三方登录: 微信登录   QQ登录  

下载须知

1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。
2: 试题试卷类文档,如果标题没有明确说明有答案则都视为没有答案,请知晓。
3: 文件的所有权益归上传用户所有。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 本站仅提供交流平台,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

版权提示 | 免责声明

本文(php微信支付之APP支付方法.docx)为本站会员(b****6)主动上传,冰豆网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。 若此文所含内容侵犯了您的版权或隐私,请立即通知冰豆网(发送邮件至service@bdocx.com或直接QQ联系客服),我们立即给予删除!

php微信支付之APP支付方法.docx

1、php微信支付之APP支付方法WechatAppPay文件代码如下:复制代码代码如下:file = _DIR_ . /payAccessToken.txt; /* * 创建APP支付最终返回参数 * throws Exception * return multitype:string NULL */ public function createAppPayData() $this-generateConfig(); $prepayid = $this-getPrepayid(); try $array = appid = $this-appid, appkey = $this-paySignk

2、ey, noncestr = $this-getRandomStr(), package = Sign=WXPay, partnerid = $this-partnerId, prepayid = $prepayid, timestamp = (string)time(), ; $arraysign = $this-sha1Sign($array); unset($arrayappkey); catch(Exception $e) throw new Exception($e-getMessage(); return $array; /* * 验证支付成功后的通知参数 * * throws E

3、xception * return boolean */ public function verifyNotify() try $staySignStr = $this-notify; unset($staySignStrsign); $sign = $this-signData($staySignStr); return $this-notifysign = $sign; catch(Exception $e) throw new Exception($e-getMessage(); /* * 魔术方法,给添加支付参数进来 * * param string $name 参数名 * param

4、 string $value 参数值 */ public function _set($name, $value) $this-$name = $value; /* * 设置access token * param string $token * throws Exception * return boolean */ public function setAccessToken() try if(!file_exists($this-file) | !is_file($this-file) $f = fopen($this-file, a); fclose($f); $content = f

5、ile_get_contents($this-file); if(!empty($content) $info = $content, true); if( time() - $infogetTime accessToken = $infoaccessToken; return true; /文件内容为空或access token已失效,重新获取 $this-outputAccessTokenToFile(); catch(Exception $e) throw new Exception($e-getMessage(); return true; /* * 写入access token 到文

6、件 * throws Exception * return boolean */ protected function outputAccessTokenToFile() try $f = fopen($this-file, wb); $token = accessToken = $this-getAccessToken(), getTime = time(), ; flock($f, LOCK_EX); fwrite($f, $token); flock($f, LOCK_UN); fclose($f); $this-accessToken = $tokenaccessToken; catc

7、h(Exception $e) throw new Exception($e-getMessage(); return true; /* * 取access token * * throws Exception * return string */ protected function getAccessToken() $url = sprintf(self:ACCESS_TOKEN_URL, $this-appid, $this-appSecret); $result = $this-getUrl($url), true ); if(isset($resulterrcode) throw n

8、ew Exception(get access token failed:$resulterrmsg); return $resultaccess_token; /* * 取预支付会话标识 * * throws Exception * return string */ protected function getPrepayid() $data = $this-config); $url = sprintf(self:POST_ORDER_URL, $this-accessToken); $result = $this-postUrl($url, $data), true ); if( iss

9、et($resulterrcode) & $resulterrcode != 0 ) throw new Exception($resulterrmsg); if( !isset($resultprepayid) ) throw new Exception(get prepayid failed, url request error.); return $resultprepayid; /* * 组装预支付参数 * * throws Exception */ protected function generateConfig() try $this-config = appid = $this

10、-appid, traceid = $this-traceid, noncestr = $this-getRandomStr(), timestamp = time(), package = $this-generatePackage(), sign_method = $this-sign_method, ; $this-configapp_signature = $this-generateSign(); catch(Exception $e) throw new Exception($e-getMessage(); /* * 生成package字段 * * 生成规则: * 1、生成sign

11、的值signValue * 2、对package参数再次拼接成查询字符串,值需要进行urlencode * 3、将sign=signValue拼接到2生成的字符串后面得到最终的package字符串 * * 第2步urlencode空格需要编码成%20而不是+ * * RFC 1738会把 空格编码成+ * RFC 3986会把空格编码成%20 * * return string */ protected function generatePackage() $this-packagesign = $this-signData($this-package); return http_build_

12、query($this-package, , &, PHP_QUERY_RFC3986); /* * 生成签名 * * return string */ protected function generateSign() $signArray = appid = $this-appid, appkey = $this-paySignkey, noncestr = $this-confignoncestr, package = $this-configpackage, timestamp = $this-configtimestamp, traceid = $this-traceid, ; re

13、turn $this-sha1Sign($signArray); /* * 签名数据 * * 生成规则: * 1、字典排序,拼接成查询字符串格式,不需要urlencode * 2、上一步得到的字符串最后拼接上key=paternerKey * 3、MD5哈希字符串并转换成大写得到sign的值signValue * * param array $data 待签名数据 * return string 最终签名结果 */ protected function signData($data) ksort($data); $str = $this-arrayToString($data); $str .= &key=$this-partnerKey; return strtoupper( $this-signMd5($str) ); /* * sha1签名 * 签名规则 * 1、字典排序 * 2、拼接查询字符串 * 3、sha1运算 * * param array $arr * return string */ protected function sha1Sign($arr) ksort($arr); return sha1( $this-arrayToString($arr) );

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1