添加后台代理代码
This commit is contained in:
1
codes/agent/game/api/payment/alipay/bak/ap.js
Normal file
1
codes/agent/game/api/payment/alipay/bak/ap.js
Normal file
@@ -0,0 +1 @@
|
||||
(function(){var b={};var a={};a.PADCHAR="=";a.ALPHA="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";a.makeDOMException=function(){var f,d;try{return new DOMException(DOMException.INVALID_CHARACTER_ERR)}catch(d){var c=new Error("DOM Exception 5");c.code=c.number=5;c.name=c.description="INVALID_CHARACTER_ERR";c.toString=function(){return"Error: "+c.name+": "+c.message};return c}};a.getbyte64=function(e,d){var c=a.ALPHA.indexOf(e.charAt(d));if(c===-1){throw a.makeDOMException()}return c};a.decode=function(f){f=""+f;var j=a.getbyte64;var h,e,g;var d=f.length;if(d===0){return f}if(d%4!==0){throw a.makeDOMException()}h=0;if(f.charAt(d-1)===a.PADCHAR){h=1;if(f.charAt(d-2)===a.PADCHAR){h=2}d-=4}var c=[];for(e=0;e<d;e+=4){g=(j(f,e)<<18)|(j(f,e+1)<<12)|(j(f,e+2)<<6)|j(f,e+3);c.push(String.fromCharCode(g>>16,(g>>8)&255,g&255))}switch(h){case 1:g=(j(f,e)<<18)|(j(f,e+1)<<12)|(j(f,e+2)<<6);c.push(String.fromCharCode(g>>16,(g>>8)&255));break;case 2:g=(j(f,e)<<18)|(j(f,e+1)<<12);c.push(String.fromCharCode(g>>16));break}return c.join("")};a.getbyte=function(e,d){var c=e.charCodeAt(d);if(c>255){throw a.makeDOMException()}return c};a.encode=function(f){if(arguments.length!==1){throw new SyntaxError("Not enough arguments")}var g=a.PADCHAR;var h=a.ALPHA;var k=a.getbyte;var e,j;var c=[];f=""+f;var d=f.length-f.length%3;if(f.length===0){return f}for(e=0;e<d;e+=3){j=(k(f,e)<<16)|(k(f,e+1)<<8)|k(f,e+2);c.push(h.charAt(j>>18));c.push(h.charAt((j>>12)&63));c.push(h.charAt((j>>6)&63));c.push(h.charAt(j&63))}switch(f.length-d){case 1:j=k(f,e)<<16;c.push(h.charAt(j>>18)+h.charAt((j>>12)&63)+g+g);break;case 2:j=(k(f,e)<<16)|(k(f,e+1)<<8);c.push(h.charAt(j>>18)+h.charAt((j>>12)&63)+h.charAt((j>>6)&63)+g);break}return c.join("")};b.pay=function(d){var c=encodeURIComponent(a.encode(d));location.href="../payment/alipay/pay.htm?goto="+c};b.decode=function(c){return a.decode(decodeURIComponent(c))};window._AP=b})();
|
||||
4
codes/agent/game/api/payment/alipay/bak/merchant.php
Normal file
4
codes/agent/game/api/payment/alipay/bak/merchant.php
Normal file
@@ -0,0 +1,4 @@
|
||||
<?php
|
||||
define('IN_MOBILE', true);
|
||||
require '../../source/bootstrap.inc.php';
|
||||
message('支付失败, 请稍后重试.');
|
||||
75
codes/agent/game/api/payment/alipay/bak/notify.php
Normal file
75
codes/agent/game/api/payment/alipay/bak/notify.php
Normal file
@@ -0,0 +1,75 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
define('IN_MOBILE', true);
|
||||
|
||||
if(!empty($_POST)) {
|
||||
$out_trade_no = $_POST['out_trade_no'];
|
||||
require '../../framework/bootstrap.inc.php';
|
||||
$_W['uniacid'] = $_W['weid'] = $_POST['body'];
|
||||
$setting = uni_setting($_W['uniacid'], array('payment'));
|
||||
if(is_array($setting['payment'])) {
|
||||
$alipay = $setting['payment']['alipay'];
|
||||
if(!empty($alipay)) {
|
||||
$prepares = array();
|
||||
foreach($_POST as $key => $value) {
|
||||
if($key != 'sign' && $key != 'sign_type') {
|
||||
$prepares[] = "{$key}={$value}";
|
||||
}
|
||||
}
|
||||
sort($prepares);
|
||||
$string = implode($prepares, '&');
|
||||
$string .= $alipay['secret'];
|
||||
$sign = md5($string);
|
||||
if($sign == $_POST['sign']) {
|
||||
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniontid`=:uniontid';
|
||||
$params = array();
|
||||
$params[':uniontid'] = $out_trade_no;
|
||||
$log = pdo_fetch($sql, $params);
|
||||
if(!empty($log) && $log['status'] == '0') {
|
||||
$log['transaction_id'] = $_POST['trade_no'];
|
||||
$record = array();
|
||||
$record['status'] = '1';
|
||||
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['weid'];
|
||||
$ret['uniacid'] = $log['uniacid'];
|
||||
$ret['result'] = 'success';
|
||||
$ret['type'] = $log['type'];
|
||||
$ret['from'] = 'notify';
|
||||
$ret['tid'] = $log['tid'];
|
||||
$ret['uniontid'] = $log['uniontid'];
|
||||
$ret['transaction_id'] = $log['transaction_id'];
|
||||
$ret['user'] = $log['openid'];
|
||||
$ret['fee'] = $log['fee'];
|
||||
$ret['is_usecard'] = $log['is_usecard'];
|
||||
$ret['card_type'] = $log['card_type'];
|
||||
$ret['card_fee'] = $log['card_fee'];
|
||||
$ret['card_id'] = $log['card_id'];
|
||||
$site->$method($ret);
|
||||
exit('success');
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
exit('fail');
|
||||
96
codes/agent/game/api/payment/alipay/bak/pay.htm
Normal file
96
codes/agent/game/api/payment/alipay/bak/pay.htm
Normal file
@@ -0,0 +1,96 @@
|
||||
<!DOCTYPE HTML>
|
||||
<html>
|
||||
<head>
|
||||
<meta charset="utf-8">
|
||||
<title>支付提示</title>
|
||||
<meta name="apple-mobile-web-app-capable" content="yes"/>
|
||||
<meta name="apple-mobile-web-app-status-bar-style" content="black"/>
|
||||
<meta name="format-detection" content="telephone=no"/>
|
||||
<meta name="format-detection" content="email=no"/>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0"/>
|
||||
<style>
|
||||
*, :before, :after {
|
||||
-webkit-tap-highlight-color: rgba(0, 0, 0, 0)
|
||||
}
|
||||
|
||||
body, div, dl, dt, dd, ul, ol, li, h1, h2, h3, h4, h5, h6, form, fieldset, legend, input, textarea, p, blockquote, th, td {
|
||||
margin: 0;
|
||||
padding: 0
|
||||
}
|
||||
|
||||
table {
|
||||
border-collapse: collapse;
|
||||
border-spacing: 0
|
||||
}
|
||||
|
||||
fieldset, img {
|
||||
border: 0
|
||||
}
|
||||
|
||||
li {
|
||||
list-style: none
|
||||
}
|
||||
|
||||
caption, th {
|
||||
text-align: left
|
||||
}
|
||||
|
||||
q:before, q:after {
|
||||
content: ""
|
||||
}
|
||||
|
||||
input:password {
|
||||
ime-mode: disabled
|
||||
}
|
||||
|
||||
:focus {
|
||||
outline: 0
|
||||
}
|
||||
|
||||
html, body {
|
||||
-webkit-touch-callout: none;
|
||||
touch-callout: none;
|
||||
-webkit-user-select: none;
|
||||
user-select: none;
|
||||
-webkit-tap-highlight-color: transparent;
|
||||
tap-highlight-color: transparent;
|
||||
height: 100%;
|
||||
margin: 0;
|
||||
padding: 0;
|
||||
text-align: center;
|
||||
font-size: 15px;
|
||||
font-weight: 300;
|
||||
font-family: "Helvetica Neue", Helvetica, Arial, "Lucida Grande", sans-serif
|
||||
}
|
||||
|
||||
a {
|
||||
text-decoration: none
|
||||
}
|
||||
|
||||
body {
|
||||
background: #F4F4F8
|
||||
}
|
||||
</style>
|
||||
</head>
|
||||
<body>
|
||||
<iframe width='100%' height='100%' id="alipayFrame" name="alipayFrame" style="position:absolute;z-index:4;left:0px;top:0px;bottom:0px;" frameborder="no" marginheight="0" marginwidth="0"></iframe>
|
||||
<script type="text/javascript" src="ap.js"></script>
|
||||
<script>
|
||||
if (location.hash.indexOf('error') != -1) {
|
||||
alert('参数错误,请检查');
|
||||
} else {
|
||||
var getQueryString = function (url, name) {
|
||||
var reg = new RegExp("(^|\\?|&)" + name + "=([^&]*)(\\s|&|$)", "i");
|
||||
if (reg.test(url)) return RegExp.$2.replace(/\+/g, " ");
|
||||
};
|
||||
var param = getQueryString(location.href, 'goto') || '';
|
||||
var iframe = document.getElementById('alipayFrame');
|
||||
iframe.src = _AP.decode(param);
|
||||
}
|
||||
document.addEventListener('WeixinJSBridgeReady', function onBridgeReady() {
|
||||
WeixinJSBridge.call('hideToolbar');
|
||||
WeixinJSBridge.call('showOptionMenu');
|
||||
});
|
||||
</script>
|
||||
</body>
|
||||
</html>
|
||||
83
codes/agent/game/api/payment/alipay/bak/return.php
Normal file
83
codes/agent/game/api/payment/alipay/bak/return.php
Normal file
@@ -0,0 +1,83 @@
|
||||
<?php
|
||||
error_reporting(0);
|
||||
define('IN_MOBILE', true);
|
||||
if (empty($_GET['out_trade_no'])) {
|
||||
exit('request failed.');
|
||||
}
|
||||
require '../../framework/bootstrap.inc.php';
|
||||
load()->app('common');
|
||||
load()->app('template');
|
||||
$_W['uniacid'] = $_W['weid'] = $_GET['body'];
|
||||
$setting = uni_setting($_W['uniacid'], array('payment'));
|
||||
if (!is_array($setting['payment'])) {
|
||||
exit('request failed.');
|
||||
}
|
||||
$alipay = $setting['payment']['alipay'];
|
||||
if (empty($alipay)) {
|
||||
exit('request failed.');
|
||||
}
|
||||
$prepares = array();
|
||||
foreach ($_GET as $key => $value) {
|
||||
if ($key != 'sign' && $key != 'sign_type') {
|
||||
$prepares[] = "{$key}={$value}";
|
||||
}
|
||||
}
|
||||
sort($prepares);
|
||||
$string = implode($prepares, '&');
|
||||
$string .= $alipay['secret'];
|
||||
$sign = md5($string);
|
||||
if($sign == $_GET['sign'] && $_GET['is_success'] == 'T' && ($_GET['trade_status'] == 'TRADE_FINISHED' || $_GET['trade_status'] == 'TRADE_SUCCESS')) {
|
||||
$sql = 'SELECT * FROM ' . tablename('core_paylog') . ' WHERE `uniontid`=:uniontid';
|
||||
$params = array();
|
||||
$params[':uniontid'] = $_GET['out_trade_no'];
|
||||
$log = pdo_fetch($sql, $params);
|
||||
if (!empty($log)) {
|
||||
if (!empty($log['status'])) {
|
||||
$record = array();
|
||||
$record['status'] = $log['status'] = '1';
|
||||
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 {$condition} LIMIT 1", array(':aid' => $_W['uniacid'], ':uid' => $log['openid'], ':cid' => $log['card_id']));
|
||||
}
|
||||
}
|
||||
$site = WeUtility::createModuleSite($log['module']);
|
||||
if (!is_error($site)) {
|
||||
$site->weid = $_W['weid'];
|
||||
$site->uniacid = $_W['uniacid'];
|
||||
$site->inMobile = true;
|
||||
$method = 'payResult';
|
||||
if (method_exists($site, $method)) {
|
||||
$ret = array();
|
||||
$ret['weid'] = $log['weid'];
|
||||
$ret['uniacid'] = $log['uniacid'];
|
||||
$ret['acid'] = $log['acid'];
|
||||
$ret['uniontid'] = $log['uniontid'];
|
||||
$ret['result'] = $log['status'] == '1' ? 'success' : 'failed';
|
||||
$ret['type'] = $log['type'];
|
||||
$ret['from'] = 'notify';
|
||||
$ret['tid'] = $log['tid'];
|
||||
$ret['user'] = $log['openid'];
|
||||
$ret['fee'] = $log['fee'];
|
||||
$ret['is_usecard'] = $log['is_usecard'];
|
||||
$ret['card_type'] = $log['card_type'];
|
||||
$ret['card_fee'] = $log['card_fee'];
|
||||
$ret['card_id'] = $log['card_id'];
|
||||
$site->$method($ret);
|
||||
$ret['from'] = 'return';
|
||||
exit($site->$method($ret));
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
message('支付异常,请返回微信客户端查看订单状态或是联系管理员', '', 'error');
|
||||
}
|
||||
Reference in New Issue
Block a user