diff --git a/app/Http/Controllers/ClientPortal/PaymentMethodController.php b/app/Http/Controllers/ClientPortal/PaymentMethodController.php index ce830357c499..8792c2f89f03 100644 --- a/app/Http/Controllers/ClientPortal/PaymentMethodController.php +++ b/app/Http/Controllers/ClientPortal/PaymentMethodController.php @@ -1,4 +1,5 @@ user()->client->getCreditCardGateway(); + $gateway = $this->getClientGateway(); $data['gateway'] = $gateway; return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod(GatewayType::CREDIT_CARD) + ->setPaymentMethod($request->query('method')) ->authorizeView($data); } @@ -60,11 +62,11 @@ class PaymentMethodController extends Controller */ public function store(Request $request) { - $gateway = auth()->user()->client->getCreditCardGateway(); + $gateway = $this->getClientGateway(); return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod(GatewayType::CREDIT_CARD) + ->setPaymentMethod($request->query('method')) ->authorizeResponse($request); } @@ -106,21 +108,21 @@ class PaymentMethodController extends Controller public function verify(ClientGatewayToken $payment_method) { - $gateway = auth()->user()->client->getCreditCardGateway(); + $gateway = $this->getClientGateway(); return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod(GatewayType::BANK_TRANSFER) + ->setPaymentMethod(request()->query('method')) ->verificationView($payment_method); } public function processVerification(ClientGatewaytoken $payment_method) { - $gateway = auth()->user()->client->getCreditCardGateway(); + $gateway = $this->getClientGateway(); return $gateway ->driver(auth()->user()->client) - ->setPaymentMethod(GatewayType::BANK_TRANSFER) + ->setPaymentMethod(request()->query('method')) ->processVerification($payment_method); } @@ -144,4 +146,17 @@ class PaymentMethodController extends Controller ->route('client.payment_methods.index') ->withSuccess('Payment method has been successfully removed.'); } + + private function getClientGateway() + { + if (request()->query('method') == GatewayType::CREDIT_CARD) { + return $gateway = auth()->user()->client->getCreditCardGateway(); + } + + if (request()->query('method') == GatewayType::BANK_TRANSFER) { + return $gateway = auth()->user()->client->getBankTransferGateway(); + } + + return abort(404); + } } diff --git a/app/Models/Client.php b/app/Models/Client.php index 41ddb0fcf693..e139572690ee 100644 --- a/app/Models/Client.php +++ b/app/Models/Client.php @@ -400,6 +400,17 @@ class Client extends BaseModel implements HasLocalePreference return null; } + public function getBankTransferMethodType() + { + if ($this->currency()->code == 'USD') { + return GatewayType::BANK_TRANSFER; + } + + if ($this->currency()->code == 'EUR') { + return GatewayType::SEPA; + } + } + public function getCurrencyCode() { if ($this->currency()) { diff --git a/app/PaymentDrivers/CheckoutComPaymentDriver.php b/app/PaymentDrivers/CheckoutComPaymentDriver.php index c15488ffb5ea..7ea15c1a3f1f 100644 --- a/app/PaymentDrivers/CheckoutComPaymentDriver.php +++ b/app/PaymentDrivers/CheckoutComPaymentDriver.php @@ -82,6 +82,11 @@ class CheckoutComPaymentDriver extends BasePaymentDriver } } + public function authorizeView($data) + { + return render('gateways.checkout.authorize'); + } + public function processPaymentView(array $data) { $data['gateway'] = $this; diff --git a/app/PaymentDrivers/Stripe/ACH.php b/app/PaymentDrivers/Stripe/ACH.php index ed2538eab62f..a0b698b652b2 100644 --- a/app/PaymentDrivers/Stripe/ACH.php +++ b/app/PaymentDrivers/Stripe/ACH.php @@ -87,7 +87,7 @@ class ACH $client_gateway_token->save(); } - return redirect()->route('client.payment_methods.verification', $client_gateway_token->hashed_id); + return redirect()->route('client.payment_methods.verification', ['id' => $client_gateway_token->hashed_id, 'method' => GatewayType::BANK_TRANSFER]); } public function verificationView(ClientGatewayToken $token) @@ -168,7 +168,7 @@ class ACH return $this->processUnsuccessfulPayment($state); } catch (\Exception $e) { if ($e instanceof \Stripe\Exception\CardException) { - return redirect()->route('client.payment_methods.verification', ClientGatewayToken::first()->hashed_id); + return redirect()->route('client.payment_methods.verification', ['id' => ClientGatewayToken::first()->hashed_id, 'method' => GatewayType::BANK_TRANSFER]); } } } diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 138a8cfd5c58..d3367910f1b4 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3234,4 +3234,6 @@ return [ 'enable_only_for_development' => 'Enable only for development', 'test_pdf' => 'Test PDF', + + 'checkout_authorize_label' => 'Checkout.com can be can saved as payment method for future use, once you complete your first transaction. Don\'t forget to check "Save card" during payment process.', ]; diff --git a/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php b/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php index 1295d1243966..a5e56ad4e9a4 100644 --- a/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/payment-methods-table.blade.php @@ -9,10 +9,24 @@ - @if($client->getCreditCardGateway()) - {{ ctrans('texts.add_payment_method') }} - @endif +