diff --git a/app/PaymentDrivers/Stripe/ImportCustomers.php b/app/PaymentDrivers/Stripe/ImportCustomers.php index 377d2d53d386..90d1eb83842f 100644 --- a/app/PaymentDrivers/Stripe/ImportCustomers.php +++ b/app/PaymentDrivers/Stripe/ImportCustomers.php @@ -26,6 +26,7 @@ use App\PaymentDrivers\StripePaymentDriver; use App\Utils\Ninja; use App\Utils\Traits\GeneratesCounter; use App\Utils\Traits\MakesHash; +use Illuminate\Database\QueryException; use Stripe\Customer; use Stripe\PaymentMethod; @@ -37,6 +38,8 @@ class ImportCustomers /** @var StripePaymentDriver */ public $stripe; + private bool $completed = true; + public $update_payment_methods; public function __construct(StripePaymentDriver $stripe) @@ -64,9 +67,14 @@ class ImportCustomers } //handle - if(is_array($customers->data) && end($customers->data) && array_key_exists('id', end($customers->data))) - $starting_after = end($customers->data)['id']; - else + // if(is_array($customers->data) && end($customers->data) && array_key_exists('id', end($customers->data))) + // $starting_after = end($customers->data)['id']; + // else + // break; + + $starting_after = isset(end($customers->data)['id']) ? end($customers->data)['id'] : false; + + if(!$starting_after) break; } while ($customers->has_more); @@ -132,10 +140,30 @@ class ImportCustomers $client->name = $customer->name ? $customer->name : $customer->email; if (! isset($client->number) || empty($client->number)) { - $client->number = $this->getNextClientNumber($client); - } - $client->save(); + $x = 1; + + do { + try { + $client->number = $this->getNextClientNumber($client); + $client->saveQuietly(); + + $this->completed = false; + } catch (QueryException $e) { + $x++; + + if ($x > 10) { + $this->completed = false; + } + } + } while ($this->completed); + + + + } + else{ + $client->save(); + } $contact = ClientContactFactory::create($client->company_id, $client->user_id); $contact->client_id = $client->id; diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index 6d781670cf0e..d7cab34fab4e 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -138,6 +138,9 @@ class PaymentIntentWebhook implements ShouldQueue $hash = isset($charge['metadata']['payment_hash']) ? $charge['metadata']['payment_hash'] : false; + if(!$hash) + return; + $payment_hash = PaymentHash::where('hash', $hash)->first(); if(!$payment_hash) diff --git a/config/ninja.php b/config/ninja.php index 45ec406ae11d..8583baa84408 100644 --- a/config/ninja.php +++ b/config/ninja.php @@ -211,5 +211,4 @@ return [ 'dev_mode' => env("YODLEE_DEV_MODE", false), 'config_name' => env("YODLEE_CONFIG_NAME", false), ], - 'dbs' => ['db-ninja-01','db-ninja-02'] -]; +]; \ No newline at end of file diff --git a/config/queue.php b/config/queue.php index 18666fc43454..412282299176 100644 --- a/config/queue.php +++ b/config/queue.php @@ -67,7 +67,7 @@ return [ 'connection' => env('REDIS_QUEUE_CONNECTION', 'default'), 'queue' => env('REDIS_QUEUE', 'default'), 'retry_after' => 90000000, - 'block_for' => 1, + 'block_for' => null, 'after_commit' => false, ],