1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-11-08 20:22:42 +01:00

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\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;
}
}

View File

@ -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())

View File

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