From b63e413d6e0ea796a84fb6c3ab3646d5fc926ece Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 9 Aug 2024 01:07:35 +0200 Subject: [PATCH] eway (#69) --- app/PaymentDrivers/Eway/CreditCard.php | 16 ++++- .../js/clients/payments/eway-credit-card.js | 8 ++- .../ninja2020/gateways/eway/pay.blade.php | 1 + .../gateways/eway/pay_livewire.blade.php | 59 +++++++++++++++++++ 4 files changed, 81 insertions(+), 3 deletions(-) create mode 100644 resources/views/portal/ninja2020/gateways/eway/pay_livewire.blade.php diff --git a/app/PaymentDrivers/Eway/CreditCard.php b/app/PaymentDrivers/Eway/CreditCard.php index 8bd3e1602001..1adefa80b56e 100644 --- a/app/PaymentDrivers/Eway/CreditCard.php +++ b/app/PaymentDrivers/Eway/CreditCard.php @@ -17,10 +17,11 @@ use App\Jobs\Util\SystemLogger; use App\Models\GatewayType; use App\Models\PaymentType; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use App\PaymentDrivers\EwayPaymentDriver; use App\Utils\Traits\MakesHash; -class CreditCard +class CreditCard implements LivewireMethodInterface { use MakesHash; @@ -102,11 +103,18 @@ class CreditCard return $token; } - public function paymentView($data) + public function paymentData(array $data): array { $data['gateway'] = $this->eway_driver; $data['public_api_key'] = $this->eway_driver->company_gateway->getConfigField('publicApiKey'); + return $data; + } + + public function paymentView($data) + { + $data = $this->paymentData($data); + return render('gateways.eway.pay', $data); } @@ -276,4 +284,8 @@ class CreditCard return $payment; } + public function livewirePaymentView(array $data): string + { + return 'gateways.eway.pay_livewire'; + } } diff --git a/resources/js/clients/payments/eway-credit-card.js b/resources/js/clients/payments/eway-credit-card.js index 3d4f99297e70..d27632b30ec8 100644 --- a/resources/js/clients/payments/eway-credit-card.js +++ b/resources/js/clients/payments/eway-credit-card.js @@ -8,6 +8,8 @@ * @license https://www.elastic.co/licensing/elastic-license */ +import { wait, instant } from '../wait'; + class EwayRapid { constructor() { this.cardStyles = @@ -510,4 +512,8 @@ class EwayRapid { } } -new EwayRapid().handle(); +function boot() { + new EwayRapid().handle(); +} + +instant() ? boot() : wait('#eway-credit-card-payment').then(() => boot()); diff --git a/resources/views/portal/ninja2020/gateways/eway/pay.blade.php b/resources/views/portal/ninja2020/gateways/eway/pay.blade.php index 3f0cc9c788a1..98c7805b886c 100644 --- a/resources/views/portal/ninja2020/gateways/eway/pay.blade.php +++ b/resources/views/portal/ninja2020/gateways/eway/pay.blade.php @@ -7,6 +7,7 @@ ctrans('texts.credit_card')]) + @endsection @section('gateway_content') diff --git a/resources/views/portal/ninja2020/gateways/eway/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/eway/pay_livewire.blade.php new file mode 100644 index 000000000000..0c8b477a6dca --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/eway/pay_livewire.blade.php @@ -0,0 +1,59 @@ +
+ + + + + + +
+ @csrf + + + + + + + +
+ + + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ ctrans('texts.credit_card') }} + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if (count($tokens) > 0) + @foreach ($tokens as $token) + + @endforeach + @endisset + + + @endcomponent + + @component('portal.ninja2020.components.general.card-element-single') +
+ @endcomponent + + @include('portal.ninja2020.gateways.includes.save_card') + + @include('portal.ninja2020.gateways.includes.pay_now', ['disabled' => true]) +
+ +@assets + + + @vite('resources/js/clients/payments/eway-credit-card.js') +@endassets