增加码支付,使用方法看wiki

前端端口偏移
Abner 9 years ago
parent 722336f905
commit 376cc28048

@ -0,0 +1,28 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>ss-panel-v3-mod_UIChanges</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>com.aptana.ide.core.unifiedBuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>com.aptana.projects.webnature</nature>
</natures>
<filteredResources>
<filter>
<id>1522297588605</id>
<name></name>
<type>26</type>
<matcher>
<id>org.eclipse.ui.ide.multiFilter</id>
<arguments>1.0-name-matches-false-false-node_modules</arguments>
</matcher>
</filter>
</filteredResources>
</projectDescription>

@ -105,6 +105,16 @@ class HomeController extends BaseController
return $newResponse; return $newResponse;
} }
public function codepay_callback($request, $response, $args)
{
echo '
<script>
window.location.href="/user/code";
</script>
';
return;
}
public function pay_callback($request, $response, $args) public function pay_callback($request, $response, $args)
{ {
Pay::callback($request); Pay::callback($request);

@ -280,6 +280,62 @@ class UserController extends BaseController
return $this->view()->assign('codes', $codes)->assign('total_in', Code::where('isused', 1)->where('type', -1)->sum('number'))->assign('total_out', Code::where('isused', 1)->where('type', -2)->sum('number'))->display('user/donate.tpl'); return $this->view()->assign('codes', $codes)->assign('total_in', Code::where('isused', 1)->where('type', -1)->sum('number'))->assign('total_out', Code::where('isused', 1)->where('type', -2)->sum('number'))->display('user/donate.tpl');
} }
function isHTTPS()
{
define('HTTPS', false);
if (defined('HTTPS') && HTTPS) return true;
if (!isset($_SERVER)) return FALSE;
if (!isset($_SERVER['HTTPS'])) return FALSE;
if ($_SERVER['HTTPS'] === 1) { //Apache
return TRUE;
} elseif ($_SERVER['HTTPS'] === 'on') { //IIS
return TRUE;
} elseif ($_SERVER['SERVER_PORT'] == 443) { //其他
return TRUE;
}
return FALSE;
}
public function codepay($request, $response, $args)
{
$codepay_id=Config::get('codepay_id');//这里改成码支付ID
$codepay_key=Config::get('codepay_key'); //这是您的通讯密钥
$uid = $this->user->id;
$price = $request->getParam('price');
$type = $request->getParam('type');
$url = (UserController::isHTTPS() ? 'https://' : 'http://').$_SERVER['HTTP_HOST'];
$data = array(
"id" => $codepay_id,//你的码支付ID
"pay_id" => $uid, //唯一标识 可以是用户ID,用户名,session_id(),订单ID,ip 付款后返回
"type" => $type,//1支付宝支付 2QQ钱包 3微信支付
"price" => $price,//金额100元
"param" => "",//自定义参数
"notify_url"=> $url.'/codepay_callback',//通知地址
"return_url"=> $url.'/codepay_callback',//跳转地址
); //构造需要传递的参数
ksort($data); //重新排序$data数组
reset($data); //内部指针指向数组中的第一个元素
$sign = ''; //初始化需要签名的字符为空
$urls = ''; //初始化URL参数为空
foreach ($data AS $key => $val) { //遍历需要传递的参数
if ($val == ''||$key == 'sign') continue; //跳过这些不参数签名
if ($sign != '') { //后面追加&拼接URL
$sign .= "&";
$urls .= "&";
}
$sign .= "$key=$val"; //拼接为url参数形式
$urls .= "$key=" . urlencode($val); //拼接为url参数形式并URL编码参数值
}
$query = $urls . '&sign=' . md5($sign .$codepay_key); //创建订单所需的参数
$url = "http://api2.fateqq.com:52888/creat_order/?".$query; //支付页面
header("Location:".$url);
}
public function code_check($request, $response, $args) public function code_check($request, $response, $args)

