diff --git a/app/Http/Controllers/ClientPortal/PaymentController.php b/app/Http/Controllers/ClientPortal/PaymentController.php index 61cdc83456be..b3bbf2a94bcb 100644 --- a/app/Http/Controllers/ClientPortal/PaymentController.php +++ b/app/Http/Controllers/ClientPortal/PaymentController.php @@ -232,6 +232,7 @@ class PaymentController extends Controller public function response(PaymentResponseRequest $request) { $gateway = CompanyGateway::find($request->input('company_gateway_id'))->firstOrFail(); + $payment_hash = PaymentHash::whereRaw('BINARY `hash`= ?', [$request->payment_hash])->first(); return $gateway diff --git a/app/PaymentDrivers/BaseDriver.php b/app/PaymentDrivers/BaseDriver.php index 7e097c704b53..4d4b017beecf 100644 --- a/app/PaymentDrivers/BaseDriver.php +++ b/app/PaymentDrivers/BaseDriver.php @@ -460,4 +460,9 @@ class BaseDriver extends AbstractPaymentDriver return $this; } + + public function getCompanyGatewayId(): int + { + return $this->company_gateway->id; + } } diff --git a/app/PaymentDrivers/CustomPaymentDriver.php b/app/PaymentDrivers/CustomPaymentDriver.php index 03c76eb7007f..3c5d4bad1967 100644 --- a/app/PaymentDrivers/CustomPaymentDriver.php +++ b/app/PaymentDrivers/CustomPaymentDriver.php @@ -28,27 +28,15 @@ class CustomPaymentDriver extends BaseDriver /** * Returns the gateway types. */ - public function gatewayTypes() :array + public function gatewayTypes(): array { $types = [ - GatewayType::CREDIT_CARD, + GatewayType::CUSTOM, ]; return $types; } - public function authorize($payment_method) - { - } - - public function purchase($amount, $return_client_response = false) - { - } - - public function refund(Payment $payment, $amount, $return_client_response = false) - { - } - public function setPaymentMethod($payment_method_id) { $this->payment_method = $payment_method_id; @@ -56,13 +44,33 @@ class CustomPaymentDriver extends BaseDriver return $this; } + /** + * View for displaying custom content of the driver. + * + * @param array $data + * @return mixed + */ public function processPaymentView($data) { - return render('gateways.custom.landing_page', $data); + $data['title'] = $this->company_gateway->getConfigField('name'); + $data['instructions'] = $this->company_gateway->getConfigField('text'); + + $this->payment_hash->data = array_merge((array) $this->payment_hash->data, $data); + $this->payment_hash->save(); + + $data['gateway'] = $this; + + return render('gateways.custom.payment', $data); } + /** + * Processing method for payment. Should never be reached with this driver. + * + * @return mixed + */ public function processPaymentResponse($request) { + return redirect()->route('client.invoices'); } /** diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index 3eef076b20d0..565053ca7601 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -3314,6 +3314,9 @@ return [ 'service' => 'Service', 'pay' => 'Pay', + + 'instructions' => 'Instructions', + 'notification_invoice_reminder1_sent_subject' => 'Reminder 1 for Invoice :invoice was sent to :client', 'notification_invoice_reminder2_sent_subject' => 'Reminder 2 for Invoice :invoice was sent to :client', 'notification_invoice_reminder3_sent_subject' => 'Reminder 3 for Invoice :invoice was sent to :client', diff --git a/resources/views/portal/ninja2020/gateways/checkout/credit_card.blade.php.old b/resources/views/portal/ninja2020/gateways/checkout/credit_card.blade.php.old deleted file mode 100644 index 71f54319f938..000000000000 --- a/resources/views/portal/ninja2020/gateways/checkout/credit_card.blade.php.old +++ /dev/null @@ -1,128 +0,0 @@ -@extends('portal.ninja2020.layout.app') -@section('meta_title', ctrans('texts.checkout_com')) - -@push('head') - - - - - - - -@endpush - -@section('body') -
- @csrf - - - - - - - - - - @isset($token) - - @endisset -
- -
-
-
- -
-
-

- {{ ctrans('texts.pay_now') }} -

-

- {{ ctrans('texts.complete_your_payment') }} -

-
-
-
- {{ ctrans('texts.payment_type') }} -
-
- {{ ctrans('texts.checkout_com') }} ({{ ctrans('texts.credit_card') }}) -
-
-
-
- {{ ctrans('texts.subtotal') }} -
-
- {{ App\Utils\Number::formatMoney($total['invoice_totals'], $client) }} -
-
- {{ ctrans('texts.gateway_fees') }} -
-
- {{ App\Utils\Number::formatMoney($total['fee_total'], $client) }} -
-
- {{ ctrans('texts.amount') }} -
-
- {{ App\Utils\Number::formatMoney($total['amount_with_fee'], $client) }} -
-
- @isset($token) -
-
- {{ ctrans('texts.card_number') }} -
-
- **** {{ ucfirst($token->meta->last4) }} -
-
-
- -
- @else -
-
- {{ ctrans('texts.token_billing_checkbox') }} -
-
- - -
-
-
-
- @if(app()->environment() == 'production') - - @else - - @endif -
-
- @endisset -
-
-
-
-@endsection \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/custom/landing_page.blade.php b/resources/views/portal/ninja2020/gateways/custom/landing_page.blade.php deleted file mode 100644 index 5129524a8bee..000000000000 --- a/resources/views/portal/ninja2020/gateways/custom/landing_page.blade.php +++ /dev/null @@ -1 +0,0 @@ -stubs \ No newline at end of file diff --git a/resources/views/portal/ninja2020/gateways/custom/payment.blade.php b/resources/views/portal/ninja2020/gateways/custom/payment.blade.php new file mode 100644 index 000000000000..d337c71897d9 --- /dev/null +++ b/resources/views/portal/ninja2020/gateways/custom/payment.blade.php @@ -0,0 +1,13 @@ +@extends('portal.ninja2020.layout.payments', ['gateway_title' => $title, 'card_title' => $title]) + +@section('gateway_content') + @component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')]) + {{ $title }} + @endcomponent + + @include('portal.ninja2020.gateways.includes.payment_details') + + @component('portal.ninja2020.components.general.card-element-single') + {!! nl2br($instructions) !!} + @endcomponent +@endsection diff --git a/resources/views/portal/ninja2020/invoices/payment.blade.php b/resources/views/portal/ninja2020/invoices/payment.blade.php index 66ecc2a0ece5..f911440f30ed 100644 --- a/resources/views/portal/ninja2020/invoices/payment.blade.php +++ b/resources/views/portal/ninja2020/invoices/payment.blade.php @@ -36,9 +36,15 @@
@foreach($payment_methods as $payment_method) - - {{ $payment_method['label'] }} - + @if($payment_method['label'] == 'Custom') + + {{ \App\Models\CompanyGateway::find($payment_method['company_gateway_id'])->firstOrFail()->getConfigField('name') }} + + @else + + {{ $payment_method['label'] }} + + @endif @endforeach
@@ -67,7 +73,7 @@
@if(!empty($invoice->number) && !is_null($invoice->number)) -
+
{{ ctrans('texts.invoice_number') }}
@@ -88,7 +94,7 @@
@endif -
+
{{ ctrans('texts.additional_info') }}