?? cappay.php
字號:
<?php
/**
* ECSHOP 首信易支付插件
* ============================================================================
* 版權(quán)所有 (C) 2005-2008 康盛創(chuàng)想(北京)科技有限公司,并保留所有權(quán)利。
* 網(wǎng)站地址: http://www.ecshop.com;http://www.comsenz.com
* ----------------------------------------------------------------------------
* 這不是一個自由軟件!您只能在不用于商業(yè)目的的前提下對程序代碼進(jìn)行修改和
* 使用;不允許對程序代碼以任何形式任何目的的再發(fā)布。
* ============================================================================
* $Author: testyang $
* $Id: cappay.php 14481 2008-04-18 11:23:01Z testyang $
*/
if (!defined('IN_ECS'))
{
die('Hacking attempt');
}
$payment_lang = ROOT_PATH . 'languages/' .$GLOBALS['_CFG']['lang']. '/payment/cappay.php';
if (file_exists($payment_lang))
{
global $_LANG;
include_once($payment_lang);
}
/**
* 模塊信息
*/
if (isset($set_modules) && $set_modules == TRUE)
{
$i = isset($modules) ? count($modules) : 0;
/* 代碼 */
$modules[$i]['code'] = basename(__FILE__, '.php');
/* 描述對應(yīng)的語言項 */
$modules[$i]['desc'] = 'cappay_desc';
/* 是否支持貨到付款 */
$modules[$i]['is_cod'] = '0';
/* 是否支持在線支付 */
$modules[$i]['is_online'] = '1';
/* 作者 */
$modules[$i]['author'] = 'ECSHOP TEAM';
/* 網(wǎng)址 */
$modules[$i]['website'] = 'http://www.beijing.com.cn';
/* 版本號 */
$modules[$i]['version'] = 'V4.3';
/* 配置信息 */
$modules[$i]['config'] = array(
array('name' => 'cappay_account', 'type' => 'text', 'value' => ''),
array('name' => 'cappay_key', 'type' => 'text', 'value' => ''),
array('name' => 'cappay_currency', 'type' => 'select', 'value' => 'USD')
);
return;
}
class cappay
{
/**
* 構(gòu)造函數(shù)
*
* @access public
* @param
*
* @return void
*/
function cappay()
{
}
function __construct()
{
$this->cappay();
}
/**
* 生成支付代碼
* @param array $order 訂單信息
* @param array $payment 支付方式信息
*/
function get_code($order, $payment)
{
$v_rcvname = trim($payment['cappay_account']);
$m_orderid = $order['log_id'];
$v_amount = $order['order_amount'];
$v_moneytype = trim($payment['cappay_currency']);;
$v_url = return_url(basename(__FILE__, '.php'));
$m_ocomment = '歡迎使用首信易支付';
$v_ymd = date('Ymd',time());
/*易支付平臺*/
$MD5Key = $payment['cappay_key']; //<--支付密鑰--> 注:此處密鑰必須與商家后臺里的密鑰一致
$v_oid = "$v_ymd-$v_rcvname-$m_orderid";
$sourcedata = $v_moneytype.$v_ymd.$v_amount.$v_rcvname.$v_oid.$v_rcvname.$v_url;
$result = $this->hmac_md5($MD5Key,$sourcedata);
$def_url = '<form method=post action="http://pay.beijing.com.cn/prs/user_payment.checkit" target="_blank">';
$def_url .= "<input type= 'hidden' name = 'v_mid' value= '".$v_rcvname."'>"; //商戶編號
$def_url .= "<input type= 'hidden' name = 'v_oid' value= '".$v_oid."'>"; //訂單編號
$def_url .= "<input type= 'hidden' name = 'v_rcvname' value= '".$v_rcvname."'>"; //收貨人姓名
$def_url .= "<input type= 'hidden' name = 'v_rcvaddr' value= '".$v_rcvname."'>"; //收貨人地址
$def_url .= "<input type= 'hidden' name = 'v_rcvtel' value= '".$v_rcvname."'>"; //收貨人電話
$def_url .= "<input type= 'hidden' name = 'v_rcvpost' value= '".$v_rcvname."'>"; //收貨人郵編
$def_url .= "<input type= 'hidden' name = 'v_amount' value= '".$v_amount."'>"; //訂單總金額
$def_url .= "<input type= 'hidden' name = 'v_ymd' value= '".$v_ymd."'>"; //訂單產(chǎn)生日期
$def_url .= "<input type= 'hidden' name = 'v_orderstatus' value ='0'>"; //配貨狀態(tài)
$def_url .= "<input type= 'hidden' name = 'v_ordername' value ='".$v_rcvname."'>"; //訂貨人姓名
$def_url .= "<input type= 'hidden' name = 'v_moneytype' value ='".$v_moneytype."'>"; //幣種,0為人民幣,1為美元
$def_url .= "<input type= 'hidden' name='v_url' value='".$v_url."'>"; //支付動作完成后返回到該url,支付結(jié)果以GET方式發(fā)送
$def_url .= "<input type='hidden' name='v_md5info' value=$result>"; //訂單數(shù)字指紋
$def_url .= "<input type='submit' value='" . $GLOBALS['_LANG']['cappay_button'] . "'>";
$def_url .= '</form>';
/*易支付會員通道
$def_url = "<form method=post action='http://pay.beijing.com.cn/customer/gb/pay_member.jsp' target='_blank'>";
$def_url .= "<input type='hidden' name='v_mid' value='".$v_rcvname."'>"; //商戶編號
$def_url .= "<input type='hidden' name='v_oid' value='".$v_oid."'>"; //訂單編號
$def_url .= "<input type='hidden' name='v_rcvname' value='".$v_rcvname."'>"; //收貨人姓名
$def_url .= "<input type='hidden' name='v_rcvaddr' value='".$v_rcvname."'>"; //收貨人地址
$def_url .= "<input type='hidden' name='v_rcvtel' value='".$v_rcvname."'>"; //收貨人電話
$def_url .= "<input type='hidden' name='v_rcvpost' value='".$v_rcvname."'>"; //收貨人郵編
$def_url .= "<input type='hidden' name='v_amount' value='".$v_amount."'>"; //訂單總金額
$def_url .= "<input type='hidden' name='v_ymd' value='".$v_ymd."'>"; //訂單產(chǎn)生日期
$def_url .= "<input type='hidden' name='v_orderstatus' value='0'>"; //配貨狀態(tài)
$def_url .= "<input type='hidden' name='v_ordername' value='".$v_rcvname."'>"; //訂貨人姓名
$def_url .= "<input type='hidden' name='v_moneytype' value='".$v_moneytype."'>"; //幣種,0為人民幣,1為美元
$def_url .= "<input type='hidden' name='v_url' value='".$v_url."'>"; //支付動作完成后返回到該url,支付結(jié)果以GET方式發(fā)送
$def_url .= "<input type='hidden' name='v_md5info' value=$result[0]>"; //訂單數(shù)字指紋
$def_url .= "<input type='submit' value='" . $GLOBALS['_LANG']['cappay_member_button'] . "'>";
$def_url .= '</form>';
//易支付手機通道
$def_url = "<form method=post action='http://pay.beijing.com.cn/customer/gb/pay_mobile.jsp' target='_blank'>";
$def_url .= "<input type='hidden' name='v_mid' value='".$v_rcvname."'>"; //商戶編號
$def_url .= "<input type='hidden' name='v_oid' value='".$v_oid."'>"; //訂單編號
$def_url .= "<input type='hidden' name='v_rcvname' value='".$v_rcvname."'>"; //收貨人姓名
$def_url .= "<input type='hidden' name='v_rcvaddr' value='".$v_rcvname."'>"; //收貨人地址
$def_url .= "<input type='hidden' name='v_rcvtel' value='".$v_rcvname."'>"; //收貨人電話
$def_url .= "<input type='hidden' name='v_rcvpost' value='".$v_rcvname."'>"; //收貨人郵編
$def_url .= "<input type='hidden' name='v_amount' value='".$v_amount."'>"; //訂單總金額
$def_url .= "<input type='hidden' name='v_ymd' value='".$v_ymd."'>"; //訂單產(chǎn)生日期
$def_url .= "<input type='hidden' name='v_orderstatus' value='0'>"; //配貨狀態(tài)
$def_url .= "<input type='hidden' name='v_ordername' value='".$v_rcvname."'>"; //訂貨人姓名
$def_url .= "<input type='hidden' name='v_moneytype' value='".$v_moneytype."'>"; //幣種,0為人民幣,1為美元
$def_url .= "<input type='hidden' name='v_url' value='".$v_url."'>"; //支付動作完成后返回到該url,支付結(jié)果以GET方式發(fā)送
$def_url .= "<input type='hidden' name='v_md5info' value=$result[0]>"; //訂單數(shù)字指紋
$def_url .= "<input type='submit' value='" . $GLOBALS['_LANG']['cappay_mobile_button'] . "'>";
$def_url .= '</form>';
//易支付英文通道
$def_url = "<form method=post action='http://pay.beijing.com.cn/prs/e_user_payment.checkit' target='_blank'>";
$def_url .= "<input type='hidden' name='v_mid' value='".$v_rcvname."'>"; //商戶編號
$def_url .= "<input type='hidden' name='v_oid' value='".$v_oid."'>"; //訂單編號
$def_url .= "<input type='hidden' name='v_rcvname' value='".$v_rcvname."'>"; //收貨人姓名
$def_url .= "<input type='hidden' name='v_rcvaddr' value='".$v_rcvname."'>"; //收貨人地址
$def_url .= "<input type='hidden' name='v_rcvtel' value='".$v_rcvname."'>"; //收貨人電話
$def_url .= "<input type='hidden' name='v_rcvpost' value='".$v_rcvname."'>"; //收貨人郵編
$def_url .= "<input type='hidden' name='v_amount' value='".$v_amount."'>"; //訂單總金額
$def_url .= "<input type='hidden' name='v_ymd' value='".$v_ymd."'>"; //訂單產(chǎn)生日期
$def_url .= "<input type='hidden' name='v_orderstatus' value='0'>"; //配貨狀態(tài)
$def_url .= "<input type='hidden' name='v_ordername' value='".$v_rcvname."'>"; //訂貨人姓名
$def_url .= "<input type='hidden' name='v_moneytype' value='".$v_moneytype."'>"; //幣種,0為人民幣,1為美元
$def_url .= "<input type='hidden' name='v_url' value='".$v_url."'>"; //支付動作完成后返回到該url,支付結(jié)果以GET方式發(fā)送
$def_url .= "<input type='hidden' name='v_md5info' value=$result[0]>"; //訂單數(shù)字指紋
$def_url .= "<input type='submit' value='" . $GLOBALS['_LANG']['cappay_en_button'] . "'>";
$def_url .= '</form>';*/
return $def_url;
}
/**
* 響應(yīng)操作
*/
function respond()
{
$payment = get_payment(basename(__FILE__, '.php'));
$v_tempdate = explode('-', $_GET['v_oid']);
//接受返回數(shù)據(jù)驗證開始
//v_md5info驗證
$md5info_paramet = $_GET['v_oid'].$_GET['v_pstatus'].$_GET['v_pstring'].$_GET['v_pmode'];
$md5info_tem = $this->hmac_md5($payment['cappay_key'],$md5info_paramet);
//v_md5money驗證
$md5money_paramet = $_GET['v_amount'].$_GET['v_moneytype'];
$md5money_tem = $this->hmac_md5($payment['cappay_key'],$md5money_paramet);
if ($md5info_tem == $_GET['v_md5info'] && $md5money_tem == $_GET['v_md5money'])
{
//改變訂單狀態(tài)
order_paid($v_tempdate[2]);
return true;
}
else
{
return false;
}
}
function hmac_md5($key, $data)
{
if (extension_loaded('mhash'))
{
return bin2hex(mhash(MHASH_MD5, $data, $key));
}
// RFC 2104 HMAC implementation for php. Hacked by Lance Rushing
$b = 64;
if (strlen($key) > $b)
{
$key = pack('H*', md5($key));
}
$key = str_pad($key, $b, chr(0x00));
$ipad = str_pad('', $b, chr(0x36));
$opad = str_pad('', $b, chr(0x5c));
$k_ipad = $key ^ $ipad;
$k_opad = $key ^ $opad;
return md5($k_opad . pack('H*', md5($k_ipad . $data)));
}
}
?>
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -