使用php实现快钱支付功能(3)_PHP教程

编辑Tag赚U币
教程Tag:暂无Tag,欢迎添加,赚取U币!

推荐:关于php 接口问题(php接口主要也就是运用curl,curl函数)
本篇文章是对php中的接口问题(php接口主要也就是运用curl,curl函数)进行了详细的分析介绍,需要的朋友参考下 接口问题 php调用接口最主要的就是使用curl抓取信息 复制代码 代码如下: $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); //url地址 curl_setopt($c


models/BillResponse.php
BillResponse.php

复制代码 代码如下:
<?php
class Application_Model_BillResponse
{
/*
* __construct()构造函数
* 生成19个参数及值,可能有一个参数的值为空,$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];
}
}
/*
* 检查签名字符串
* 快钱返回的签名字符串是$this->signMsg
* 使用base64对前面字符串进行解码
* 验证使用快钱给的公钥验证
* 快钱那边他们把返回来的参数值不为空的使用私钥加密生成了$this->signMsg
* 快钱给了我们私钥对应的公钥,我们使用这个公钥来验证。1成功,0失败,-1错误。
*/
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成功时10,失败时11
return '10'==$this->payResult;
}
public function getOrderId(){
return str_replace('XXX', '', $this->orderId);
}
}


需要一个公钥和一个私钥,这个不是一对的
都是一半
99bill-rsa.cer
99bill-rsa.pem

分享:基于simple_html_dom的使用小结
本篇文章对simple html dom的使用进行了详细的分析介绍,需要的朋友参考下 复制代码 代码如下: P简单范例 ?phpinclude simple_html_dom.php ; //加载simple_html_dom.php文件 $html = file_get_html('http://www.google.com/'); //获取html$dom = new simple_html_dom()

共3页上一页123下一页
来源:模板无忧//所属分类:PHP教程/更新时间:2013-07-03
相关PHP教程