1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 08:21:34 +02:00

Hide "Pay now" button if no gateways are configured

This commit is contained in:
Benjamin Beganović 2021-07-14 14:54:09 +02:00
parent 04e17c7349
commit 7e5a231bf8
6 changed files with 32 additions and 7 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
{"/livewire.js":"/livewire.js?id=54d078b2ce39327a1702"}
{"/livewire.js":"/livewire.js?id=b09cb328e689f1bb8d77"}

View File

@ -94,7 +94,7 @@
{!! App\Models\Invoice::badgeForStatus($invoice->status) !!}
</td>
<td class="flex items-center justify-end px-6 py-4 text-sm font-medium leading-5 whitespace-no-wrap">
@if($invoice->isPayable() && $invoice->balance > 0)
@if($invoice->isPayable() && $invoice->balance > 0 && !empty(auth()->user()->client->service()->getPaymentMethods(0)))
<form action="{{ route('client.invoices.bulk') }}" method="post">
@csrf
<input type="hidden" name="invoices[]" value="{{ $invoice->hashed_id }}">

View File

@ -16,7 +16,10 @@
<form action="{{ route('client.invoices.bulk') }}" method="post" id="bulkActions">
@csrf
<button type="submit" class="button button-primary bg-primary" name="action" value="download">{{ ctrans('texts.download') }}</button>
<button type="submit" class="button button-primary bg-primary" name="action" value="payment">{{ ctrans('texts.pay_now') }}</button>
@if(!empty(auth()->user()->client->service()->getPaymentMethods(0)))
<button type="submit" class="button button-primary bg-primary" name="action" value="payment">{{ ctrans('texts.pay_now') }}</button>
@endif
</form>
</div>
<div class="flex flex-col mt-4">

View File

@ -12,6 +12,7 @@
namespace Tests\Browser\ClientPortal;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
@ -76,4 +77,25 @@ class InvoicesTest extends DuskTestCase
->visitRoute('client.logout');
});
}
public function testPayNowButtonIsntShowingWhenNoGatewaysConfigured()
{
$this->disableCompanyGateways();
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->assertDontSee('Pay Now');
});
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->assertSee('Pay Now')
->visitRoute('client.logout');
});
}
}