Payments without token

This commit is contained in:
Benjamin Beganović 2021-08-26 15:46:31 +02:00
parent 016e8033fb
commit 760de008f8
2 changed files with 65 additions and 0 deletions

View File

@ -76,4 +76,11 @@ class ACH implements MethodInterface
}
}
}
public function paymentView(array $data)
{
$data['gateway'] = $this->braintree;
return render('gateways.braintree.ach.pay', $data);
}
}

View File

@ -0,0 +1,58 @@
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'ACH', 'card_title' => 'ACH'])
@section('gateway_content')
@if(count($tokens) > 0)
<div class="alert alert-failure mb-4" hidden id="errors"></div>
@include('portal.ninja2020.gateways.includes.payment_details')
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">
<input type="hidden" name="payment_method_id" value="{{ $payment_method_id }}">
<input type="hidden" name="source" value="">
<input type="hidden" name="amount" value="{{ $amount }}">
<input type="hidden" name="currency" value="{{ $currency }}">
<input type="hidden" name="customer" value="{{ $customer->id }}">
<input type="hidden" name="payment_hash" value="{{ $payment_hash }}">
</form>
@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->hashed_id }}"
name="payment-type"
class="form-radio cursor-pointer toggle-payment-with-token"/>
<span class="ml-1 cursor-pointer">{{ ctrans('texts.bank_transfer') }} (*{{ $token->meta->last4 }})</span>
</label>
@endforeach
@endisset
@endcomponent
@include('portal.ninja2020.gateways.includes.pay_now')
@else
@component('portal.ninja2020.components.general.card-element-single', ['title' => 'ACH', 'show_title' => false])
<span class="block">{{ ctrans('texts.bank_account_not_linked') }}</span>
<a class="hover:underline text-primary mt-2 block"
href="{{ route('client.payment_methods.index') }}">{{ ctrans('texts.add_payment_method') }}</a>
@endcomponent
@endif
@endsection
@push('footer')
<script>
Array
.from(document.getElementsByClassName('toggle-payment-with-token'))
.forEach((element) => element.addEventListener('click', (element) => {
document.querySelector('input[name=source]').value = element.target.dataset.token;
}));
document.getElementById('pay-now').addEventListener('click', function () {
document.getElementById('server-response').submit();
});
</script>
@endpush