diff --git a/app/Services/Gateway/AopF2F.php b/app/Services/Gateway/AopF2F.php index 97175bba..814989c8 100644 --- a/app/Services/Gateway/AopF2F.php +++ b/app/Services/Gateway/AopF2F.php @@ -24,7 +24,7 @@ class AopF2F extends AbstractPayment $gateway->setAppId(Config::get('f2fpay_app_id')); $gateway->setPrivateKey(Config::get('merchant_private_key')); // 可以是路径,也可以是密钥内容 $gateway->setAlipayPublicKey(Config::get('alipay_public_key')); // 可以是路径,也可以是密钥内容 - $notifyUrl = Config::get('f2fNotifyUrl') ?? (Config::get('baseUrl') . '/payment/notify'); + $notifyUrl = Config::get('f2fNotifyUrl') ?? (Config::get('baseUrl') . '/payment/notify/f2fpay'); $gateway->setNotifyUrl($notifyUrl); return $gateway; } diff --git a/app/Services/Gateway/BitPayX.php b/app/Services/Gateway/BitPayX.php index cc118d88..88c872e6 100644 --- a/app/Services/Gateway/BitPayX.php +++ b/app/Services/Gateway/BitPayX.php @@ -104,9 +104,9 @@ class BitPayX extends AbstractPayment } $data['title'] = '支付单号:' . $pl->tradeno; $data['description'] = '充值:' . $price . ' 元'; - $data['callback_url'] = Config::get('baseUrl') . '/payment/notify'; + $data['callback_url'] = Config::get('baseUrl') . '/payment/notify/bitpayx'; - $data['success_url'] = Config::get('baseUrl') . '/user/payment/return?merchantTradeNo='; + $data['success_url'] = Config::get('baseUrl') . '/user/payment/return/bitpayx?merchantTradeNo='; $data['success_url'] .= $pl->tradeno; $data['cancel_url'] = $data['success_url']; diff --git a/app/Services/Gateway/IDtPay.php b/app/Services/Gateway/IDtPay.php index eda28f06..28c3c654 100644 --- a/app/Services/Gateway/IDtPay.php +++ b/app/Services/Gateway/IDtPay.php @@ -37,11 +37,11 @@ class IDtPay extends AbstractPayment /**************************请求参数**************************/ - $notify_url = Config::get("baseUrl")."/payment/notify"; + $notify_url = Config::get("baseUrl")."/payment/notify/idtpay"; //需http://格式的完整路径,不能加?id=123这类自定义参数 //页面跳转同步通知页面路径 - $return_url = Config::get("baseUrl")."/user/payment/return"; + $return_url = Config::get("baseUrl")."/user/payment/return/idtpay"; //需http://格式的完整路径,不能加?id=123这类自定义参数,不能写成http://localhost/ //商户订单号 @@ -212,7 +212,7 @@ class IDtPay extends AbstractPayment $("#msg").html("非法的金额!"); } $.ajax({ - \'url\':"/user/payment/purchase", + \'url\':"/user/payment/purchase/idtpay", \'data\':{ \'price\':price, \'type\':type, diff --git a/app/Services/Gateway/PAYJS.php b/app/Services/Gateway/PAYJS.php index 2de7d8cc..e87c87f7 100644 --- a/app/Services/Gateway/PAYJS.php +++ b/app/Services/Gateway/PAYJS.php @@ -91,7 +91,7 @@ class PAYJS extends AbstractPayment //$data['type'] = $type; $data['out_trade_no'] = $pl->tradeno; $data['total_fee'] = (float) $price * 100; - $data['notify_url'] = Config::get('baseUrl') . '/payment/notify?way=payjs'; + $data['notify_url'] = Config::get('baseUrl') . '/payment/notify/payjs?way=payjs'; //$data['callback_url'] = Config::get('baseUrl') . '/user/code'; $params = $this->prepareSign($data); $data['sign'] = $this->sign($params); diff --git a/app/Services/Gateway/SPay.php b/app/Services/Gateway/SPay.php index 0c9ffebd..7c98df66 100755 --- a/app/Services/Gateway/SPay.php +++ b/app/Services/Gateway/SPay.php @@ -42,8 +42,8 @@ class SPay extends AbstractPayment $data['total_fee'] = $total_fee; //支付金额 $data['partner'] = Config::get('alipay_id'); //spay合作者id - $data['notify_url'] = Config::get('baseUrl') . '/spay_back'; //不能有get参数 也就是?xxx=xxx& xxx=xxx - $data['return_url'] = Config::get('baseUrl') . '/spay_back'; //不能有get参数 也就是?xxx=xxx& xxx=xxx + $data['notify_url'] = Config::get('baseUrl') . '/spay_back/spay'; //不能有get参数 也就是?xxx=xxx& xxx=xxx + $data['return_url'] = Config::get('baseUrl') . '/spay_back/spay'; //不能有get参数 也就是?xxx=xxx& xxx=xxx $data['out_trade_no'] = $out_trade_no; //商户唯一订单号 $data['service'] = 'create_direct_pay_by_user'; $i = 0; @@ -129,7 +129,7 @@ class SPay extends AbstractPayment $(\'#readytopay\').modal(); $("#readytopay").on(\'shown.bs.modal\', function () { $.ajax({ - \'url\': "/user/payment/purchase", + \'url\': "/user/payment/purchase/spay", \'data\': { \'price\': price, }, diff --git a/app/Services/Gateway/TomatoPay.php b/app/Services/Gateway/TomatoPay.php index ce9130f1..9128db13 100644 --- a/app/Services/Gateway/TomatoPay.php +++ b/app/Services/Gateway/TomatoPay.php @@ -106,7 +106,7 @@ class TomatoPay extends AbstractPayment $("#msg").html("非法的金额!"); } $.ajax({ - \'url\':"/user/payment/purchase", + \'url\':"/user/payment/purchase/tomatopay", \'data\':{ \'price\':price, \'type\':type, diff --git a/app/Services/Payment.php b/app/Services/Payment.php index 54b48df4..81785529 100644 --- a/app/Services/Payment.php +++ b/app/Services/Payment.php @@ -13,10 +13,14 @@ use App\Services\Gateway\{ }; class Payment -{ - public static function getClient() - { - $method = Config::get('payment_system'); +{ public static function getPaymentSystem(){ + $raw_methods = Config::get('payment_system'); + return str_split($raw_methods,","); +} + public static function getClient($method="") + { if ($method==""|$method==null){ + $method=self::getPaymentSystem()[0]; + } switch ($method) { case ('codepay'): return new Codepay(); @@ -46,31 +50,33 @@ class Payment } public static function notify($request, $response, $args) - { - return self::getClient()->notify($request, $response, $args); + { $type = $args['type']; + return self::getClient($type)->notify($request, $response, $args); } public static function returnHTML($request, $response, $args) - { - return self::getClient()->getReturnHTML($request, $response, $args); + { $type = $args['type']; + return self::getClient($type)->getReturnHTML($request, $response, $args); } public static function purchaseHTML() - { - if (self::getClient() != null) { - return self::getClient()->getPurchaseHTML(); + { $methods =self::getPaymentSystem(); + $return_string =""; + foreach ($methods as $method){ + if (self::getClient($method) != null) { + $return_string = $return_string . self::getClient($method)->getPurchaseHTML(); + } } - - return ''; + return $return_string; } public static function getStatus($request, $response, $args) - { - return self::getClient()->getStatus($request, $response, $args); + { $type = $args['type']; + return self::getClient($type)->getStatus($request, $response, $args); } public static function purchase($request, $response, $args) - { - return self::getClient()->purchase($request, $response, $args); + { $type = $args['type']; + return self::getClient($type)->purchase($request, $response, $args); } } diff --git a/config/routes.php b/config/routes.php index b7de79e3..8c9ff400 100644 --- a/config/routes.php +++ b/config/routes.php @@ -51,6 +51,8 @@ $app->add(new WhoopsMiddleware()); // Home $app->post('/spay_back', App\Services\Payment::class . ':notify'); $app->get('/spay_back', App\Services\Payment::class . ':notify'); +$app->post('/spay_back/{type}', App\Services\Payment::class . ':notify'); +$app->get('/spay_back/{type}', App\Services\Payment::class . ':notify'); $app->get('/', App\Controllers\HomeController::class . ':index'); $app->get('/indexold', App\Controllers\HomeController::class . ':indexold'); $app->get('/404', App\Controllers\HomeController::class . ':page404'); @@ -152,7 +154,9 @@ $app->group('/user', function () { //Reconstructed Payment System $this->post('/payment/purchase', App\Services\Payment::class . ':purchase'); + $this->post('/payment/purchase/{type}', App\Services\Payment::class . ':purchase'); $this->get('/payment/return', App\Services\Payment::class . ':returnHTML'); + $this->get('/payment/return/{type}', App\Services\Payment::class . ':returnHTML'); // Crypto Payment - BTC, ETH, EOS, BCH, LTC etch $this->post('/payment/bitpay/purchase', App\Services\BitPayment::class . ':purchase'); @@ -161,10 +165,11 @@ $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->get('/notify', App\Services\Payment::class . ':notify'); + $this->get('/notify/{type}', App\Services\Payment::class . ':notify'); $this->post('/status', App\Services\Payment::class . ':getStatus'); - + $this->post('/status/{type}', App\Services\Payment::class . ':getStatus'); $this->post('/bitpay/notify', App\Services\BitPayment::class . ':notify'); $this->post('/bitpay/status', App\Services\BitPayment::class . ':getStatus'); }); diff --git a/resources/views/material/user/aopf2f.tpl b/resources/views/material/user/aopf2f.tpl index d18cecb6..d6f4b14d 100755 --- a/resources/views/material/user/aopf2f.tpl +++ b/resources/views/material/user/aopf2f.tpl @@ -23,7 +23,7 @@ $("#readytopay").on('shown.bs.modal', function () { $.ajax({ type: "POST", - url: "/user/payment/purchase", + url: "/user/payment/purchase/f2fpay", dataType: "json", data: { amount: $$getValue('amount') @@ -62,7 +62,7 @@ function f() { $.ajax({ type: "POST", - url: "/payment/status", + url: "/payment/status/f2fpay", dataType: "json", data: { pid: pid diff --git a/resources/views/material/user/bitpayx.tpl b/resources/views/material/user/bitpayx.tpl index 3944bb6a..94399908 100644 --- a/resources/views/material/user/bitpayx.tpl +++ b/resources/views/material/user/bitpayx.tpl @@ -42,7 +42,7 @@ $('#readytopay').modal(); $("#readytopay").on('shown.bs.modal', function () { $.ajax({ - 'url': "/user/payment/purchase", + 'url': "/user/payment/purchase/bitpayx", 'data': { 'price': price, 'type': type, @@ -66,7 +66,7 @@ function f() { $.ajax({ type: "POST", - url: "/payment/status", + url: "/payment/status/bitpayx", dataType: "json", data: { pid: pid diff --git a/resources/views/material/user/payjs.tpl b/resources/views/material/user/payjs.tpl index 54a2c1b9..9c8dae5b 100644 --- a/resources/views/material/user/payjs.tpl +++ b/resources/views/material/user/payjs.tpl @@ -29,7 +29,7 @@ $('#readytopay').modal(); $("#readytopay").on('shown.bs.modal', function () { $.ajax({ - url: "/user/payment/purchase", + url: "/user/payment/purchase/payjs", data: { price, type, @@ -65,7 +65,7 @@ function f() { $.ajax({ type: "POST", - url: "/payment/status", + url: "/payment/status/payjs", dataType: "json", data: { pid