From 9910e4f9973976449e0a1afe93c479c06b3548c9 Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 11 Jan 2022 08:55:11 +1100 Subject: [PATCH] Test GoCardless webhooks for valid events --- app/PaymentDrivers/GoCardlessPaymentDriver.php | 9 +++++++++ app/Services/Payment/UpdateInvoicePayment.php | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index 721125409090..1cb6e2fb8183 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -234,6 +234,15 @@ class GoCardlessPaymentDriver extends BaseDriver $this->init(); + + if(!is_array($request->events) || !is_object($request->events)){ + + nlog("No GoCardless events to process in response?"); + return response()->json([], 200); + + } + + foreach ($request->events as $event) { if ($event['action'] === 'confirmed') { $payment = Payment::query() diff --git a/app/Services/Payment/UpdateInvoicePayment.php b/app/Services/Payment/UpdateInvoicePayment.php index e1750713c95b..16c5d9738b2c 100644 --- a/app/Services/Payment/UpdateInvoicePayment.php +++ b/app/Services/Payment/UpdateInvoicePayment.php @@ -87,7 +87,7 @@ class UpdateInvoicePayment $invoice->refresh(); $invoice->service() - ->touchPdf() + ->touchPdf(true) ->workFlow() ->save();