From 3a97b39e3b824a4e58651ba365b0362e8b260897 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Wed, 7 Dec 2022 07:43:38 +1100 Subject: [PATCH] Ensure we retrieve archived invoices in Stripe payment webhook --- .../Stripe/Jobs/PaymentIntentWebhook.php | 58 +++++++++++-------- 1 file changed, 33 insertions(+), 25 deletions(-) diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index d3a8ad40e7d6..e6971ae79a67 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -154,31 +154,6 @@ class PaymentIntentWebhook implements ShouldQueue 'card_details' => isset($charge['payment_method_details']['card']['brand']) ? $charge['payment_method_details']['card']['brand'] : PaymentType::CREDIT_CARD_OTHER ]; - if(isset($pi['allowed_source_types']) && in_array('card', $pi['allowed_source_types'])) - { - - $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); - $client = $invoice->client; - - $this->updateCreditCardPayment($payment_hash, $client, $meta); - } - elseif(isset($pi['payment_method_types']) && in_array('card', $pi['payment_method_types'])) - { - - $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); - $client = $invoice->client; - - $this->updateCreditCardPayment($payment_hash, $client, $meta); - } - elseif(isset($pi['payment_method_types']) && in_array('us_bank_account', $pi['payment_method_types'])) - { - - $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); - $client = $invoice->client; - - $this->updateAchPayment($payment_hash, $client, $meta); - } - SystemLogger::dispatch( ['response' => $this->stripe_request, 'data' => []], SystemLog::CATEGORY_GATEWAY_RESPONSE, @@ -188,6 +163,39 @@ class PaymentIntentWebhook implements ShouldQueue $company, ); + if(isset($pi['allowed_source_types']) && in_array('card', $pi['allowed_source_types'])) + { + + $invoice = Invoice::with('client')->withTrashed()->find($payment_hash->fee_invoice_id); + $client = $invoice->client; + + if($invoice->is_deleted) + return; + + $this->updateCreditCardPayment($payment_hash, $client, $meta); + } + elseif(isset($pi['payment_method_types']) && in_array('card', $pi['payment_method_types'])) + { + + $invoice = Invoice::with('client')->withTrashed()->find($payment_hash->fee_invoice_id); + $client = $invoice->client; + + if($invoice->is_deleted) + return; + + $this->updateCreditCardPayment($payment_hash, $client, $meta); + } + elseif(isset($pi['payment_method_types']) && in_array('us_bank_account', $pi['payment_method_types'])) + { + + $invoice = Invoice::with('client')->withTrashed()->find($payment_hash->fee_invoice_id); + $client = $invoice->client; + + if($invoice->is_deleted) + return; + + $this->updateAchPayment($payment_hash, $client, $meta); + } }