Paytrace: New payment flow (#74)

* pass livewirePaymentView & processPaymentView thru base driver

* add paymentData to the interface

* paytrace
This commit is contained in:
Benjamin Beganović 2024-08-09 01:08:36 +02:00
parent cbd852a0fc
commit fc80287429
3 changed files with 35 additions and 5 deletions

View File

@ -18,12 +18,13 @@ use App\Models\Invoice;
use App\Models\Payment; use App\Models\Payment;
use App\Models\PaymentType; use App\Models\PaymentType;
use App\Models\SystemLog; use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\PaytracePaymentDriver; use App\PaymentDrivers\PaytracePaymentDriver;
use App\Utils\Traits\MakesHash; use App\Utils\Traits\MakesHash;
use Illuminate\Http\Request; use Illuminate\Http\Request;
use Illuminate\Support\Str; use Illuminate\Support\Str;
class CreditCard class CreditCard implements LivewireMethodInterface
{ {
use MakesHash; use MakesHash;
@ -36,8 +37,7 @@ class CreditCard
public function authorizeView($data) public function authorizeView($data)
{ {
$data['client_key'] = $this->paytrace->getAuthToken(); $data = $this->paymentData($data);
$data['gateway'] = $this->paytrace;
return render('gateways.paytrace.authorize', $data); return render('gateways.paytrace.authorize', $data);
} }
@ -240,4 +240,23 @@ class CreditCard
return $this->paytrace->processUnsuccessfulTransaction($data); 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;
}
} }

View File

@ -8,6 +8,8 @@
* @license https://www.elastic.co/licensing/elastic-license * @license https://www.elastic.co/licensing/elastic-license
*/ */
import { instant, wait } from '../wait';
class PayTraceCreditCard { class PayTraceCreditCard {
constructor() { constructor() {
this.clientKey = document.querySelector( this.clientKey = document.querySelector(
@ -217,7 +219,15 @@ class PayTraceCreditCard {
return this.handlePaymentWithToken(e); return this.handlePaymentWithToken(e);
}); });
if (Array.from(document.getElementsByClassName('toggle-payment-with-token')).length === 0 && !instant()) {
document.getElementById('toggle-payment-with-credit-card').click();
}
} }
} }
function boot() {
new PayTraceCreditCard().handle(); new PayTraceCreditCard().handle();
}
instant() ? boot() : wait('#paytrace-credit-card-payment').then(() => boot())

View File

@ -6,6 +6,7 @@
<meta name="ctrans-cvv" content="{{ ctrans('texts.cvv') }}"> <meta name="ctrans-cvv" content="{{ ctrans('texts.cvv') }}">
<meta name="ctrans-card_number" content="{{ ctrans('texts.card_number') }}"> <meta name="ctrans-card_number" content="{{ ctrans('texts.card_number') }}">
<meta name="ctrans-expires" content="{{ ctrans('texts.expires') }}"> <meta name="ctrans-expires" content="{{ ctrans('texts.expires') }}">
<meta name="instant-payment" content="yes" />
@endsection @endsection
@section('gateway_content') @section('gateway_content')