Minor fixes for gocardless

This commit is contained in:
David Bomba 2022-05-14 07:30:40 +10:00
parent 641fd20ef2
commit 0c55a9968d
2 changed files with 10 additions and 7 deletions

View File

@ -230,14 +230,11 @@ class GoCardlessPaymentDriver extends BaseDriver
public function processWebhookRequest(PaymentWebhookRequest $request) public function processWebhookRequest(PaymentWebhookRequest $request)
{ {
// Allow app to catch up with webhook request. // Allow app to catch up with webhook request.
sleep(2);
$this->init(); $this->init();
nlog("GoCardless Event"); nlog("GoCardless Event");
nlog($request->all()); nlog($request->all());
if(!is_array($request->events) || !is_object($request->events)){ if(!is_array($request->events) || !is_object($request->events)){
nlog("No GoCardless events to process in response?"); nlog("No GoCardless events to process in response?");
@ -245,19 +242,24 @@ class GoCardlessPaymentDriver extends BaseDriver
} }
sleep(1);
foreach ($request->events as $event) { foreach ($request->events as $event) {
if ($event['action'] === 'confirmed') { if ($event['action'] === 'confirmed') {
nlog("Searching for transaction reference");
$payment = Payment::query() $payment = Payment::query()
->where('transaction_reference', $event['links']['payment']) ->where('transaction_reference', $event['links']['payment'])
->where('company_id', $request->getCompany()->id) // ->where('company_id', $request->getCompany()->id)
->first(); ->first();
if ($payment) { if ($payment) {
$payment->status_id = Payment::STATUS_COMPLETED; $payment->status_id = Payment::STATUS_COMPLETED;
$payment->save(); $payment->save();
} }
else
nlog("I was unable to find the payment for this reference");
//finalize payments on invoices here. //finalize payments on invoices here.
} }
@ -266,7 +268,7 @@ class GoCardlessPaymentDriver extends BaseDriver
$payment = Payment::query() $payment = Payment::query()
->where('transaction_reference', $event['links']['payment']) ->where('transaction_reference', $event['links']['payment'])
->where('company_id', $request->getCompany()->id) // ->where('company_id', $request->getCompany()->id)
->first(); ->first();
if ($payment) { if ($payment) {

View File

@ -226,6 +226,7 @@ class Statement
->whereIn('status_id', $this->invoiceStatuses()) ->whereIn('status_id', $this->invoiceStatuses())
->whereBetween('date', [Carbon::parse($this->options['start_date']), Carbon::parse($this->options['end_date'])]) ->whereBetween('date', [Carbon::parse($this->options['start_date']), Carbon::parse($this->options['end_date'])])
->orderBy('due_date', 'ASC') ->orderBy('due_date', 'ASC')
->orderBy('date', 'ASC')
->cursor(); ->cursor();
} }