多支付同时使用, 请用,分割支付方式,测试ing

multi-payment
Rico 7 years ago
parent b0125a1b94
commit d2f01ef594

@ -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;
}

@ -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'];

@ -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,

@ -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);

@ -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,
},

@ -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,

@ -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);
}
}

@ -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');
});

@ -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

@ -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

@ -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

Loading…
Cancel
Save