Authored by whb

temp 逛和支付

Showing 33 changed files with 3969 additions and 12 deletions

Too many changes to show.

To preserve performance only 33 of 33+ files are displayed.

<?php
namespace LibModels\Web\Guang;
use Api\Yohobuy;
use Api\Sign;
class InfoData
{
/**
* 获取接口地址
* @return string
*/
public static function getUrl($type)
{
//作者信息
if ($type == 'author') {
return Yohobuy::SERVICE_URL.'guang/service/v1/author/getAuthor';
}
//文章评论列表
elseif($type == 'commentList') {
return Yohobuy::SERVICE_URL.'guang/api/v1/comments/getList';
}
//热门标签
elseif ($type == 'getTagTop') {
return Yohobuy::SERVICE_URL.'guang/api/v2/article/getTagTop';
}
//精彩推荐
elseif ($type == 'getArticleByViewsNum') {
return Yohobuy::SERVICE_URL.'guang/api/v2/article/getArticleByViewsNum';
}
elseif ($type == 'getBrand'){
return Yohobuy::SERVICE_URL.'guang/service/v2/article/getBrand';
}
//相关文章
elseif ($type == 'getOtherArticle') {
return Yohobuy::SERVICE_URL.'guang/service/v2/article/getOtherArticle';
}
//文章标题等相关信息
elseif ($type == 'getArticle') {
return Yohobuy::SERVICE_URL.'guang/service/v2/article/getArticle';
}
//文章详情
elseif ($type == 'getArticleContent') {
return Yohobuy::SERVICE_URL.'guang/service/v2/article/getArticleContent';
}
//基本信息
elseif ($type == 'getArticleBaseInfo') {
return Yohobuy::SERVICE_URL.'guang/api/v1/article/getArticleBaseInfo';
}
//添加评论
elseif ($type == 'addComment') {
return Yohobuy::SERVICE_URL.'guang/api/v1/comments/add';
}
//点赞
elseif ($type == 'setPraise') {
return Yohobuy::SERVICE_URL.'guang/api/v2/praise/setPraise';
}
//取消赞
elseif ($type == 'cancelPraise') {
return Yohobuy::SERVICE_URL.'guang/api/v2/praise/cancel';
}
//收藏
elseif ($type == 'setFavorite') {
return Yohobuy::SERVICE_URL.'guang/api/v1/favorite/setFavorite';
}
//取消收藏
elseif ($type == 'cancelFavorite') {
return Yohobuy::SERVICE_URL.'guang/api/v1/favorite/cancelFavorite';
}
}
/**
* 调用接口
* @param string $url
* @param array $param
* @param bool $onlyUrl true:返回请求地址; false:返回接口数据
* @return mixed
*/
public static function webApi($url, $param, $onlyUrl = false)
{
$param += Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['client_secret'] = Sign::getSign($param);
if ($onlyUrl) {
return Yohobuy::httpBuildQuery($url, $param);
}
return Yohobuy::get($url, $param);
}
/**
* 根据文章id获取文章信息
* @param $id
* @param $onlyUrl
* @return mixed
*/
public static function getArticleInfo($id, $onlyUrl = false)
{
$param['article_id'] = $id;
return self::webApi(self::getUrl('getArticle'), $param, $onlyUrl);
}
/**
* 组建根据文章id查询作者信息的url
* @param $authorId
* @param bool $onlyUrl
* @return mixed
*/
public static function author($authorId, $onlyUrl = false)
{
$param['author_id'] = $authorId;
return self::webApi(self::getUrl('author'), $param, $onlyUrl);
}
/**
* 热门标签
* @param int $page
* @param int $limit
* @param bool $onlyUrl
* @return string
*/
public static function tagTop($page = 1,$limit = 10, $onlyUrl = false)
{
$param['page'] = $page;
$param['limit'] = $limit;
return self::webApi(self::getUrl('getTagTop'), $param, $onlyUrl);
}
/**
* 组建根据文章id查询评论列表
* @param $articleId
* @param $page
* @param $limit
* @param $onlyUrl
* @return string
*/
public static function comment($articleId, $page = 1, $limit = 10, $onlyUrl = false)
{
$param['article_id'] = $articleId;
$param['page'] = $page;
$param['limit'] = $limit;
return self::webApi(self::getUrl('commentList'), $param, $onlyUrl);
}
/**
* 文章详细内容
* @param $articleId
* @param bool $onlyUrl
* @return mixed
*/
public static function articleContent($articleId, $onlyUrl = false)
{
$param['article_id'] = $articleId;
return self::webApi(self::getUrl('getArticleContent'), $param, $onlyUrl);
}
/**
* 判断用户是否收藏文章地址
* @param $articleId
* @param $uid
* @param $udid
* @param bool $onlyUrl
* @return mixed
*/
public static function baseInfo($articleId, $uid, $udid, $onlyUrl = false)
{
$param['id'] = $articleId;
$param['uid'] = $uid;
$param['udid'] = $udid;
return self::webApi(self::getUrl('getArticleBaseInfo'), $param, $onlyUrl);
}
/**
* 文章相关品牌
* @param $articleId
* @param bool $onlyUrl
* @return mixed
*/
public static function relateBrand($articleId, $onlyUrl = false)
{
$param['article_id'] = $articleId;
return self::webApi(self::getUrl('getBrand'), $param, $onlyUrl);
}
/**
* 相关文章列表
* @param $articleId
* @param $tag
* @param int $limit
* @param bool $onlyUrl
* @return mixed
*/
public static function relateList($articleId, $tag, $limit = 3, $onlyUrl = false)
{
$param['article_id'] = $articleId;
$param['tags'] = $tag;
$param['limit'] = $limit;
return self::webApi(self::getUrl('getOtherArticle'), $param, $onlyUrl);
}
/**
* 精彩推荐(48小时内浏览最多的文章)
*
* @param string $gender
* @param int $page
* @param int $limit
* @param bool $onlyUrl
* @return mixed
*/
public static function recommend($gender, $page = 1, $limit = 10, $onlyUrl = false)
{
$param['gender'] = $gender;
$param['page'] = $page;
$param['limit'] = $limit;
return self::webApi(self::getUrl('getArticleByViewsNum'), $param, $onlyUrl);
}
/**
* 添加文章评论
* @param $id 文章id
* @param $uid 用户id
* @param $content 评论内容
* @return mixed
*/
public static function addComment($id, $uid, $content)
{
$param['article_id'] = $id;
$param['uid'] = $uid;
$param['content'] = $content;
return self::webApi(self::getUrl('addComment'), $param);
}
/**
* 点赞
* @param $id
* @param $udid
* @return mixed
*/
public static function setPraise($id, $udid)
{
$param['article_id'] = $id;
$param['udid'] = $udid;
return self::webApi(self::getUrl('setPraise'), $param);
}
/**
* 取消赞
* @param $id
* @param $udid
* @return mixed
*/
public static function cancelPraise($id, $udid)
{
$param['article_id'] = $id;
$param['udid'] = $udid;
return self::webApi(self::getUrl('cancelPraise'), $param);
}
/**
* 收藏文章
* @param $id
* @param $uid
* @return mixed
*/
public static function setFavorite($id, $uid)
{
$param['article_id'] = $id;
$param['uid'] = $uid;
return self::webApi(self::getUrl('setFavorite'), $param);
}
/**
* 取消文章收藏
* @param $id
* @param $uid
* @return mixed
*/
public static function cancelFavorite($id, $uid)
{
$param['article_id'] = $id;
$param['uid'] = $uid;
return self::webApi(self::getUrl('cancelFavorite'), $param);
}
}
\ No newline at end of file
... ...
<?php
namespace LibModels\Web\Guang;
class ListData extends \LibModels\Wap\Guang\ListData {
}
\ No newline at end of file
<?php
namespace LibModels\Web\Guang;
use Api\Sign;
use Api\Yohobuy;
/**
* 逛首页列表相关的数据模型
*
* @name ListData
* @package LibModels/Web/Guang
* @copyright yoho.inc
* @version 1.0 (2015-10-10 9:54:07)
* @author fei.hong <fei.hong@yoho.cn>
*/
class ListData
{
const URI_CATEGORY = 'guang/api/v1/category/get';
const URI_ARTICLELIST = 'guang/api/v2/article/getList';
const URI_GETAUTHOR = 'guang/service/v1/author/getAuthor';
/**
* 逛分类
*
* 备注: id (0:最新,1:话题,2:搭配,3:潮人,4:潮品,5:小贴士)
*
* @return array
*/
public static function category()
{
$param = Yohobuy::param();
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_CATEGORY, $param, 3600); // 有缓存1小时
}
/**
* 逛内容列表
*
* @param string $gender "1,3"表示男, "2,3"表示女, "1,2,3"表示所有
* @param int $sortId 分类ID
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @param string $tag 标签
* @param int $authorId 作者ID
* @param int $limit 返回的限制数
* @param bool $useCache 是否使用缓存
* @return array
*/
public static function article($gender, $sortId, $uid = 0, $udid = '', $page = 1, $tag = null, $authorId = null, $limit = null, $useCache = false)
{
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['page'] = $page;
$param['uid'] = $uid;
$param['udid'] = $udid;
if (isset($sortId)) {
$param['sort_id'] = $sortId;
}
if (!empty($tag)) {
$param['tag'] = $tag;
}
if (isset($authorId) && is_numeric($authorId)) {
$param['author_id'] = $authorId;
}
if (isset($limit)) {
$param['limit'] = $limit;
}
$param['client_type'] = "web";
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['client_secret'] = Sign::getSign($param);
$cache = $useCache ? 300 : false;
return Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_ARTICLELIST, $param, $cache); // 缓存5分钟
}
/**
* 根据分类进行分组的逛内容列表
*
* @param array $category 分类
* @param string $gender "1,3"表示男, "2,3"表示女
* @param int $uid 用户ID
* @param string $udid 客户端唯一标识
* @param int $page 分页第几页, 默认第1页
* @return array
*/
public static function articleGroup($category, $gender, $uid = 0, $udid, $page = 1)
{
$urlList = array();
$param = array();
foreach ($category as $value) {
$param = Yohobuy::param();
$param['gender'] = $gender;
$param['page'] = $page;
$param['sort_id'] = $value['id'];
$param['uid'] = $uid;
$param['udid'] = $udid;
$param['client_secret'] = Sign::getSign($param);
$urlList[$value['id']] = Yohobuy::httpBuildQuery(Yohobuy::SERVICE_URL . self::URI_ARTICLELIST, $param);
}
return Yohobuy::getMulti($urlList);
}
/**
* 获取作者信息
*
* @param int $id 作者ID
* @return array
*/
public static function author($id)
{
$result = array();
if (is_numeric($id)) {
// $result = Yohobuy::yarClient(Yohobuy::SERVICE_URL . self::URI_AUTHOR, 'getAuthor', array($id), 3600); // 缓存1小时
$param = Yohobuy::param();
$param['author_id'] = $id;
$param['client_type'] = "web";
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['client_secret'] = Sign::getSign($param);
$result = Yohobuy::get(Yohobuy::SERVICE_URL . self::URI_GETAUTHOR, $param); // 缓存1小时
}
return $result;
}
}
... ...
... ... @@ -2,7 +2,7 @@
namespace LibModels\Web\Guang;
use Api\Yohobuy;
use Api\Sign;
class PlusstarData extends \LibModels\Wap\Guang\PlusstarData {
class PlusstarData {
const URI_BRANDLIST = 'guang/api/v3/plustar/getlist';
/**
... ...
<?php
namespace LibModels\Web\Product;
use Api\Sign;
use Api\Yohobuy;
/**
* 支付操作类
*
* @package LibModels\Web\Product
* @author Gtskk
* @copyright 2016/3/24 14:23 Gtskk<iamgtskk@gmail.com>
* @version: 0.0.1
*/
class PayData
{
/**
* 获取指定用户的订单数目
*
* @param int $uid 用户ID
* @return mixed
*/
public static function getOrderCountByUid($uid)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getOrderCountByUid';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取支付方式列表
*
* @return mixed
*/
public static function getPaymentList()
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getPaymentList';
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 根据支付方式id获取单个支付方式有关信息
*
* @param int $id 支付方式id
* @return mixed
*/
public static function getPaymentById($id)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getPaymentById';
$param['id'] = $id;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* ERP提交订单状态
*
* @param string $orderCode 订单号
* @param int $payment 支付方式id
* @param string $bankName 银行名称
* @param string $bankCode 银行代码
* @param string $amount 金额
* @param string $payOrderCode 支付订单代码
* @param string $tradeNo 交易码
* @param string $bankBillNo 银行订单码
* @return mixed
*/
public static function submitOrderStatus($orderCode, $payment, $bankName, $bankCode, $amount, $payOrderCode, $tradeNo, $bankBillNo)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.submitOrderStatus';
$param['order_code'] = $orderCode;
$param['payment'] = $payment;
$param['bank_name'] = $bankName;
$param['bank_code'] = $bankCode;
$param['amount'] = $amount;
$param['payOrderCode'] = $payOrderCode;
$param['trade_no'] = $tradeNo;
$param['bank_bill_no'] = $bankBillNo;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 更新订单的状态
*
* @param int $id 订单ID
* @param int $uid 用户ID
* @param int $payment 支付方式ID
* @param string $paymentStatus 支付状态(Y或者N)
* @param string $bankCode 银行代码
* @return mixed
*/
public static function updateOrderStatus($id, $uid, $payment, $paymentStatus, $bankCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.updatePaymentStatus';
$param['id'] = $id;
$param['uid'] = $uid;
$param['payment'] = $payment;
$param['payment_status'] = $paymentStatus;
$param['bank_code'] = $bankCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 获取订单的支付银行
*
* @param string $orderCode 订单号
* @return mixed
*/
public static function getBankByOrder($orderCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.getOrderPayBank';
$param['orderCode'] = $orderCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 添加订单支付银行记录
*
* @param string $orderCode 订单号
* @param int $payment 支付方式ID
* @param string $bankCode 银行码
* @return mixed
*/
public static function setOrderPayBank($orderCode, $payment, $bankCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.addOrderPayBank';
$param['orderCode'] = $orderCode;
$param['payment'] = $payment;
$param['bankCode'] = $bankCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 更改订单支付银行记录
*
* @param string $orderCode 订单号
* @param int $payment 支付方式ID
* @param string $bankCode 银行码
* @return mixed
*/
public static function updateOrderPayBank($orderCode, $payment, $bankCode)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'web.SpaceOrders.modifyOrderPayBank';
$param['orderCode'] = $orderCode;
$param['payment'] = $payment;
$param['bankCode'] = $bankCode;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
/**
* 发送短信息(默认不传递area参数,传递了就是给特定国家码的手机号发送短信)
*
* @param string $mobile 手机号
* @param string $template 模板类型
* @param string $codes 对应模板中的参数
* @return mixed
*/
public static function sendMessage($mobile, $template, $codes)
{
$param = Yohobuy::param();
$param['client_type'] = 'web';
$param['private_key'] = Yohobuy::$privateKeyList['web'];
$param['method'] = 'app.message.sendMsg';
$param['mobile'] = $mobile;
$param['template'] = $template;
$param['codes'] = $codes;
$param['client_secret'] = Sign::getSign($param);
return Yohobuy::get(Yohobuy::API_URL, $param);
}
}
\ No newline at end of file
... ...
... ... @@ -343,29 +343,34 @@ class Helpers
*/
public static function formatArticle($articleData, $showTag = true, $isApp = false, $showAuthor = true, $uid = null)
{
// 资讯ID不存在,则不显示
// 资讯ID不存在,则不显示
if (!isset($articleData['id'])) {
return false;
}
$width = $height = 360;
$isSquareImage = true;
if($articleData['conver_image_type'] == 2) {
$width = 360;
$height = 240;
$isSquareImage = false;
}
$result = array();
$result['id'] = $articleData['id'];
$result['classification'] = $articleData['category_name'];
$result['isReco'] = $articleData['is_recommended'];
$result['url'] = $isApp ? $articleData['url'] : self::url('/info/index', array('id' => $articleData['id']), 'guang');
$result['isReco'] = $articleData['is_recommended'] ? true : false;
$result['url'] = $isApp ? $articleData['url'] : self::url('/'.$articleData['id'].'.html', array(), 'guang');
$result['img'] = self::getImageUrl($articleData['src'], $width, $height);
$result['isSquareImg'] = true;
$result['isSquareImg'] = $isSquareImage;
$result['title'] = $articleData['title'];
if(empty($articleData['author'])){
$articleData['author']['name'] = '';
$articleData['author']['avatar'] = '';
}
$result['author'] = $articleData['author']['name'];
$result['editorUrl'] = $articleData['author']['avatar'];
if (isset($articleData['author']['author_id']) && !empty($articleData['author']['author_id'])) {
$author_id = $articleData['author']['author_id'];
$result['editorUrl'] = self::url('/Index/editor', array('author_id' => $author_id), 'guang');
}
$result['pTime'] = $articleData['publish_time'];
$result['pView'] = $articleData['views_num'];
$result['content'] = $articleData['intro'];
... ... @@ -428,7 +433,7 @@ class Helpers
public static function formatTag($tagData, $isApp = false, $uid = null) {
$result = array();
$result['tag'] = $tagData['name'];
$result['url'] = $tagData['url'];
$result['url'] = Helpers::url('/tags/index', array('query'=>urlencode($tagData['name'])), 'guang');
return $result;
}
... ...
<?php
namespace WebPlugin\Pay\AliExpressgateway;
class Config
{
var $pay_url = "https://mapi.alipay.com/gateway.do";
/**
* 服务名,即时到帐为create_direct_pay_by_user
* Enter description here ...
* @var String
*/
var $service = "create_direct_pay_by_user";
/**
* 合作伙伴在支付宝的用户ID
* Enter description here ...
* @var string
*/
var $partner = "";
/**
* 编码
* Enter description here ...
* @var String
*/
var $input_charset = "utf-8";
/**
* 通知url,(用于后台提交)
* Enter description here ...
* @var String
*/
var $notify_url = "notice/aliexpressgatewaynotice";
/**
* 浏览器的返回
* Enter description here ...
* @var string
*/
var $return_url = "notice/aliexpressgatewayreturn";
/**
* 签名方式
* Enter description here ...
* @var String
*/
var $sign_type = "MD5";
/**
* 支付类型,1为购买
* Enter description here ...
* @var Integer
*/
var $payment_type = "1";
/**
* expressGateway、expressGatewayCredit
* @var unknown_type
*/
var $paymethod = "expressGateway";
/**
* 自动登陆标识,N则跳到银行,Y则直接在支付宝填
* @var array
*/
var $default_login = "Y";
/**
* Key
* Enter description here ...
* @var String
*/
var $alipay_key = "";
/**
* 销售者mail
* Enter description here ...
* @var String
*/
var $sellerMail = "";
/**
* 防钓鱼配置
*/
var $anti_fishing = array(
'ip_enable' => true,
'timestamp_enable' =>true
);
}
... ...
<?php
namespace WebPlugin\Pay\AliExpressgateway;
use DOMDocument;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config ;
public function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'AliExpressgateway';
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->partner = $myConfig->merchant_id;
$this->config->alipay_key = $myConfig->merchant_key;
$this->config->sellerMail = $myConfig->merchant_other_code;
}
/**
* 获取时间戳
*/
private function getTimestamp() {
$url = "https://mapi.alipay.com/gateway.do?service=query_timestamp&partner=" . trim(strtolower($this->config->partner)) . "&_input_charset=" . trim(strtolower($this->config->input_charset));
$doc = new DOMDocument();
$doc->load($url);
$itemEncrypt_key = $doc->getElementsByTagName("encrypt_key");
$encrypt_key = $itemEncrypt_key->item(0)->nodeValue;
return $encrypt_key;
}
public function getPayRequestPars(Reqparams $params)
{
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
$parameter = array(
'service' => $this->config->service,
'partner' => $this->config->partner,
'_input_charset' => $this->config->input_charset,
'notify_url' => $baseUrl . $this->config->notify_url,
'return_url' => $baseUrl . $this->config->return_url,
/* 业务参数 */
'subject' => $params->goodsName,
'out_trade_no' => $params->orderCode,
'total_fee' => $params->totalFee / 100, //单位为元
'payment_type' => $this->config->payment_type,
'paymethod' => $this->config->paymethod,
'default_login' => $this->config->default_login,
'defaultbank' => $params->paymentParameter,
'seller_email' => $this->config->sellerMail
);
if($this->config->anti_fishing['timestamp_enable']) {
$anti_phishing_key = $this->getTimestamp();
if(!empty($anti_phishing_key)) {
$parameter['anti_phishing_key'] = $anti_phishing_key;
}
}
if($this->config->anti_fishing['ip_enable']) {
$parameter['exter_invoke_ip'] = $params->spbill_create_ip;
}
// 除去数组中的空值和签名参数
$para_filter = array();
foreach ($parameter AS $k => $v) {
if($k == "sign" || $k == "sign_type" || $v == "") {
continue;
} else {
$para_filter[$k] = $parameter[$k];
}
}
ksort($para_filter);
reset($para_filter);
$param = '';
$sign = '';
foreach ($para_filter AS $key => $val)
{
$param .= "$key=" .urlencode($val). "&";
$sign .= "$key=$val&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1). $this->config->alipay_key;
$result = array(
'pay_url' => $this->config->pay_url,
'pars' => $param . "&sign=" . md5($sign). "&sign_type=" . $this->config-> sign_type,
'reqType' => 'get'
);
return $result;
}
/**
* 解析响应
*
* @param array $arrResponse
* @return Rspparams
*/
public function parseResponse(array $arrResponse)
{
/* 返回示例
* http://www.yohobuy.com/pay/notice/aliexpressgatewayreturn?buyer_email=tds%40smartunite.com&buyer_id=2088302294447308&exterface=create_direct_pay_by_user&is_success=T&notify_id=RqPnCoPT3K9%252Fvwbh3I7xtEV5W65QRToFQ5fPrXsVxt12e%252FExCtC1XNiKnuRwupLaVLAR&notify_time=2011-06-11+07%3A48%3A10&notify_type=trade_status_sync&out_trade_no=1061003000&payment_type=1&seller_email=shop%40yoho.cn&seller_id=2088001550230585&subject=YOHO%E5%95%86%E5%93%81&total_fee=0.01&trade_no=2011061199833830&trade_status=TRADE_SUCCESS&sign=ca1c49f58d17eaa57aac308d0ac64434&sign_type=MD5
*/
if(isset($arrResponse['q'])){
unset($arrResponse['q']);
}
$rsp = new Rspparams();
if(!$this->checkResponse($arrResponse))
{
//验证不成功
$rsp->payResult = -1;
}
else
{
$rsp->bankName = "";
$rsp->orderCode = $arrResponse["out_trade_no"];
$rsp->payResult = $this->convertResult($arrResponse["trade_status"]);
$rsp->payTime = $arrResponse["gmt_payment"];
$rsp->totalFee = $arrResponse["total_fee"];
$rsp->resultMsg = $arrResponse["notify_type"];
//添加支付订单号和交易号
$rsp->payOrderCode = $arrResponse["out_trade_no"];
$rsp->tradeNo = $arrResponse['trade_no'];
$rsp->bankBillNo = "";
}
return $rsp;
}
protected function convertResult($resultCode)
{
if($resultCode == "TRADE_SUCCESS")
{
return 200;
}
return 400;
}
/**
* 除去数组中的空值和签名参数
* @param $para 签名参数组
* @return array 去掉空值与签名参数后的新签名参数组
*/
private function paraFilter($para) {
$para_filter = array();
foreach ($para as $key=>$val) {
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}
/**
* 对数组排序
* @param $para 排序前的数组
* @return 排序前的数组
*/
private function argSort($para) {
ksort($para);
reset($para);
return $para;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
* @param array $arrResponse
* @return bool|void
*/
protected function checkResponse(array $arrResponse)
{
ksort($arrResponse);
reset($arrResponse);
$sign = '';
foreach ($arrResponse AS $key=>$val)
{
if ($key != 'sign' && $key != 'sign_type' && $key != 'code')
{
$sign .= "$key=$val&";
}
}
$sign = substr($sign, 0, -1) . $this->config->alipay_key;
return md5($sign) != $arrResponse['sign'] ? false : true;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Alibank;
class Config
{
var $pay_url = "https://mapi.alipay.com/gateway.do";
/**
* 服务名,即时到帐为create_direct_pay_by_user
* Enter description here ...
* @var String
*/
var $service = "create_direct_pay_by_user";
/**
* 合作伙伴在支付宝的用户ID
* Enter description here ...
* @var string
*/
var $partner = "";
/**
* 编码
* Enter description here ...
* @var String
*/
var $input_charset = "utf-8";
/**
* 通知url,(用于后台提交)
* Enter description here ...
* @var String
*/
var $notify_url = "notice/alibanknotice";
/**
* 浏览器的返回
* Enter description here ...
* @var string
*/
var $return_url = "notice/alibankreturn";
/**
* 签名方式
* Enter description here ...
* @var String
*/
var $sign_type = "MD5";
/**
* 支付类型,1为购买
* Enter description here ...
* @var Integer
*/
var $payment_type = "1";
/**
* Key
* Enter description here ...
* @var String
*/
var $alipay_key = "";
/**
* 销售者mail
* Enter description here ...
* @var String
*/
var $sellerMail = "";
/**
* 防钓鱼配置
*/
var $anti_fishing = array(
'ip_enable' => false,
'timestamp_enable' =>false
);
}
... ...
<?php
namespace WebPlugin\Pay\Alibank;
use DOMDocument;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config ;
public function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'alibank';
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->partner = $myConfig->merchant_id;
$this->config->alipay_key = $myConfig->merchant_key;
$this->config->sellerMail = $myConfig->merchant_other_code;
}
/**
* 获取时间戳
*/
private function getTimestamp()
{
$url = "https://mapi.alipay.com/gateway.do?service=query_timestamp&partner=" . trim(strtolower($this->config->partner)) . "&_input_charset=" . trim(strtolower($this->config->input_charset));
$doc = new DOMDocument();
$doc->load($url);
$itemEncrypt_key = $doc->getElementsByTagName("encrypt_key");
$encrypt_key = $itemEncrypt_key->item(0)->nodeValue;
return $encrypt_key;
}
public function getPayRequestPars(Reqparams $params)
{
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
$loseTime = intval(($params->orderTime + 7200 -time())/60);
// $loseTime = intval((strtotime(date("Y-m-d 10:00:00", strtotime("+1 day")))-time())/60);
$parameter = array(
'service' => $this->config->service,
'partner' => $this->config->partner,
'_input_charset' => $this->config->input_charset,
'notify_url' => $baseUrl . $this->config->notify_url,
'return_url' => $baseUrl . $this->config->return_url,
/* 业务参数 */
'subject' => $params->goodsName,
'out_trade_no' => $params->orderCode.'_'.$params->paymentParameter,
'total_fee' => $params->totalFee / 100, //单位为元
'payment_type' => $this->config->payment_type,
'defaultbank' => $params->paymentParameter,
'seller_email' => $this->config->sellerMail,
// 'it_b_pay' => $loseTime . 'm'
);
if($this->config->anti_fishing['timestamp_enable']) {
$anti_phishing_key = $this->getTimestamp();
if(!empty($anti_phishing_key)) {
$parameter['anti_phishing_key'] = $anti_phishing_key;
}
}
if($this->config->anti_fishing['ip_enable']) {
$parameter['exter_invoke_ip'] = $params->spbill_create_ip;
}
// 除去数组中的空值和签名参数
$para_filter = array();
foreach ($parameter AS $k => $v) {
if($k == "sign" || $k == "sign_type" || $v == "") {
continue;
} else {
$para_filter[$k] = $parameter[$k];
}
}
ksort($para_filter);
reset($para_filter);
$param = '';
$sign = '';
foreach ($para_filter AS $key => $val) {
$param .= "$key=" .urlencode($val). "&";
$sign .= "$key=$val&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1);
//如果存在转义字符,那么去掉转义
if(get_magic_quotes_gpc()){$sign = stripslashes($sign);}
$sign .= $this->config->alipay_key;
$result = array(
'pay_url' => $this->config->pay_url,
'pars' => $param . "&sign=" . md5($sign). "&sign_type=" . $this->config-> sign_type,
'reqType' => 'get'
);
return $result;
}
public function parseResponse(array $arrResponse)
{
/* 返回示例
* http://www.yohobuy.com/pay/notice/alipayreturn?buyer_email=tds%40smartunite.com&buyer_id=2088302294447308&exterface=create_direct_pay_by_user&is_success=T&notify_id=RqPnCoPT3K9%252Fvwbh3I7xtEV5W65QRToFQ5fPrXsVxt12e%252FExCtC1XNiKnuRwupLaVLAR&notify_time=2011-06-11+07%3A48%3A10&notify_type=trade_status_sync&out_trade_no=1061003000&payment_type=1&seller_email=shop%40yoho.cn&seller_id=2088001550230585&subject=YOHO%E5%95%86%E5%93%81&total_fee=0.01&trade_no=2011061199833830&trade_status=TRADE_SUCCESS&sign=ca1c49f58d17eaa57aac308d0ac64434&sign_type=MD5
*/
if(isset($arrResponse['q'])){
unset($arrResponse['q']);
}
$rsp = new Rspparams();
if(!$this->checkResponse($arrResponse))
{
//验证不成功
$rsp->payResult = -1;
}
else
{
$rsp->bankName = "";
$outTradeNo = $arrResponse["out_trade_no"];
// if(strlen($outTradeNo) > 9) {
// $outTradeNo = substr($outTradeNo, 2);
// }
//支付订单处理
$orderCodeArr = explode('_',$outTradeNo);
if(count($orderCodeArr) == 2){
$rsp->orderCode = $orderCodeArr[0];
$rsp->bankName = $orderCodeArr[1];
}else{
$rsp->orderCode = $outTradeNo;
$rsp->bankName = "";
}
$rsp->payResult = $this->convertResult($arrResponse["trade_status"]);
$rsp->payTime = isset($arrResponse["gmt_payment"]) ? $arrResponse["gmt_payment"] : time();
$rsp->totalFee = $arrResponse["total_fee"];
$rsp->resultMsg = $arrResponse["notify_type"];
//添加支付订单号和交易号和银行的流水号
$rsp->payOrderCode = $outTradeNo;
$rsp->tradeNo = $arrResponse['trade_no'];
$rsp->bankBillNo = $arrResponse['bank_seq_no'] ? $arrResponse['bank_seq_no'] : "";
}
return $rsp;
}
protected function convertResult($resultCode)
{
if($resultCode == "TRADE_SUCCESS")
{
return 200;
}
return 400;
}
/**
* 除去数组中的空值和签名参数
* @param $para 签名参数组
* return 去掉空值与签名参数后的新签名参数组
*/
private function paraFilter($para) {
$para_filter = array();
foreach ($para as $key=>$val) {
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}
/**
* 对数组排序
* @param $para 排序前的数组
* return 排序后的数组
*/
private function argSort($para) {
ksort($para);
reset($para);
return $para;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
*/
protected function checkResponse(array $arrResponse)
{
ksort($arrResponse);
reset($arrResponse);
$sign = '';
foreach ($arrResponse AS $key=>$val)
{
if ($key != 'sign' && $key != 'sign_type' && $key != 'code')
{
$sign .= "$key=$val&";
}
}
$sign = substr($sign, 0, -1) . $this->config->alipay_key;
return md5($sign) != $arrResponse['sign'] ? false : true;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Alibarcode;
class Config
{
//老网关,2013年3月20日下线
// var $pay_url = "https://www.alipay.com/cooperate/gateway.do";
//新网关
var $pay_url = "https://mapi.alipay.com/gateway.do";
/**
* 测试网关
* @var unknown_type
*/
// var $pay_url = 'http://mapi.d4192.alipay.net/cooperate/gateway.do';
/**
* 服务名,即时到帐为create_direct_pay_by_user
* Enter description here ...
* @var String
*/
var $service = "create_direct_pay_by_user";
/**
* 合作伙伴在支付宝的用户ID
* Enter description here ...
* @var string
*/
var $partner = "";
/**
* 编码
* Enter description here ...
* @var String
*/
var $input_charset = "utf-8";
/**
* 通知url,(用于后台提交)
* Enter description here ...
* @var String
*/
var $notify_url = "notice/alibarcodenotice";
/**
* 浏览器的返回
* Enter description here ...
* @var string
*/
var $return_url = "notice/alibarcodereturn";
/**
* 签名方式
* Enter description here ...
* @var String
*/
var $sign_type = "MD5";
/**
* 支付类型,1为购买
* Enter description here ...
* @var Integer
*/
var $payment_type = "1";
/**
* Key
* Enter description here ...
* @var String
*/
var $alipay_key = "";
/**
* 销售者mail
* Enter description here ...
* @var String
*/
var $sellerMail = "";
/**
*
* @var unknown_type
*/
var $qr_pay_mode = 2;
/**
* 防钓鱼配置
*/
var $anti_fishing = array(
'ip_enable' => false,
'timestamp_enable' =>false
);
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Alibarcode;
use DOMDocument;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config ;
public function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'alipay';
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]);
$this->config->partner = $myConfig->merchant_id;
$this->config->alipay_key = $myConfig->merchant_key;
$this->config->sellerMail = $myConfig->merchant_other_code;
}
/**
* 获取时间戳
*/
private function getTimestamp() {
$url = "https://mapi.alipay.com/gateway.do?service=query_timestamp&partner=" . trim(strtolower($this->config->partner)) . "&_input_charset=" . trim(strtolower($this->config->input_charset));
$doc = new DOMDocument();
$doc->load($url);
$itemEncrypt_key = $doc->getElementsByTagName("encrypt_key");
$encrypt_key = $itemEncrypt_key->item(0)->nodeValue;
return $encrypt_key;
}
public function getPayRequestPars(Reqparams $params)
{
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
$loseTime = intval(($params->orderTime + 7200 -time())/60);
// $loseTime = intval((strtotime(date("Y-m-d 10:00:00", strtotime("+1 day")))-time())/60); //第二天十点
$parameter = array(
'service' => $this->config->service,
'partner' => $this->config->partner,
'_input_charset' => $this->config->input_charset,
'notify_url' => $baseUrl . $this->config->notify_url,
'return_url' => $baseUrl . $this->config->return_url,
/* 业务参数 */
'subject' => $params->goodsName,
'out_trade_no' => $params->orderCode,
// 'it_b_pay' => $loseTime . 'm',
'total_fee' => $params->totalFee / 100, //单位为元
'payment_type' => $this->config->payment_type,
'seller_email' => $this->config->sellerMail,
'sign_id_ext' =>$params->uid,
'sign_name_ext' => $params->userName,
'qr_pay_mode' => $this->config->qr_pay_mode
);
if($this->config->anti_fishing['timestamp_enable']) {
$anti_phishing_key = $this->getTimestamp();
if(!empty($anti_phishing_key)) {
$parameter['anti_phishing_key'] = $anti_phishing_key;
}
}
if($this->config->anti_fishing['ip_enable']) {
$parameter['exter_invoke_ip'] = $params->spbill_create_ip;
}
if(!empty($params->paymentParameter)){
//使用快捷支付,但是支付宝扫码支付不用传token
// $parameter['token'] = $params->paymentParameter;
}
ksort($parameter);
reset($parameter);
$param = '';
$sign = '';
foreach ($parameter AS $key => $val)
{
$param .= "$key=" .urlencode($val). "&";
$sign .= "$key=$val&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1). $this->config->alipay_key;
$result = array(
'pay_url' => $this->config->pay_url,
'pars' => $param . "&sign=" . md5($sign). "&sign_type=" . $this->config-> sign_type,
'reqType' => 'get'
);
return $result;
}
public function parseResponse(array $arrResponse)
{
/* 返回示例
* http://www.yohobuy.com/pay/notice/alibarcodereturn?buyer_email=tds%40smartunite.com&buyer_id=2088302294447308&exterface=create_direct_pay_by_user&is_success=T&notify_id=RqPnCoPT3K9%252Fvwbh3I7xtEV5W65QRToFQ5fPrXsVxt12e%252FExCtC1XNiKnuRwupLaVLAR&notify_time=2011-06-11+07%3A48%3A10&notify_type=trade_status_sync&out_trade_no=1061003000&payment_type=1&seller_email=shop%40yoho.cn&seller_id=2088001550230585&subject=YOHO%E5%95%86%E5%93%81&total_fee=0.01&trade_no=2011061199833830&trade_status=TRADE_SUCCESS&sign=ca1c49f58d17eaa57aac308d0ac64434&sign_type=MD5
*/
if(isset($arrResponse['q'])){
unset($arrResponse['q']);
}
$rsp = new Rspparams();
if(!$this->checkResponse($arrResponse))
{
//验证不成功
$rsp->payResult = -1;
}
else
{
$rsp->bankName = "";
$outTradeNo = $arrResponse["out_trade_no"];
$rsp->orderCode = $outTradeNo;
$rsp->payResult = $this->convertResult($arrResponse["trade_status"]);
$rsp->payTime = $arrResponse["gmt_payment"];
$rsp->totalFee = $arrResponse["total_fee"];
$rsp->resultMsg = $arrResponse["notify_type"];
//添加支付订单号和交易号
$rsp->payOrderCode = $outTradeNo;
$rsp->tradeNo = $arrResponse['trade_no'];
$rsp->bankBillNo = "";
}
return $rsp;
}
protected function convertResult($resultCode)
{
if($resultCode == "TRADE_SUCCESS")
{
return 200;
}
return 400;
}
/**
* 除去数组中的空值和签名参数
* @param $para 签名参数组
* @return array 去掉空值与签名参数后的新签名参数组
*/
private function paraFilter($para) {
$para_filter = array();
foreach ($para as $key=>$val) {
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}
/**
* 对数组排序
* @param $para 排序前的数组
* @return 排序前的数组
*/
private function argSort($para) {
ksort($para);
reset($para);
return $para;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
* @param array $arrResponse
* @return bool|void
*/
protected function checkResponse(array $arrResponse)
{
ksort($arrResponse);
reset($arrResponse);
$sign = '';
foreach ($arrResponse AS $key=>$val)
{
if ($key != 'sign' && $key != 'sign_type' && $key != 'code')
{
$sign .= "$key=$val&";
}
}
$sign = substr($sign, 0, -1) . $this->config->alipay_key;
return md5($sign) != $arrResponse['sign'] ? false : true;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Alipay;
class Config
{
//老网关,2013年3月20日下线
// var $pay_url = "https://www.alipay.com/cooperate/gateway.do";
//新网关
var $pay_url = "https://mapi.alipay.com/gateway.do";
/**
* 服务名,即时到帐为create_direct_pay_by_user
* Enter description here ...
* @var String
*/
var $service = "create_direct_pay_by_user";
/**
* 合作伙伴在支付宝的用户ID
* Enter description here ...
* @var string
*/
var $partner = "";
/**
* 编码
* Enter description here ...
* @var String
*/
var $input_charset = "utf-8";
/**
* 通知url,(用于后台提交)
* Enter description here ...
* @var String
*/
var $notify_url = "notice/alipaynotice";
/**
* 浏览器的返回
* Enter description here ...
* @var string
*/
var $return_url = "notice/alipayreturn";
/**
* 签名方式
* Enter description here ...
* @var String
*/
var $sign_type = "MD5";
/**
* 支付类型,1为购买
* Enter description here ...
* @var Integer
*/
var $payment_type = "1";
/**
* Key
* Enter description here ...
* @var String
*/
var $alipay_key = "";
/**
* 销售者mail
* Enter description here ...
* @var String
*/
var $sellerMail = "";
/**
* 防钓鱼配置
*/
var $anti_fishing = array(
'ip_enable' => false,
'timestamp_enable' =>false
);
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Alipay;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config ;
public function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'alipay';
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->partner = $myConfig->merchant_id;
$this->config->alipay_key = $myConfig->merchant_key;
$this->config->sellerMail = $myConfig->merchant_other_code;
}
/**
* 获取时间戳
*/
private function getTimestamp() {
$url = "https://mapi.alipay.com/gateway.do?service=query_timestamp&partner=" . trim(strtolower($this->config->partner)) . "&_input_charset=" . trim(strtolower($this->config->input_charset));
$doc = new DOMDocument();
$doc->load($url);
$itemEncrypt_key = $doc->getElementsByTagName("encrypt_key");
$encrypt_key = $itemEncrypt_key->item(0)->nodeValue;
return $encrypt_key;
}
/**
* @param Reqparams $params
* @return array
*/
public function getPayRequestPars(Reqparams $params)
{
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
// $loseTime = intval(($params->orderTime + 7200 -time())/60);
// $loseTime = intval((strtotime(date("Y-m-d 10:00:00", strtotime("+1 day")))-time())/60); //第二天十点
$parameter = array(
'service' => $this->config->service,
'partner' => $this->config->partner,
'_input_charset' => $this->config->input_charset,
'notify_url' => $baseUrl . $this->config->notify_url,
'return_url' => $baseUrl . $this->config->return_url,
/* 业务参数 */
'subject' => $params->goodsName,
'out_trade_no' => $params->orderCode,
// 'it_b_pay' => $loseTime . 'm',
'total_fee' => $params->totalFee / 100, //单位为元
'payment_type' => $this->config->payment_type,
'seller_email' => $this->config->sellerMail,
'sign_id_ext' =>$params->uid,
'sign_name_ext' => $params->userName
);
if($this->config->anti_fishing['timestamp_enable']) {
$anti_phishing_key = $this->getTimestamp();
if(!empty($anti_phishing_key)) {
$parameter['anti_phishing_key'] = $anti_phishing_key;
}
}
if($this->config->anti_fishing['ip_enable']) {
$parameter['exter_invoke_ip'] = $params->spbill_create_ip;
}
if(!empty($params->paymentParameter)){
//使用快捷支付
$parameter['token'] = $params->paymentParameter;
}
ksort($parameter);
reset($parameter);
$param = '';
$sign = '';
foreach ($parameter AS $key => $val)
{
$param .= "$key=" .urlencode($val). "&";
$sign .= "$key=$val&";
}
$param = substr($param, 0, -1);
$sign = substr($sign, 0, -1). $this->config->alipay_key;
$result = array(
'pay_url' => $this->config->pay_url,
'pars' => $param . "&sign=" . md5($sign). "&sign_type=" . $this->config-> sign_type,
'reqType' => 'get'
);
return $result;
}
public function parseResponse(array $arrResponse)
{
/* 返回示例
* http://www.yohobuy.com/pay/notice/alipayreturn?buyer_email=tds%40smartunite.com&buyer_id=2088302294447308&exterface=create_direct_pay_by_user&is_success=T&notify_id=RqPnCoPT3K9%252Fvwbh3I7xtEV5W65QRToFQ5fPrXsVxt12e%252FExCtC1XNiKnuRwupLaVLAR&notify_time=2011-06-11+07%3A48%3A10&notify_type=trade_status_sync&out_trade_no=1061003000&payment_type=1&seller_email=shop%40yoho.cn&seller_id=2088001550230585&subject=YOHO%E5%95%86%E5%93%81&total_fee=0.01&trade_no=2011061199833830&trade_status=TRADE_SUCCESS&sign=ca1c49f58d17eaa57aac308d0ac64434&sign_type=MD5
*/
if(isset($arrResponse['q'])){
unset($arrResponse['q']);
}
$rsp = new Rspparams();
if(!$this->checkResponse($arrResponse))
{
//验证不成功
$rsp->payResult = -1;
}
else
{
$rsp->bankName = "";
$outTradeNo = $arrResponse["out_trade_no"];
$rsp->orderCode = $outTradeNo;
$rsp->payResult = $this->convertResult($arrResponse["trade_status"]);
$rsp->payTime = isset($arrResponse["gmt_payment"]) ? $arrResponse["gmt_payment"] : '';
$rsp->totalFee = $arrResponse["total_fee"];
$rsp->resultMsg = $arrResponse["notify_type"];
//添加支付订单号和交易号
$rsp->payOrderCode = $outTradeNo;
$rsp->tradeNo = $arrResponse['trade_no'];
$rsp->bankBillNo = "";
}
return $rsp;
}
protected function convertResult($resultCode)
{
if($resultCode == "TRADE_SUCCESS")
{
return 200;
}
return 400;
}
/**
* 除去数组中的空值和签名参数
* @param $para 签名参数组
* return 去掉空值与签名参数后的新签名参数组
*/
private function paraFilter($para) {
$para_filter = array();
foreach ($para as $key=>$val) {
if($key == "sign" || $key == "sign_type" || $val == "")continue;
else $para_filter[$key] = $para[$key];
}
return $para_filter;
}
/**
* 对数组排序
* @param $para 排序前的数组
* return 排序后的数组
*/
private function argSort($para) {
ksort($para);
reset($para);
return $para;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
*/
protected function checkResponse(array $arrResponse)
{
ksort($arrResponse);
reset($arrResponse);
$sign = '';
foreach ($arrResponse AS $key=>$val)
{
if ($key != 'sign' && $key != 'sign_type' && $key != 'code')
{
$sign .= "$key=$val&";
}
}
$sign = substr($sign, 0, -1) . $this->config->alipay_key;
return md5($sign) != $arrResponse['sign'] ? false : true;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Allinpay;
/**
* 通联支付配置
* @author Smile
*
*/
class Config
{
var $pay_url = 'http://service.allinpay.com/gateway/index.do';
/**
* 编码
* Enter description here ...
* @var String
*/
var $input_charset = 1; //1为utf-8, 2为gbk, 3为gb2312
/**
* 通知url,(用于后台提交)
* Enter description here ...
* @var String
*/
var $notify_url = "notice/allinpaynotice";
/**
* 浏览器的返回
* Enter description here ...
* @var string
*/
var $return_url = "notice/allinpayreturn";
/**
* 签名方式, 0为md5, 1为证书
* Enter description here ...
* @var String
*/
var $sign_type = "0";
/**
* 支付接口请求版本
* @var string
*/
var $version = 'v1.0'; //必填
/**
* 商户号
* @var string
*/
var $merchantId = ''; //商户号
/**
* 签名key
* @var unknown_type
*/
var $merchantKey = '';
/**
* 支付方式
* @var unknown_type
*/
var $payType = 0; //非直连为0
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Allinpay;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config;
public function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'allinpay';
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]);
$this->config->merchantId = $myConfig->merchant_id;
$this->config->merchantKey = $myConfig->merchant_key;
}
/**
* @param Reqparams $params
* @return array
*/
public function getPayRequestPars(Reqparams $params)
{
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
$loseTime = intval(($params->orderTime + 7200 - time()) / 60);
$reqData = array(
'inputCharset' => $this->config->input_charset,
'pickupUrl' => $baseUrl . $this->config->return_url,
'receiveUrl' => $baseUrl . $this->config->notify_url,
'version' => $this->config->version,
'language' => 1,
'signType' => $this->config->sign_type,
'merchantId' => $this->config->merchantId,
'orderNo' => $params->orderCode,
'orderAmount' => $params->totalFee,
'orderCurrency' => 0, //币种,0为人民币
'orderDatetime' => date('YmdHis', $params->orderTime),
'orderExpireDatetime' => $loseTime,
'payType' => $this->config->payType
);
$paramsArr = array();
foreach ($reqData as $k => $v) {
$paramsArr[] = $k . '=' . $v;
}
$reqData['signMsg'] = strtoupper(md5(implode('&', $paramsArr) . '&key=' . $this->config->merchantKey));
return array(
'pay_url' => $this->config->pay_url,
'pars' => $reqData,
'reqType' => 'post'
);
}
/**
* 回复解析(non-PHPdoc)
* @param array $arrResponse
* @return void|Rspparams
*/
public function parseResponse(array $arrResponse)
{
$rsp = new Rspparams();
if (!$this->checkResponse($arrResponse)) {
$rsp->payResult = -1;
} else {
$rsp->bankName = "";
$rsp->orderCode = $arrResponse["orderNo"];
$rsp->payResult = $this->convertResult($arrResponse["payResult"]);
$rsp->payTime = $arrResponse["payDatetime"];
$rsp->totalFee = $arrResponse["payAmount"] / 100;
$rsp->resultMsg = $arrResponse["payResult"];
//添加支付订单号和交易号
$rsp->payOrderCode = $arrResponse["orderNo"];
$rsp->tradeNo = "";
$rsp->bankBillNo = "";
}
return $rsp;
}
protected function convertResult($resultCode)
{
if ($resultCode == 1) {
return 200;
}
return 400;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
* @param array $arrResponse
* @return bool|void
*/
protected function checkResponse(array $arrResponse)
{
$strParams = 'merchantId=' . $arrResponse['merchantId'];
$paramKey = array('version', 'language', 'signType', 'payType', 'issuerId', 'paymentOrderId', 'orderNo', 'orderDatetime', 'orderAmount', 'payDatetime', 'payAmount', 'ext1', 'ext2', 'payResult', 'errorCode', 'returnDatetime');
foreach ($paramKey as $k) {
if (isset($arrResponse[$k]) && $arrResponse[$k] != "") {
$strParams .= '&' . $k . '=' . $arrResponse[$k];
}
}
$signMsg = strtoupper(md5($strParams . '&key=' . $this->config->merchantKey));
return $signMsg == $arrResponse['signMsg'] ? true : false;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay;
class Banks
{
private static $list = array(
'BOCB2C' => array(
'name' => '中国银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/zhongguo.png'
),
'ABC' => array(
'name' => '中国农业银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/nongye.png'
),
'SPABANK' => array(
'name' => '平安银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/pingan.png'
),
'CMBC' => array(
'name' => '中国民生银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/minsheng.png'
),
"ICBCB2C" => array(
'name' => '中国工商银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/gongshang.png'
),
'SPDB' => array(
'name' => '浦发银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/pufa.png'
),
'BJRCB' => array(
'name' => '北京农商银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/beijingnongshang.png'
),
'HZCBB2C' => array(
'name' => '杭州银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/hangzhou.png'
),
'CMB' => array(
'name' => '招商银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/zhaoshang.png'
),
'CIB' => array(
'name' => '兴业银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/xingye.png'
),
'FDB' => array(
'name' => '富滇银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/fudian.png'
),
'CEB-DEBIT' => array(
'name' => '中国光大银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/guangda.png'
),
'CCB' => array(
'name' => '中国建设银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/zhongguojianshe.png'
),
'GDB' => array(
'name' => '广发银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/guangfa.png'
),
'POSTGC' => array(
'name' => '中国邮政储蓄',
'ico' => 'http://static.yohobuy.com/images/pay/icon/zhongguoyouzhengchuxu.png'
),
'SHBANK' => array(
'name' => '上海银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/shanghai.png'
),
'NBBANK' => array(
'name' => '宁波银行',
'ico' => 'http://static.yohobuy.com/images/pay/icon/ningbo.png'
)
// 'SDB' => array(
// 'name' => '深圳发展银行',
// 'ico' => 'http://static.yohobuy.com/images/bankico/SDB.gif'
// ),
/* 'COMM' => array(
'name' => '交通银行',
'ico' => 'http://static.yohobuy.com/images/bankico/COMM.gif'
), */
// 'CITIC' => array(
// 'name' => '中信银行',
// 'ico' => 'http://static.yohobuy.com/images/bankico/CITIC.gif'
// ),
// 'CEB' => array(
// 'name' => '光大银行',
// 'ico' => 'http://static.yohobuy.com/images/bankico/CEB.gif'
// ),
);
/**
* 获取银行列表
*
* @return array
*/
public static function getList(){
$ret = self::$list;
unset($ret['ICBC']);
unset($ret['BOC']);
// unset($ret['CEB']);
return $ret;
}
/**
* @return array
*/
public static function getExpressgatewayList() {
$support = array('ICBC', 'ABC', 'CMB', 'CCB', 'BOC', 'CEB-DEBIT', 'SPABANK');
$ret = array();
foreach ($support as $k) {
if(isset(self::$list[$k])){
$ret[$k] = self::$list[$k];
}
}
return $ret;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Chinabank;
/**
* 网银支付接口
* Enter description here ...
* @author smile
*
*/
class Config
{
/**
* 支付地址(方式3)
* Enter description here ...
* @var String
*/
var $payUrl = "https://pay3.chinabank.com.cn/PayGate";
/**
* 商户的回调地址
* Enter description here ...
* @var String
*/
var $merchantUrl = "notice/chinabank";
/**
* 异步通知
*/
var $autoReceiveUrl = "notice/chinabankautorev";
/**
* 商户ID
* Enter description here ...
* @var unknown_type
*/
var $merchantAcctId = "";
/**
* 分行号
* Enter description here ...
* @var String
*/
var $branchID = "";
/**
* 商户Key
* Enter description here ...
* @var string
*/
var $sp_key = "";
/**
* 币种
* Enter description here ...
* @var unknown_type
*/
var $feeType = "CNY";
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Chinabank;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config ;
function __construct(array $paymentParams)
{
$this->logProjectPrefix = 'chinabank';
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->merchantAcctId = $myConfig->merchant_id;
$this->config->sp_key = $myConfig->merchant_key;
// $this->config->branchID = $myConfig->merchant_other_code;
}
public function getPayRequestPars(Reqparams $params) {
parent::getPayRequestPars($params);
$baseUrl = $this->getBaseNoticeUrl($params->isTest);
$reqData = array();
$reqData['v_mid'] = $this->config->merchantAcctId; //商户ID
$reqData['v_oid'] = $params->orderCode;
$reqData['v_amount'] = $params->totalFee * 0.01;
$reqData['v_moneytype'] = $this->config->feeType;
$reqData['v_url'] = $baseUrl . $this->config->merchantUrl;
$reqData['v_md5info']= strtoupper(md5($reqData['v_amount'] . $reqData['v_moneytype'] . $reqData['v_oid']. $reqData['v_mid'] . $reqData['v_url']. $this->config->sp_key));
$reqData['remark1'] = $params->orderCode;
$reqData['remark2'] = "[url:=".$baseUrl . $this->config->autoReceiveUrl."]";
$result = array(
'pay_url' => $this->config->payUrl,
'pars' => $reqData,
'reqType' => 'post'
);
return $result;
}
/**
* 解析结果
* (non-PHPdoc)
* @see QCPay_Utils_Abstract::parseResponse()
* @param array $arrResponse
* @return void|QCPay_Utils_Rspparams
*/
function parseResponse(Array $arrResponse){
// {"v_md5all":"8F7E33B3759DC55F0E776120B5C16A55","v_md5info":"e42e938417bd01d8eb69235c1ebe9be3","remark1":"110610002420","v_pmode":null,"remark2":"","v_idx":"5607406315","v_md5":"2E9135262B2729B23B049EBBE80E5183","v_pstatus":"20","v_pstring":null,"v_md5str":"2E9135262B2729B23B049EBBE80E5183","v_md5money":"9330e642e14622f4993ce5a6e9781bbd","v_moneytype":"CNY","v_oid":"110610002420","v_amount":"0.01"}
//把中文进行转码
$arrResponse["v_pmode"] = mb_convert_encoding($arrResponse["v_pmode"], "UTF-8", "GBK");
$arrResponse["v_pstring"] = mb_convert_encoding($arrResponse["v_pstring"], "UTF-8", "GBK");
//定义结果返回变量
$rsp = new Rspparams();
if(!$this->checkResponse($arrResponse)){
//验证不成功
$rsp->payResult = 400;
}
else{
$rsp->bankName = $arrResponse["v_pmode"];
$rsp->orderCode = $arrResponse["v_oid"];
$rsp->payResult = $this->convertResult($arrResponse["v_pstatus"]);
$rsp->payTime = time();
$rsp->totalFee = $arrResponse["v_amount"];
$rsp->resultMsg = $arrResponse["v_pstring"];
//添加支付订单号和交易号
$rsp->payOrderCode = $arrResponse["v_oid"];
$rsp->tradeNo = "";
$rsp->bankBillNo = "";
}
return $rsp;
}
/**
* (non-PHPdoc)
* @see QPay_Utils_Abstract::convertResult()
* @param $resultCode
* @return int|void
*/
protected function convertResult($resultCode)
{
if($resultCode == 20) //20为支付成功,30为支付失败
{
return 200;
}
return $resultCode;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
* @param array $arrResponse
* @return bool|void
*/
protected function checkResponse(array $arrResponse)
{
$signText = $arrResponse["v_oid"]. $arrResponse['v_pstatus'] . $arrResponse['v_amount']
. $arrResponse['v_moneytype'] . $this->config->sp_key;
if(strtoupper(md5($signText)) == $arrResponse['v_md5str']){
return true;
}
return false;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Cmb;
/**
* 招商银行支付接口配置,使用招商银行的支付方式2,可以返回结果,但无需带上参数
* Enter description here ...
* @author smile
*
*/
class Config
{
/**
* 支付地址(方式3)
* Enter description here ...
* @var String
*/
var $payUrl = "https://netpay.cmbchina.com/netpayment/BaseHttp.dll?PrePayC1";
/**
* 商户的回调地址
* Enter description here ...
* @var String
*/
var $merchantUrl = "http://yohoerp.yoho.cn:10000/pay/notice/cmb";
/**
* 商户ID
* Enter description here ...
* @var unknown_type
*/
var $merchantAcctId = "";
/**
* 分行号
* Enter description here ...
* @var String
*/
var $branchID = "";
/**
* 商户Key
* Enter description here ...
* @var unknown_type
*/
var $sp_key = "";
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Cmb;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
class Service extends PayAbstract
{
var $config ;
function __construct(array $paymentParams)
{
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->merchantAcctId = $myConfig->merchant_id;
$this->config->sp_key = $myConfig->merchant_key;
$this->config->branchID = $myConfig->merchant_other_code;
}
public function getPayRequestPars(Reqparams $params)
{
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Ips;
class Config
{
/**
* 支付地址
* Enter description here ...
* @var String
*/
var $payUrl = "https://pay.ips.com.cn/ipayment.aspx";
/**
* 测试支付的url
* Enter description here ...
* @var String
*/
var $payUrlTest = "http://pay.ips.net.cn/ipayment.aspx";
/**
* 商户编号
* Enter description here ...
* @var unknown_type
*/
var $merCode = "";
/**
* 币种
* Enter description here ...
* @var unknown_type
*/
var $currencyType = "RMB";
/**
*
* Enter description here ...
* @var unknown_type
*/
var $gatewayType = "";
/**
* 语言
* Enter description here ...
* @var unknown_type
*/
var $lang = "GB";
/**
* 支付返回结果的地址
* Enter description here ...
* @var String
*/
var $merchantUrl = "notice/ips";
/**
* 订单支付接口加密方式,0为无需加密,2为MD5加密
* Enter description here ...
* @var Integer
*/
var $orderEncodeType = "2";
/**
* 交易返回接口的加密方式,12为md5
* Enter description here ...
* @var unknown_type
*/
var $retEncodeType = "12";
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Ips;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
class Service extends PayAbstract
{
var $config;
function __construct(array $paymentParams)
{
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->merchantAcctId = $myConfig->merchant_id;
$this->config->sp_key = $myConfig->merchant_key;
}
public function getPayRequestPars(Reqparams $params)
{
}
public function parseResponse(array $arrResponse)
{
}
/**
* 验证回复的正确性
*/
protected function checkResponse(array $arrResponse)
{
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Kqshenzhou;
class Config
{
/**
* 支付请求的地址
* Enter description here ...
* @var string
*/
var $pay_url = "https://www.99bill.com/szxgateway/recvMerchantInfoAction.htm";
/**
* 编码,1为utf8
* Enter description here ...
* @var unknown_type
*/
var $inputCharset = 1;
/**
* 回调地址
* Enter description here ...
* @var unknown_type
*/
var $bgUrl = "http://yohoerp.yoho.cn:10000/pay/notice/kqshenzhou";
/**
* 接受支付结果的页面地址.与[bgUrl]不能同时为空。必须是绝对地址。
* Enter description here ...
* @var String
*/
var $pageUrl="";
/**
* 版本
* Enter description here ...
* @var unknown_type
*/
var $version = "v2.0";
/**
* 语言种类 1为中文
* Enter description here ...
* @var unknown_type
*/
var $language = 1;
/**
* 签名类型,1为md5
* Enter description here ...
* @var unknown_type
*/
var $signType = 1;
/**
* 商户ID
* Enter description here ...
* @var unknown_type
*/
var $merchantAcctId = "";
/**
* 商户Key
* Enter description here ...
* @var unknown_type
*/
var $sp_key = "";
/**
* 00 代表显示快钱各支付方式列表;10 代表只显示银
* 行卡支付方式;11 代表只显示电话银行支付方式;12
* 代表只显示快钱账户支付方式; 代表只显示线下支付
* Enter description here ...
* @var unknown_type
*/
var $payType = "00";
/**
* 是否可以重复提交的标记 代表同一订单号只允许提交 1 次;0 表示同一订单 1号在没有支付成功的前提下可重复提交多次
* Enter description here ...
* @var unknown_type
*/
var $redoFlag = 0;
/**全额支付标志
*只能选择数字 0 或 1
*0代表非全额支付方式,支付完成后返回订单金额为商户提交的订单金额。如果预付费卡面额小于订单金额时,返回支付结果为失败;预付费卡面额大于或等于订单金额时,返回支付结果为成功;
*1 代表全额支付方式,支付完成后返回订单金额为用户预付费卡的面额。只要预付费卡销卡成功,返回支上海快钱信息服务有限公司 版权所有 第 6 页付结果都为成功。
*/
var $fullAmountFlag="0";
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Kqshenzhou;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
use WebPlugin\Pay\Rspparams;
class Service extends PayAbstract
{
var $config;
function __construct(array $paymentParams)
{
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->merchantAcctId = $myConfig->merchant_id;
$this->config->sp_key = $myConfig->merchant_key;
}
public function getPayRequestPars(Reqparams $params)
{
$signMsgVal = '';
$signMsgVal=$this->appendParam($signMsgVal,"inputCharset",$this->config->inputCharset);
$signMsgVal=$this->appendParam($signMsgVal,"bgUrl", $this->baseNoticeUrl . $this->config->bgUrl);
$signMsgVal=$this->appendParam($signMsgVal,"pageUrl",$this->config->pageUrl);
$signMsgVal=$this->appendParam($signMsgVal,"version",$this->config->version);
$signMsgVal=$this->appendParam($signMsgVal,"language",$this->config->language);
$signMsgVal=$this->appendParam($signMsgVal,"signType",$this->config->signType);
$signMsgVal=$this->appendParam($signMsgVal,"merchantAcctId",$this->config->merchantAcctId);
$signMsgVal=$this->appendParam($signMsgVal,"payerName","");
$signMsgVal=$this->appendParam($signMsgVal,"payerContactType","");
$signMsgVal=$this->appendParam($signMsgVal,"payerContact","");
$signMsgVal=$this->appendParam($signMsgVal,"orderId",$params->orderCode);
$signMsgVal=$this->appendParam($signMsgVal,"orderAmount",$params->totalFee);
$signMsgVal=$this->appendParam($signMsgVal,"payType",$this->config->payType);
$signMsgVal=$this->appendParam($signMsgVal,"fullAmountFlag",$this->config->fullAmountFlag);
$signMsgVal=$this->appendParam($signMsgVal,"orderTime", date("YmdHis"));
$signMsgVal=$this->appendParam($signMsgVal,"productName",urlencode($params->goodsName));
$signMsgVal=$this->appendParam($signMsgVal,"productNum","");
$signMsgVal=$this->appendParam($signMsgVal,"productId","");
$signMsgVal=$this->appendParam($signMsgVal,"productDesc",urlencode(""));
$signMsgVal=$this->appendParam($signMsgVal,"ext1","");
$signMsgVal=$this->appendParam($signMsgVal,"ext2","");
$signMsgVal=$this->appendParam($signMsgVal,"key",$this->config->sp_key);
$signMsg= strtoupper(md5($signMsgVal));
$result = array(
'pay_url' => $this->config->pay_url,
'pars' => $signMsgVal . "&signMsg=" . $signMsg,
'reqType' => 'get'
);
return $result;
}
public function parseResponse(array $arrResponse)
{
$rsp = new Rspparams();
if(!$this->checkResponse($arrResponse))
{
//验证不成功
$rsp->payResult = -1;
}
else
{
$rsp->bankName = $this->getPaytypeName($arrResponse["payType"]) ;
$rsp->bargainorId = $arrResponse["merchantAcctId"];
$rsp->orderId = $arrResponse["orderId"];
$rsp->payResult = $this->convertResult($arrResponse["payResult"]);
$rsp->payTime = $arrResponse["billOrderTime"];
$rsp->totalFee = $arrResponse["payAmount"];
}
return $rsp;
}
/**
* 获取支付方式名称
* @return string
*/
private function getPaytypeName()
{
$res = "";
switch($res)
{
case "00":
return "神州行卡密支付和快钱账户支付";
case "41":
return "快钱账户支付";
case "42":
return "神州行卡密支付和快钱账户支付";
case "52":
return "神州行卡密支付";
}
}
/**
* @param $resultCode
* @return int|void
*/
protected function convertResult($resultCode)
{
return $resultCode == "10" ? 0 : 1;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
*/
protected function checkResponse(array $arrResponse)
{
$merchantSignMsgVal = '';
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"merchantAcctId",$arrResponse["merchantAcctId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"version", $arrResponse["version"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"language", $arrResponse["language"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"payType", $arrResponse["payType"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"cardNumber", $arrResponse["cardNumber"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"cardPwd", $arrResponse["cardPwd"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"orderId", $arrResponse["orderId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"orderAmount", $arrResponse["orderAmount"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"dealId", $arrResponse["dealId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"orderTime", $arrResponse["orderTime"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"ext1", $arrResponse["ext1"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"ext2", $arrResponse["ext2"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"payAmount", $arrResponse["payAmount"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"billOrderTime", $arrResponse["billOrderTime"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"payResult", $arrResponse["payResult"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"signType", $arrResponse["signType"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"key", $this->config->sp_key);
if( strtoupper(md5($merchantSignMsgVal)) == $arrResponse["signMsg"] )
{
return true;
}
return false;
}
private function appendParam($returnStr, $paramId, $paramValue) {
if ($returnStr != "") {
if ($paramValue != "") {
$returnStr .= "&" . $paramId . "=" . $paramValue;
}
} else {
If ($paramValue != "") {
$returnStr = $paramId . "=" . $paramValue;
}
}
return $returnStr;
}
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Kuaiqian;
class Config
{
/**
* 支付请求的地址
* Enter description here ...
* @var string
*/
var $pay_url = "https://www.99bill.com/gateway/recvMerchantInfoAction.htm";
/**
* 编码,1为utf8
* Enter description here ...
* @var unknown_type
*/
var $inputCharset = 1;
/**
* 回调地址
* Enter description here ...
* @var unknown_type
*/
var $bgUrl = "notice/kuaiqian";
/**
* 版本
* Enter description here ...
* @var unknown_type
*/
var $version = "v2.0";
/**
* 语言种类 1为中文
* Enter description here ...
* @var unknown_type
*/
var $language = 1;
/**
* 签名类型,1为md5
* Enter description here ...
* @var unknown_type
*/
var $signType = 1;
/**
* 商户ID
* Enter description here ...
* @var unknown_type
*/
var $merchantAcctId = "";
/**
* 商户Key
* Enter description here ...
* @var unknown_type
*/
var $sp_key = "";
/**
* 00 代表显示快钱各支付方式列表;10 代表只显示银
* 行卡支付方式;11 代表只显示电话银行支付方式;12
* 代表只显示快钱账户支付方式; 代表只显示线下支付
* Enter description here ...
* @var unknown_type
*/
var $payType = "00";
/**
* 是否可以重复提交的标记 代表同一订单号只允许提交 1 次;0 表示同一订单 1号在没有支付成功的前提下可重复提交多次
* Enter description here ...
* @var unknown_type
*/
var $redoFlag = 0;
}
\ No newline at end of file
... ...
<?php
namespace WebPlugin\Pay\Kuaiqian;
use WebPlugin\Pay\PayAbstract;
use WebPlugin\Pay\Reqparams;
class Service extends PayAbstract
{
var $config ;
function __construct(array $paymentParams)
{
$this->config = new Config();
$myConfig = json_decode($paymentParams["pay_params"]) ;
$this->config->merchantAcctId = $myConfig->merchant_id;
$this->config->sp_key = $myConfig->merchant_key;
}
public function getPayRequestPars(Reqparams $params)
{
$signText = '';
//先添加不可为空的参数
$signText .= "inputCharset=" . $this->config-> inputCharset;
$signText .= "&bgUrl=" . $this->baseNoticeUrl . $this->config->bgUrl;
$signText .= "&version=" . $this->config->version;
$signText .= "&language=" . $this->config->language;
$signText .= "&signType=" . $this->config->signType;
$signText .= "&merchantAcctId=" . $this->config-> merchantAcctId;
$signText .= "&orderId=" . $params->orderCode;
$signText .= "&orderAmount=" . $params->totalFee;
$signText .= "&orderTime=" . date("YmdHis");
$signText .= "&payType=" . $this->config->payType;
$signMsg = strtoupper(md5($signText . "&key=" . $this->config->sp_key));
return array(
'pay_url' => $this->config->pay_url,
'pars' => $signText . "&signMsg=" . $signMsg,
'reqType' => 'get'
);
}
/**
* (non-PHPdoc)
* @see QPay_Utils_Abstract::parseResponse()
* @param array $arrResponse
* @return void|QCPay_Utils_Rspparams
*/
public function parseResponse(array $arrResponse)
{
$rsp = new QCPay_Utils_Rspparams();
if(!$this->checkResponse($arrResponse))
{
//验证不成功
$rsp->payResult = -1;
}
else
{
$rsp->bankName = $arrResponse["bankId"];
$rsp->orderCode = $arrResponse["orderId"];
$rsp->payResult = $this->convertResult($arrResponse["payResult"]);
$rsp->payTime = $this->convertTime($arrResponse["orderTime"]);
$rsp->totalFee = $arrResponse["orderAmount"];
$rsp->resultMsg = "";
//添加支付订单号和交易号
$rsp->payOrderCode = $arrResponse["orderId"];
$rsp->tradeNo = "";
$rsp->bankBillNo = "";
}
return $rsp;
}
/**
* 转化时间
* Enter description here ...
* @param string $payTime
* @return int
*/
private function convertTime($payTime)
{
$strTime = substr($payTime, 0, 4) . '-' . substr($payTime, 4, 2) . '-' . substr($payTime, 6, 2) . ' ' .
substr($payTime, 8, 2) . ':' . substr($payTime, 10, 2) . ':' . substr($payTime, 12, 2);
return strtotime($strTime);
}
/**
* 转换结果
* Enter description here ...
* @param string $resultCode
* @return int|void
*/
protected function convertResult($resultCode)
{
if($resultCode == '10')
{
return 200;
}
return 400;
}
/**
* 验证回复的正确性
* @see QPay_Utils_Abstract::verifResponse()
*/
protected function checkResponse(array $arrResponse)
{
$merchantSignMsgVal = '';
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"merchantAcctId",$arrResponse["merchantAcctId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"version",$arrResponse["version"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"language",$arrResponse["language"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"signType",$arrResponse["signType"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"payType",$arrResponse["payType"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"bankId",$arrResponse["bankId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"orderId",$arrResponse["orderId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"orderTime",$arrResponse["orderTime"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"orderAmount",$arrResponse["orderAmount"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"dealId",$arrResponse["dealId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"bankDealId",$arrResponse["bankDealId"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"dealTime",$arrResponse["dealTime"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"payAmount",$arrResponse["payAmount"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"fee",$arrResponse["fee"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"ext1",$arrResponse["ext1"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"ext2",$arrResponse["ext2"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"payResult",$arrResponse["payResult"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"errCode",$arrResponse["errCode"]);
$merchantSignMsgVal=$this->appendParam($merchantSignMsgVal,"key",$this->config->sp_key);
return strtoupper(md5($merchantSignMsgVal)) == $arrResponse["signMsg"] ? true :false;
}
private function appendParam($returnStr, $paramId, $paramValue) {
if ($returnStr != "") {
if ($paramValue != "") {
$returnStr .= "&" . $paramId . "=" . $paramValue;
}
} else {
If ($paramValue != "") {
$returnStr = $paramId . "=" . $paramValue;
}
}
return $returnStr;
}
}
\ No newline at end of file
... ...
<?php
require_once('lib/chinabank_utf8.MotoClient.php');
class QCPay_Utils_Motopay_Service
{
//var $motoClient;
function __construct()
{
//$myConfig = json_decode($paymentParams["pay_params"]) ;
// /$this->motoClient = new MotoClient ();
//$this->motoClient->setMerchantTerminalAndKey($myConfig->merchant_id, $myConfig->other_code, $myConfig->merchant_key);
}
function consumeF()
{$motoClient = new MotoClient();
// $motoClient->setMerchantTerminalAndKey('20003518', '8', 'test');
$result = $motoClient->consume("", $_POST['cardid'], $_POST['month'].$_POST['year'], $_POST['money'], array('name'=>$_POST['name'], 'idcard'=>$_POST['idcard'], 'cvv2'=>$_POST['cvv'], 'mobile'=>'139', 'note'=>'nothing'));
echo "oid: {$result[$motoClient->MOTO_KEY_OID]},<br/> authcode: {$result[$motoClient->MOTO_KEY_AUTHID]},<br/>";
echo "result: {$result[result]}<br/>";
echo "bankname: {$result[$motoClient->MOTO_KEY_BANKNAME]},<br/>";
echo "cardname: {$result[$motoClient->MOTO_KEY_CARDNAME]},<br/>";
echo 'error msg: '.iconv('UTF-8', 'GBK', $result[$motoClient->MOTO_KEY_ERROR_CN]).',<br/>';
echo "The end <br/>";
$str_utf = $result[$motoClient->MOTO_KEY_ERROR_CN];
$str_gbk = iconv('UTF-8', 'GBK', $str_utf);
echo "utf8: '$str_utf'<br/>";
echo "gbk: '$str_gbk'<br/>";
echo '00: '.($str_utf == $str_utf).'<br/>';
echo '01: '.($str_utf != $str_gbk).'<br/>';
echo 'md5($str_utf): "'.md5($str_utf).'"<br/>';
echo 'md5($str_gbk): "'.md5($str_gbk).'"<br/>';
echo '02: '.( md5($str_utf) != md5($str_gbk) ).'<br/>';
}
}
\ No newline at end of file
... ...
<?php
/*
+----------------------------------------------------------------------+
| Sofee Framework For PHP4 |
+----------------------------------------------------------------------+
| Copyright (c) 2004-2005 The Sofee Development Team |
+----------------------------------------------------------------------+
| This source file is subject to the GNU Lesser Public License (LGPL), |
| that is bundled with this package in the file LICENSE, and is |
| available at through the world-wide-web at |
| http://www.fsf.org/copyleft/lesser.html |
| If you did not receive a copy of the LGPL and are unable to |
| obtain it through the world-wide-web, you can get it by writing the |
| Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, |
| MA 02111-1307, USA. |
+----------------------------------------------------------------------+
| Author: Justin Wu <ezdevelop@gmail.com> |
+----------------------------------------------------------------------+
*/
/* $Id: SofeeXmlParser.php,v 1.3 2005/05/30 06:30:14 wenlong Exp $ */
/**
* Sofee XML Parser class - This is an XML parser based on PHP's "xml" extension.
*
* The SofeeXmlParser class provides a very simple and easily usable toolset to convert XML
* to an array that can be processed with array iterators.
*
* @package SofeeFramework
* @access public
* @version $Revision: 1.1 $
* @author Justin Wu <wenlong@php.net>
* @homepage http://www.sofee.cn
* @copyright Copyright (c) 2004-2005 Sofee Development Team.(http://www.sofee.cn)
* @since 2005-05-30
* @see PEAR:XML_Parser | SimpleXML extension
*/
class SofeeXmlParser {
/**
* XML parser handle
*
* @var resource
* @see xml_parser_create()
*/
var $parser;
/**
* source encoding
*
* @var string
*/
var $srcenc;
/**
* target encoding
*
* @var string
*/
var $dstenc;
/**
* the original struct
*
* @access private
* @var array1
*/
var $_struct = array();
/**
* Constructor
*
* @access public
* @param mixed [$srcenc] source encoding
* @param mixed [$dstenc] target encoding
* @return void
* @since
*/
function SofeeXmlParser($srcenc = null, $dstenc = null) {
$this->srcenc = $srcenc;
$this->dstenc = $dstenc;
// initialize the variable.
$this->parser = null;
$this->_struct = array();
}
/**
* Free the resources
*
* @access public
* @return void
**/
function free() {
if (isset($this->parser) && is_resource($this->parser)) {
xml_parser_free($this->parser);
unset($this->parser);
}
}
/**
* Parses the XML file
*
* @access public
* @param string [$file] the XML file name
* @return void
* @since
*/
function parseFile($file) {
$data = @file_get_contents($file) or die("Can't open file $file for reading!");
$this->parseString($data);
}
/**
* Parses a string.
*
* @access public
* @param string [$data] XML data
* @return void
*/
function parseString($data) {
if ($this->srcenc === null) {
$this->parser = @xml_parser_create() or die('Unable to create XML parser resource.');
} else {
$this->parser = @xml_parser_create($this->srcenc) or die('Unable to create XML parser resource with '. $this->srcenc .' encoding.');
}
if ($this->dstenc !== null) {
@xml_parser_set_option($this->parser, XML_OPTION_TARGET_ENCODING, $this->dstenc) or die('Invalid target encoding');
}
xml_parser_set_option($this->parser, XML_OPTION_CASE_FOLDING, 0); // lowercase tags
xml_parser_set_option($this->parser, XML_OPTION_SKIP_WHITE, 1); // skip empty tags
if (!xml_parse_into_struct($this->parser, $data, &$this->_struct)) {
printf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($this->parser)),
xml_get_current_line_number($this->parser)
);
$this->free();
exit();
}
$this->_count = count($this->_struct);
$this->free();
}
/**
* return the data struction
*
* @access public
* @return array
*/
function getTree() {
$i = 0;
$tree = array();
$tree = $this->addNode(
$tree,
$this->_struct[$i]['tag'],
(isset($this->_struct[$i]['value'])) ? $this->_struct[$i]['value'] : '',
(isset($this->_struct[$i]['attributes'])) ? $this->_struct[$i]['attributes'] : '',
$this->getChild($i)
);
unset($this->_struct);
return ($tree);
}
/**
* recursion the children node data
*
* @access public
* @param integer [$i] the last struct index
* @return array
*/
function getChild(&$i) {
// contain node data
$children = array();
// loop
while (++$i < $this->_count) {
// node tag name
$tagname = $this->_struct[$i]['tag'];
$value = isset($this->_struct[$i]['value']) ? $this->_struct[$i]['value'] : '';
$attributes = isset($this->_struct[$i]['attributes']) ? $this->_struct[$i]['attributes'] : '';
switch ($this->_struct[$i]['type']) {
case 'open':
// node has more children
$child = $this->getChild($i);
// append the children data to the current node
$children = $this->addNode($children, $tagname, $value, $attributes, $child);
break;
case 'complete':
// at end of current branch
$children = $this->addNode($children, $tagname, $value, $attributes);
break;
case 'cdata':
// node has CDATA after one of it's children
$children['value'] .= $value;
break;
case 'close':
// end of node, return collected data
return $children;
break;
}
}
//return $children;
}
/**
* Appends some values to an array
*
* @access public
* @param array [$target]
* @param string [$key]
* @param string [$value]
* @param array [$attributes]
* @param array [$child] the children
* @return void
* @since
*/
function addNode($target, $key, $value = '', $attributes = '', $child = '') {
if (!isset($target[$key]['value']) && !isset($target[$key][0])) {
if ($child != '') {
$target[$key] = $child;
}
if ($attributes != '') {
foreach ($attributes as $k => $v) {
$target[$key][$k] = $v;
}
}
$target[$key]['value'] = $value;
} else {
if (!isset($target[$key][0])) {
// is string or other
$oldvalue = $target[$key];
$target[$key] = array();
$target[$key][0] = $oldvalue;
$index = 1;
} else {
// is array
$index = count($target[$key]);
}
if ($child != '') {
$target[$key][$index] = $child;
}
if ($attributes != '') {
foreach ($attributes as $k => $v) {
$target[$key][$index][$k] = $v;
}
}
$target[$key][$index]['value'] = $value;
}
return $target;
}
}
?>
\ No newline at end of file
... ...
<?php
class CreateXML {
/**
* 编码
* @access private
* @var array1
*/
//var $encoding;
/**
* @access private
* @var array1
*/
var $_tree;
var $encoding="UTF-8";
/**
* Constructor
*/
function CBCreateXML($encoding = 'UTF-8') {
$this->encoding = $encoding;
$this->_tree = array();
}
/**
* 建立根节点
*/
function createRoot($sname, $sversion) {
$tree = array();
$tree['tag'] = 'cb-xdoc';
$tree['attrs'] = array(
'sname' => $sname,
'sversion' => $sversion
);
/*
$tree['att.sname'] = $sname;
$tree['att.sversion'] = $sversion;
*/
$this->_tree = $tree;
}
/**
* 建立普通节点
*/
function addNode($name, $type, $val) {
$node = array();
$node['tag'] = 'node';
$node['attrs'] = array(
'name' => $name,
'type' => $type
);
switch ($type) {
case 'list':
case 'map':
$node['node'] = array();
foreach($val as $k=>$v) {
$node['node'][] = $this->_recursionGetNode($k, $v);
}
break;
default:
$node['val'] = $val;
}
/*
$node['att.name'] = $name;
$node['att.type'] = $type;
if ($type = 'money') {
$node['att.currency'] = 'CNY';
}
$node['val'] = $val;
*/
$this->_tree['node'][] = $node;
}
function _recursionGetNode($name, $val) {
$node = array();
$node['tag'] = 'node';
$node['attrs'] = array('name' => $name);
$type = gettype($val);
switch ($type) {
case "array":
$node['attrs']['type'] = 'map';
foreach($val as $k=>$v) {
$node['node'][] = $this->_recursionGetNode($k, $v);
}
break;
case "integer":
$node['attrs']['type'] = 'int';
$node['val'] = $val;
break;
default:
$node['attrs']['type'] = 'string';
$node['val'] = $val;
}
return $node;
}
function getTree() {
return $this->_tree;
}
function getString() {
$tree = $this->_tree;
$strxml = "<?xml version=\"1.0\" encoding=\"{$this->encoding}\"?>\n";
$strxml .= "<{$tree['tag']} sname=\"{$tree['attrs']['sname']}\" sversion=\"{$tree['attrs']['sversion']}\">\n";
foreach ($tree['node'] as $node) {
$strxml .= $this->_2str($node);
}
$strxml .= "</{$tree['tag']}>\n";
return $strxml;
}
function _2str($node, $sp=" ") {
$tag = $node['tag'];
$name = $node['attrs']['name'];
$type = $node['attrs']['type'];
$val = $node['val'];
// 开始 <node>
if ($type == 'money') {
$str = "$sp<$tag name=\"$name\" type=\"$type\" currency=\"{$node['att.currency']}\">\n";
} else {
$str = "$sp<$tag name=\"$name\" type=\"$type\">\n";
}
/**
if ($type == 'string') {
$str .= '<![CDATA[' . $val . ']]>';
} else {
$str .= $val;
}*/
// 值
switch($type) {
case 'NULL':
return '';
case 'string':
$str .= "$sp <![CDATA[$val]]>\n";
break;
case 'list':
case 'map':
if (array_key_exists('node', $node)) {
foreach ($node['node'] as $n) {
$str .= $this->_2str($n, $sp." ");
}
}
break;
default:
$str .= "$sp $val\n";
}
// 关闭 </node>
$str .= "$sp</$tag>\n";
return $str;
}
}
?>
\ No newline at end of file
... ...
<?php
/**
* 网银在线 MOTO客户端接口
* 版本: 2.5(php)
* 开发者:ch.tommy@gmail.com
*/
require_once('nusoap.php');
require_once('chinabank_utf8.CreateXML.php');
require_once('chinabank_utf8.XmlParser.php');
class MOTOConstant {
// 固定参数
var $encoding ="UTF-8"; //编码格式
var $soap_method= 'invoke02'; //方法名称
var $version = '3.0(PHP)'; //版本
var $type = 'md5'; //加密类型
// 可配参数
#var $soap_url = 'http://motopay5.chinabank.com.cn/webservice/motoPHP'; //正式通讯地址
var $soap_url ="http://motopaytest.chinabank.com.cn/webservice/motoPHP"; //测试通讯地址
var $merchantid = '901'; //商户号
var $terminalid = '90101'; //终端号
var $md5key = 'test'; //传输密钥
/**
* 以下是常量定义
*/
// 错误代码
var $MOTO_RET_SUCCESS = "0"; // 交易成功
var $MOTO_RET_SUCCESS_ING = "1"; // 交易处理中
var $MOTO_RET_FAILURE = "E12041000"; // 交易失败
var $MOTO_RET_ERROR = "E12041001"; // 内部错误
var $MOTO_RET_NET = "E12041002"; // 通讯错误
var $MOTO_RET_DB = "E12041003"; // 数据库错误
var $MOTO_RET_AUTH = "E12041004"; // 安全验证失败
var $MOTO_RET_OID = "E12041005"; // 交易号格式错误
var $MOTO_RET_CARD = "E12041006"; // 信用卡格式错误
var $MOTO_RET_CARDEXP = "E12041007"; // 信用卡有效期格式错误
var $MOTO_RET_AMOUNT = "E12041008"; // 交易金额格式错误
var $MOTO_RET_NAME = "E12041009"; // 持卡人姓名格式错误
var $MOTO_RET_IDCARD = "E12041010"; // 持卡人证件格式错误
var $MOTO_RET_MOBILE = "E12041011"; // 持卡人电话格式错误
var $MOTO_RET_NOTE = "E12041012"; // 备注格式错误
var $MOTO_RET_MERCHANT = "E12041013"; // 商户号错误
var $MOTO_RET_TERMINAL = "E12041014"; // 终端号错误
var $MOTO_RET_MERCHANTEX = "E12041015"; // 商户信息不完整
var $MOTO_RET_PURVIEW_XF = "E12041016"; // 终端没有消费权限
var $MOTO_RET_PURVIEW_XFCX = "E12041017"; // 终端没有撤销消费权限
var $MOTO_RET_PURVIEW_SQ = "E12041018"; // 终端没有预授权权限
var $MOTO_RET_PURVIEW_SQCX = "E12041019"; // 终端没有撤销预授权权限
var $MOTO_RET_PURVIEW_QR = "E12041020"; // 终端没有预授权确认权限
var $MOTO_RET_PURVIEW_QRCX = "E12041021"; // 终端没有撤销预授权确认权限
var $MOTO_RET_PURVIEW_TK = "E12041022"; // 终端没有退款权限
var $MOTO_RET_SING_LIMIT = "E12041023"; // 超出单笔交易限额
var $MOTO_RET_MOTO_CARD = "E12041024"; // MOTO不支持此信用卡
var $MOTO_RET_MERCHANT_CARD = "E12041025"; // 商户不支持此信用卡
var $MOTO_RET_DAY_NUM = "E12041026"; // 信用卡日交易次数限制
var $MOTO_RET_DAY_DATE = "E12041027"; // 信用卡日交易有效期错误次数限制
var $MOTO_RET_DAY_AMOUNT = "E12041028"; // 信用卡日交易金额上限错误次数限制
var $MOTO_RET_DAY_LIMIT = "E12041029"; // 超出日交易限额
var $MOTO_RET_ORDERID = "E12041030"; // 商户交易号重复
var $MOTO_RET_OORDER = "E12041031"; // 原交易不存在
var $MOTO_RET_OCARD = "E12041032"; // 信用卡原交易不符
var $MOTO_RET_OAMOUNT = "E12041033"; // 金额原交易不符
var $MOTO_RET_OSTATE = "E12041034"; // 原交易不允许此操作
var $MOTO_RET_OOORDER = "E12041035"; // 原原交易不存在
var $MOTO_RET_FLOAT = "E12041036"; // 超出预授权金额浮动范围
var $MOTO_RET_REFUND = "E12041037"; // 退款金额不正确
var $MOTO_RET_ORDER = "E12041038"; // 查询无此交易
var $MOTO_RET_PURVIEW = "E12041039"; // 无此交易查询权限
var $MOTO_RET_XML = "E12041040"; // 消费成功 / 状态失败
var $MOTO_RET_TERMINAL_TYPE = "E12041041"; // 终端接入方式错误
var $MOTO_RET_BANK = "E12041042"; // 此卡不允许做此交易
var $MOTO_RET_MAIL = "E12041043"; // 持卡人邮件格式不正确
var $MOTO_RET_VERSION = "E12041044"; // 客户端版本号不正确
var $MOTO_RET_CVV2 = "E12041045"; // CVV2不允许为空 或者cvv2错
var $MOTO_RET_WS_IP = "E12041046"; // IP校检失败
var $MOTO_RET_BLACKCARD = "E12041047"; // 此卡为风险卡
var $MOTO_CLIENT_AUTH = "E12042004"; // php客户端安全验证错误
// 关键字
var $MOTO_KEY_ENCODE = "encode"; // 密文
var $MOTO_KEY_SIGN = "sign"; // 签名
var $MOTO_KEY_CLIENT = "client"; // 客户端
var $MOTO_KEY_TYPE = "type"; // 交易类型
var $MOTO_KEY_OID = "oid"; // 交易号
var $MOTO_KEY_OOID = "ooid"; // 原交易号
var $MOTO_KEY_CARD = "card"; // 信用卡号
var $MOTO_KEY_CARDEXP = "cardexp"; // 信用卡有效期
var $MOTO_KEY_AMOUNT = "amount"; // 金额
var $MOTO_KEY_EXTEND = "extend"; // 附加参数
var $MOTO_KEY_TIME = "time"; // 远程时间
var $MOTO_KEY_MERCHANT = "merchant"; // 商户号
var $MOTO_KEY_TERMINAL = "terminal"; // 终端号
var $name = "authid"; // 银行授权号
var $MOTO_KEY_BANKNAME = "bankname"; // 银行名称
var $MOTO_KEY_CARDNAME = "cardname"; // 信用卡名称
var $MOTO_KEY_ERROR = "error"; // 错误信息
var $MOTO_KEY_ERROR_CN = "_error"; // 错误信息解释
// 附加参数关键字
var $MOTO_KEY_EXTEND_NAME = "name"; // 持卡人姓名
var $MOTO_KEY_EXTEND_IDCARD = "idcard"; // 持卡人证件号
var $MOTO_KEY_EXTEND_MOBILE = "mobile"; // 持卡人手机号
var $MOTO_KEY_EXTEND_MAIL = "mail"; // 持卡人E-Mail
var $MOTO_KEY_EXTEND_NOTE = "note"; // 备注
var $MOTO_KEY_EXTEND_CVV2 = "cvv2"; // cvv2
// 查询结果
var $MOTO_SEARCH_OID = "_oid"; // 交易号
var $MOTO_SEARCH_AID = "_aid"; // 授权号
var $MOTO_SEARCH_TYPE = "_type"; // 交易类型
var $MOTO_SEARCH_TYPECODE = "_typecode"; // 交易类型码
var $MOTO_SEARCH_CARD = "_card"; // 信用卡号
var $MOTO_SEARCH_AMOUNT = "_amount"; // 交易金额
var $MOTO_SEARCH_DATE = "_date"; // 交易日期
var $MOTO_SEARCH_STATE = "_state"; // 交易状态
var $MOTO_SEARCH_STATECODE = "_statecode"; // 交易状态码
var $MOTO_SEARCH_CODE = "_code"; // 交易结果
var $MOTO_SEARCH_BANKNAME = "_bankname"; // 银行名称
var $MOTO_SEARCH_CARDNAME = "_cardname"; // 信用卡名称
var $MOTO_SEARCH_SETTLE = "_settle"; // 结算标识
var $MOTO_SEARCH_RECEIVE = "_receive"; // 是否受理卡
var $MOTO_SEARCH_RECCARD = "_reccard"; // 商户受理卡
var $MOTO_SEARCH_RECCARDCB = "_reccardcb"; // 网银受理卡
// 远程调用服务名称
var $MOTO_REMOTE_CONSUME = "ConsumeService"; // 消费交易
var $MOTO_REMOTE_CONSUME_REVOKE = "ConsumeRevokeService"; // 撤销消费
var $MOTO_REMOTE_AUTHORIZE = "AuthorizeService"; // 预授权交易
var $MOTO_REMOTE_AUTHORIZE_REVOKE = "AuthorizeRevokeService"; // 撤销预授权交易
var $MOTO_REMOTE_CONFIRM = "ConfirmService"; // 确认交易
var $MOTO_REMOTE_CONFIRM_REVOKE = "ConfirmRevokeService"; // 撤销确认交易
var $MOTO_REMOTE_REFUND = "RefundService"; // 退款申请
var $MOTO_REMOTE_SEARCH = "SearchService"; // 交易查询
var $MOTO_REMOTE_REVERSE = "ReverseService"; // 冲正交易
var $MOTO_REMOTE_SEARCHCARD = "SearchCardService"; // 查询受理卡
}
class MotoClient extends MOTOConstant {
function CBInterface($encoding = 'UTF-8') {
$this->encoding=$encoding ; //初始化编码格式
}
/**
* 函数功能:设置商户号 终端号 和 传输密钥
* 说 明:当商户使用多个MOTO商户号时可使用此函数设置每次交易的商户号和传输密钥
*/
function setMerchantTerminalAndKey($merchantid, $terminalid, $md5key) {
$this->merchantid = $merchantid;
$this->terminalid = $terminalid;
$this->md5key = $md5key;
}
/**
* 函数功能:原创调用适配
*/
function remoteInvoke($service, $parameter) {
// 合成XML
$xdoc = new CreateXML($this->encoding);
$xdoc->createRoot($service, $this->version);
foreach($parameter as $key => $val) {
$xdoc->addNode($key, $val['type'], $val['value']);
}
// 加密 签名
$xstr = $xdoc->getString();
// echo "xstr: $xstr";
$req_sign = strtoupper(md5($xstr.$this->md5key));
$req_code = base64_encode ($xstr);
// 远程调用
//生成SOAP调用是的参数
$param = array(
'service' => $service, //服务名
'merchant' => $this->merchantid, //服务名
'encoding' => $this->encoding, //编码类型
'type' => $this->type, //加密类型(采用什么方式进行加密的)
'code' => $req_code, //经过BASE64编码的明文
'sign' => $req_sign //加密后的数据
);
// print_r($param);
//调用网银提供的soap方法
echo "<b>url: $this->soap_url </b></br>";
$soap_client = new soapclientw($this->soap_url, true);
$rs = $soap_client->call($this->soap_method, $param);
//判断是否连接主机成功,若失败则报错
if($soap_client->getError()){
echo $soap_client->getError() . '<br/>';
return array(
'sname' => $service,
'result' => $this->MOTO_RET_NET,
'error' => $this->MOTO_RET_NET,
'_error' => $soap_client->getError());
}
//echo "-----------------------------<br/>\n";
//print_a('rs', $rs);
// 处理返回值
$rtcode = $rs['string'][0];
$rtmsg = base64_decode( $rs['string'][1] );
//echo "code: $rtmsg<br\>\n";
if ( strtoupper(md5($rtmsg.$this->md5key)) == $rs['string'][2] ) {
echo "return sign OK! <br>\n";
// 解码
// $rtmsg = iconv('GBK', 'UTF-8', $rtmsg);
// $rtmsg = iconv('UTF-8', 'GBK', $rtmsg);
echo "<pre>\n $rtmsg \n<pre>";
return xml2array( $rtmsg );
// return xml2array($rtmsg);
} else {
echo "Chinabank Soap SIGN ERR! <br>\n";
return array(
'sname' => $service,
'result' => $this->MOTO_CLIENT_AUTH,
'error' => $this->MOTO_CLIENT_AUTH,
'_error' => 'SING ERR');
}
}
function consume2($orderid, $card, $cardexp, $amount, $extend) {
$service = 'ConsumeService';
$today = getdate();
$parameter = array();
$parameter['oid'] = array('type' => 'string', 'value' => ($orderid==null ? '' : $orderid) );
$parameter['card'] = array('type' => 'string', 'value' => $card);
$parameter['cardexp'] = array('type' => 'string', 'value' => $cardexp);
$parameter['amount'] = array('type' => 'int', 'value' => $amount);
$parameter['merchant'] = array('type' => 'string', 'value' => $this->merchantid);
$parameter['terminal'] = array('type' => 'string', 'value' => $this->terminalid);
$parameter['time'] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter['extend'] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function consume($orderid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_CONSUME;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function consumeRevoke($orderid, $oldid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_CONSUME_REVOKE;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_OOID] = array('type' => 'string', 'value' => ($oldid == null ? '' : $oldid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
// 预授权
function authorize($orderid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_AUTHORIZE;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function authorizeRevoke($orderid, $oldid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_AUTHORIZE_REVOKE;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_OOID] = array('type' => 'string', 'value' => ($oldid == null ? '' : $oldid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function authorizeCfm($orderid, $oldid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_CONFIRM;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_OOID] = array('type' => 'string', 'value' => ($oldid == null ? '' : $oldid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function authorizeCfmRevoke($orderid, $oldid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_CONFIRM_REVOKE;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_OOID] = array('type' => 'string', 'value' => ($oldid == null ? '' : $oldid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function refundment($orderid, $oldid, $card, $cardexp, $amount, $extend) {
$service = $this->MOTO_REMOTE_REFUND;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => ($orderid == null ? '' : $orderid) );
$parameter[$this->MOTO_KEY_OOID] = array('type' => 'string', 'value' => ($oldid == null ? '' : $oldid) );
$parameter[$this->MOTO_KEY_CARD] = array('type' => 'string', 'value' => $card);
$parameter[$this->MOTO_KEY_CARDEXP] = array('type' => 'string', 'value' => $cardexp);
$parameter[$this->MOTO_KEY_AMOUNT] = array('type' => 'int', 'value' => $amount);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_TIME] = array('type' => 'date', 'value' => date('Y-m-d H:i:s', $today[0]) );
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function search($orderid) {
$service = $this->MOTO_REMOTE_SEARCH;
$today = getdate();
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => $orderid);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
function reverse($orderid) {
$service = $this->MOTO_REMOTE_REVERSE;
$parameter = array();
$parameter[$this->MOTO_KEY_OID] = array('type' => 'string', 'value' => $orderid);
$parameter[$this->MOTO_KEY_MERCHANT] = array('type' => 'string', 'value' => $this->merchantid);
$parameter[$this->MOTO_KEY_TERMINAL] = array('type' => 'string', 'value' => $this->terminalid);
$parameter[$this->MOTO_KEY_EXTEND] = array('type' => 'map', 'value' => ($extend==null ? array() : $extend) );
return $this->remoteInvoke($service, $parameter);
}
}
class CBResult {
var $rtcode;
var $map;
function CBResult($rtcode) {
$this->rtcode = $rtcode;
$this->map = array();
}
function getRtcode() {
return $this->rtcode;
}
function setRtcode($rtcode) {
$this->rtcode = $rtcode;
}
function getValue($key) {
return $this->map[$key];
}
function setValue($key, $value) {
$this->map[$key] = $value;
}
function setMap($map) {
$this->map = $map;
}
function getMap() {
return $this->map;
}
}
?>
\ No newline at end of file
... ...
<?php
function print_a($name, $arr) {
echo "$name: ";
print_r($arr);
echo "<br/>\n";
}
class SaxElement {
var $parentNode;
var $tagName;
var $val;
var $attrs;
var $childs;
function SaxElement($tagName) {
$this->tagName = $tagName;
$this->attrs = array();
$this->childs = array();
}
function setParentNode(& $parentNode) {
$this->parentNode = & $parentNode;
}
function setValue($val) {
$this->val = $val;
}
function addAttr($key, $val) {
$this->attrs[$key] = $val;
}
function setAttrs($attrs) {
$this->attrs = $attrs;
}
function addChild(& $element) {
array_push($this->childs, &$element);
}
function getParent() {
return $this->parent;
}
function getChilds() {
return $this->childs;
}
function isRoot() {
return $this->parent == NULL;
}
/**
* 得到类XML的结构
*/
function getArray() {
$arr = array();
$arr['tag'] = $this->tagName;
$arr['attrs'] = $this->attrs;
if ($this->val != NULL) {
$arr['value'] = $this->val;
} elseif ( sizeof($this->childs) ) {
$arr['childs'] = array();
foreach($this->childs as $childElement) {
$arr['childs'][] = $childElement->getArray();
}
}
return $arr;
}
/**
* 得到简化的结构
*/
function getArray2() {
$rs = array();
$rs['sname'] = $this->attrs['sname'];
$rs['result'] = $this->attrs['result'];
foreach($this->childs as $child) {
$rt = $child->_getArray2();
$rs[ $rt['key'] ] = $rt['value'];
}
return $rs;
}
function _getArray2() {
$rt = array();
$name = $this->attrs['name'];
$type = $this->attrs['type'];
switch ($type) {
case 'list':
case 'map':
$var = array();
foreach($this->childs as $i => $child) {
$_rt = $child->_getArray2();
$k = $_rt['key'];
$k = ($k==null ? $i : $k);
$var[$k] = $_rt['value'];
}
break;
default:
$var = $this->val;
}
$rt['key'] = $name;
$rt['value'] = $var;
return $rt;
}
}
$rootDom;
$stack = array();
function startElement($parser, $name, $attrs) {
global $rootDom, $stack;
if ( sizeof($stack)==0 ) {
// 当栈为空时认为是XML的根节点
$rootDom = new SaxElement($name);
$rootDom->setAttrs($attrs);
array_push($stack, &$rootDom);
} else {
$element = new SaxElement($name);
$element->setAttrs($attrs);
$parent = &$stack[sizeof($stack)-1];
$element->setParentNode($parent);
$parent->addChild($element);
array_push($stack, &$element);
}
}
function endElement($parser, $name) {
global $stack;
array_pop($stack);
}
function characterData($parser, $data) {
if ( trim($data)!="" ) {
global $stack;
$element = &$stack[sizeof($stack)-1];
$element->setValue($data);
}
}
function xml2array($xml) {
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
xml_parser_set_option($xml_parser, XML_OPTION_CASE_FOLDING, 0);
xml_parser_set_option($xml_parser, XML_OPTION_SKIP_WHITE, 1);
if (!xml_parse($xml_parser, $xml)) {
die(sprintf("XML error: %s at line %d",
xml_error_string(xml_get_error_code($xml_parser)),
xml_get_current_line_number($xml_parser)));
}
xml_parser_free($xml_parser);
global $rootDom;
return $rootDom->getArray2();
}
/*
* 测试
$xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>
<root sname=\"ConsumeService\" result=\"0\">
<node name=\"time\" type=\"date\">2008-01-22</node>
<node name=\"merchantid\" type=\"string\">1001</node>
<node name=\"ch\" type=\"list\">
<node type=\"int\">22</node>
<node type=\"int\">33</node>
<node type=\"string\">44</node>
</node>
<node name=\"mapping\" type=\"map\">
<node name=\"aaa\" type=\"string\">22</node>
<node name=\"bbb\" type=\"int\">33</node>
<node name=\"ccc\" type=\"int\">44</node>
</node>
</root>";
$arr = xml2array($xml);
print_a('return', $arr);
$xml = "<?xml version=\"1.0\" encoding=\"GBK\"?>
<cb-xdoc sname=\"ConsumeService\" result=\"E12042000\"><node name=\"_error\" type=\"string\"><![CDATA[银行不允许此交易]]></node><node name=\"error\" type=\"string\"><![CDATA[E12042000]]></node></cb-xdoc>";
$arr = xml2array($xml);
print_a('return', $arr);
*/
?>
\ No newline at end of file
... ...