diff --git a/app/PaymentDrivers/PayTrace/CreditCard.php b/app/PaymentDrivers/PayTrace/CreditCard.php
index 2c2672aa62..970994d3c3 100644
--- a/app/PaymentDrivers/PayTrace/CreditCard.php
+++ b/app/PaymentDrivers/PayTrace/CreditCard.php
@@ -18,12 +18,13 @@ use App\Models\Invoice;
use App\Models\Payment;
use App\Models\PaymentType;
use App\Models\SystemLog;
+use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\PaytracePaymentDriver;
use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request;
use Illuminate\Support\Str;
-class CreditCard
+class CreditCard implements LivewireMethodInterface
{
use MakesHash;
@@ -36,9 +37,8 @@ class CreditCard
public function authorizeView($data)
{
- $data['client_key'] = $this->paytrace->getAuthToken();
- $data['gateway'] = $this->paytrace;
-
+ $data = $this->paymentData($data);
+
return render('gateways.paytrace.authorize', $data);
}
@@ -239,5 +239,24 @@ class CreditCard
];
return $this->paytrace->processUnsuccessfulTransaction($data);
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function livewirePaymentView(array $data): string
+ {
+ return 'gateways.paytrace.pay_livewire';
+ }
+
+ /**
+ * @inheritDoc
+ */
+ public function paymentData(array $data): array
+ {
+ $data['client_key'] = $this->paytrace->getAuthToken();
+ $data['gateway'] = $this->paytrace;
+
+ return $data;
}
}
diff --git a/resources/js/clients/payments/paytrace-credit-card.js b/resources/js/clients/payments/paytrace-credit-card.js
index 9b67b1ed8d..bf361f0593 100644
--- a/resources/js/clients/payments/paytrace-credit-card.js
+++ b/resources/js/clients/payments/paytrace-credit-card.js
@@ -8,6 +8,8 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
+import { instant, wait } from '../wait';
+
class PayTraceCreditCard {
constructor() {
this.clientKey = document.querySelector(
@@ -217,7 +219,15 @@ class PayTraceCreditCard {
return this.handlePaymentWithToken(e);
});
+
+ if (Array.from(document.getElementsByClassName('toggle-payment-with-token')).length === 0 && !instant()) {
+ document.getElementById('toggle-payment-with-credit-card').click();
+ }
}
}
-new PayTraceCreditCard().handle();
+function boot() {
+ new PayTraceCreditCard().handle();
+}
+
+instant() ? boot() : wait('#paytrace-credit-card-payment').then(() => boot())
diff --git a/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php b/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php
index 582954aa36..85e8caaf76 100644
--- a/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php
+++ b/resources/views/portal/ninja2020/gateways/paytrace/pay.blade.php
@@ -6,6 +6,7 @@
+
@endsection
@section('gateway_content')