From 917474695623c2b8e5e8ff0496eeb508f2d321c6 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Thu, 23 Jun 2022 20:55:26 +1000 Subject: [PATCH] Fixes for stripe webhooks --- .../Stripe/Jobs/PaymentIntentWebhook.php | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php index 48d8bcd33dd1..d94b4ec296ae 100644 --- a/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php +++ b/app/PaymentDrivers/Stripe/Jobs/PaymentIntentWebhook.php @@ -121,7 +121,19 @@ class PaymentIntentWebhook implements ShouldQueue nlog("payment intent"); nlog($this->stripe_request); - if(optional($this->stripe_request['object']['charges']['data'][0]['metadata']['payment_hash']) && in_array('card', $this->stripe_request['object']['allowed_source_types'])) + if(array_key_exists('allowed_source_types', $this->stripe_request['object']) && optional($this->stripe_request['object']['charges']['data'][0]['metadata']['payment_hash']) && in_array('card', $this->stripe_request['object']['allowed_source_types'])) + { + nlog("hash found"); + + $hash = $this->stripe_request['object']['charges']['data'][0]['metadata']['payment_hash']; + + $payment_hash = PaymentHash::where('hash', $hash)->first(); + $invoice = Invoice::with('client')->find($payment_hash->fee_invoice_id); + $client = $invoice->client; + + $this->updateCreditCardPayment($payment_hash, $client); + } + elseif(array_key_exists('payment_method_types', $this->stripe_request['object']) && optional($this->stripe_request['object']['charges']['data'][0]['metadata']['payment_hash']) && in_array('card', $this->stripe_request['object']['payment_method_types'])) { nlog("hash found");