本文整理汇总了PHP中RequestHandler::setParameter方法的典型用法代码示例。如果您正苦于以下问题:PHP RequestHandler::setParameter方法的具体用法?PHP RequestHandler::setParameter怎么用?PHP RequestHandler::setParameter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RequestHandler
的用法示例。
在下文中一共展示了RequestHandler::setParameter方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_payment_code
public function get_payment_code($payment_notice_id)
{
require APP_ROOT_PATH . "system/payment/Tenpay/classes/RequestHandler.class.php";
$payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where id = " . $payment_notice_id);
$money = round($payment_notice['money'], 2);
$payment_info = $GLOBALS['db']->getRow("select id,config,logo from " . DB_PREFIX . "payment where id=" . intval($payment_notice['payment_id']));
$payment_info['config'] = unserialize($payment_info['config']);
$subject = $payment_notice['deal_name'] == "" ? "充值" . format_price($payment_notice['money']) : $payment_notice['deal_name'];
$data_return_url = get_domain() . APP_ROOT . '/index.php?ctl=payment&act=response&class_name=Tenpay';
$data_notify_url = get_domain() . APP_ROOT . '/index.php?ctl=payment&act=notify&class_name=Tenpay';
$cmd_no = '1';
/* 获得订单的流水号,补零到10位 */
$sp_billno = $payment_notice_id;
$spbill_create_ip = $_SERVER['REMOTE_ADDR'];
/* 交易日期 */
$today = to_date($payment_notice['create_time'], 'YmdHis');
/* 将商户号+年月日+流水号 */
$out_trade_no = $payment_notice['notice_sn'];
/* 银行类型:支持纯网关和财付通 */
$bank_type = '0';
$desc = $subject;
$attach = $payment_info['config']['tencentpay_sign'];
/* 返回的路径 */
$return_url = $data_return_url;
/* 总金额 */
$total_fee = $money * 100;
/* 货币类型 */
$fee_type = '1';
/* 重写自定义签名 */
//$payment['magic_string'] = abs(crc32($payment['magic_string']));
/* 数字签名 */
/*$sign_text = "cmdno=" . $cmd_no . "&date=" . $today . "&bargainor_id=" . $payment_info['config']['tencentpay_id'] .
"&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_info['config']['tencentpay_key'];
$sign = strtoupper(md5($sign_text));*/
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($payment_info['config']['tencentpay_key']);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $payment_info['config']['tencentpay_id']);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", $total_fee);
//总金额
$reqHandler->setParameter("return_url", $return_url);
$reqHandler->setParameter("notify_url", $data_notify_url);
$reqHandler->setParameter("body", $desc);
$reqHandler->setParameter("bank_type", $bank_type);
//银行类型,默认为财付通
//用户ip
$reqHandler->setParameter("spbill_create_ip", get_client_ip());
//客户端IP
$reqHandler->setParameter("fee_type", $fee_type);
//币种
$reqHandler->setParameter("subject", $desc);
//商品名称,(中介交易时必填)
//系统可选参数
$reqHandler->setParameter("sign_type", "MD5");
//签名方式,默认为MD5,可选RSA
$reqHandler->setParameter("service_version", "1.0");
//接口版本号
$reqHandler->setParameter("input_charset", "utf-8");
//字符集
$reqHandler->setParameter("sign_key_index", "1");
//密钥序号
//业务可选参数
$reqHandler->setParameter("attach", $attach);
//附件数据,原样返回就可以了
$reqHandler->setParameter("product_fee", "");
//商品费用
$reqHandler->setParameter("transport_fee", "0");
//物流费用
$reqHandler->setParameter("time_start", $today);
//订单生成时间
$reqHandler->setParameter("time_expire", "");
//订单失效时间
$reqHandler->setParameter("buyer_id", "");
//买方财付通帐号
$reqHandler->setParameter("goods_tag", "");
//商品标记
$reqHandler->setParameter("trade_mode", $cmd_no);
//交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
$reqHandler->setParameter("transport_desc", "");
//物流说明
$reqHandler->setParameter("trans_type", "1");
//交易类型
$reqHandler->setParameter("agentid", "");
//平台ID
$reqHandler->setParameter("agent_type", "");
//代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id", "");
//卖家的商户号
//请求的URL
$reqUrl = $reqHandler->getRequestURL();
if ($_REQUEST['v'] == 1) {
$debugInfo = $reqHandler->getDebugInfo();
echo "<br/>" . $reqUrl . "<br/>";
//.........这里部分代码省略.........
示例2: invite_payurl
function invite_payurl($amount, $price, &$orderid, $bank = 'DEFAULT')
{
include_once DISCUZ_ROOT . './source/class/class_chinese.php';
global $_G;
$date = dgmdate(TIMESTAMP, 'YmdHis');
$suffix = dgmdate(TIMESTAMP, 'His') . rand(1000, 9999);
$transaction_id = DISCUZ_PARTNER . $date . $suffix;
$orderid = dgmdate(TIMESTAMP, 'YmdHis') . random(14);
$chinese = new Chinese(strtoupper(CHARSET), 'GBK');
$subject = $chinese->Convert(lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit') . '_(' . $_G['clientip'] . ')');
$reqHandler = new RequestHandler();
$reqHandler->setGateURL("https://gw.tenpay.com/gateway/pay.htm");
$reqHandler->init();
$reqHandler->setKey(DISCUZ_SECURITYCODE);
$reqHandler->setParameter("partner", DISCUZ_PARTNER);
$reqHandler->setParameter("out_trade_no", $orderid);
$reqHandler->setParameter("total_fee", $price * 100);
$reqHandler->setParameter("return_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
$reqHandler->setParameter("notify_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
$reqHandler->setParameter("body", $subject);
$reqHandler->setParameter("bank_type", $bank);
$reqHandler->setParameter("spbill_create_ip", $_G['clientip']);
$reqHandler->setParameter("fee_type", "1");
$reqHandler->setParameter("subject", $subject);
$reqHandler->setParameter("sign_type", "MD5");
$reqHandler->setParameter("service_version", "1.0");
$reqHandler->setParameter("input_charset", "GBK");
$reqHandler->setParameter("sign_key_index", "1");
$reqHandler->setParameter("attach", "tenpay");
$reqHandler->setParameter("time_start", $date);
$reqHandler->setParameter("trade_mode", "1");
$reqHandler->setParameter("trans_type", "1");
$reqHandler->setParameter("agentid", DISCUZ_AGENTID);
$reqHandler->setParameter("agent_type", "2");
$reqUrl = $reqHandler->getRequestURL();
return $reqUrl;
}
示例3: recharge
public function recharge(){
////////////////////////////////////
//参数数据
$total_fee =floatval($_POST['price']);
$total_fee1=$total_fee;
$total_fee =floatval($total_fee)*100;
$body = '会员充值';
$orderName=$body;
$out_trade_no = $this->user['id'].'_'.time();
$notify_url = C('site_url').U('Tenpay/notify_url');
//需http://格式的完整路径,不能加?id=123这类自定义参数
//页面跳转同步通知页面路径
$return_url = C('site_url').U('Tenpay/charge_return');
//
if(!$total_fee)exit('必须有价格才能支付');
import("@.ORG.TenpayComputer.RequestHandler");
$reqHandler = new RequestHandler();
$reqHandler->init();
$key=trim(C('tenpay_partnerkey'));
$partner=trim(C('tenpay_partnerid'));
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", $total_fee); //总金额
$reqHandler->setParameter("return_url", $return_url);
$reqHandler->setParameter("notify_url", $notify_url);
$reqHandler->setParameter("body", '财付通在线支付');
$reqHandler->setParameter("bank_type", "DEFAULT"); //银行类型,默认为财付通
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);//客户端IP
$reqHandler->setParameter("fee_type", "1"); //币种
$reqHandler->setParameter("subject",'member recharge'); //商品名称,(中介交易时必填)
//系统可选参数
$reqHandler->setParameter("sign_type", "MD5"); //签名方式,默认为MD5,可选RSA
$reqHandler->setParameter("service_version", "1.0"); //接口版本号
$reqHandler->setParameter("input_charset", "utf-8"); //字符集
$reqHandler->setParameter("sign_key_index", "1"); //密钥序号
//业务可选参数
$reqHandler->setParameter("attach", ""); //附件数据,原样返回就可以了
$reqHandler->setParameter("product_fee", ""); //商品费用
$reqHandler->setParameter("transport_fee", "0"); //物流费用
$reqHandler->setParameter("time_start", date("YmdHis")); //订单生成时间
$reqHandler->setParameter("time_expire", ""); //订单失效时间
$reqHandler->setParameter("buyer_id", ""); //买方财付通帐号
$reqHandler->setParameter("goods_tag", ""); //商品标记
$reqHandler->setParameter("trade_mode",1); //交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
$reqHandler->setParameter("transport_desc",""); //物流说明
$reqHandler->setParameter("trans_type","1"); //交易类型
$reqHandler->setParameter("agentid",""); //平台ID
$reqHandler->setParameter("agent_type",""); //代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id",""); //卖家的商户号
//请求的URL
$reqUrl = $reqHandler->getRequestURL();
//获取debug信息,建议把请求和debug信息写入日志,方便定位问题
/**/
$debugInfo = $reqHandler->getDebugInfo();
//
$data=M('Indent')->data(
array('uid'=>session('uid'),'month'=>0,'title'=>$body,'uname'=>'','gid'=>0,'create_time'=>time(),'indent_id'=>$out_trade_no,'price'=>$total_fee1))->add();
//
header('Location:'.$reqUrl);
}
示例4: notify
public function notify($request)
{
// $url = "http://o2o.7dit.com/tenpay.php?";
// foreach($_REQUEST as $k=>$v)
// {
// $url.=$k."=".$v."&";
// }
// $str = file_get_contents(APP_ROOT_PATH."log.txt")."\n".print_r($_REQUEST,1)."\n".$url;
// @file_put_contents(APP_ROOT_PATH."log.txt", $str);
require_once APP_ROOT_PATH . "system/payment/tenpayc2c/ResponseHandler.class.php";
require_once APP_ROOT_PATH . "system/payment/tenpayc2c/RequestHandler.class.php";
require_once APP_ROOT_PATH . "system/payment/tenpayc2c/TenpayHttpClient.class.php";
require_once APP_ROOT_PATH . "system/payment/tenpayc2c/ClientResponseHandler.class.php";
$return_res = array('info' => '', 'status' => false);
$payment = $GLOBALS['db']->getRow("select id,config from " . DB_PREFIX . "payment where class_name='tenpayc2c'");
$payment['config'] = unserialize($payment['config']);
/* 创建支付应答对象 */
$resHandler = new ResponseHandler();
$resHandler->setKey($payment['config']['tencentpay_key']);
//判断签名
if ($resHandler->isTenpaySign()) {
//通知id
// error_reporting(E_ALL);
// ini_set("display_errors",1);
$notify_id = $resHandler->getParameter("notify_id");
//通过通知ID查询,确保通知来至财付通
//创建查询请求
$queryReq = new RequestHandler();
$queryReq->init();
$queryReq->setKey($payment['config']['tencentpay_key']);
$queryReq->setGateUrl("https://gw.tenpay.com/gateway/simpleverifynotifyid.xml");
$queryReq->setParameter("partner", $payment['config']['tencentpay_id']);
$queryReq->setParameter("notify_id", $notify_id);
//通信对象
$httpClient = new TenpayHttpClient();
$httpClient->setTimeOut(5);
//设置请求内容
$httpClient->setReqContent($queryReq->getRequestURL());
//后台调用
if ($httpClient->call()) {
//设置结果参数
$queryRes = new ClientResponseHandler();
$queryRes->setContent($httpClient->getResContent());
$queryRes->setKey($payment['config']['tencentpay_key']);
if ($resHandler->getParameter("trade_mode") == "2") {
//判断签名及结果(中介担保)
//只有签名正确,retcode为0,trade_state为0才是支付成功
// print_r($queryRes);
if ($queryRes->isTenpaySign() && $queryRes->getParameter("retcode") == "0") {
//取结果参数做业务处理
$out_trade_no = $resHandler->getParameter("out_trade_no");
//财付通订单号
$transaction_id = $resHandler->getParameter("transaction_id");
//金额,以分为单位
$total_fee = $resHandler->getParameter("total_fee");
//如果有使用折扣券,discount有值,total_fee+discount=原请求的total_fee
$discount = $resHandler->getParameter("discount");
//------------------------------
//处理业务开始
//------------------------------
//处理数据库逻辑
//注意交易单不要重复处理
//注意判断返回金额
if ($resHandler->getParameter("trade_state") == "0" || $resHandler->getParameter("trade_state") == '5' || $resHandler->getParameter("status") == "3") {
$payment_notice = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "payment_notice where notice_sn = '" . $out_trade_no . "'");
$order_info = $GLOBALS['db']->getRow("select * from " . DB_PREFIX . "deal_order where id = " . $payment_notice['order_id']);
require_once APP_ROOT_PATH . "system/libs/cart.php";
$GLOBALS['db']->query("update " . DB_PREFIX . "payment_notice set outer_notice_sn = '" . $transaction_id . "' where id = " . $payment_notice['id']);
$rs = payment_paid($payment_notice['id']);
if ($rs) {
order_paid($payment_notice['order_id']);
echo "success";
} else {
echo 'fail';
}
} else {
echo "success";
}
} else {
//错误时,返回结果可能没有签名,写日志trade_state、retcode、retmsg看失败详情。
//echo "验证签名失败 或 业务错误信息:trade_state=" . $resHandler->getParameter("trade_state") . ",retcode=" . $queryRes-> getParameter("retcode"). ",retmsg=" . $queryRes->getParameter("retmsg") . "<br/>" ;
echo "fail";
}
}
//获取查询的debug信息,建议把请求、应答内容、debug信息,通信返回码写入日志,方便定位问题
/*
echo "<br>------------------------------------------------------<br>";
echo "http res:" . $httpClient->getResponseCode() . "," . $httpClient->getErrInfo() . "<br>";
echo "query req:" . htmlentities($queryReq->getRequestURL(), ENT_NOQUOTES, "GB2312") . "<br><br>";
echo "query res:" . htmlentities($queryRes->getContent(), ENT_NOQUOTES, "GB2312") . "<br><br>";
echo "query reqdebug:" . $queryReq->getDebugInfo() . "<br><br>" ;
echo "query resdebug:" . $queryRes->getDebugInfo() . "<br><br>";
*/
} else {
//通信失败
echo "fail";
//后台调用通信失败,写日志,方便定位问题
echo "<br>call err:" . $httpClient->getResponseCode() . "," . $httpClient->getErrInfo() . "<br>";
}
} else {
//.........这里部分代码省略.........
示例5: rand
$partner = "1900000109";
/* 密钥 */
$key = "8934e7d15453e97507ef794cf7b0519d";
//4位随机数
$randNum = rand(1000, 9999);
//订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行
$out_trade_no = date("YmdHis") . $randNum;
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("total_fee", "2");
//总金额
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("return_url", "http://localhost:8080/payReturnUrl.php");
//支付成功后返回
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("notify_url", "http://localhost:8080/payNotifyUrl.php");
$reqHandler->setParameter("body", "测试");
$reqHandler->setParameter("bank_type", "DEFAULT");
//银行类型,默认为财付通
$reqHandler->setParameter("fee_type", "1");
//币种
//系统可选参数
示例6: foreach
/**
* Process the payment and return the result
**/
function process_payment($order_id)
{
global $woocommerce;
require_once "classes/RequestHandler.class.php";
$order = new WC_Order($order_id);
if (sizeof($order->get_items()) > 0) {
foreach ($order->get_items() as $item) {
if ($item['qty']) {
$item_names[] = $item['name'] . ' x ' . $item['qty'];
}
}
}
//////////////////////////////
/* 商户号 */
$partner = $this->tenpayUid;
/* 密钥 */
$key = $this->tenpayKey;
//订单号,此处用时间加随机数生成,商户根据自己情况调整,只要保持全局唯一就行
$out_trade_no = 'CIP' . $order_id;
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", ($order->get_order_total() - $order->get_total_discount()) * 100);
//总金额
$reqHandler->setParameter("return_url", CI_WC_ALI_PATH . "/payReturnUrl.php");
$reqHandler->setParameter("notify_url", CI_WC_ALI_PATH . "/payNotifyUrl.php");
$reqHandler->setParameter("body", implode(',', $item_names));
$reqHandler->setParameter("bank_type", "DEFAULT");
//银行类型,默认为财付通
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("fee_type", "1");
//币种
$reqHandler->setParameter("subject", '');
//商品名称,(中介交易时必填)
//系统可选参数
$reqHandler->setParameter("sign_type", "MD5");
//签名方式,默认为MD5,可选RSA
$reqHandler->setParameter("service_version", "1.0");
//接口版本号
$reqHandler->setParameter("input_charset", "UTF-8");
//字符集
$reqHandler->setParameter("sign_key_index", "1");
//密钥序号
//业务可选参数
$reqHandler->setParameter("attach", "");
//附件数据,原样返回就可以了
$reqHandler->setParameter("product_fee", "");
//商品费用
$reqHandler->setParameter("transport_fee", "0");
//物流费用
$reqHandler->setParameter("time_start", date("YmdHis"));
//订单生成时间
$reqHandler->setParameter("time_expire", "");
//订单失效时间
$reqHandler->setParameter("buyer_id", "");
//买方财付通帐号
$reqHandler->setParameter("goods_tag", "");
//商品标记
$reqHandler->setParameter("trade_mode", "1");
//交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
$reqHandler->setParameter("transport_desc", "");
//物流说明
$reqHandler->setParameter("trans_type", "1");
//交易类型
$reqHandler->setParameter("agentid", "");
//平台ID
$reqHandler->setParameter("agent_type", "");
//代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id", "");
//卖家的商户号
$reqUrl = $reqHandler->getRequestURL();
$html_text = '
<script>window.location.href="' . $reqUrl . '"</script>';
//param end
$output = "\r\n\t\t\t<html>\r\n\t\t <head>\r\n\t\t\t\t<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\">\r\n\t\t <title>正在前往财付通...</title>\r\n\t\t </head>\r\n\t\t <body>{$html_text}</body></html>";
echo $output;
exit;
return array('result' => 'success', 'redirect' => $output);
}
示例7: date
//支付方式:及时支付
$strDate = date("Ymd");
$strTime = date("His");
/* 商品价格(包含运费),以分为单位 */
$total_fee = $order_price * 100;
/* 商品名称 */
$desc = "商品:" . $product_name . ",备注:" . $remarkexplain;
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", $total_fee);
//总金额
$reqHandler->setParameter("return_url", $return_url);
$reqHandler->setParameter("notify_url", $notify_url);
$reqHandler->setParameter("body", $desc);
$reqHandler->setParameter("bank_type", "DEFAULT");
//银行类型,默认为财付通
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("fee_type", "1");
//币种
$reqHandler->setParameter("subject", $desc);
//商品名称,(中介交易时必填)
示例8: config
public function config($config = null)
{
$this->config = $config;
$partner = $config['id'];
//财付通商户号
$key = $config['key'];
//财付通密钥
$return_url = $config['ReturnUrl'];
//显示支付结果页面,*替换成payReturnUrl.php所在路径
$notify_url = $config['NotifyUrl'];
//支付完成后的回调处理页面,*替换成payNotifyUrl.php所在路径
/* 获取提交的订单号 */
$out_trade_no = $config['code'];
/* 获取提交的商品名称 */
$product_name = $config['title'];
/* 获取提交的商品价格 */
$order_price = $config['money'];
/* 获取提交的备注信息 */
$remarkexplain = '';
/* 支付方式 */
$trade_mode = $config['type'];
/* 商品价格(包含运费),以分为单位 */
$total_fee = $order_price * 100;
/* 商品名称 */
//$desc = "商品:".$product_name.",备注:".$remarkexplain;
$desc = $product_name;
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", $total_fee);
//总金额
$reqHandler->setParameter("return_url", $return_url);
$reqHandler->setParameter("notify_url", $notify_url);
$reqHandler->setParameter("body", $desc);
$reqHandler->setParameter("bank_type", $config['pay_bank']);
//银行类型,默认为财付通DEFAULT
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("fee_type", "1");
//币种
$reqHandler->setParameter("subject", $desc);
//商品名称,(中介交易时必填)
//系统可选参数
$reqHandler->setParameter("sign_type", "MD5");
//签名方式,默认为MD5,可选RSA
$reqHandler->setParameter("service_version", "1.0");
//接口版本号
$reqHandler->setParameter("input_charset", "utf-8");
//字符集
$reqHandler->setParameter("sign_key_index", "1");
//密钥序号
//业务可选参数
$reqHandler->setParameter("attach", "");
//附件数据,原样返回就可以了
$reqHandler->setParameter("product_fee", "");
//商品费用
$reqHandler->setParameter("transport_fee", "0");
//物流费用
$reqHandler->setParameter("time_start", date("YmdHis"));
//订单生成时间
$reqHandler->setParameter("time_expire", "");
//订单失效时间
$reqHandler->setParameter("buyer_id", "");
//买方财付通帐号
$reqHandler->setParameter("goods_tag", "");
//商品标记
$reqHandler->setParameter("trade_mode", $trade_mode);
//交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
$reqHandler->setParameter("transport_desc", "");
//物流说明
$reqHandler->setParameter("trans_type", "1");
//交易类型
$reqHandler->setParameter("agentid", "");
//平台ID
$reqHandler->setParameter("agent_type", "");
//代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id", "");
//卖家的商户号
//请求的URL
$this->url = $reqUrl = $reqHandler->getRequestURL();
//获取debug信息,建议把请求和debug信息写入日志,方便定位问题
$this->debugInfo = $debugInfo = $reqHandler->getDebugInfo();
}
示例9: invite_payurl
function invite_payurl($amount, $price, &$orderid)
{
include_once DISCUZ_ROOT . './source/class/class_chinese.php';
global $_G;
$date = dgmdate(TIMESTAMP, 'Ymd');
$suffix = dgmdate(TIMESTAMP, 'His') . rand(1000, 9999);
$transaction_id = DISCUZ_PARTNER . $date . $suffix;
$orderid = dgmdate(TIMESTAMP, 'YmdHis') . random(14);
if (!DISCUZ_TENPAY_DIRECT) {
$reqHandler = new MediPayRequestHandler();
$reqHandler->init();
$reqHandler->setKey(DISCUZ_TENPAY_OPENTRANS_KEY);
$encode_type = '1';
if (strtolower(CHARSET) == 'utf-8') {
$encode_type = '2';
}
$reqHandler->setParameter("chnid", DISCUZ_TENPAY_OPENTRANS_CHNID);
$reqHandler->setParameter("encode_type", $encode_type);
$reqHandler->setParameter("mch_desc", lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit') . '_(' . $_G['clientip'] . ')');
$reqHandler->setParameter("mch_name", lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit'));
$reqHandler->setParameter("mch_price", $price * 100);
$reqHandler->setParameter("mch_returl", $_G['siteurl'] . 'api/trade/notify_invite.php');
$reqHandler->setParameter("mch_type", '2');
$reqHandler->setParameter("mch_vno", $orderid);
$reqHandler->setParameter("need_buyerinfo", '2');
$reqHandler->setParameter("seller", DISCUZ_TENPAY_OPENTRANS_CHNID);
$reqHandler->setParameter("show_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
$reqHandler->setParameter("transport_desc", '');
$reqHandler->setParameter("transport_fee", 0);
$reqHandler->setParameter('attach', 'tenpay');
$reqUrl = $reqHandler->getRequestURL();
return $reqUrl;
}
$reqHandler = new RequestHandler();
$reqHandler->setGateURL("https://www.tenpay.com/cgi-bin/v1.0/pay_gate.cgi");
$reqHandler->init();
$reqHandler->setKey(DISCUZ_SECURITYCODE);
$reqHandler->setParameter("bargainor_id", DISCUZ_PARTNER);
$reqHandler->setParameter("sp_billno", $orderid);
$reqHandler->setParameter("transaction_id", $transaction_id);
$reqHandler->setParameter("total_fee", $price * 100);
$reqHandler->setParameter("return_url", $_G['siteurl'] . 'api/trade/notify_invite.php');
$chinese = new Chinese(strtoupper(CHARSET), 'GBK');
$reqHandler->setParameter("desc", $chinese->Convert(lang('forum/misc', 'invite_forum_payment') . '_' . intval($amount) . '_' . lang('forum/misc', 'invite_forum_payment_unit') . '_(' . $_G['clientip'] . ')'));
$reqHandler->setParameter("cmdno", "1");
$reqHandler->setParameter("date", $date);
$reqHandler->setParameter("fee_type", "1");
$reqHandler->setParameter("attach", "tenpay");
$reqHandler->setParameter("bank_type", "0");
$reqHandler->setParameter("agentid", DISCUZ_AGENTID);
$reqHandler->setParameter("key_index", "1");
$reqHandler->setParameter("verify_relation_flag", "1");
$reqHandler->setParameter("ver", "3");
$reqHandler->setParameter("spbill_create_ip", $_G['clientip']);
$reqUrl = $reqHandler->getRequestURL();
return $reqUrl;
}
示例10: pay
public function pay()
{
import("@.ORG.Tenpay.RequestHandler");
import("@.ORG.Tenpay.client.ClientResponseHandler");
import("@.ORG.Tenpay.client.TenpayHttpClient");
$partner = $this->payConfig['partnerid'];
$key = $this->payConfig['partnerkey'];
$orderid = $_GET['orderid'];
if (!$orderid) {
$orderid = $_GET['single_orderid'];
//单个订单
}
$out_trade_no = $orderid;
//before
$payHandel = new payHandle($this->token, $_GET['from']);
$orderInfo = $payHandel->beforePay($orderid);
$price = $orderInfo['price'];
//
if (!$price) {
exit('必须有价格才能支付');
}
$orderName = $_GET['orderName'];
$total_fee = floatval($price);
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("http://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_init.cgi");
$httpClient = new TenpayHttpClient();
//应答对象
$resHandler = new ClientResponseHandler();
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("total_fee", $total_fee * 100);
//总金额
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("ver", "2.0");
//版本类型
$reqHandler->setParameter("bank_type", "0");
//银行类型,财付通填写0
$return_url = C('site_url') . '/index.php?g=Wap&m=Tenpay&a=return_url&token=' . $this->token . '&wecha_id=' . $this->wecha_id . '&from=' . $_GET['from'];
$reqHandler->setParameter("callback_url", $return_url);
//交易完成后跳转的URL
$reqHandler->setParameter("bargainor_id", $partner);
//商户号
$reqHandler->setParameter("sp_billno", $out_trade_no);
//商户订单号
$notify_url = C('site_url') . '/index.php?g=Wap&m=Tenpay&a=notify_url';
$reqHandler->setParameter("notify_url", $notify_url);
//接收财付通通知的URL,需绝对路径
$reqHandler->setParameter("desc", $orderName ? $orderName : 'wechat');
$reqHandler->setParameter("attach", "");
$httpClient->setReqContent($reqHandler->getRequestURL());
//后台调用
if ($httpClient->call()) {
$resHandler->setContent($httpClient->getResContent());
//获得的token_id,用于支付请求
$token_id = $resHandler->getParameter('token_id');
$reqHandler->setParameter("token_id", $token_id);
//请求的URL
//$reqHandler->setGateUrl("https://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_gate.cgi");
//此次请求只需带上参数token_id就可以了,$reqUrl和$reqUrl2效果是一样的
//$reqUrl = $reqHandler->getRequestURL();
$reqUrl = "http://wap.tenpay.com/cgi-bin/wappayv2.0/wappay_gate.cgi?token_id=" . $token_id;
}
header('Location:' . $reqUrl);
}
示例11: RequestHandler
$partner = "1900000109";
/* 密钥 */
$key = "8934e7d15453e97507ef794cf7b0519d";
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
//通信对象
$httpClient = new TenpayHttpClient();
//应答对象
$resHandler = new ClientResponseHandler();
//-----------------------------
//设置请求参数
//-----------------------------
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/normalorderquery.xml");
$reqHandler->setParameter("partner", $partner);
//out_trade_no和transaction_id至少一个必填,同时存在时transaction_id优先
$reqHandler->setParameter("out_trade_no", "201009151621261820");
//$reqHandler->setParameter("transaction_id", "2000000501201004300000000442");
//-----------------------------
//设置通信参数
//-----------------------------
$httpClient->setTimeOut(5);
//设置请求内容
$httpClient->setReqContent($reqHandler->getRequestURL());
//后台调用
if ($httpClient->call()) {
//设置结果参数
$resHandler->setContent($httpClient->getResContent());
$resHandler->setKey($key);
//判断签名及结果
示例12: RequestHandler
/* 商户号 */
$partner = "1900000109";
/* 密钥 */
$key = "8934e7d15453e97507ef794cf7b0519d";
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("http://wap.tenpay.com/cgi-bin/wapmainv2.0/wm_query_order.cgi");
$httpClient = new TenpayHttpClient();
//应答对象
$resHandler = new ClientResponseHandler();
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("ver", "2.0");
//版本号
$reqHandler->setParameter("bargainor_id", $partner);
//商户号
//transaction_id、sp_billno两项有一项必填,都存在则以transaction_id为准
$reqHandler->setParameter("transaction_id", "1900000109201010200898845817");
//财付通的交易单号
//$reqHandler->setParameter("sp_billno", "201010200898845817"); //商户内部产生的订单号
$reqHandler->setParameter("attach", iconv('UTF-8', 'GBK', "中文"));
//商户附加信息,如果包含中文字符,需要转换为GBK
$reqHandler->setParameter("charset", 1);
//商户号
$httpClient->setReqContent($reqHandler->getRequestURL());
//后台调用
if ($httpClient->call()) {
$resHandler->setContent($httpClient->getResContent());
示例13: dopay
public function dopay($money = null, $order = null, $ordername = null)
{
//取插件配置参数
$conf = F('pluginTenpay');
if (empty($conf) || APP_DEBUG) {
$data = M('Addons')->field('param')->where("mark='Tenpay'")->find();
$conf = json_decode($data['param'], true);
F('pluginTenpay', $conf);
}
define('SHANGHU_ID', $conf['partner']);
define('SHANGHU_KEY', $conf['key']);
require_once TENPAY_PATH . "/lib/classes/RequestHandler.class.php";
require_once TENPAY_PATH . "/lib/tenpay_config.php";
/* 获取提交的订单号 */
$out_trade_no = $order;
/* 获取提交的商品名称 */
$product_name = $ordername;
/* 获取提交的商品价格 */
$order_price = $money;
/* 获取提交的备注信息 */
$remarkexplain = '没有备注';
/* 支付方式 1:即时到帐,2:中介担保,3:后台选择*/
$trade_mode = 1;
$strDate = date("Ymd");
$strTime = date("His");
/* 商品价格(包含运费),以分为单位 */
$total_fee = $order_price * 100;
/* 商品名称 */
$desc = "商品:" . $product_name . ",备注:" . $remarkexplain;
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://gw.tenpay.com/gateway/pay.htm");
//----------------------------------------
//设置支付参数
//----------------------------------------
$reqHandler->setParameter("partner", $partner);
$reqHandler->setParameter("out_trade_no", $out_trade_no);
$reqHandler->setParameter("total_fee", $total_fee);
//总金额
$reqHandler->setParameter("return_url", $return_url);
$reqHandler->setParameter("notify_url", $notify_url);
$reqHandler->setParameter("body", $desc);
$reqHandler->setParameter("bank_type", "DEFAULT");
//银行类型,默认为财付通
//用户ip
$reqHandler->setParameter("spbill_create_ip", $_SERVER['REMOTE_ADDR']);
//客户端IP
$reqHandler->setParameter("fee_type", "1");
//币种
$reqHandler->setParameter("subject", $desc);
//商品名称,(中介交易时必填)
//系统可选参数
$reqHandler->setParameter("sign_type", "MD5");
//签名方式,默认为MD5,可选RSA
$reqHandler->setParameter("service_version", "1.0");
//接口版本号
$reqHandler->setParameter("input_charset", "utf-8");
//字符集
$reqHandler->setParameter("sign_key_index", "1");
//密钥序号
//业务可选参数
$reqHandler->setParameter("attach", "");
//附件数据,原样返回就可以了
$reqHandler->setParameter("product_fee", "");
//商品费用
$reqHandler->setParameter("transport_fee", "0");
//物流费用
$reqHandler->setParameter("time_start", date("YmdHis"));
//订单生成时间
$reqHandler->setParameter("time_expire", "");
//订单失效时间
$reqHandler->setParameter("buyer_id", "");
//买方财付通帐号
$reqHandler->setParameter("goods_tag", "");
//商品标记
$reqHandler->setParameter("trade_mode", $trade_mode);
//交易模式(1.即时到帐模式,2.中介担保模式,3.后台选择(卖家进入支付中心列表选择))
$reqHandler->setParameter("transport_desc", "");
//物流说明
$reqHandler->setParameter("trans_type", "1");
//交易类型
$reqHandler->setParameter("agentid", "");
//平台ID
$reqHandler->setParameter("agent_type", "");
//代理模式(0.无代理,1.表示卡易售模式,2.表示网店模式)
$reqHandler->setParameter("seller_id", "");
//卖家的商户号
//请求的URL
$reqUrl = $reqHandler->getRequestURL();
//获取debug信息,建议把请求和debug信息写入日志,方便定位问题
/**/
$debugInfo = $reqHandler->getDebugInfo();
$html = <<<eot
<form id="tenpay_form" action="{$reqHandler->getGateUrl()}" method="post" target="_blank">
eot;
$params = $reqHandler->getAllParameters();
foreach ($params as $k => $v) {
$html .= "<input type=\"hidden\" name=\"{$k}\" value=\"{$v}\" />\n";
//.........这里部分代码省略.........
示例14: RequestHandler
$partner = "1900000109";
/* 密钥 */
$key = "8934e7d15453e97507ef794cf7b0519d";
/* 创建支付请求对象 */
$reqHandler = new RequestHandler();
//通信对象
$httpClient = new TenpayHttpClient();
//应答对象
$resHandler = new ClientResponseHandler();
//-----------------------------
//设置请求参数
//-----------------------------
$reqHandler->init();
$reqHandler->setKey($key);
$reqHandler->setGateUrl("https://mch.tenpay.com/refundapi/gateway/refund.xml");
$reqHandler->setParameter("partner", $partner);
//out_trade_no和transaction_id至少一个必填,同时存在时transaction_id优先
//$reqHandler->setParameter("out_trade_no", "201101121111462844");
$reqHandler->setParameter("transaction_id", "1900000109201101120023707085");
//必须保证全局唯一,同个退款单号财付通认为是同笔请求
$reqHandler->setParameter("out_refund_no", "2011032400002");
$reqHandler->setParameter("total_fee", "2");
$reqHandler->setParameter("refund_fee", "1");
$reqHandler->setParameter("op_user_id", "1900000109");
//操作员密码,MD5处理
$reqHandler->setParameter("op_user_passwd", md5("111111"));
//接口版本号,取值1.1
$reqHandler->setParameter("service_version", "1.1");
//-----------------------------
//设置通信参数
//-----------------------------
示例15: notify_url
public function notify_url()
{
$partner = CS_Tenpay_ID;
$key = CS_Tenpay_Key;
require CSCMSPATH . "pay/tenpay/ResponseHandler.class.php";
require CSCMSPATH . "pay/tenpay/RequestHandler.class.php";
require CSCMSPATH . "pay/tenpay/client/ClientResponseHandler.class.php";
require CSCMSPATH . "pay/tenpay/client/TenpayHttpClient.class.php";
$resHandler = new ResponseHandler();
$resHandler->setKey($key);
if ($resHandler->isTenpaySign()) {
$notify_id = $resHandler->getParameter("notify_id");
$queryReq = new RequestHandler();
$queryReq->init();
$queryReq->setKey($key);
$queryReq->setGateUrl("https://gw.tenpay.com/gateway/simpleverifynotifyid.xml");
$queryReq->setParameter("partner", $partner);
$queryReq->setParameter("notify_id", $notify_id);
$httpClient = new TenpayHttpClient();
$httpClient->setTimeOut(5);
$httpClient->setReqContent($queryReq->getRequestURL());
if ($httpClient->call()) {
$queryRes = new ClientResponseHandler();
$queryRes->setContent($httpClient->getResContent());
$queryRes->setKey($key);
if ($resHandler->getParameter("trade_mode") == "1") {
//判断签名及结果(即时到帐)
if ($queryRes->isTenpaySign() && $queryRes->getParameter("retcode") == "0" && $resHandler->getParameter("trade_state") == "0") {
$out_trade_no = $resHandler->getParameter("out_trade_no");
$transaction_id = $resHandler->getParameter("transaction_id");
$total_fee = $resHandler->getParameter("total_fee");
$discount = $resHandler->getParameter("discount");
//获取订单记录
$row = $this->CsdjDB->get_row('pay', '*', $out_trade_no, 'dingdan');
if ($row && $row->pid != 1) {
//增加金钱
$this->db->query("update " . CS_SqlPrefix . "user set rmb=rmb+" . $row->rmb . " where id=" . $row->uid . "");
//改变状态
$this->db->query("update " . CS_SqlPrefix . "pay set pid=1 where id=" . $row->id . "");
//发送通知
$add['uida'] = $row->uid;
$add['uidb'] = 0;
$add['name'] = L('pay_11');
$add['neir'] = L('pay_17', array($row->rmb, $out_trade_no));
$add['addtime'] = time();
$this->CsdjDB->get_insert('msg', $add);
}
echo "success";
} else {
echo "fail";
}
} elseif ($resHandler->getParameter("trade_mode") == "2") {
//判断签名及结果(中介担保)
if ($queryRes->isTenpaySign() && $queryRes->getParameter("retcode") == "0") {
$out_trade_no = $resHandler->getParameter("out_trade_no");
$transaction_id = $resHandler->getParameter("transaction_id");
$total_fee = $resHandler->getParameter("total_fee");
$discount = $resHandler->getParameter("discount");
$row = $this->CsdjDB->get_row('pay', '*', $out_trade_no, 'dingdan');
switch ($resHandler->getParameter("trade_state")) {
case "0":
//付款成功
if ($row) {
$this->db->query("update " . CS_SqlPrefix . "pay set pid=2 where id=" . $row->id . "");
//发送通知
$add['uida'] = $row->uid;
$add['uidb'] = 0;
$add['name'] = L('pay_13');
$add['neir'] = L('pay_14', array($row->rmb, $out_trade_no));
$add['addtime'] = time();
$this->CsdjDB->get_insert('msg', $add);
}
break;
case "1":
//交易创建
break;
case "2":
//收获地址填写完毕
break;
case "4":
//卖家发货成功
if ($row) {
$this->db->query("update " . CS_SqlPrefix . "pay set pid=3 where id=" . $row->id . "");
//发送通知
$add['uida'] = $row->uid;
$add['uidb'] = 0;
$add['name'] = L('pay_15');
$add['neir'] = L('pay_16', array($out_trade_no));
$add['addtime'] = time();
$this->CsdjDB->get_insert('msg', $add);
}
break;
case "5":
//买家收货确认,交易成功
if ($row && $row->pid != 1) {
//增加金钱
$this->db->query("update " . CS_SqlPrefix . "user set rmb=rmb+" . $row->rmb . " where id=" . $row->uid . "");
//改变状态
$this->db->query("update " . CS_SqlPrefix . "pay set pid=1 where id=" . $row->id . "");
//发送通知
//.........这里部分代码省略.........