'tenpay_account', 'type' => 'text', 'value' => ''),
array('name' => 'tenpay_key', 'type' => 'text', 'value' => ''),
array('name' => 'magic_string', 'type' => 'text', 'value' => '')
);
return;
}
/**
* 类
*/
class tenpay
{
/**
* 构造函数
*
* @access public
* @param
*
* @return void
*/
function tenpay()
{
}
function __construct()
{
$this->tenpay();
}
/**
* 生成支付代码
* @param array $order 订单信息
* @param array $payment 支付方式信息
*/
function get_code($order, $payment)
{
$cmd_no = '1';
/* 获得订单的流水号,补零到10位 */
$sp_billno = $order['order_sn'];
/* 交易日期 */
$today = date('Ymd');
/* 将商户号+年月日+流水号 */
$bill_no = str_pad($order['log_id'], 10, 0, STR_PAD_LEFT);
$transaction_id = $payment['tenpay_account'].$today.$bill_no;
/* 银行类型:支持纯网关和财付通 */
$bank_type = '0';
/* 订单描述,用订单号替代 */
if (!empty($order['order_id']))
{
//$desc = get_goods_name_by_id($order['order_id']);
$desc = $order['order_sn'];
$attach = '';
}
else
{
$desc = $GLOBALS['_LANG']['account_voucher'];
$attach = 'voucher';
}
/* 编码标准 */
if (!defined('EC_CHARSET') || EC_CHARSET == 'utf-8')
{
$desc = ecs_iconv('utf-8', 'gbk', $desc);
}
/* 返回的路径 */
$return_url = return_url('tenpay');
/* 总金额 */
$total_fee = floatval($order['order_amount']) * 100;
/* 货币类型 */
$fee_type = '1';
/* 财付通风险防范参数 */
$spbill_create_ip = $_SERVER['REMOTE_ADDR'];
/* 数字签名 */
$sign_text = "cmdno=" . $cmd_no . "&date=" . $today . "&bargainor_id=" . $payment['tenpay_account'] .
"&transaction_id=" . $transaction_id . "&sp_billno=" . $sp_billno .
"&total_fee=" . $total_fee . "&fee_type=" . $fee_type . "&return_url=" . $return_url .
"&attach=" . $attach . "&spbill_create_ip=" . $spbill_create_ip . "&key=" . $payment['tenpay_key'];
$sign = strtoupper(md5($sign_text));
/* 交易参数 */
$parameter = array(
'cmdno' => $cmd_no, // 业务代码, 财付通支付支付接口填 1
'date' => $today, // 商户日期:如20051212
'bank_type' => $bank_type, // 银行类型:支持纯网关和财付通
'desc' => $desc, // 交易的商品名称
'purchaser_id' => '', // 用户(买方)的财付通帐户,可以为空
'bargainor_id' => $payment['tenpay_account'], // 商家的财付通商户号
'transaction_id' => $transaction_id, // 交易号(订单号),由商户网站产生(建议顺序累加)
'sp_billno' => $sp_billno, // 商户系统内部的定单号,最多10位
'total_fee' => $total_fee, // 订单金额
'fee_type' => $fee_type, // 现金支付币种
'return_url' => $return_url, // 接收财付通返回结果的URL
'attach' => $attach, // 用户自定义签名
'sign' => $sign, // MD5签名
'spbill_create_ip' => $spbill_create_ip, //财付通风险防范参数
'sys_id' => '542554970', //ecshop C账号 不参与签名
'sp_suggestuser' => '1202822001' //财付通分配的商户号
);
$button = '