diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index 9aa9a3f5447b..6a774fe1999d 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -230,14 +230,11 @@ class GoCardlessPaymentDriver extends BaseDriver public function processWebhookRequest(PaymentWebhookRequest $request) { // Allow app to catch up with webhook request. - sleep(2); - $this->init(); nlog("GoCardless Event"); nlog($request->all()); - if(!is_array($request->events) || !is_object($request->events)){ nlog("No GoCardless events to process in response?"); @@ -245,19 +242,24 @@ class GoCardlessPaymentDriver extends BaseDriver } + sleep(1); + foreach ($request->events as $event) { if ($event['action'] === 'confirmed') { + + nlog("Searching for transaction reference"); + $payment = Payment::query() ->where('transaction_reference', $event['links']['payment']) - ->where('company_id', $request->getCompany()->id) + // ->where('company_id', $request->getCompany()->id) ->first(); if ($payment) { $payment->status_id = Payment::STATUS_COMPLETED; $payment->save(); } - - + else + nlog("I was unable to find the payment for this reference"); //finalize payments on invoices here. } @@ -266,7 +268,7 @@ class GoCardlessPaymentDriver extends BaseDriver $payment = Payment::query() ->where('transaction_reference', $event['links']['payment']) - ->where('company_id', $request->getCompany()->id) + // ->where('company_id', $request->getCompany()->id) ->first(); if ($payment) { diff --git a/app/Services/Client/Statement.php b/app/Services/Client/Statement.php index f968e32bb740..b96e4b51ff12 100644 --- a/app/Services/Client/Statement.php +++ b/app/Services/Client/Statement.php @@ -226,6 +226,7 @@ class Statement ->whereIn('status_id', $this->invoiceStatuses()) ->whereBetween('date', [Carbon::parse($this->options['start_date']), Carbon::parse($this->options['end_date'])]) ->orderBy('due_date', 'ASC') + ->orderBy('date', 'ASC') ->cursor(); }