From 73bc91f74332bb74083fb574e11181b35f71c556 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 26 Aug 2024 14:27:05 +0200 Subject: [PATCH] rotessa acss --- app/PaymentDrivers/Rotessa/PaymentMethod.php | 38 ++++++++--- app/PaymentDrivers/RotessaPaymentDriver.php | 9 +++ .../bank_transfer/pay_livewire.blade.php | 65 +++++++++++++++++++ 3 files changed, 103 insertions(+), 9 deletions(-) create mode 100644 resources/views/portal/ninja2020/gateways/rotessa/bank_transfer/pay_livewire.blade.php diff --git a/app/PaymentDrivers/Rotessa/PaymentMethod.php b/app/PaymentDrivers/Rotessa/PaymentMethod.php index 4883490319..bb427267d8 100755 --- a/app/PaymentDrivers/Rotessa/PaymentMethod.php +++ b/app/PaymentDrivers/Rotessa/PaymentMethod.php @@ -14,6 +14,7 @@ namespace App\PaymentDrivers\Rotessa; use App\Models\Payment; use App\Models\SystemLog; +use App\PaymentDrivers\Common\LivewireMethodInterface; use Illuminate\View\View; use App\Models\GatewayType; use App\Models\PaymentType; @@ -28,7 +29,7 @@ use App\PaymentDrivers\Common\MethodInterface; use Omnipay\Common\Exception\InvalidResponseException; use App\Http\Requests\ClientPortal\Payments\PaymentResponseRequest; -class PaymentMethod implements MethodInterface +class PaymentMethod implements MethodInterface, LivewireMethodInterface { private array $transaction = [ @@ -123,14 +124,8 @@ class PaymentMethod implements MethodInterface */ public function paymentView(array $data): View { - $data['gateway'] = $this->rotessa; - $data['amount'] = $data['total']['amount_with_fee']; - $data['due_date'] = date('Y-m-d', min(max(strtotime($data['invoices']->max('due_date')), strtotime('now')), strtotime('+1 day'))); - $data['process_date'] = $data['due_date']; - $data['currency'] = $this->rotessa->client->getCurrencyCode(); - $data['frequency'] = 'Once'; - $data['installments'] = 1; - $data['invoice_nums'] = $data['invoices']->pluck('invoice_number')->join(', '); + $data = $this->paymentData($data); + return render('gateways.rotessa.bank_transfer.pay', $data ); } @@ -220,4 +215,29 @@ class PaymentMethod implements MethodInterface throw new PaymentFailed($exception->getMessage(), $exception->getCode()); } + + /** + * @inheritDoc + */ + public function livewirePaymentView(array $data): string + { + return 'gateways.rotessa.bank_transfer.pay_livewire'; + } + + /** + * @inheritDoc + */ + public function paymentData(array $data): array + { + $data['gateway'] = $this->rotessa; + $data['amount'] = $data['total']['amount_with_fee']; + $data['due_date'] = date('Y-m-d', min(max(strtotime($data['invoices']->max('due_date')), strtotime('now')), strtotime('+1 day'))); + $data['process_date'] = $data['due_date']; + $data['currency'] = $this->rotessa->client->getCurrencyCode(); + $data['frequency'] = 'Once'; + $data['installments'] = 1; + $data['invoice_nums'] = $data['invoices']->pluck('invoice_number')->join(', '); + + return $data; + } } diff --git a/app/PaymentDrivers/RotessaPaymentDriver.php b/app/PaymentDrivers/RotessaPaymentDriver.php index e52b206e98..1c4a7cf6b5 100644 --- a/app/PaymentDrivers/RotessaPaymentDriver.php +++ b/app/PaymentDrivers/RotessaPaymentDriver.php @@ -278,4 +278,13 @@ class RotessaPaymentDriver extends BaseDriver return $this->company_gateway->getConfigField('testMode') ? 'https://sandbox-api.rotessa.com/v1/' : 'https://api.rotessa.com/v1/'; } + public function processPaymentViewData(array $data) + { + return $this->payment_method->paymentData($data); + } + + public function livewirePaymentView(array $data) + { + return $this->payment_method->livewirePaymentView($data); + } } diff --git a/resources/views/portal/ninja2020/gateways/rotessa/bank_transfer/pay_livewire.blade.php b/resources/views/portal/ninja2020/gateways/rotessa/bank_transfer/pay_livewire.blade.php new file mode 100644 index 0000000000..1096b1e7d0 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/rotessa/bank_transfer/pay_livewire.blade.php @@ -0,0 +1,65 @@ +
+ @if (count($tokens) > 0) + + + @include('portal.ninja2020.gateways.includes.payment_details') + +
+ @csrf + + + + + + + + + + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')]) + @if (count($tokens) > 0) + @foreach ($tokens as $token) +
+ @endforeach + @endisset +
+ {{ ctrans('texts.process_date') }} +
+
+ +
+ @endcomponent +
+ @else + @component('portal.ninja2020.components.general.card-element-single', ['title' => ctrans('texts.direct_debit'), 'show_title' => false]) + {{ ctrans('texts.bank_account_not_linked') }} + + {{ ctrans('texts.add_payment_method') }} + @endcomponent + @endif + + @if (count($tokens) > 0) + @include('portal.ninja2020.gateways.includes.pay_now') + @endif +
+ +@script + +@endscript \ No newline at end of file