This commit is contained in:
Benjamin Beganović 2024-08-09 01:07:35 +02:00 committed by GitHub
parent 0fff78b0a0
commit b63e413d6e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 81 additions and 3 deletions

View File

@ -17,10 +17,11 @@ use App\Jobs\Util\SystemLogger;
use App\Models\GatewayType;
use App\Models\PaymentType;
use App\Models\SystemLog;
use App\PaymentDrivers\Common\LivewireMethodInterface;
use App\PaymentDrivers\EwayPaymentDriver;
use App\Utils\Traits\MakesHash;
class CreditCard
class CreditCard implements LivewireMethodInterface
{
use MakesHash;
@ -102,11 +103,18 @@ class CreditCard
return $token;
}
public function paymentView($data)
public function paymentData(array $data): array
{
$data['gateway'] = $this->eway_driver;
$data['public_api_key'] = $this->eway_driver->company_gateway->getConfigField('publicApiKey');
return $data;
}
public function paymentView($data)
{
$data = $this->paymentData($data);
return render('gateways.eway.pay', $data);
}
@ -276,4 +284,8 @@ class CreditCard
return $payment;
}
public function livewirePaymentView(array $data): string
{
return 'gateways.eway.pay_livewire';
}
}

View File

@ -8,6 +8,8 @@
* @license https://www.elastic.co/licensing/elastic-license
*/
import { wait, instant } from '../wait';
class EwayRapid {
constructor() {
this.cardStyles =
@ -510,4 +512,8 @@ class EwayRapid {
}
}
new EwayRapid().handle();
function boot() {
new EwayRapid().handle();
}
instant() ? boot() : wait('#eway-credit-card-payment').then(() => boot());

View File

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

View File

@ -0,0 +1,59 @@
<div class="rounded-lg border bg-card text-card-foreground shadow-sm overflow-hidden py-5 bg-white sm:gap-4"
id="eway-credit-card-payment">
<meta name="public-api-key" content="{{ $public_api_key }}">
<meta name="translation-card-name" content="{{ ctrans('texts.cardholder_name') }}">
<meta name="translation-expiry_date" content="{{ ctrans('texts.date') }}">
<meta name="translation-card_number" content="{{ ctrans('texts.card_number') }}">
<meta name="translation-cvv" content="{{ ctrans('texts.cvv') }}">
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
<input type="hidden" name="gateway_response">
<input type="hidden" name="store_card" id="store_card">
<input type="hidden" name="payment_hash" value="{{ $payment_hash }}">
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="1">
<input type="hidden" name="token" id="token" value="">
<input type="hidden" name="securefieldcode" value="">
</form>
<div class="alert alert-failure mb-4" hidden id="errors"></div>
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.payment_type')])
{{ ctrans('texts.credit_card') }}
@endcomponent
@include('portal.ninja2020.gateways.includes.payment_details')
@component('portal.ninja2020.components.general.card-element', ['title' => ctrans('texts.pay_with')])
@if (count($tokens) > 0)
@foreach ($tokens as $token)
<label class="mr-4">
<input type="radio" data-token="{{ $token->token }}" name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token" />
<span class="ml-1 cursor-pointer">**** {{ $token->meta?->last4 }}</span>
</label>
@endforeach
@endisset
<label>
<input type="radio" id="toggle-payment-with-credit-card" class="form-radio cursor-pointer" name="payment-type"
checked />
<span class="ml-1 cursor-pointer">{{ __('texts.new_card') }}</span>
</label>
@endcomponent
@component('portal.ninja2020.components.general.card-element-single')
<div id="eway-secure-panel"></div>
@endcomponent
@include('portal.ninja2020.gateways.includes.save_card')
@include('portal.ninja2020.gateways.includes.pay_now', ['disabled' => true])
</div>
@assets
<script src="https://secure.ewaypayments.com/scripts/eWAY.min.js" data-init="false"></script>
@vite('resources/js/clients/payments/eway-credit-card.js')
@endassets