From d39b5a5f67b15a0d23ad6aaf6052efcfe06d39ed Mon Sep 17 00:00:00 2001 From: Rico Date: Wed, 27 Nov 2019 20:13:56 +0800 Subject: [PATCH 01/10] add idt pay --- .../Gateway/IDt/epay_core.function.php | 176 +++++++++++++ .../Gateway/IDt/epay_md5.function.php | 41 +++ .../Gateway/IDt/epay_notify.class.php | 121 +++++++++ .../Gateway/IDt/epay_submit.class.php | 98 +++++++ app/Services/Gateway/IDtPay.php | 241 ++++++++++++++++++ config/.config.example.php | 13 + 6 files changed, 690 insertions(+) create mode 100755 app/Services/Gateway/IDt/epay_core.function.php create mode 100755 app/Services/Gateway/IDt/epay_md5.function.php create mode 100755 app/Services/Gateway/IDt/epay_notify.class.php create mode 100755 app/Services/Gateway/IDt/epay_submit.class.php create mode 100644 app/Services/Gateway/IDtPay.php diff --git a/app/Services/Gateway/IDt/epay_core.function.php b/app/Services/Gateway/IDt/epay_core.function.php new file mode 100755 index 00000000..4f8dc58e --- /dev/null +++ b/app/Services/Gateway/IDt/epay_core.function.php @@ -0,0 +1,176 @@ + \ No newline at end of file diff --git a/app/Services/Gateway/IDt/epay_md5.function.php b/app/Services/Gateway/IDt/epay_md5.function.php new file mode 100755 index 00000000..7bb643fe --- /dev/null +++ b/app/Services/Gateway/IDt/epay_md5.function.php @@ -0,0 +1,41 @@ + \ No newline at end of file diff --git a/app/Services/Gateway/IDt/epay_notify.class.php b/app/Services/Gateway/IDt/epay_notify.class.php new file mode 100755 index 00000000..fbe41eff --- /dev/null +++ b/app/Services/Gateway/IDt/epay_notify.class.php @@ -0,0 +1,121 @@ +alipay_config = $alipay_config; + $this->http_verify_url = $this->alipay_config['apiurl'].'api.php?'; + } + function AlipayNotify($alipay_config) { + $this->__construct($alipay_config); + } + /** + * 针对notify_url验证消息是否是支付宝发出的合法消息 + * @return 验证结果 + */ + function verifyNotify(){ + if(empty($_GET)) {//判断POST来的数组是否为空 + return false; + } + else { + //生成签名结果 + $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]); + //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) + $responseTxt = 'true'; + //if (! empty($_POST["notify_id"])) {$responseTxt = $this->getResponse($_POST["notify_id"]);} + + //验证 + //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 + //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 + if (preg_match("/true$/i",$responseTxt) && $isSign) { + return true; + } else { + return false; + } + } + } + + /** + * 针对return_url验证消息是否是支付宝发出的合法消息 + * @return 验证结果 + */ + function verifyReturn(){ + if(empty($_GET)) {//判断POST来的数组是否为空 + return false; + } + else { + //生成签名结果 + $isSign = $this->getSignVeryfy($_GET, $_GET["sign"]); + //获取支付宝远程服务器ATN结果(验证是否是支付宝发来的消息) + $responseTxt = 'true'; + //if (! empty($_GET["notify_id"])) {$responseTxt = $this->getResponse($_GET["notify_id"]);} + + //验证 + //$responsetTxt的结果不是true,与服务器设置问题、合作身份者ID、notify_id一分钟失效有关 + //isSign的结果不是true,与安全校验码、请求时的参数格式(如:带自定义参数等)、编码格式有关 + if (preg_match("/true$/i",$responseTxt) && $isSign) { + return true; + } else { + return false; + } + } + } + + /** + * 获取返回时的签名验证结果 + * @param $para_temp 通知返回来的参数数组 + * @param $sign 返回的签名结果 + * @return 签名验证结果 + */ + function getSignVeryfy($para_temp, $sign) { + //除去待签名参数数组中的空值和签名参数 + $para_filter = paraFilter($para_temp); + + //对待签名参数数组排序 + $para_sort = argSort($para_filter); + + //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 + $prestr = createLinkstring($para_sort); + + $isSgin = false; + $isSgin = md5Verify($prestr, $sign, $this->alipay_config['key']); + + return $isSgin; + } + + /** + * 获取远程服务器ATN结果,验证返回URL + * @param $notify_id 通知校验ID + * @return 服务器ATN结果 + * 验证结果集: + * invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空 + * true 返回正确信息 + * false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟 + */ + function getResponse($notify_id) { + $transport = strtolower(trim($this->alipay_config['transport'])); + $partner = trim($this->alipay_config['partner']); + $veryfy_url = ''; + if($transport == 'https') { + $veryfy_url = $this->https_verify_url; + } + else { + $veryfy_url = $this->http_verify_url; + } + $veryfy_url = $veryfy_url."partner=" . $partner . "¬ify_id=" . $notify_id; + $responseTxt = getHttpResponseGET($veryfy_url, $this->alipay_config['cacert']); + + return $responseTxt; + } +} +?> diff --git a/app/Services/Gateway/IDt/epay_submit.class.php b/app/Services/Gateway/IDt/epay_submit.class.php new file mode 100755 index 00000000..a50c9bc5 --- /dev/null +++ b/app/Services/Gateway/IDt/epay_submit.class.php @@ -0,0 +1,98 @@ +alipay_config = $alipay_config; + $this->alipay_gateway_new = $this->alipay_config['apiurl'].'submit.php?'; + } + function AlipaySubmit($alipay_config) { + $this->__construct($alipay_config); + } + + /** + * 生成签名结果 + * @param $para_sort 已排序要签名的数组 + * return 签名结果字符串 + */ + function buildRequestMysign($para_sort) { + //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串 + $prestr = createLinkstring($para_sort); + + $mysign = md5Sign($prestr, $this->alipay_config['key']); + + return $mysign; + } + + /** + * 生成要请求给支付宝的参数数组 + * @param $para_temp 请求前的参数数组 + * @return 要请求的参数数组 + */ + function buildRequestPara($para_temp) { + //除去待签名参数数组中的空值和签名参数 + $para_filter = paraFilter($para_temp); + + //对待签名参数数组排序 + $para_sort = argSort($para_filter); + + //生成签名结果 + $mysign = $this->buildRequestMysign($para_sort); + + //签名结果与签名方式加入请求提交参数组中 + $para_sort['sign'] = $mysign; + $para_sort['sign_type'] = strtoupper(trim($this->alipay_config['sign_type'])); + + return $para_sort; + } + + /** + * 生成要请求给支付宝的参数数组 + * @param $para_temp 请求前的参数数组 + * @return 要请求的参数数组字符串 + */ + function buildRequestParaToString($para_temp) { + //待请求参数数组 + $para = $this->buildRequestPara($para_temp); + + //把参数组中所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串,并对字符串做urlencode编码 + $request_data = createLinkstringUrlencode($para); + + return $request_data; + } + + /** + * 建立请求,以表单HTML形式构造(默认) + * @param $para_temp 请求参数数组 + * @param $method 提交方式。两个值可选:post、get + * @param $button_name 确认按钮显示文字 + * @return 提交表单HTML文本 + */ + function buildRequestForm($para_temp, $method='POST', $button_name='正在跳转') { + //待请求参数数组 + $para = $this->buildRequestPara($para_temp); + + $sHtml = "
"; + while (list ($key, $val) = each ($para)) { + $sHtml.= ""; + } + + //submit按钮控件请不要含有name属性 + $sHtml = $sHtml."
"; + + $sHtml = $sHtml.""; + + return $sHtml; + } +} +?> \ No newline at end of file diff --git a/app/Services/Gateway/IDtPay.php b/app/Services/Gateway/IDtPay.php new file mode 100644 index 00000000..c9ca7104 --- /dev/null +++ b/app/Services/Gateway/IDtPay.php @@ -0,0 +1,241 @@ +getParsedBodyParam('type'); + $price = $request->getParsedBodyParam('price'); + if ($price <= 0) { + return $response->write(json_encode(['errcode' => -1, 'errmsg' => "非法的金额."])); + } + $user = Auth::getUser(); + $pl = new Paylist(); + $pl->userid = $user->id; + $pl->total = $price; + $pl->tradeno = self::generateGuid(); + $pl->save(); + + $settings = Config::get("idtpay"); + $alipay_config = array( + 'partner' => $settings['partner'], + 'key' => $settings['key'], + 'sign_type' => $settings['sign_type'], + 'input_charset' => $settings['input_charset'], + 'transport' => $settings['transport'], + 'apiurl' => $settings['apiurl'] + ); + + + /**************************请求参数**************************/ + $notify_url = $alipay_config['apiurl']."/payment/notify"; + //需http://格式的完整路径,不能加?id=123这类自定义参数 + + //页面跳转同步通知页面路径 + $return_url = $alipay_config['apiurl']."、user/payment/return"; + //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ + + //商户订单号 + $out_trade_no = $pl->tradeno; + //商户网站订单系统中唯一订单号,必填 + + + //商品名称 + $name =$settings["subjects"][array_rand($settings["subjects"])]; + //付款金额 + $money =$price; + //站点名称 + $sitename = $settings['appname']; + //必填 + + //订单描述 + + /************************************************************/ + //构造要请求的参数数组,无需改动 + $parameter = array( + "pid" => trim($alipay_config['partner']), + "type" => $type, + "notify_url" => $notify_url, + "return_url" => $return_url, + "out_trade_no" => $out_trade_no, + "name" => $name, + "money" => $money, + "sitename" => $sitename + ); + + //建立请求 + $alipaySubmit = new AlipaySubmit($alipay_config); + $html_text = $alipaySubmit->buildRequestForm($parameter); + return $response->write(json_encode(['code' => $html_text, 'errcode' => 0, 'pid' => $pl->id])); + } + + public function notify($request, $response, $args) + { + + $settings = Config::get("idtpay"); + $alipay_config = array( + 'partner' => $settings['partner'], + 'key' => $settings['key'], + 'sign_type' => $settings['sign_type'], + 'input_charset' => $settings['input_charset'], + 'transport' => $settings['transport'], + 'apiurl' => $settings['apiurl'] + ); + + //计算得出通知验证结果 + $alipayNotify = new AlipayNotify($alipay_config); + $verify_result = $alipayNotify->verifyNotify(); + + if($verify_result) { + + if ($_GET['trade_status'] == 'TRADE_SUCCESS') { + $this->postPayment($_GET['out_trade_no'], "IDtPay"); + } + return $response->write('success'); + + } + else { + //验证失败 + return $response->write('fail'); + } + } + public function getReturnHTML($request, $response, $args) + { + + $pid = $_GET['out_trade_no']; + $p = Paylist::where('tradeno', '=', $pid)->first(); + $money = $p->total; + if ($p->status == 1) { + $success = 1; + } else { + $settings = Config::get("idtpay"); + $alipay_config = array( + 'partner' => $settings['partner'], + 'key' => $settings['key'], + 'sign_type' => $settings['sign_type'], + 'input_charset' => $settings['input_charset'], + 'transport' => $settings['transport'], + 'apiurl' => $settings['apiurl'] + ); + + //计算得出通知验证结果 + $alipayNotify = new AlipayNotify($alipay_config); + $verify_result = $alipayNotify->verifyNotify(); + + if($verify_result) { + + if ($_GET['trade_status'] == 'TRADE_SUCCESS') { + $this->postPayment($_GET['out_trade_no'], "IDtPay"); + $success = 1; + } + else { + $success = 0; + } + + } + else { + $success = 0; + } + } + return View::getSmarty()->assign('money', $money)->assign('success', $success)->fetch('user/pay_success.tpl'); + + + + } + public function getPurchaseHTML() + { + return ' +
+

充值

+
支付方式:
+
推荐使用支付宝支付,更快到账!
+
+ +
+ + +
+
+
+
+
+
+ +'; + } + public function getStatus($request, $response, $args) + { + $return = []; + $p = Paylist::where('tradeno', $_POST['pid'])->first(); + $return['ret'] = 1; + $return['result'] = $p->status; + // file_put_contents(BASE_PATH.'/bitpay_status_success.log', json_encode($return)."\r\n", FILE_APPEND); + return json_encode($return); + } +} diff --git a/config/.config.example.php b/config/.config.example.php index 44588cf1..689b15b3 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -241,6 +241,19 @@ $_ENV['payjs_mchid']=''; $_ENV['payjs_key']=''; +$_ENV['idtpay']=[ + 'partner'=>"", //商户号 + 'key' =>"", //商户key + 'sign_type'=>strtoupper('MD5'), + 'input_charset'=>strtolower('utf-8'), + 'subjects'=>["内存",'手抓饼'], //商品名称 + 'transport'=>'https' ,//访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http + 'apiurl'=>'http://', //http开头 + 'appname'=>$_ENV['appName'], + +]; + + //其他面板显示设置------------------------------------------------------------------------------------------ #用户文档 From a8f2224484d365f447352e330ffe0ae6882d301e Mon Sep 17 00:00:00 2001 From: Rico Date: Sun, 1 Dec 2019 00:19:19 +0800 Subject: [PATCH 02/10] =?UTF-8?q?=E5=85=88=E5=A2=9E=E5=8A=A0tomatopay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Gateway/TomatoPay.php | 139 +++++++++++++++++++++++++++++ app/Services/Payment.php | 4 +- config/.config.example.php | 15 ++++ 3 files changed, 157 insertions(+), 1 deletion(-) create mode 100644 app/Services/Gateway/TomatoPay.php diff --git a/app/Services/Gateway/TomatoPay.php b/app/Services/Gateway/TomatoPay.php new file mode 100644 index 00000000..17badf2c --- /dev/null +++ b/app/Services/Gateway/TomatoPay.php @@ -0,0 +1,139 @@ +getParsedBodyParam('type'); + $price = $request->getParsedBodyParam('price'); + if ($price <= 0) { + return $response->write(json_encode(['errcode' => -1, 'errmsg' => "非法的金额."])); + } + $user = Auth::getUser(); + $settings = $_ENV['tomatopay'][$type]; + $pl = new Paylist(); + $pl->userid = $user->id; + $pl->total = $price; + $pl->tradeno = self::generateGuid(); + $pl->save(); + $fqaccount = $settings['account']; + $fqkey = $settings['token']; + $fqmchid = $settings['mchid']; + $fqtrade = $pl->tradeno; + $fqcny = $price; + + $signs = md5( + 'mchid=' . $fqmchid . '&account=' . $fqaccount . '&cny=' . $fqcny . '&type=1&trade=' . $fqtrade . $fqkey + ); + $url = 'https://b.fanqieui.com/gateways/' . $type . '.php?account=' + . $fqaccount . '&mchid=' . $fqmchid . '&type=1' + . '&trade=' . $fqtrade . '&cny=' . $fqcny . '&signs=' . $signs; + $result = ""; + return $response->write(json_encode(['code' => $result, 'errcode' => 0, 'pid' => $pl->id])); + } + + public function notify($request, $response, $args) + { + $type = $args['type']; + $settings = $_ENV['tomatopay'][$type]; + $order_data = $request->getParsedBody(); + $signs = $order_data['sign']; + unset($order_data['sign']); + $security = $order_data; + $o = ''; + foreach ($security as $k => $v) { + $o .= "$k=" . urlencode($v) . "&"; + } + $sign = md5(substr($o, 0, -1) . $settings['token']); + if ($sign == $signs) { + $this->postPayment($order_data['out_trade_no'], "在线支付"); + return $response->write('success'); + } else { + return $response->write('failed'); + } + } + public function getPurchaseHTML() + { + return ' +
+

充值

+
支付方式:
+
推荐使用支付宝支付,更快到账!
+
+ +
+ + +
+
+
+
+
+
+ +'; + } +} diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 8d042773..1fbe4f59 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -9,7 +9,7 @@ namespace App\Services; use App\Services\Gateway\{ - AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, PAYJS, BitPayX + AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, PAYJS, BitPayX,TomatoPay }; class Payment @@ -36,6 +36,8 @@ class Payment return new BitPayX(Config::get('bitpay_secret')); case ('payjs'): return new PAYJS(Config::get('payjs_key')); + case ("tomatopay"): + return new TomatoPay(); default: return null; } diff --git a/config/.config.example.php b/config/.config.example.php index 44588cf1..0dd5d0bb 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -240,6 +240,21 @@ $_ENV['bitpay_secret']=''; $_ENV['payjs_mchid']=''; $_ENV['payjs_key']=''; +#tomatopay番茄云支付 +#使用教程:https://swapidc.fanqieui.com/?t/329.html tg群 https://t.me/fanqiepay +$_ENV['tomatopay'] = [ + 'wxpay'=>[ + 'mchid' => '', // 商户号 + 'account' => '', //您在番茄云支付的登录邮箱 + 'token' => "" // 安全验证码 + ], + 'alipay'=>[ + 'mchid' => '', // 商户号 + 'account' => '', //您在番茄云支付的登录邮箱 + 'token' => "" // 安全验证码 + ], + ]; + //其他面板显示设置------------------------------------------------------------------------------------------ From 53135aa66b0246e45bc6c763fa5cf3d1a4bf1a8d Mon Sep 17 00:00:00 2001 From: Rico Date: Sun, 1 Dec 2019 19:38:15 +0800 Subject: [PATCH 03/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dtomataopay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Gateway/TomatoPay.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/Services/Gateway/TomatoPay.php b/app/Services/Gateway/TomatoPay.php index 17badf2c..ce9130f1 100644 --- a/app/Services/Gateway/TomatoPay.php +++ b/app/Services/Gateway/TomatoPay.php @@ -136,4 +136,16 @@ class TomatoPay extends AbstractPayment '; } + public function getReturnHTML($request, $response, $args) + { + // TODO: Implement getReturnHTML() method. + } + public function getStatus($request, $response, $args) + { + $return = []; + $p = Paylist::where('tradeno', $_POST['pid'])->first(); + $return['ret'] = 1; + $return['result'] = $p->status; + return json_encode($return); + } } From 9d8d7e5eed1c26078bb866f870c4684a1f4a2244 Mon Sep 17 00:00:00 2001 From: Rico Date: Sun, 1 Dec 2019 19:49:05 +0800 Subject: [PATCH 04/10] =?UTF-8?q?=E5=A2=9E=E5=8A=A0idtpay?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Payment.php | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 1fbe4f59..54b48df4 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -9,7 +9,7 @@ namespace App\Services; use App\Services\Gateway\{ - AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, PAYJS, BitPayX,TomatoPay + AopF2F, Codepay, DoiAMPay, PaymentWall, ChenPay, SPay, TrimePay, PAYJS, BitPayX,TomatoPay,IDtPay }; class Payment @@ -38,6 +38,8 @@ class Payment return new PAYJS(Config::get('payjs_key')); case ("tomatopay"): return new TomatoPay(); + case ("idtpay"): + return new IDtPay(); default: return null; } From 85b0165fd64faa10b661ec387b9e3d81acc82e17 Mon Sep 17 00:00:00 2001 From: Rico Date: Mon, 9 Dec 2019 00:40:36 +0800 Subject: [PATCH 05/10] add router and using idtpay now --- app/Services/Gateway/IDtPay.php | 5 +++-- config/routes.php | 1 + 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/app/Services/Gateway/IDtPay.php b/app/Services/Gateway/IDtPay.php index c9ca7104..80924d27 100644 --- a/app/Services/Gateway/IDtPay.php +++ b/app/Services/Gateway/IDtPay.php @@ -5,6 +5,7 @@ namespace App\Services\Gateway; use App\Services\Auth; use App\Models\Paylist; use App\Services\Config; +use App\Services\View; require_once("IDt/epay_submit.class.php"); require_once("IDt/epay_notify.class.php"); @@ -36,11 +37,11 @@ class IDtPay extends AbstractPayment /**************************请求参数**************************/ - $notify_url = $alipay_config['apiurl']."/payment/notify"; + $notify_url = Config::get("baseUrl")."/payment/notify"; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 - $return_url = $alipay_config['apiurl']."、user/payment/return"; + $return_url = Config::get("baseUrl")."/user/payment/return"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //商户订单号 diff --git a/config/routes.php b/config/routes.php index eeedec33..b7de79e3 100644 --- a/config/routes.php +++ b/config/routes.php @@ -161,6 +161,7 @@ $app->group('/user', function () { $app->group('/payment', function () { $this->post('/notify', App\Services\Payment::class . ':notify'); + $this->get('/notify', App\Services\Payment::class . ':notify'); $this->post('/notify/{type}', App\Services\Payment::class . ':notify'); $this->post('/status', App\Services\Payment::class . ':getStatus'); From a1538408151a60a57e2ea63bcf3ee1d08b56ea08 Mon Sep 17 00:00:00 2001 From: Rico Date: Mon, 9 Dec 2019 00:42:36 +0800 Subject: [PATCH 06/10] update --- app/Services/Gateway/IDtPay.php | 54 ++++++++++++++++++++------------- 1 file changed, 33 insertions(+), 21 deletions(-) diff --git a/app/Services/Gateway/IDtPay.php b/app/Services/Gateway/IDtPay.php index 80924d27..590d0111 100644 --- a/app/Services/Gateway/IDtPay.php +++ b/app/Services/Gateway/IDtPay.php @@ -80,32 +80,44 @@ class IDtPay extends AbstractPayment public function notify($request, $response, $args) { + $pid = $_GET['out_trade_no']; + $p = Paylist::where('tradeno', '=', $pid)->first(); + if ($p->status == 1) { + $success = 1; + } else { + $settings = Config::get("idtpay"); + $alipay_config = array( + 'partner' => $settings['partner'], + 'key' => $settings['key'], + 'sign_type' => $settings['sign_type'], + 'input_charset' => $settings['input_charset'], + 'transport' => $settings['transport'], + 'apiurl' => $settings['apiurl'] + ); - $settings = Config::get("idtpay"); - $alipay_config = array( - 'partner' => $settings['partner'], - 'key' => $settings['key'], - 'sign_type' => $settings['sign_type'], - 'input_charset' => $settings['input_charset'], - 'transport' => $settings['transport'], - 'apiurl' => $settings['apiurl'] - ); + //计算得出通知验证结果 + $alipayNotify = new AlipayNotify($alipay_config); + $verify_result = $alipayNotify->verifyNotify(); - //计算得出通知验证结果 - $alipayNotify = new AlipayNotify($alipay_config); - $verify_result = $alipayNotify->verifyNotify(); + if($verify_result) { - if($verify_result) { + if ($_GET['trade_status'] == 'TRADE_SUCCESS') { + $this->postPayment($_GET['out_trade_no'], "IDtPay"); + $success = 1; + } + else { + $success = 0; + } - if ($_GET['trade_status'] == 'TRADE_SUCCESS') { - $this->postPayment($_GET['out_trade_no'], "IDtPay"); } - return $response->write('success'); - - } - else { - //验证失败 - return $response->write('fail'); + else { + $success = 0; + } + } + if ($success==1){ + echo "success"; + }else{ + echo "fail"; } } public function getReturnHTML($request, $response, $args) From 70baa59963d7ea6b8658d93b332efaf6751236af Mon Sep 17 00:00:00 2001 From: Rico Date: Tue, 10 Dec 2019 16:41:49 +0800 Subject: [PATCH 07/10] =?UTF-8?q?=E6=9B=B4=E6=96=B0api=20url?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- config/.config.example.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/.config.example.php b/config/.config.example.php index ca7584b0..69287b68 100644 --- a/config/.config.example.php +++ b/config/.config.example.php @@ -263,7 +263,7 @@ $_ENV['idtpay']=[ 'input_charset'=>strtolower('utf-8'), 'subjects'=>["内存",'手抓饼'], //商品名称 'transport'=>'https' ,//访问模式,根据自己的服务器是否支持ssl访问,若支持请选择https;若不支持请选择http - 'apiurl'=>'http://', //http开头 + 'apiurl'=>'https://pay.idt.xyz/', //http开头 'appname'=>$_ENV['appName'], ]; From 0c5b40d12ed2acffc3d97e7bc0d5c62a59324ad9 Mon Sep 17 00:00:00 2001 From: Rico Date: Tue, 10 Dec 2019 16:46:26 +0800 Subject: [PATCH 08/10] =?UTF-8?q?=E5=88=A0=E9=99=A4=E4=B8=8D=E9=9C=80?= =?UTF-8?q?=E8=A6=81=E7=9A=84f?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Services/Gateway/IDtPay.php | 1 - 1 file changed, 1 deletion(-) diff --git a/app/Services/Gateway/IDtPay.php b/app/Services/Gateway/IDtPay.php index 590d0111..eda28f06 100644 --- a/app/Services/Gateway/IDtPay.php +++ b/app/Services/Gateway/IDtPay.php @@ -237,7 +237,6 @@ class IDtPay extends AbstractPayment } } }); - setTimeout(f, 1000); }); '; From 95b60b72f9285b787c66bc7007f16f797f929aea Mon Sep 17 00:00:00 2001 From: Rico Date: Tue, 10 Dec 2019 16:59:02 +0800 Subject: [PATCH 09/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dip=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/Command/Job.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Command/Job.php b/app/Command/Job.php index 28a2c238..3634235a 100644 --- a/app/Command/Job.php +++ b/app/Command/Job.php @@ -303,7 +303,7 @@ class Job $ips[$alive_ip->ip] = 1; if ($user->node_connector < count($ips)) { //暂时封禁 - $isDisconnect = Disconnect::where('id', '=', $alive_ip->ip)->where( + $isDisconnect = Disconnect::where('ip', '=', $alive_ip->ip)->where( 'userid', '=', $user->id From b0125a1b94f540c203f7f2aeb3eef0c89a2c4a7f Mon Sep 17 00:00:00 2001 From: Rico Date: Thu, 12 Dec 2019 08:29:35 +0800 Subject: [PATCH 10/10] =?UTF-8?q?=E4=BF=AE=E5=A4=8D7.2=20=E5=8F=8A?= =?UTF-8?q?=E5=85=B6=E4=BB=A5=E4=B8=8A=E7=9A=84bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../Gateway/IDt/epay_core.function.php | 22 +++++++++---------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/app/Services/Gateway/IDt/epay_core.function.php b/app/Services/Gateway/IDt/epay_core.function.php index 4f8dc58e..ecdd2991 100755 --- a/app/Services/Gateway/IDt/epay_core.function.php +++ b/app/Services/Gateway/IDt/epay_core.function.php @@ -16,11 +16,11 @@ */ function createLinkstring($para) { $arg = ""; - while (list ($key, $val) = each ($para)) { + foreach ($para as $key=>$val){ $arg.=$key."=".$val."&"; } //去掉最后一个&字符 - $arg = substr($arg,0,count($arg)-2); + $arg = rtrim($arg,'&'); //如果存在转义字符,那么去掉转义 if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} @@ -34,11 +34,11 @@ function createLinkstring($para) { */ function createLinkstringUrlencode($para) { $arg = ""; - while (list ($key, $val) = each ($para)) { - $arg.=$key."=".urlencode($val)."&"; - } - //去掉最后一个&字符 - $arg = substr($arg,0,count($arg)-2); + foreach ($para as $key=>$val){ + $arg.=$key."=".$val."&"; + } + //去掉最后一个&字符 + $arg = rtrim($arg,'&'); //如果存在转义字符,那么去掉转义 if(get_magic_quotes_gpc()){$arg = stripslashes($arg);} @@ -52,10 +52,10 @@ function createLinkstringUrlencode($para) { */ function paraFilter($para) { $para_filter = array(); - while (list ($key, $val) = each ($para)) { - if($key == "sign" || $key == "sign_type" || $val == "")continue; - else $para_filter[$key] = $para[$key]; - } + foreach ($para as $key=>$val){ + if($key == "sign" || $key == "sign_type" || $val == "")continue; + else $para_filter[$key] = $para[$key]; + } return $para_filter; } /**