@ -23,6 +23,8 @@ class Pay
return Pay::f2fpay_html($user); return Pay::f2fpay_html($user);
case 'yftpay': case 'yftpay':
return Pay::yftpay_html($user); return Pay::yftpay_html($user);
case 'codepay':
return Pay::codepay_html($user);
default: default:
return ""; return "";
} }
@ -95,6 +97,22 @@ class Pay
</form> </form>
'; ';
} }
private static function codepay_html($user)
{
return '
<p class="card-heading">请输入充值金额</p>
<form name="codepay" action="/user/code/codepay" method="get">
<input class="form-control" id="price" name="price" placeholder="输入充值金额后,点击你要付款的应用图标即可" autofocus="autofocus" type="number" min="0.01" max="1000" step="0.01" required="required">
<br>
<button class="btn btn-flat waves-attach" id="btnSubmit" type="submit" name="type" value="1" ><img src="/images/alipay.jpg" width="50px" height="50px" /></button>
<button class="btn btn-flat waves-attach" id="btnSubmit" type="submit" name="type" value="2" ><img src="/images/qqpay.jpg" width="50px" height="50px" /></button>
<button class="btn btn-flat waves-attach" id="btnSubmit" type="submit" name="type" value="3" disabled><img src="/images/weixin.jpg" width="50px" height="50px" /></button>
</form>
';
}
private static function pmw_html($user) private static function pmw_html($user)
{ {
\Paymentwall_Config::getInstance()->set(array( \Paymentwall_Config::getInstance()->set(array(
@ -658,6 +676,116 @@ class Pay
echo "fail"; //请不要修改或删除 echo "fail"; //请不要修改或删除
} }
} }
private static function codepay_callback(){
//以下五行无需更改
ksort($_POST); //排序post参数
reset($_POST); //内部指针指向数组中的第一个元素
$codepay_key=Config::get('codepay_key'); //这是您的密钥
$sign = '';//初始化
foreach ($_POST AS $key => $val) { //遍历POST参数
if ($val == '' || $key == 'sign') continue; //跳过这些不签名
if ($sign) $sign .= '&'; //第一个字符串签名不加& 其他加&连接起来参数
$sign .= "$key=$val"; //拼接为url参数形式
}
if (!$_POST['pay_no'] || md5($sign . $codepay_key) != $_POST['sign']) { //不合法的数据
exit('fail'); //返回成功 不要删除哦
} else { //合法的数据
//业务处理
$pay_id = $_POST['pay_id']; //需要充值的ID 或订单号 或用户名
$money = (float)$_POST['money']; //实际付款金额
$price = (float)$_POST['price']; //订单的原价
//$param = $_POST['param']; //自定义参数
$pay_no = $_POST['pay_no']; //流水号
$codeq=Code::where("code", "=", $pay_no)->first();
if ($codeq==null){
$user=User::find($pay_id);
$codeq=new Code();
$codeq->code=$pay_no;
$codeq->isused=1;
$codeq->type=-1;
$codeq->number=$price;
$codeq->usedatetime=date("Y-m-d H:i:s");
$codeq->userid=$user->id;
$codeq->save();
$user->money=$user->money+$price;
$user->save();
//更新返利
if ($user->ref_by!=""&&$user->ref_by!=0&&$user->ref_by!=null) {
$gift_user=User::where("id", "=", $user->ref_by)->first();
$gift_user->money=($gift_user->money+($codeq->number*(Config::get('code_payback')/100)));
$gift_user->save();
$Payback=new Payback();
$Payback->total=$total;
$Payback->userid=$user->id;
$Payback->ref_by=$user->ref_by;
$Payback->ref_get=$codeq->number*(Config::get('code_payback')/100);
$Payback->datetime=time();
$Payback->save();
}
exit('success'); //返回成功 不要删除哦
}
}
if ($codeq!=null){
echo '
<script>
alert("支付成功,第三方支付小飞机pay祝您购物愉快");
window.location.href="/user/code";
</script>
';
return;
}
}
private static function notify(){
//系统订单号
$trade_no = $_POST['pay_no'];
//交易用户
$trade_id = strtok($_POST['pay_id'], "@");
//金额
$trade_num = $_POST['price'];
$param = urldecode($_POST['param']);
$codeq=Code::where("code", "=", $trade_no)->first();
if($codeq!=null){
exit('success'); //说明数据已经处理完毕
return;
}
if($param!=Config::get('alipay')||$trade_no==''){ //鉴权失败
exit('fail');
return;
}
//更新用户账户
$user=User::find($trade_id);
$codeq=new Code();
$codeq->code=$trade_no;
$codeq->isused=1;
$codeq->type=-1;
$codeq->number=$_POST['price'];
$codeq->usedatetime=date("Y-m-d H:i:s");
$codeq->userid=$user->id;
$codeq->save();
$user->money=$user->money+$trade_num;
$user->save();
//更新返利
if ($user->ref_by!=""&&$user->ref_by!=0&&$user->ref_by!=null) {
$gift_user=User::where("id", "=", $user->ref_by)->first();
$gift_user->money=($gift_user->money+($codeq->number*(Config::get('code_payback')/100)));
$gift_user->save();
$Payback=new Payback();
$Payback->total=$trade_num;
$Payback->userid=$user->id;
$Payback->ref_by=$user->ref_by;
$Payback->ref_get=$codeq->number*(Config::get('code_payback')/100);
$Payback->datetime=time();
$Payback->save();
}
exit('success'); //返回成功 不要删除哦
}
public static function callback($request) public static function callback($request)
{ {
$driver = Config::get("payment_system"); $driver = Config::get("payment_system");
@ -670,6 +798,8 @@ class Pay
return Pay::zfbjk_callback($request); return Pay::zfbjk_callback($request);
case 'f2fpay': case 'f2fpay':
return Pay::f2fpay_callback(); return Pay::f2fpay_callback();
case 'codepay':
return Pay::codepay_callback();
default: default:
return ""; return "";
} }

@ -296,9 +296,14 @@ $System_Config['sendgrid_sender'] = '';
#支付系统 #支付系统
#取值 doiampay,paymentwall,zfbjk,spay,f2fpay,yftpay,none #取值 codepay,doiampay,paymentwall,zfbjk,spay,f2fpay,yftpay,none
$System_Config['payment_system']='none'; $System_Config['payment_system']='none';
#codepay码支付
#wiki地址:https://github.com/NimaQu/ss-panel-v3-mod_UIChanges/wiki/%E7%A0%81%E6%94%AF%E4%BB%98%E5%AF%B9%E6%8E%A5%E6%95%99%E7%A8%8B/
$System_Config['codepay_id']='';//码支付ID
$System_Config['codepay_key']='';//码支付通信密钥
#doiampay,https://www.daimiyun.cn/v3/ #doiampay,https://www.daimiyun.cn/v3/
$System_Config['doiampay']=[ $System_Config['doiampay']=[
'enabled' => [ 'enabled' => [

@ -72,6 +72,7 @@ $app->get('/404', 'App\Controllers\HomeController:page404');
$app->get('/405', 'App\Controllers\HomeController:page405'); $app->get('/405', 'App\Controllers\HomeController:page405');
$app->get('/500', 'App\Controllers\HomeController:page500'); $app->get('/500', 'App\Controllers\HomeController:page500');
$app->get('/pwm_pingback', 'App\Controllers\HomeController:pay_callback'); $app->get('/pwm_pingback', 'App\Controllers\HomeController:pay_callback');
$app->post('/notify', 'App\Controllers\HomeController:notify');
$app->post('/alipay_callback', 'App\Controllers\HomeController:pay_callback'); $app->post('/alipay_callback', 'App\Controllers\HomeController:pay_callback');
$app->post('/pay_callback', 'App\Controllers\HomeController:pay_callback'); $app->post('/pay_callback', 'App\Controllers\HomeController:pay_callback');
$app->get('/pay_callback', 'App\Controllers\HomeController:pay_callback'); $app->get('/pay_callback', 'App\Controllers\HomeController:pay_callback');
@ -81,7 +82,8 @@ $app->get('/staff', 'App\Controllers\HomeController:staff');
$app->get('/gfwlistjs', 'App\Controllers\LinkController:GetGfwlistJs'); $app->get('/gfwlistjs', 'App\Controllers\LinkController:GetGfwlistJs');
$app->post('/telegram_callback', 'App\Controllers\HomeController:telegram'); $app->post('/telegram_callback', 'App\Controllers\HomeController:telegram');
$app->get('/yft/notify','App\Controllers\YFTPayCallBackController:yft_notify'); $app->get('/yft/notify','App\Controllers\YFTPayCallBackController:yft_notify');
$app->get('/codepay_callback', 'App\Controllers\HomeController:codepay_callback');
$app->post('/codepay_callback', 'App\Controllers\HomeController:pay_callback');
// User Center // User Center
@ -147,6 +149,7 @@ $app->group('/user', function () {
$this->get('/alipay', 'App\Controllers\UserController:alipay'); $this->get('/alipay', 'App\Controllers\UserController:alipay');
$this->post('/code/f2fpay', 'App\Controllers\UserController:f2fpay'); $this->post('/code/f2fpay', 'App\Controllers\UserController:f2fpay');
$this->get('/code/f2fpay', 'App\Controllers\UserController:f2fpayget'); $this->get('/code/f2fpay', 'App\Controllers\UserController:f2fpayget');
$this->get('/code/codepay', 'App\Controllers\UserController:codepay');
$this->get('/code_check', 'App\Controllers\UserController:code_check'); $this->get('/code_check', 'App\Controllers\UserController:code_check');
$this->post('/code', 'App\Controllers\UserController:codepost'); $this->post('/code', 'App\Controllers\UserController:codepost');
$this->post('/gacheck', 'App\Controllers\UserController:GaCheck'); $this->post('/gacheck', 'App\Controllers\UserController:GaCheck');

Binary file not shown.

After

Width:  |  Height:  |  Size: 31 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 40 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB

Loading…
Cancel
Save