Remove fullfilled listener from gocardless webhook
This commit is contained in:
parent
a1278e783d
commit
98450f434d
|
|
@ -323,53 +323,53 @@ class GoCardlessPaymentDriver extends BaseDriver
|
||||||
//after i resolve the payment hash, ensure the invoice has not been marked as paid and the payment does not already exist.
|
//after i resolve the payment hash, ensure the invoice has not been marked as paid and the payment does not already exist.
|
||||||
//if it does exist, ensure it is completed and not pending.
|
//if it does exist, ensure it is completed and not pending.
|
||||||
|
|
||||||
if ($event['action'] == 'fulfilled' && array_key_exists('billing_request', $event['links'])) {
|
// if ($event['action'] == 'fulfilled' && array_key_exists('billing_request', $event['links'])) {
|
||||||
$hash = PaymentHash::whereJsonContains('data->billing_request', $event['links']['billing_request'])->first();
|
// $hash = PaymentHash::whereJsonContains('data->billing_request', $event['links']['billing_request'])->first();
|
||||||
|
|
||||||
if (!$hash) {
|
// if (!$hash) {
|
||||||
nlog("GoCardless: couldn't find a hash, need to abort => Billing Request => " . $event['links']['billing_request']);
|
// nlog("GoCardless: couldn't find a hash, need to abort => Billing Request => " . $event['links']['billing_request']);
|
||||||
return response()->json([], 200);
|
// return response()->json([], 200);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->setPaymentHash($hash);
|
// $this->setPaymentHash($hash);
|
||||||
|
|
||||||
$billing_request = $this->gateway->billingRequests()->get(
|
// $billing_request = $this->gateway->billingRequests()->get(
|
||||||
$event['links']['billing_request']
|
// $event['links']['billing_request']
|
||||||
);
|
// );
|
||||||
|
|
||||||
$payment = $this->gateway->payments()->get(
|
// $payment = $this->gateway->payments()->get(
|
||||||
$billing_request->payment_request->links->payment
|
// $billing_request->payment_request->links->payment
|
||||||
);
|
// );
|
||||||
|
|
||||||
if ($billing_request->status === 'fulfilled') {
|
// if ($billing_request->status === 'fulfilled') {
|
||||||
$invoices = Invoice::query()->whereIn('id', $this->transformKeys(array_column($hash->invoices(), 'invoice_id')))->withTrashed()->get();
|
// $invoices = Invoice::query()->whereIn('id', $this->transformKeys(array_column($hash->invoices(), 'invoice_id')))->withTrashed()->get();
|
||||||
|
|
||||||
$this->client = $invoices->first()->client;
|
// $this->client = $invoices->first()->client;
|
||||||
|
|
||||||
$invoices->each(function ($invoice) {
|
// $invoices->each(function ($invoice) {
|
||||||
//if payments exist already, they just need to be confirmed.
|
// //if payments exist already, they just need to be confirmed.
|
||||||
if ($invoice->payments()->exists()) {
|
// if ($invoice->payments()->exists()) {
|
||||||
$invoice->payments()->where('status_id', 1)->cursor()->each(function ($payment) {
|
// $invoice->payments()->where('status_id', 1)->cursor()->each(function ($payment) {
|
||||||
$payment->status_id = 4;
|
// $payment->status_id = 4;
|
||||||
$payment->save();
|
// $payment->save();
|
||||||
});
|
// });
|
||||||
}
|
// }
|
||||||
});
|
// });
|
||||||
|
|
||||||
// remove all paid invoices
|
// // remove all paid invoices
|
||||||
$invoices->filter(function ($invoice) {
|
// $invoices->filter(function ($invoice) {
|
||||||
return $invoice->isPayable();
|
// return $invoice->isPayable();
|
||||||
});
|
// });
|
||||||
|
|
||||||
//return early if nothing to do
|
// //return early if nothing to do
|
||||||
if ($invoices->count() == 0) {
|
// if ($invoices->count() == 0) {
|
||||||
nlog("GoCardless: Could not harvest any invoices - probably all paid!!");
|
// nlog("GoCardless: Could not harvest any invoices - probably all paid!!");
|
||||||
return response()->json([], 200);
|
// return response()->json([], 200);
|
||||||
}
|
// }
|
||||||
|
|
||||||
$this->processSuccessfulPayment($payment);
|
// $this->processSuccessfulPayment($payment);
|
||||||
}
|
// }
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
return response()->json([], 200);
|
return response()->json([], 200);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue