diff --git a/app/Http/Livewire/PaymentMethods/UpdateDefaultMethod.php b/app/Http/Livewire/PaymentMethods/UpdateDefaultMethod.php new file mode 100644 index 000000000000..a90d1c1b4ccb --- /dev/null +++ b/app/Http/Livewire/PaymentMethods/UpdateDefaultMethod.php @@ -0,0 +1,56 @@ +company = $this->client->company; + + MultiDB::setDb($this->company->db); + + $this->is_disabled = $this->token->is_default; + } + + public function makeDefault(): void + { + if ($this->token->is_default) { + return; + } + + $this->client->gateway_tokens()->update(['is_default' => 0]); + + $this->token->is_default = 1; + $this->token->save(); + + $this->emit('UpdateDefaultMethod::method-updated'); + } + + public function render() + { + return render('components.livewire.update-default-payment-method'); + } +} diff --git a/resources/lang/en/texts.php b/resources/lang/en/texts.php index ac3d8f0e1a31..231537067f77 100644 --- a/resources/lang/en/texts.php +++ b/resources/lang/en/texts.php @@ -4268,6 +4268,9 @@ $LANG = array( 'company_import_failure_body' => 'There was an error importing the company data, the error message was:', 'recurring_invoice_due_date' => 'Due Date', 'amount_cents' => 'Amount in pennies,pence or cents', + 'default_payment_method_label' => 'Default Payment Method', + 'default_payment_method' => 'Make this your preferred way of paying.', + 'already_default_payment_method' => 'This is your preferred way of paying.', ); return $LANG; diff --git a/resources/views/portal/ninja2020/components/livewire/update-default-payment-method.blade.php b/resources/views/portal/ninja2020/components/livewire/update-default-payment-method.blade.php new file mode 100644 index 000000000000..4bd64bed3770 --- /dev/null +++ b/resources/views/portal/ninja2020/components/livewire/update-default-payment-method.blade.php @@ -0,0 +1,25 @@ +
+
+
+
+

+ {{ ctrans('texts.default_payment_method_label') }} +

+
+ + +

+ {{ $token->is_default ? ctrans('texts.already_default_payment_method') : ctrans('texts.default_payment_method') }} +

+
+
+
+
+ +
+
+
+
+
diff --git a/resources/views/portal/ninja2020/payment_methods/show.blade.php b/resources/views/portal/ninja2020/payment_methods/show.blade.php index bfd4e3fa7436..ba7254080699 100644 --- a/resources/views/portal/ninja2020/payment_methods/show.blade.php +++ b/resources/views/portal/ninja2020/payment_methods/show.blade.php @@ -15,61 +15,61 @@
@if(!empty($payment_method->gateway_type->name) && !is_null($payment_method->gateway_type->name)) -
-
- {{ ctrans('texts.payment_type') }} -
-
- {{ ucfirst($payment_method->gateway_type->name) }} -
-
+
+
+ {{ ctrans('texts.payment_type') }} +
+
+ {{ ucfirst($payment_method->gateway_type->name) }} +
+
@endif @if(!empty($payment_method->meta) && !is_null($payment_method->meta)) -
-
- {{ ctrans('texts.type') }} -
-
- {{ optional($payment_method->meta)->brand }} - {{ optional($payment_method->meta)->scheme }} -
-
+
+
+ {{ ctrans('texts.type') }} +
+
+ {{ optional($payment_method->meta)->brand }} + {{ optional($payment_method->meta)->scheme }} +
+
@endif @if(!empty($payment_method->meta->last4) && !is_null($payment_method->meta->last4)) -
-
- {{ ctrans('texts.card_number') }} -
-
- **** {{ ucfirst($payment_method->meta->last4) }} -
-
+
+
+ {{ ctrans('texts.card_number') }} +
+
+ **** {{ ucfirst($payment_method->meta->last4) }} +
+
@endif - + @if(!empty($payment_method->created_at) && !is_null($payment_method->created_at)) -
-
- {{ ctrans('texts.date_created') }} -
-
- {{ $payment_method->formatDateTimestamp($payment_method->created_at, auth()->user()->client->date_format()) }} -
-
+
+
+ {{ ctrans('texts.date_created') }} +
+
+ {{ $payment_method->formatDateTimestamp($payment_method->created_at, auth()->user()->client->date_format()) }} +
+
@endif @if(!empty($payment_method->is_default) && !is_null($payment_method->is_default)) -
-
- {{ ctrans('texts.default') }} -
-
- {{ $payment_method->is_default ? ctrans('texts.yes') : ctrans('texts.no') }} +
+
+ {{ ctrans('texts.default') }} +
+
+ {{ $payment_method->is_default ? ctrans('texts.yes') : ctrans('texts.no') }} +
-
@endif - + @isset($payment_method->meta->exp_month)
@@ -83,7 +83,10 @@
-
+ + @livewire('payment-methods.update-default-method', ['token' => $payment_method, 'client' => $client]) + +
@@ -109,3 +112,11 @@
@endsection + +@section('footer') + +@endsection