From 4a3f8278ea8399b03abe8529448090a859c0e633 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 2 Jul 2024 08:20:10 +1000 Subject: [PATCH] Updates for new payment flow --- app/Livewire/Flow2/PaymentMethod.php | 38 ++++++++++++++++--- app/Livewire/InvoicePay.php | 4 ++ .../livewire/payment_method-flow2.blade.php | 30 +++++++++------ .../stripe/credit_card/livewire_pay.blade.php | 1 - 4 files changed, 56 insertions(+), 17 deletions(-) diff --git a/app/Livewire/Flow2/PaymentMethod.php b/app/Livewire/Flow2/PaymentMethod.php index 80de9a8c2b52..796eabb3e773 100644 --- a/app/Livewire/Flow2/PaymentMethod.php +++ b/app/Livewire/Flow2/PaymentMethod.php @@ -23,19 +23,47 @@ class PaymentMethod extends Component public $variables; + public $methods = []; + + public $isLoading = true; + + public function placeholder() + { + return <<<'HTML' +
+ + + + +
+ HTML; + } + public function mount() { + $this->isLoading = true; $this->invoice = $this->context['invoice']; $this->variables = $this->context['variables']; + + MultiDB::setDb($this->invoice->company->db); + + $this->methods = $this->invoice->client->service()->getPaymentMethods($this->invoice->balance); + + if(count($this->methods) == 1) { + $this->dispatch('payment-method-selected', company_gateway_id: $this->methods[0]['company_gateway_id'], gateway_type_id: $this->methods[0]['gateway_type_id'], amount: $this->invoice->balance); + } + + $this->isLoading=false; + } + public function render() { - - MultiDB::setDb($this->invoice->company->db); + + + //If there is only one payment method, skip display and push straight to the form!! - $methods = $this->invoice->client->service()->getPaymentMethods($this->invoice->balance); - - return render('components.livewire.payment_method-flow2', ['methods' => $methods, 'amount' => $this->invoice->balance]); + return render('components.livewire.payment_method-flow2', ['methods' => $this->methods, 'amount' => $this->invoice->balance]); } } diff --git a/app/Livewire/InvoicePay.php b/app/Livewire/InvoicePay.php index 8234c1bb450b..0ae0d0db36b8 100644 --- a/app/Livewire/InvoicePay.php +++ b/app/Livewire/InvoicePay.php @@ -116,6 +116,10 @@ class InvoicePay extends Component $client = $invite->contact->client; $variables = ($invite && auth()->guard('contact')->user()->client->getSetting('show_accept_invoice_terms')) ? (new HtmlEngine($invite))->generateLabelsAndValues() : false; $settings = $client->getMergedSettings(); + + $this->terms_accepted = !$settings->show_accept_invoice_terms; + $this->signature_accepted = !$settings->require_invoice_signature; + $this->context['variables'] = $variables; $this->context['invoice'] = $invite->invoice; $this->context['settings'] = $settings; diff --git a/resources/views/portal/ninja2020/components/livewire/payment_method-flow2.blade.php b/resources/views/portal/ninja2020/components/livewire/payment_method-flow2.blade.php index 464e9f4fefb8..4d2418971b56 100644 --- a/resources/views/portal/ninja2020/components/livewire/payment_method-flow2.blade.php +++ b/resources/views/portal/ninja2020/components/livewire/payment_method-flow2.blade.php @@ -1,18 +1,26 @@ -
+
+ +
+ + + + +
+ @foreach($methods as $index => $method) - + @endforeach - + @script