From 74726f0cabd83fe91621ba3003b77f165dc3d848 Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 15:57:29 +0800
Subject: [PATCH 1/8] gopay
---
Application/Sdk/View/default/Spend/paycallback.html | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Application/Sdk/View/default/Spend/paycallback.html b/Application/Sdk/View/default/Spend/paycallback.html
index 6a4afe28..d4461dfb 100644
--- a/Application/Sdk/View/default/Spend/paycallback.html
+++ b/Application/Sdk/View/default/Spend/paycallback.html
@@ -61,7 +61,7 @@
$(function() {
$(window).load( function(){
if ($(".gopay").val() == 1) {
- window.location.hef = $(".gopay_url").val();
+ window.location.href = $(".gopay_url").val();
}
});
From f170881e441da0159c96bf3e039679306ce4bde1 Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 16:00:14 +0800
Subject: [PATCH 2/8] gopay
---
Application/Sdk/Controller/PayH5Controller.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php
index df9dc41e..a96f981f 100644
--- a/Application/Sdk/Controller/PayH5Controller.class.php
+++ b/Application/Sdk/Controller/PayH5Controller.class.php
@@ -1161,7 +1161,7 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
if($is_pay['status']==1){
if($request['code']==1){
- $json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}";
+ $json_data['url'] = $is_pay['mweb_url'];//.'&redirect_url='.C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}";
$request['pay_url'] = $json_data['url'];
$this->add_spend($request,1);
From a1d141439312977129ce4c1f2bd80e3b92be51e6 Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 16:02:49 +0800
Subject: [PATCH 3/8] gopay
---
Application/Sdk/Controller/PayH5Controller.class.php | 2 +-
Application/Sdk/View/default/Spend/paycallback.html | 1 -
2 files changed, 1 insertion(+), 2 deletions(-)
diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php
index a96f981f..df9dc41e 100644
--- a/Application/Sdk/Controller/PayH5Controller.class.php
+++ b/Application/Sdk/Controller/PayH5Controller.class.php
@@ -1161,7 +1161,7 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
if($is_pay['status']==1){
if($request['code']==1){
- $json_data['url'] = $is_pay['mweb_url'];//.'&redirect_url='.C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}";
+ $json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}";
$request['pay_url'] = $json_data['url'];
$this->add_spend($request,1);
diff --git a/Application/Sdk/View/default/Spend/paycallback.html b/Application/Sdk/View/default/Spend/paycallback.html
index d4461dfb..288b848c 100644
--- a/Application/Sdk/View/default/Spend/paycallback.html
+++ b/Application/Sdk/View/default/Spend/paycallback.html
@@ -33,7 +33,6 @@
- {$gopay_url}
继续支付
From d5633d744e774bf969fba4030f12846be3a6dc8e Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 16:04:30 +0800
Subject: [PATCH 4/8] gopay
---
Application/Sdk/Controller/PayH5Controller.class.php | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php
index df9dc41e..ccedbeb7 100644
--- a/Application/Sdk/Controller/PayH5Controller.class.php
+++ b/Application/Sdk/Controller/PayH5Controller.class.php
@@ -1161,7 +1161,7 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
if($is_pay['status']==1){
if($request['code']==1){
- $json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}";
+ $json_data['url'] = $is_pay['mweb_url'].'&redirect_url='.urlencode(C('PAY_DOMAIN')."sdk.php/Spend/paycallback/orderno/{$request['pay_order_number']}/game_id/{$request['game_id']}/paytype/weixinpay");
$request['pay_url'] = $json_data['url'];
$this->add_spend($request,1);
From fd413dd9a4caf64cfa4f39885586ee59f345a6a1 Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 17:23:44 +0800
Subject: [PATCH 5/8] new_set_message
---
Application/Sdk/Controller/UserController.class.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php
index 9c30b6e5..2f901c17 100644
--- a/Application/Sdk/Controller/UserController.class.php
+++ b/Application/Sdk/Controller/UserController.class.php
@@ -927,7 +927,7 @@ class UserController extends BaseController
}
if(strlen($nickname_len) > 16){
- $this -> set_message(1027, "fail", "昵称过长");
+ $this -> new_set_message(1027, "fail", "昵称过长");
}
$nk = M('User', 'tab_') -> field('id,account,nickname') -> where(['nickname' => $user['nickname']]) -> find();
if (!empty($nk) && is_array($nk) && $user['user_id'] != $nk['id']) {
@@ -937,7 +937,7 @@ class UserController extends BaseController
break;
case 'pwd':
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,15}$/', $user['password'])){
- $this -> set_message(1027, "fail", "密码必须6-15位字母和数字组合");
+ $this -> new_set_message(1027, "fail", "密码必须6-15位字母和数字组合");
}
if ($user['old_password'] == $user['password']) {
From a50449bc0d8c2dec0e0530577ccfe77c1f1eef04 Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 17:25:17 +0800
Subject: [PATCH 6/8] new_set_message
---
Application/Sdk/Controller/UserController.class.php | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/Application/Sdk/Controller/UserController.class.php b/Application/Sdk/Controller/UserController.class.php
index 2f901c17..dca5a34b 100644
--- a/Application/Sdk/Controller/UserController.class.php
+++ b/Application/Sdk/Controller/UserController.class.php
@@ -927,7 +927,7 @@ class UserController extends BaseController
}
if(strlen($nickname_len) > 16){
- $this -> new_set_message(1027, "fail", "昵称过长");
+ $this -> new_set_message(1027, "昵称过长");
}
$nk = M('User', 'tab_') -> field('id,account,nickname') -> where(['nickname' => $user['nickname']]) -> find();
if (!empty($nk) && is_array($nk) && $user['user_id'] != $nk['id']) {
@@ -937,7 +937,7 @@ class UserController extends BaseController
break;
case 'pwd':
if(!preg_match('/^(?![^a-zA-Z]+$)(?!\D+$).{6,15}$/', $user['password'])){
- $this -> new_set_message(1027, "fail", "密码必须6-15位字母和数字组合");
+ $this -> new_set_message(1027, "密码必须6-15位字母和数字组合");
}
if ($user['old_password'] == $user['password']) {
From a9efb0d08bba5e74fd8ff4537e12cf78130839a8 Mon Sep 17 00:00:00 2001
From: tpingzhang <635929049@qq.com>
Date: Mon, 4 Nov 2019 17:48:19 +0800
Subject: [PATCH 7/8] gopay
---
.../Sdk/Controller/PayH5Controller.class.php | 31 ++++++++--
.../Sdk/Controller/SpendController.class.php | 10 ++-
.../Sdk/View/default/Spend/pay_way.html | 39 +-----------
.../Sdk/View/default/Spend/paycallback.html | 61 +++++++------------
4 files changed, 58 insertions(+), 83 deletions(-)
diff --git a/Application/Sdk/Controller/PayH5Controller.class.php b/Application/Sdk/Controller/PayH5Controller.class.php
index ccedbeb7..1138b04f 100644
--- a/Application/Sdk/Controller/PayH5Controller.class.php
+++ b/Application/Sdk/Controller/PayH5Controller.class.php
@@ -238,7 +238,7 @@ class PayH5Controller extends BaseController{
/**
*支付宝移动支付
*/
- public function apple_alipay_pay($user_id,$game_id){
+ public function ali_pay($user_id,$game_id){
#获取SDK上POST方式传过来的数据 然后base64解密 然后将json字符串转化成数组
//echo json_encode(['code'=>0,'msg'=> $user_id."game:".$game_id]);exit;
$file=file_get_contents("./Application/Sdk/OrderNo/".$user_id."-".$game_id.".txt");
@@ -290,10 +290,11 @@ class PayH5Controller extends BaseController{
$request['body']=$request['price'];
//$request['callback'] = 'http://'.$_SERVER['HTTP_HOST']. "/sdk.php/Spend/pay_success/orderno/".$request['pay_order_number'].'/game_id/'.$request['game_id'];
//$request['notifyurl'] = 'http://'.$_SERVER['HTTP_HOST']. "/callback.php/Notify/notify/apitype/alipay/method/notify";
+
$pay_url=$this->pay($request);
- //echo $pay_url['url'];die;
- //redirect($pay_url['url']);
- echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>$pay_url['url'],'wap'=>1]]);exit;
+ $request['pay_url'] = $pay_url['url'];
+ $orderno = $pay_url['out_trade_no'];
+// echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>$pay_url['url'],'wap'=>1]]);exit;
} else {/* app */
$game_set_data = get_game_set_info($request['game_id']);
$request['apitype'] = "alipay";
@@ -305,9 +306,18 @@ class PayH5Controller extends BaseController{
$data = $this->alipay_app_pay($request);
$md5_sign = $this->encrypt_md5(base64_encode($data['arg']), $game_set_data["access_key"]);
$data = array("orderInfo" => base64_encode($data['arg']), "out_trade_no" => $data['out_trade_no'], "order_sign" => $data['sign'], "md5_sign" => $md5_sign);
-
- echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>json_encode($data),'wap'=>0]]);exit;
+ $request['pay_url'] = json_encode($data);
+ $orderno = $data['out_trade_no'];
+// echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>json_encode($data),'wap'=>0]]);exit;
}
+ // 存入pay_url 继续支付
+ M("spend", "tab_")->where([
+ 'extend' => $request['extend'],
+ 'game_id' => $request['game_id'],
+ 'pay_order_number' => $pay_url['out_trade_no']
+ ])->save([
+ 'pay_url' => $request['pay_url']
+ ]);
}elseif(get_zfb_type() == 2) { // 双乾
@@ -392,6 +402,14 @@ class PayH5Controller extends BaseController{
echo json_encode(['code'=>200,'msg'=>'','data'=>['url'=>$pay_url['msg'],'wap'=>1]]);exit;
}
}
+
+ redirect(U('spend/paycallback', array(
+ 'sdk_version' => $request['sdk_version'],
+ 'paytype' => 'alipay',
+ 'orderno' => $orderno,
+ 'game_id' => $game_id,
+ 'gopay' => 1 // 立即支付
+ )));
}
private function alipay_app_pay($param = array())
@@ -1291,6 +1309,7 @@ ADD COLUMN `pay_url` text CHARACTER SET utf8 COLLATE utf8_general_ci NULL AFTER
}
}
redirect(U('spend/paycallback', array(
+ 'sdk_version' => $request['sdk_version'],
'paytype' => 'weixinpay',
'orderno' => $request['pay_order_number'],
'game_id' => $game_id,
diff --git a/Application/Sdk/Controller/SpendController.class.php b/Application/Sdk/Controller/SpendController.class.php
index 5976b7f4..8ea51023 100644
--- a/Application/Sdk/Controller/SpendController.class.php
+++ b/Application/Sdk/Controller/SpendController.class.php
@@ -6,6 +6,7 @@ use Think\Controller;
use Org\JtpaySDK\Jtpay;
use Org\SqpaySDK\Sqpay;
use Think\Log;
+use Qiniu\json_decode;
class SpendController extends Controller {
@@ -286,8 +287,13 @@ ADD COLUMN `pay_url` varchar(255) NOT NULL DEFAULT '' AFTER `check_sign`;
// if ($result['pay_way'] == C('PAY_WAY.ALIPAY') || $result['pay_way'] == C('PAY_WAY.SQ_ALIPAY'))
// $gopayUrl = "/sdk.php/PayH5/platform_alipay_pay/pay_order_number/{$result['pay_order_number']}/game_id/{$result['game_id']}/user_token/{$userToken}";
}
-// pp($gopayUrl);
-
+ // 如果是json格式 且是alipay 则 alipay app
+ if (json_decode($gopayUrl) && $paytype == 'alipay') {
+ $this->assign("aliapp", 1);
+ } else {
+ $this->assign("aliapp", 0);
+ }
+// pp($orderno);
$this->assign("orderno", $orderno);
$this->assign("paytype", $paytype);
$this->assign ('pay_url', $result['pay_url']);
diff --git a/Application/Sdk/View/default/Spend/pay_way.html b/Application/Sdk/View/default/Spend/pay_way.html
index d9eb7b8a..7c069fe6 100644
--- a/Application/Sdk/View/default/Spend/pay_way.html
+++ b/Application/Sdk/View/default/Spend/pay_way.html
@@ -170,7 +170,7 @@
-
+

@@ -280,43 +280,8 @@ $(function() {
if (flag) return ;
flag = true;
- var that = $(this),url = $.trim(that.attr('data-url'));
- if(that.hasClass('disabledbtn')){return false;}
- that.addClass('disabled');
- $.ajax({
- type:'post',
- dataType:'json',
- data:{},
- url:url,
- success:function(result) {
- if(result.code==200) {
- var data = result.data;
- if(data.wap==1) {
-
- location.href = data.url;
-
- } else if (data.wap==1) {
- window.webkit.messageHandlers.noticeAppResult.postMessage(data.url);
- }
- else {
- if ($('#sdk_version').val() == 1)
- window.txyxsdk.getZFBPay(data.url);
- else
- window.webkit.messageHandlers.noticeAppResult.postMessage(data.url);
- }
- } else {
- layer.open({
- content: result.msg
- ,skin: 'msg'
- ,time: 2 //2秒后自动关闭
- });
- }
- },error:function() {
- that.removeClass('disabledbtn');
- }
+ window.location.href = $(this).data('url');
- });
-
return false;
});
diff --git a/Application/Sdk/View/default/Spend/paycallback.html b/Application/Sdk/View/default/Spend/paycallback.html
index 288b848c..319ceb27 100644
--- a/Application/Sdk/View/default/Spend/paycallback.html
+++ b/Application/Sdk/View/default/Spend/paycallback.html
@@ -16,6 +16,7 @@
+