添加后台代理代码
This commit is contained in:
32
codes/agent/game/api/payment/baifubao/bfb_pay.cfg.php
Normal file
32
codes/agent/game/api/payment/baifubao/bfb_pay.cfg.php
Normal file
@@ -0,0 +1,32 @@
|
||||
<?php
|
||||
/**
|
||||
* [WEIZAN System] Copyright (c) 2014 012WZ.COM
|
||||
* WEIZAN is NOT a free software, it under the license terms, visited http://www.012wz.com/ for more details.
|
||||
*/
|
||||
|
||||
final class sp_conf{
|
||||
static public $SP_NO;
|
||||
static public $SP_KEY_FILE;
|
||||
static public $LOG_FILE;
|
||||
const SP_PAY_RESULT_SUCCESS = 1;
|
||||
const SP_PAY_RESULT_WAITING = 2;
|
||||
const BFB_PAY_DIRECT_NO_LOGIN_URL = "https://www.baifubao.com/api/0/pay/0/direct";
|
||||
const BFB_PAY_DIRECT_LOGIN_URL = "https://www.baifubao.com/api/0/pay/0/direct/0";
|
||||
const BFB_PAY_WAP_DIRECT_URL = "https://www.baifubao.com/api/0/pay/0/wapdirect";
|
||||
const BFB_QUERY_ORDER_URL = "https://www.baifubao.com/api/0/query/0/pay_result_by_order_no";
|
||||
const BFB_QUERY_RETRY_TIME = 3;
|
||||
const BFB_PAY_RESULT_SUCCESS = 1;
|
||||
const BFB_NOTIFY_META = "<meta name=\"VIP_BFB_PAYMENT\" content=\"BAIFUBAO\">";
|
||||
const SIGN_METHOD_MD5 = 1;
|
||||
const SIGN_METHOD_SHA1 = 2;
|
||||
const BFB_PAY_INTERFACE_SERVICE_ID = 1;
|
||||
const BFB_QUERY_INTERFACE_SERVICE_ID = 11;
|
||||
const BFB_INTERFACE_VERSION = 2;
|
||||
const BFB_INTERFACE_ENCODING = 1;
|
||||
const BFB_INTERFACE_OUTPUT_FORMAT = 1;
|
||||
const BFB_INTERFACE_CURRENTCY = 1;
|
||||
}
|
||||
|
||||
sp_conf::$LOG_FILE = IA_ROOT . '/data/logs/bfb_' . date('Ymd') . '.log';
|
||||
sp_conf::$SP_NO = $payment['mchid'];
|
||||
sp_conf::$SP_KEY_FILE = $payment['signkey'];
|
||||
339
codes/agent/game/api/payment/baifubao/bfb_sdk.php
Normal file
339
codes/agent/game/api/payment/baifubao/bfb_sdk.php
Normal file
@@ -0,0 +1,339 @@
|
||||
<?php
|
||||
|
||||
/**
|
||||
* [WEIZAN System] Copyright (c) 2014 012WZ.COM
|
||||
* WEIZAN is NOT a free software, it under the license terms, visited http://www.012wz.com/ for more details.
|
||||
*/
|
||||
|
||||
|
||||
if (!defined("BFB_SDK_ROOT"))
|
||||
{
|
||||
define("BFB_SDK_ROOT", dirname(__FILE__) . DIRECTORY_SEPARATOR);
|
||||
}
|
||||
|
||||
require_once(BFB_SDK_ROOT . 'bfb_pay.cfg.php');
|
||||
|
||||
if (!function_exists('curl_init')) {
|
||||
exit('您的PHP没有安装 配置cURL扩展,请先安装配置cURL,具体方法可以上网查。');
|
||||
}
|
||||
|
||||
if (!function_exists('json_decode')) {
|
||||
exit('您的PHP不支持JSON,请升级您的PHP版本。');
|
||||
}
|
||||
|
||||
|
||||
class bfb_sdk{
|
||||
public $err_msg;
|
||||
public $order_no;
|
||||
|
||||
function __construct() {
|
||||
}
|
||||
|
||||
|
||||
function create_baifubao_pay_order_url($params, $url) {
|
||||
if (empty($params ['service_code']) || empty($params ['sp_no']) ||
|
||||
empty($params ['order_create_time']) ||
|
||||
empty($params ['order_no']) ||
|
||||
empty($params ['goods_name']) ||
|
||||
empty($params ['total_amount']) ||
|
||||
empty($params ['currency']) ||
|
||||
empty($params ['return_url']) ||
|
||||
empty($params ['pay_type']) ||
|
||||
empty($params ['input_charset']) ||
|
||||
empty($params ['version']) ||
|
||||
empty($params ['sign_method'])) {
|
||||
$this->log(sprintf('invalid params, params:[%s]', print_r($params, true)));
|
||||
return false;
|
||||
}
|
||||
if (!in_array($url,
|
||||
array (
|
||||
sp_conf::BFB_PAY_DIRECT_LOGIN_URL,
|
||||
sp_conf::BFB_PAY_DIRECT_NO_LOGIN_URL,
|
||||
sp_conf::BFB_PAY_WAP_DIRECT_URL
|
||||
))) {
|
||||
$this->log(
|
||||
sprintf('invalid url[%s], bfb just provide three kind of pay url',
|
||||
$url));
|
||||
return false;
|
||||
}
|
||||
|
||||
$pay_url = $url;
|
||||
|
||||
if (false === ($sign = $this->make_sign($params))) {
|
||||
return false;
|
||||
}
|
||||
$this->order_no = $params ['order_no'];
|
||||
$params ['sign'] = $sign;
|
||||
$params_str = http_build_query($params);
|
||||
$this->log(
|
||||
sprintf('the params that create baifubao pay order is [%s]',
|
||||
$params_str));
|
||||
|
||||
return $pay_url . '?' . $params_str;
|
||||
}
|
||||
|
||||
|
||||
function check_bfb_pay_result_notify() {
|
||||
if (empty($_GET) || !isset($_GET ['sp_no']) || !isset(
|
||||
$_GET ['order_no']) || !isset($_GET ['bfb_order_no']) ||
|
||||
!isset($_GET ['bfb_order_create_time']) ||
|
||||
!isset($_GET ['pay_time']) || !isset($_GET ['pay_type']) ||
|
||||
!isset($_GET ['total_amount']) || !isset($_GET ['fee_amount']) ||
|
||||
!isset($_GET ['currency']) || !isset($_GET ['pay_result']) ||
|
||||
!isset($_GET ['input_charset']) || !isset($_GET ['version']) ||
|
||||
!isset($_GET ['sign']) || !isset($_GET ['sign_method'])) {
|
||||
$this->err_msg = 'return_url页面的请求的必选参数不足';
|
||||
$this->log(
|
||||
sprintf('missing the params of return_url page, params[%s]',
|
||||
print_r($_GET)));
|
||||
}
|
||||
$arr_params = $_GET;
|
||||
$this->order_no = $arr_params ['order_no'];
|
||||
if (sp_conf::$SP_NO != $arr_params ['sp_no']) {
|
||||
$this->err_msg = '百付宝的支付结果通知中商户ID无效,该通知无效';
|
||||
$this->log(
|
||||
'the id in baifubao notify is wrong, this notify is invaild');
|
||||
return false;
|
||||
}
|
||||
if (sp_conf::BFB_PAY_RESULT_SUCCESS != $arr_params ['pay_result']) {
|
||||
$this->err_msg = '百付宝的支付结果通知中商户支付结果异常,该通知无效';
|
||||
$this->log(
|
||||
'the pay result in baifubao notify is wrong, this notify is invaild');
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false === $this->check_sign($arr_params)) {
|
||||
$this->err_msg = '百付宝后台通知签名校验失败';
|
||||
$this->log('baifubao notify sign failed');
|
||||
return false;
|
||||
}
|
||||
$this->log('baifubao notify sign success');
|
||||
|
||||
|
||||
$order_no = $arr_params ['order_no'];
|
||||
$order_state = $this->query_order_state($order_no);
|
||||
$this->log(sprintf('order state in sp server is [%s]', $order_state));
|
||||
if (sp_conf::SP_PAY_RESULT_WAITING == $order_state) {
|
||||
$this->log('the order state is right, the order is waiting for pay');
|
||||
return true;
|
||||
} elseif (sp_conf::SP_PAY_RESULT_SUCCESS == $order_state) {
|
||||
$this->log('the order state is wrong, this order has been paid');
|
||||
$this->err_msg = '订单[%s]已经处理,此百付宝后台支付通知为重复通知';
|
||||
return false;
|
||||
} else {
|
||||
$this->log(
|
||||
sprintf('the order state is wrong, it is [%s]',
|
||||
$order_state));
|
||||
$this->err_msg = '订单[%s]状态异常';
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
function notify_bfb() {
|
||||
$rep_str = "<html><head>" . sp_conf::BFB_NOTIFY_META .
|
||||
"</head><body><h1>这是一个return_url页面</h1></body></html>";
|
||||
echo "$rep_str";
|
||||
}
|
||||
|
||||
|
||||
private function query_order_state($order_no) {
|
||||
|
||||
return sp_conf::SP_PAY_RESULT_WAITING;
|
||||
}
|
||||
|
||||
|
||||
function query_baifubao_pay_result_by_order_no($order_no) {
|
||||
$params = array (
|
||||
'service_code' => sp_conf::BFB_QUERY_INTERFACE_SERVICE_ID, 'sp_no' => sp_conf::$SP_NO,
|
||||
'order_no' => $order_no,
|
||||
'output_type' => sp_conf::BFB_INTERFACE_OUTPUT_FORMAT, 'output_charset' => sp_conf::BFB_INTERFACE_ENCODING, 'version' => sp_conf::BFB_INTERFACE_VERSION,
|
||||
'sign_method' => sp_conf::SIGN_METHOD_MD5
|
||||
);
|
||||
|
||||
|
||||
if (false === ($sign = $this->make_sign($params))) {
|
||||
$this->log(
|
||||
'make sign for query baifubao pay result interface failed');
|
||||
return false;
|
||||
}
|
||||
$params ['sign'] = $sign;
|
||||
$params_str = http_build_query($params);
|
||||
|
||||
$query_url = sp_conf::BFB_QUERY_ORDER_URL . '?' . $params_str;
|
||||
$this->log(
|
||||
sprintf('the url of query baifubao pay result is [%s]',
|
||||
$query_url));
|
||||
$content = $this->request($query_url);
|
||||
$retry = 0;
|
||||
while (empty($content) && $retry < sp_conf::BFB_QUERY_RETRY_TIME) {
|
||||
$content = $this->request($query_url);
|
||||
$retry++;
|
||||
}
|
||||
if (empty($content)) {
|
||||
$this->err_msg = '调用百付宝订单号查询接口失败';
|
||||
return false;
|
||||
}
|
||||
$this->log(
|
||||
sprintf('the result from baifubao query pay result is [%s]',
|
||||
$content));
|
||||
$response_arr = json_decode(json_encode(isimplexml_load_string($content)), true);
|
||||
foreach ($response_arr as &$value) {
|
||||
if (empty($value) && is_array($value)) {
|
||||
$value = '';
|
||||
}
|
||||
}
|
||||
unset($value);
|
||||
if (empty($response_arr) || !isset($response_arr ['query_status']) ||
|
||||
!isset($response_arr ['sp_no']) ||
|
||||
!isset($response_arr ['order_no']) ||
|
||||
!isset($response_arr ['bfb_order_no']) ||
|
||||
!isset($response_arr ['bfb_order_create_time']) ||
|
||||
!isset($response_arr ['pay_time']) ||
|
||||
!isset($response_arr ['pay_type']) ||
|
||||
!isset($response_arr ['goods_name']) ||
|
||||
!isset($response_arr ['total_amount']) ||
|
||||
!isset($response_arr ['fee_amount']) ||
|
||||
!isset($response_arr ['currency']) ||
|
||||
!isset($response_arr ['pay_result']) ||
|
||||
!isset($response_arr ['sign']) ||
|
||||
!isset($response_arr ['sign_method'])) {
|
||||
$this->err_msg = sprintf('百付宝的订单查询接口查询失败,返回数据为[%s]',
|
||||
print_r($response_arr, true));
|
||||
return false;
|
||||
}
|
||||
if (0 != $response_arr ['query_status']) {
|
||||
$this->log(
|
||||
sprintf(
|
||||
'query the baifubao pay result interface faild, the query_status is [%s]',
|
||||
$response_arr ['query_status']));
|
||||
$this->err_msg = sprintf('百付宝的订单查询接口查询失败,查询状态为[%s]',
|
||||
$response_arr ['query_status']);
|
||||
return false;
|
||||
}
|
||||
if (sp_conf::$SP_NO != $response_arr ['sp_no']) {
|
||||
$this->log(
|
||||
'the sp_no returned from baifubao pay result interface is invaild');
|
||||
$this->err_msg = '百付宝的订单查询接口的响应数据中商户ID无效,该通知无效';
|
||||
return false;
|
||||
}
|
||||
if (sp_conf::BFB_PAY_RESULT_SUCCESS != $response_arr ['pay_result']) {
|
||||
$this->log(
|
||||
sprintf(
|
||||
'the pay result returned from baifubao pay result interface is invalid, is [%s]',
|
||||
$response_arr ['pay_result']));
|
||||
$this->err_msg = '百付宝的订单查询接口的响应数据中商户支付结果异常,该通知无效';
|
||||
return false;
|
||||
}
|
||||
|
||||
$response_arr ['goods_name'] = iconv("UTF-8", "GBK",
|
||||
$response_arr ['goods_name']);
|
||||
if (isset($response_arr ['buyer_sp_username'])) {
|
||||
$response_arr ['buyer_sp_username'] = iconv("UTF-8", "GBK",
|
||||
$response_arr ['buyer_sp_username']);
|
||||
}
|
||||
if (false === $this->check_sign($response_arr)) {
|
||||
$this->log(
|
||||
'sign the result returned from baifubao pay result interface failed');
|
||||
$this->err_msg = '百付宝订单查询接口响应数据签名校验失败';
|
||||
return false;
|
||||
}
|
||||
|
||||
return print_r($response_arr, true);
|
||||
}
|
||||
|
||||
|
||||
private function make_sign($params) {
|
||||
if (is_array($params)) {
|
||||
if (ksort($params)) {
|
||||
if(false === ($params ['key'] = $this->get_sp_key())){
|
||||
return false;
|
||||
}
|
||||
$arr_temp = array ();
|
||||
foreach ($params as $key => $val) {
|
||||
$arr_temp [] = $key . '=' . $val;
|
||||
}
|
||||
$sign_str = implode('&', $arr_temp);
|
||||
if ($params ['sign_method'] == sp_conf::SIGN_METHOD_MD5) {
|
||||
return md5($sign_str);
|
||||
} else if ($params ['sign_method'] == sp_conf::SIGN_METHOD_SHA1) {
|
||||
return sha1($sign_str);
|
||||
} else{
|
||||
$this->log('unsupported sign method');
|
||||
$this->err_msg = '签名方法不支持';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->log('ksort failed');
|
||||
$this->err_msg = '表单参数数组排序失败';
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
$this->log('the params of making sign should be a array');
|
||||
$this->err_msg = '生成签名的参数必须是一个数组';
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function check_sign($params) {
|
||||
$sign = $params ['sign'];
|
||||
unset($params ['sign']);
|
||||
foreach ($params as &$value) {
|
||||
$value = urldecode($value); }
|
||||
unset($value);
|
||||
if (false !== ($my_sign = $this->make_sign($params))) {
|
||||
if (0 !== strcmp($my_sign, $sign)) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private function get_sp_key() {
|
||||
return sp_conf::$SP_KEY_FILE;
|
||||
|
||||
}
|
||||
|
||||
|
||||
function request($url) {
|
||||
$curl = curl_init(); curl_setopt($curl, CURLOPT_URL, $url);
|
||||
curl_setopt($curl, CURLOPT_HEADER, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 3); curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
|
||||
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
|
||||
|
||||
$res = curl_exec($curl); $err = curl_error($curl);
|
||||
|
||||
if (false === $res || !empty($err)) {
|
||||
$info = curl_getinfo($curl);
|
||||
curl_close($curl);
|
||||
|
||||
$this->log(
|
||||
sprintf(
|
||||
'curl the baifubao pay result interface failed, err_msg [%s]',
|
||||
$info));
|
||||
$this->err_msg = $info;
|
||||
return false;
|
||||
}
|
||||
curl_close($curl); return $res;
|
||||
}
|
||||
|
||||
|
||||
function log($msg) {
|
||||
if(defined(sp_conf::$LOG_FILE)) {
|
||||
error_log(
|
||||
sprintf("[%s] [order_no: %s] : %s\n", date("Y-m-d H:i:s"),
|
||||
$this->order_no, $msg));
|
||||
}
|
||||
else {
|
||||
error_log(
|
||||
sprintf("[%s] [order_no: %s] : %s\n", date("Y-m-d H:i:s"),
|
||||
$this->order_no, $msg), 3, sp_conf::$LOG_FILE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
?>
|
||||
72
codes/agent/game/api/payment/baifubao/notify.php
Normal file
72
codes/agent/game/api/payment/baifubao/notify.php
Normal file
@@ -0,0 +1,72 @@
|
||||
<?php
|
||||
/**
|
||||
* [Weizan System] Copyright (c) 2014 012WZ.COM
|
||||
* Weizan is NOT a free software, it under the license terms, visited http://www.012wz.com/ for more details.
|
||||
*/
|
||||
define('IN_MOBILE', true);
|
||||
require '../../framework/bootstrap.inc.php';
|
||||
$_GPC['i'] = !empty($_GPC['i']) ? $_GPC['i'] : $_GET['extra'];
|
||||
require '../../app/common/bootstrap.app.inc.php';
|
||||
load()->app('common');
|
||||
load()->app('template');
|
||||
|
||||
$setting = uni_setting($_W['uniacid'], array('payment'));
|
||||
if(!is_array($setting['payment'])) {
|
||||
exit('没有设定支付参数.');
|
||||
}
|
||||
$payment = $setting['payment']['baifubao'];
|
||||
require 'bfb_sdk.php';
|
||||
$bfb_sdk = new bfb_sdk();
|
||||
if (!empty($_GPC['pay_result']) && $_GPC['pay_result'] == '1') {
|
||||
if (true === $bfb_sdk->check_bfb_pay_result_notify()) {
|
||||
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniontid`=:uniontid';
|
||||
$params = array();
|
||||
$params[':uniontid'] = $_GPC['order_no'];
|
||||
$log = pdo_fetch($sql, $params);
|
||||
if(!empty($log) && $log['status'] == '0') {
|
||||
$log['tag'] = iunserializer($log['tag']);
|
||||
$log['tag']['bfb_order_no'] = $_POST['bfb_order_no'];
|
||||
$record = array();
|
||||
$record['status'] = 1;
|
||||
$record['tag'] = iserializer($log['tag']);
|
||||
pdo_update('core_paylog', $record, array('plid' => $log['plid']));
|
||||
|
||||
if($log['is_usecard'] == 1 && $log['card_type'] == 1 && !empty($log['encrypt_code']) && $log['acid']) {
|
||||
load()->classs('coupon');
|
||||
$acc = new coupon($log['acid']);
|
||||
$codearr['encrypt_code'] = $log['encrypt_code'];
|
||||
$codearr['module'] = $log['module'];
|
||||
$codearr['card_id'] = $log['card_id'];
|
||||
$acc->PayConsumeCode($codearr);
|
||||
}
|
||||
if($log['is_usecard'] == 1 && $log['card_type'] == 2) {
|
||||
$now = time();
|
||||
$log['card_id'] = intval($log['card_id']);
|
||||
pdo_query('UPDATE ' . tablename('activity_coupon_record') . " SET status = 2, usetime = {$now}, usemodule = '{$log['module']}' WHERE uniacid = :aid AND couponid = :cid AND uid = :uid AND status = 1 LIMIT 1", array(':aid' => $_W['uniacid'], ':uid' => $log['openid'], ':cid' => $log['card_id']));
|
||||
}
|
||||
|
||||
$site = WeUtility::createModuleSite($log['module']);
|
||||
if(!is_error($site)) {
|
||||
$method = 'payResult';
|
||||
if (method_exists($site, $method)) {
|
||||
$ret = array();
|
||||
$ret['weid'] = $log['uniacid'];
|
||||
$ret['uniacid'] = $log['uniacid'];
|
||||
$ret['result'] = 'success';
|
||||
$ret['type'] = $log['type'];
|
||||
$ret['from'] = 'notify';
|
||||
$ret['tid'] = $log['tid'];
|
||||
$ret['uniontid'] = $log['uniontid'];
|
||||
$ret['user'] = $log['openid'];
|
||||
$ret['fee'] = $log['fee'];
|
||||
$ret['tag'] = $log['tag'];
|
||||
$site->$method($ret);
|
||||
$bfb_sdk->notify_bfb();
|
||||
exit('success');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
$bfb_sdk->notify_bfb();
|
||||
exit('fail');
|
||||
89
codes/agent/game/api/payment/baifubao/pay.php
Normal file
89
codes/agent/game/api/payment/baifubao/pay.php
Normal file
@@ -0,0 +1,89 @@
|
||||
<?php
|
||||
/**
|
||||
* [Weizan System] Copyright (c) 2014 012WZ.COM
|
||||
* Weizan is NOT a free software, it under the license terms, visited http://www.012wz.com/ for more details.
|
||||
*/
|
||||
define('IN_MOBILE', true);
|
||||
require '../../framework/bootstrap.inc.php';
|
||||
$_GPC['i'] = !empty($_GPC['i']) ? $_GPC['i'] : $_GET['extra'];
|
||||
require '../../app/common/bootstrap.app.inc.php';
|
||||
load()->app('common');
|
||||
load()->app('template');
|
||||
|
||||
$sl = $_GPC['ps'];
|
||||
$params = @json_decode(base64_decode($sl), true);
|
||||
|
||||
$setting = uni_setting($_W['uniacid'], array('payment'));
|
||||
if(!is_array($setting['payment'])) {
|
||||
exit('没有设定支付参数.');
|
||||
}
|
||||
$payment = $setting['payment']['baifubao'];
|
||||
require 'bfb_sdk.php';
|
||||
|
||||
if (!empty($_GPC['pay_result']) && $_GPC['pay_result'] == '1') {
|
||||
$bfb_sdk = new bfb_sdk();
|
||||
if (true === $bfb_sdk->check_bfb_pay_result_notify()) {
|
||||
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniontid`=:uniontid';
|
||||
$params = array();
|
||||
$params[':uniontid'] = $_GPC['order_no'];
|
||||
$log = pdo_fetch($sql, $params);
|
||||
$site = WeUtility::createModuleSite($log['module']);
|
||||
if(!is_error($site)) {
|
||||
$method = 'payResult';
|
||||
if (method_exists($site, $method)) {
|
||||
$ret = array();
|
||||
$ret['weid'] = $log['uniacid'];
|
||||
$ret['uniacid'] = $log['uniacid'];
|
||||
$ret['result'] = 'success';
|
||||
$ret['type'] = $log['type'];
|
||||
$ret['from'] = 'return';
|
||||
$ret['tid'] = $log['tid'];
|
||||
$ret['uniontid'] = $log['uniontid'];
|
||||
$ret['user'] = $log['openid'];
|
||||
$ret['fee'] = $log['fee'];
|
||||
$ret['tag'] = $log['tag'];
|
||||
$site->$method($ret);
|
||||
$bfb_sdk->notify_bfb();
|
||||
exit('success');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `plid`=:plid';
|
||||
$paylog = pdo_fetch($sql, array(':plid' => $params['tid']));
|
||||
if(!empty($paylog) && $paylog['status'] != '0') {
|
||||
exit('这个订单已经支付成功, 不需要重复支付.');
|
||||
}
|
||||
$auth = sha1($sl . $paylog['uniacid'] . $_W['config']['setting']['authkey']);
|
||||
if($auth != $_GPC['auth']) {
|
||||
exit('参数传输错误.');
|
||||
}
|
||||
$_W['openid'] = intval($paylog['openid']);
|
||||
$bfb_sdk = new bfb_sdk();
|
||||
|
||||
$params = array (
|
||||
'service_code' => sp_conf::BFB_PAY_INTERFACE_SERVICE_ID,
|
||||
'sp_no' => sp_conf::$SP_NO,
|
||||
'order_create_time' => date("YmdHis"),
|
||||
'order_no' => $paylog['uniontid'],
|
||||
'goods_name' => iconv('utf-8', 'gbk', $params['title']),
|
||||
'total_amount' => $params['fee'] * 100,
|
||||
'currency' => sp_conf::BFB_INTERFACE_CURRENTCY,
|
||||
'buyer_sp_username' => $_W['openid'],
|
||||
'return_url' => $_W['siteroot'] . 'notify.php',
|
||||
'page_url' => $_W['siteroot'] . 'pay.php',
|
||||
'pay_type' => '2',
|
||||
'bank_no' => '201',
|
||||
'expire_time' => date('YmdHis', strtotime('+15 day')),
|
||||
'input_charset' => sp_conf::BFB_INTERFACE_ENCODING,
|
||||
'version' => sp_conf::BFB_INTERFACE_VERSION,
|
||||
'sign_method' => sp_conf::SIGN_METHOD_MD5,
|
||||
'extra' => $_W['uniacid'],
|
||||
);
|
||||
|
||||
$order_url = $bfb_sdk->create_baifubao_pay_order_url($params, sp_conf::BFB_PAY_WAP_DIRECT_URL);
|
||||
if(false !== $order_url) {
|
||||
echo "<script>window.location=\"" . $order_url . "\";</script>";
|
||||
exit;
|
||||
}
|
||||
Reference in New Issue
Block a user