tenpay.api.php
来自「贝宝的网络支付网关技术文档! 有ASP,PHP,Java接口及测试规范!」· PHP 代码 · 共 98 行
PHP
98 行
<?php
/*
[Discuz!] (C)2001-2007 Comsenz Inc.
This is NOT a freeware, use is subject to license terms
$Id: tenpay.api.php 2008-04-12 18:28:41 Monkey $
*/
//note Discuz! Tenpay
if(!defined('IN_DISCUZ')) {
exit('Access Denied');
}
define('DISCUZ_PARTNER', '');//商户号
define('DISCUZ_SECURITYCODE', '');//密钥
/*debug
* 获取或判断分类状态值
* @param $method - 分类名
* @param $status - -1:返回类别 其他数字:判断是否为此类状态
* @return 值
*/
function credit_payurl($price, &$orderid) {
global $bbname, $discuz_uid, $discuz_userss, $language, $boardurl, $extcredits, $creditstrans, $onlineip, $ec_ratio, $ec_account, $timestamp, $authkey, $charset, $_DCACHE;
$date = gmdate('Ymd', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600);
$orderid = gmdate('His', $timestamp + $_DCACHE['settings']['timeoffset'] * 3600).rand(1000, 9999);
$args = array(
'cmdno' => 1,
'date' => $date,
'bargainor_id' => DISCUZ_PARTNER,
'transaction_id' => DISCUZ_PARTNER.$date.$orderid,
'sp_billno' => $orderid,
'total_fee' => $price * 100,
'fee_type' => 1,
'return_url' => $boardurl.'api/trade/credit.notify.php',
'attach' => 'tenpay',
);
$strSignText = 'cmdno='.$args['cmdno'].
'&date=' .$args['date'].
'&bargainor_id='.$args['bargainor_id'].
'&transaction_id='.$args['transaction_id'].
'&sp_billno='.$args['sp_billno'].
'&total_fee='.$args['total_fee'].
'&fee_type='.$args['fee_type'].
'&return_url='.$args['return_url'].
'&attach='.$args['attach'];
$strRequest = $strSignText.
'&bank_type=0'.
'&desc='.rawurlencode($language['credit_forum_payment'].'_'.$extcredits[$creditstrans]['title'].'_'.intval($price * $ec_ratio).'_'.$extcredits[$creditstrans]['unit'].'_('.$onlineip.')').
'&purchaser_id='.
'&sign='.strtoupper(md5($strSignText.'&key='.DISCUZ_SECURITYCODE));
$orderid = $date.$orderid;
return 'https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi?'.$strRequest;
}
/*debug
* 接口返回值校验
* @param $type 返回类型 credit积分 trade商品
* @return 值
*/
function trade_notifycheck($type) {
global $boardurl;
$strResponseText = 'cmdno='.$_GET['cmdno'].
'&pay_result='.$_GET['pay_result'] .
'&date='.$_GET['date'].
'&transaction_id='.$_GET['transaction_id'] .
'&sp_billno='.$_GET['sp_billno'].
'&total_fee='.$_GET['total_fee'].
'&fee_type='.$_GET['fee_type'].
'&attach='.$_GET['attach'].
'&key='.DISCUZ_SECURITYCODE;
$strLocalSign = strtoupper(md5($strResponseText));
if($type == 'credit' && $strLocalSign == $_GET['sign'] && DISCUZ_PARTNER == $_GET['bargainor_id']) {
return array(
'validator' => !$_GET['pay_result'],
'status' => 1,
'order_no' => substr($_GET['transaction_id'], 10),
'price' => $_GET['total_fee'] / 100,
'location' => 'memcp.php?action=credits&operation=addfunds&return=success'
);
} else {
return array(
'validator' => FALSE,
'location' => 'memcp.php?action=credits&operation=addfunds&return=fail'
);
}
}
?>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?