使用php實(shí)現(xiàn)快錢(qián)支付功能(3)_PHP教程
教程Tag:暫無(wú)Tag,歡迎添加,賺取U幣!
推薦:關(guān)于php 接口問(wèn)題(php接口主要也就是運(yùn)用curl,curl函數(shù))本篇文章是對(duì)php中的接口問(wèn)題(php接口主要也就是運(yùn)用curl,curl函數(shù))進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下 接口問(wèn)題 php調(diào)用接口最主要的就是使用curl抓取信息 復(fù)制代碼 代碼如下: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); //url地址 curl_setopt($c
models/BillResponse.php
BillResponse.php
<?php
class Application_Model_BillResponse
{
/*
* __construct()構(gòu)造函數(shù)
* 生成19個(gè)參數(shù)及值,可能有一個(gè)參數(shù)的值為空,$this->errCode的值可能為空
*/
public function __construct($response){
$KeyOrders = array('merchantAcctId','version','language','signType','payType','bankId','orderId','orderTime','orderAmount',
'dealId','bankDealId','dealTime','payAmount','fee','ext1','ext2','payResult','errCode', 'signMsg');
foreach($KeyOrders as $key){
$this->{$key} = $response[$key];
}
}
/*
* 檢查簽名字符串
* 快錢(qián)返回的簽名字符串是$this->signMsg
* 使用base64對(duì)前面字符串進(jìn)行解碼
* 驗(yàn)證使用快錢(qián)給的公鑰驗(yàn)證
* 快錢(qián)那邊他們把返回來(lái)的參數(shù)值不為空的使用私鑰加密生成了$this->signMsg
* 快錢(qián)給了我們私鑰對(duì)應(yīng)的公鑰,我們使用這個(gè)公鑰來(lái)驗(yàn)證。1成功,0失敗,-1錯(cuò)誤。
*/
public function checkSignMsg(){
$KeyOrders = array('merchantAcctId','version','language','signType','payType','bankId','orderId','orderTime','orderAmount',
'dealId','bankDealId','dealTime','payAmount','fee','ext1','ext2','payResult','errCode',);
foreach($KeyOrders as $key){
if(''==$this->{$key}){continue;}
$params[$key] = $this->{$key};
}
//$pub_key_id 公鑰
$pub_key_id = openssl_get_publickey(file_get_contents("99bill-rsa.cer", "r"));
return openssl_verify(urldecode(http_build_query($params)), base64_decode($this->signMsg), $pub_key_id);
}
public function isSuccess(){
//$this->payResult成功時(shí)10,失敗時(shí)11
return '10'==$this->payResult;
}
public function getOrderId(){
return str_replace('XXX', '', $this->orderId);
}
}
需要一個(gè)公鑰和一個(gè)私鑰,這個(gè)不是一對(duì)的
都是一半
99bill-rsa.cer
99bill-rsa.pem
分享:基于simple_html_dom的使用小結(jié)本篇文章對(duì)simple html dom的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下 復(fù)制代碼 代碼如下: P簡(jiǎn)單范例 ?phpinclude simple_html_dom.php ; //加載simple_html_dom.php文件 $html = file_get_html('http://www.google.com/'); //獲取html$dom = new simple_html_dom()
相關(guān)PHP教程:
- PHPNOW安裝Memcached擴(kuò)展方法詳解
- php記錄頁(yè)面代碼執(zhí)行時(shí)間
- PHP中獎(jiǎng)概率的抽獎(jiǎng)算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對(duì)圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問(wèn)控制的和運(yùn)算符優(yōu)先級(jí)介紹
- 關(guān)于PHP語(yǔ)言構(gòu)造器介紹
- php/js獲取客戶(hù)端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國(guó)語(yǔ)言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說(shuō)明:
PHP教程-使用php實(shí)現(xiàn)快錢(qián)支付功能(3)
。