Fixes for GoCardless webhooks

This commit is contained in:
David Bomba 2022-06-11 07:02:24 +10:00
parent 6e357d8c7b
commit 54c97a8755

View File

@ -235,7 +235,7 @@ class GoCardlessPaymentDriver extends BaseDriver
nlog("GoCardless Event");
nlog($request->all());
if(!is_array($request->events) || !is_object($request->events)){
if(!$request->has("events")){
nlog("No GoCardless events to process in response?");
return response()->json([], 200);
@ -251,12 +251,13 @@ 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) {
$payment->status_id = Payment::STATUS_COMPLETED;
$payment->save();
nlog("GoCardless completed");
}
else
nlog("I was unable to find the payment for this reference");
@ -268,12 +269,13 @@ 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) {
$payment->status_id = Payment::STATUS_FAILED;
$payment->save();
nlog("GoCardless completed");
}
}
}