Hide "Pay now" button if no available payment methods

This commit is contained in:
Benjamin Beganović 2020-08-24 07:18:57 +02:00
parent a0db7fdb1e
commit c985bdf1aa
2 changed files with 37 additions and 27 deletions

View File

@ -3264,4 +3264,7 @@ return [
'payment_error_code_20087' => '20087: Bad Track Data (invalid CVV and/or expiry date)', 'payment_error_code_20087' => '20087: Bad Track Data (invalid CVV and/or expiry date)',
'download_selected' => 'Download selected', 'download_selected' => 'Download selected',
'to_pay_invoices' => 'To pay invoices, you have to',
'add_payment_method_first' => 'add payment method, first',
]; ];

View File

@ -5,7 +5,6 @@
<meta name="show-invoice-terms" content="{{ $settings->show_accept_invoice_terms ? true : false }}"> <meta name="show-invoice-terms" content="{{ $settings->show_accept_invoice_terms ? true : false }}">
<meta name="require-invoice-signature" content="{{ $settings->require_invoice_signature ? true : false }}"> <meta name="require-invoice-signature" content="{{ $settings->require_invoice_signature ? true : false }}">
<script src="https://cdn.jsdelivr.net/npm/signature_pad@2.3.2/dist/signature_pad.min.js"></script> <script src="https://cdn.jsdelivr.net/npm/signature_pad@2.3.2/dist/signature_pad.min.js"></script>
<meta name="turbolinks-visit-control" content="reload">
@endpush @endpush
@section('body') @section('body')
@ -23,36 +22,44 @@
<div class="col-span-6 md:col-start-2 md:col-span-4"> <div class="col-span-6 md:col-start-2 md:col-span-4">
<div class="flex justify-end"> <div class="flex justify-end">
<div class="flex justify-end mb-2"> <div class="flex justify-end mb-2">
<div x-data="{ open: false }" @keydown.window.escape="open = false" @click.away="open = false" <!-- Pay now button -->
class="relative inline-block text-left"> @if(count($payment_methods) > 0)
<div> <div x-data="{ open: false }" @keydown.window.escape="open = false" @click.away="open = false"
<div class="rounded-md shadow-sm"> class="relative inline-block text-left">
<button @click="open = !open" type="button" <div>
class="inline-flex justify-center w-full rounded-md border border-gray-300 px-4 py-2 bg-white text-sm leading-5 font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:bg-gray-50 active:text-gray-800 transition ease-in-out duration-150"> <div class="rounded-md shadow-sm">
{{ ctrans('texts.pay_now') }} <button @click="open = !open" type="button"
<svg class="-mr-1 ml-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20"> class="inline-flex justify-center w-full rounded-md border border-gray-300 px-4 py-2 bg-white text-sm leading-5 font-medium text-gray-700 hover:text-gray-500 focus:outline-none focus:border-blue-300 focus:shadow-outline-blue active:bg-gray-50 active:text-gray-800 transition ease-in-out duration-150">
<path fill-rule="evenodd" {{ ctrans('texts.pay_now') }}
d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z" <svg class="-mr-1 ml-2 h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
clip-rule="evenodd"/> <path fill-rule="evenodd"
</svg> d="M5.293 7.293a1 1 0 011.414 0L10 10.586l3.293-3.293a1 1 0 111.414 1.414l-4 4a1 1 0 01-1.414 0l-4-4a1 1 0 010-1.414z"
</button> clip-rule="evenodd"/>
</svg>
</button>
</div>
</div> </div>
</div> <div x-show="open" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg">
<div x-show="open" class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg"> <div class="rounded-md bg-white shadow-xs">
<div class="rounded-md bg-white shadow-xs"> <div class="py-1">
<div class="py-1"> @foreach($payment_methods as $payment_method)
@foreach($payment_methods as $payment_method) <a data-turbolinks="false" href="#" @click="{ open = false }"
<a data-turbolinks="false" href="#" @click="{ open = false }" data-company-gateway-id="{{ $payment_method['company_gateway_id'] }}"
data-company-gateway-id="{{ $payment_method['company_gateway_id'] }}" data-gateway-type-id="{{ $payment_method['gateway_type_id'] }}"
data-gateway-type-id="{{ $payment_method['gateway_type_id'] }}" class="dropdown-gateway-button block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">
class="dropdown-gateway-button block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900"> {{ $payment_method['label'] }}
{{ $payment_method['label'] }} </a>
</a> @endforeach
@endforeach </div>
</div> </div>
</div> </div>
</div> </div>
</div> @else
<span class="inline-flex items-center text-sm">
<span>{{ ctrans('texts.to_pay_invoices') }} &nbsp;</span>
<a class="button-link" href="{{ route('client.payment_methods.index') }}">{{ ctrans('texts.add_payment_method_first') }}.</a>
</span>
@endif
</div> </div>
</div> </div>