Hide archived payment methods where the gateway has been archived / deleted

This commit is contained in:
David Bomba 2022-02-18 10:52:17 +11:00
parent 6ec6ae8756
commit ded4b2af28
4 changed files with 26 additions and 7 deletions

View File

@ -36,6 +36,10 @@ class PaymentMethodsTable extends Component
->with('gateway_type')
->where('company_id', $this->company->id)
->where('client_id', $this->client->id)
->whereHas('gateway', function ($query) {
$query->where('is_deleted',0)
->where('deleted_at', NULL);
})
->orderBy($this->sort_field, $this->sort_asc ? 'asc' : 'desc')
->paginate($this->per_page);

View File

@ -307,8 +307,14 @@ class AutoBillInvoice extends AbstractService
{
//get all client gateway tokens and set the is_default one to the first record
$gateway_tokens = $this->client->gateway_tokens()->orderBy('is_default', 'DESC')->get();
// $gateway_tokens = $this->client->gateway_tokens;
$gateway_tokens = $this->client
->gateway_tokens()
->whereHas('gateway', function ($query) {
$query->where('is_deleted',0)
->where('deleted_at', NULL);
})->orderBy('is_default', 'DESC')
->get();
$filtered_gateways = $gateway_tokens->filter(function ($gateway_token) use($amount) {

View File

@ -1,7 +1,4 @@
@php
// $token_billing = $gateway instanceof \App\Models\CompanyGateway
// ? $gateway->token_billing !== 'always'
// : $gateway->company_gateway->token_billing !== 'always';
$gateway_instance = $gateway instanceof \App\Models\CompanyGateway ? $gateway : $gateway->company_gateway;
$token_billing = true;
@ -9,7 +6,7 @@
$checked_on = '';
$checked_off = 'checked';
if($gateway_instance->token_billing == 'off' || $gateway_instance->token_billing == 'always'){
if($gateway_instance->token_billing == 'off'){
$token_billing = false;
$token_billing_string = 'false';
}

View File

@ -1,5 +1,17 @@
@extends('portal.ninja2020.layout.payments', ['gateway_title' => 'Credit card', 'card_title' => 'Credit card'])
@php
$gateway_instance = $gateway instanceof \App\Models\CompanyGateway ? $gateway : $gateway->company_gateway;
$token_billing_string = 'true';
if($gateway_instance->token_billing == 'off' || $gateway_instance->token_billing == 'optin'){
$token_billing_string = 'false';
}
@endphp
@section('gateway_head')
@if($gateway->company_gateway->getConfigField('account_id'))
<meta name="stripe-account-id" content="{{ $gateway->company_gateway->getConfigField('account_id') }}">
@ -18,7 +30,7 @@
<form action="{{ route('client.payments.response') }}" method="post" id="server-response">
@csrf
<input type="hidden" name="gateway_response">
<input type="hidden" name="store_card">
<input type="hidden" name="store_card" value="{{ $token_billing_string }}">
<input type="hidden" name="payment_hash" value="{{ $payment_hash }}">
<input type="hidden" name="company_gateway_id" value="{{ $gateway->getCompanyGatewayId() }}">