From a6008aff53df00eb0491fbc51d01993b8615c323 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 19 May 2021 13:24:18 +1000 Subject: [PATCH] Fixes for importing customers into Stripe. --- app/PaymentDrivers/Stripe/ImportCustomers.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/app/PaymentDrivers/Stripe/ImportCustomers.php b/app/PaymentDrivers/Stripe/ImportCustomers.php index 6b6d32973081..2ddf7a910182 100644 --- a/app/PaymentDrivers/Stripe/ImportCustomers.php +++ b/app/PaymentDrivers/Stripe/ImportCustomers.php @@ -57,15 +57,19 @@ class ImportCustomers private function addCustomer(Customer $customer) { + if(!$account->isPaidHostedClient() && Client::where('company_id', $this->stripe->company_gateway->company_id)->count() > config('ninja.quotas.free.clients')) + return; + $account = $this->stripe->company_gateway->company->account; + nlog("search Stripe for {$custom->id}"); + $existing_customer = $this->stripe ->company_gateway ->client_gateway_tokens() ->where('gateway_customer_reference', $customer->id) ->exists(); - if($existing_customer) return; @@ -105,8 +109,6 @@ class ImportCustomers $client->name = property_exists($customer, 'name') ? $customer->name : ''; - if(!$account->isPaidHostedClient() && Client::where('company_id', $this->stripe->company_gateway->company_id)->count() <= config('ninja.quotas.free.clients')){ - $client->save(); $contact = ClientContactFactory::create($client->company_id, $client->user_id); @@ -114,8 +116,7 @@ class ImportCustomers $contact->first_name = $client->name ?: ''; $contact->phone = $client->phone ?: ''; $contact->email = $client->email ?: ''; - $contact->save(); - - } + $contact->save(); + } }