使用php實(shí)現(xiàn)快錢支付功能(2)_PHP教程
教程Tag:暫無Tag,歡迎添加,賺取U幣!
推薦:關(guān)于php 接口問題(php接口主要也就是運(yùn)用curl,curl函數(shù))本篇文章是對php中的接口問題(php接口主要也就是運(yùn)用curl,curl函數(shù))進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下 接口問題 php調(diào)用接口最主要的就是使用curl抓取信息 復(fù)制代碼 代碼如下: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); //url地址 curl_setopt($c
modules/default/views/scripts/index/index.phtml
https://www.99bill.com/gateway/recvMerchantInfoAction.htm
<?php $BillRequest = (array)$this->BillRequest;?>
<div style="display:none;">
<form name="kqPay" action="https://www.99bill.com/gateway/recvMerchantInfoAction.htm" method="post">
<?php foreach($BillRequest as $key => $val):?>
<input type="hidden" name="<?php echo $key;?>" value="<?php echo $val;?>"/>
<?php endforeach;?>
<input type="submit" name="submit" value="提交到快錢" id="kqPay">
</form>
</div>
<script>
document.getElementById('kqPay').click();
</script>
models/BillRequest.php
BillRequest.php
<?php
class Application_Model_BillRequest
{
public function __construct($MockOrder){
/*
* 人民幣網(wǎng)關(guān)賬號。
*第一種方式:該賬號為11位人民幣網(wǎng)關(guān)商戶編號+01,該參數(shù)必填。01對應(yīng)工商銀行。
*第二種方式:該賬號為16位人民幣網(wǎng)關(guān)商戶
*/
$this->merchantAcctId = "1001011111101";
//服務(wù)器接收支付結(jié)果的后臺地址,該參數(shù)務(wù)必填寫,絕對路徑//不能為空。
$this->bgUrl = "http://99bill/default/index/receive";
//商戶訂單號,以下采用時間來定義訂單號,商戶可以根據(jù)自己訂單號的定義規(guī)則來定義該值//不能為空。
$this->orderId = 'TOLPC'.sprintf("%09d", $MockOrder['orderId']);
//訂單金額,金額以“分”為單位,商戶測試以1分測試即可,切勿以大金額測試,該參數(shù)必填//不能為空
$this->orderAmount =$MockOrder['orderAmount'];
//訂單提交時間,格式:yyyyMMddHHmmss,如:20071117020101//不能為空。
$this->orderTime = date("YmdHis", $MockOrder['orderTime']);
//支付人姓名,可以為空。
$this->payerName= "";
//支付人聯(lián)系類型,1 代表電子郵件方式;2 代表手機(jī)聯(lián)系方式。可以為空。
$this->payerContactType = "";
//支付人聯(lián)系方式,與payerContactType設(shè)置對應(yīng),payerContactType為1,則填寫郵箱地址;payerContactType為2,則填寫手機(jī)號碼�?梢詾榭铡�
$this->payerContact = "";
//商品名稱,可以為空。
$this->productName= "TOLPC";
//商品數(shù)量,可以為空。
$this->productNum = "1";
//商品代碼,可以為空。
$this->productId = $MockOrder['ets_license'];
//商品描述,可以為空。
$this->productDesc = "";
//支付方式,一般為00,代表所有的支付方式。如果是銀行直連商戶,該值為10,必填//不能為空
$this->payType = "00";
//編碼方式,1代表 UTF-8; 2 代表 GBK; 3代表 GB2312 默認(rèn)為1,該參數(shù)必填//不能為空
$this->inputCharset = "1";
//網(wǎng)關(guān)版本,固定值:v2.0,該參數(shù)必填//不能為空
$this->version = "v2.0";
//語言種類,1代表中文顯示,2代表英文顯示。默認(rèn)為1,該參數(shù)必填//不能為空
$this->language = "1";
//簽名類型,該值為4,代表PKI加密方式,該參數(shù)必填//不能為空
$this->signType = "4";
//接收支付結(jié)果的頁面地址,該參數(shù)一般置為空即可。
$this->pageUrl = "";
//擴(kuò)展字段1,商戶可以傳遞自己需要的參數(shù),支付完快錢會原值返回,可以為空。
$this->ext1 = $MockOrder['orderId'];
//擴(kuò)展自段2,商戶可以傳遞自己需要的參數(shù),支付完快錢會原值返回,可以為空。
$this->ext2 = $MockOrder['orderTime'];
//銀行代碼,如果payType為00,該值可以為空;如果payType為10,該值必須填寫,具體請參考銀行列表。
$this->bankId = "";
//同一訂單禁止重復(fù)提交標(biāo)志,實(shí)物購物車填1,虛擬產(chǎn)品用0。1代表只能提交一次,0代表在支付不成功情況下可以再提交�?蔀榭铡�
$this->redoFlag = "";
//快錢合作伙伴的帳戶號,即商戶編號,可為空。
$this->pid = "";
//快錢提供的request參數(shù)。
$KeyOrders = array('inputCharset','pageUrl','bgUrl','version','language','signType','merchantAcctId','payerName','payerContactType','payerContact',
'orderId','orderAmount','orderTime','productName','productNum','productId','productDesc','ext1','ext2','payType','bankId','redoFlag','pid',);
//判斷快錢提供的request參數(shù)的值是否為空,把非空的參數(shù)及值重新組建數(shù)組
foreach($KeyOrders as $key){
if(''==$this->{$key}){continue;}
$params[$key] = $this->{$key};
}
//http_build_query()生成URL-encode之后的請求字符串
//urldecode()還原未編碼的字符串
//getSignMsg() PKI加密,也可使用MD5加密
//MD5加密方式 strtoupper(md5(urldecode(http_build_query($params))));這種不常用了。
//常用PKI加密
$this->signMsg = $this->getSignMsg(urldecode(http_build_query($params)));
}
//PKI加密技術(shù)
public function getSignMsg($param){
//99bill-rsa.pem是快錢的一個CA證書
//本地隨機(jī)生成一個KEY,用此KEY加密數(shù)據(jù) KEY為$priv_key_id
$priv_key_id = openssl_get_privatekey(file_get_contents("99bill-rsa.pem", "r"));
//用$priv_key_id給$param數(shù)據(jù)加密。
//計算一個簽名字符串$param通過使用SHA1哈希加密,隨后$priv_key_id私鑰加密。數(shù)據(jù)本身是不加密的。
openssl_sign($param, $signMsg, $priv_key_id, OPENSSL_ALGO_SHA1);
//從存儲器上釋放$priv_key_id
openssl_free_key($priv_key_id);
//使用base64對數(shù)據(jù)進(jìn)行編碼
return base64_encode($signMsg);
}
}
分享:基于simple_html_dom的使用小結(jié)本篇文章對simple html dom的使用進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下 復(fù)制代碼 代碼如下: P簡單范例 ?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記錄頁面代碼執(zhí)行時間
- PHP中獎概率的抽獎算法程序代碼
- apache設(shè)置靜態(tài)文件緩存方法介紹
- php對圖像的各種處理函數(shù)代碼小結(jié)
- PHP 關(guān)于訪問控制的和運(yùn)算符優(yōu)先級介紹
- 關(guān)于PHP語言構(gòu)造器介紹
- php/js獲取客戶端mac地址的實(shí)現(xiàn)代碼
- php5.5新數(shù)組函數(shù)array_column使用
- PHP preg_match的匹配多國語言的技巧
- php 中序列化和json使用介紹
- php采集文章中的圖片獲取替換到本地
- 相關(guān)鏈接:
- 教程說明:
PHP教程-使用php實(shí)現(xiàn)快錢支付功能(2)
。