1
0
mirror of https://github.com/invoiceninja/invoiceninja.git synced 2024-09-20 16:31:33 +02:00

gocardless webhook handling

This commit is contained in:
David Bomba 2022-11-07 14:24:33 +11:00
parent eb1355cbd7
commit b5d4f83654

View File

@ -275,27 +275,36 @@ class GoCardlessPaymentDriver extends BaseDriver
}
//billing_request fulfilled
//PaymentHash::whereJsonContains('data->billing_request', 'BRQ0001BQ8JESEV')->first();
//
//i need to build more context here, i need the client , the payment hash resolved and update the class properties.
//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($event['action'] == 'fulfilled' && array_key_exists('billing_request', $event['links'])) {
if($event['action'] == 'fulfilled' && array_key_exists('billing_request', $event['links'])) {
// $billing_request = $this->go_cardless->gateway->billingRequests()->get(
// $event['links']['billing_request']
// );
$hash = PaymentHash::whereJsonContains('data->billing_request', $event['links']['billing_request'])->first();
// $payment = $this->go_cardless->gateway->payments()->get(
// $billing_request->payment_request->links->payment
// );
if(!$hash){
nlog("GoCardless couldn't find a hash, need to abort => Billing Request => " . $event['links']['billing_request']);
return;
}
// if ($billing_request->status === 'fulfilled') {
// $this->processSuccessfulPayment($payment);
// }
$this->go_cardless->setPaymentHash($hash);
// }
$billing_request = $this->go_cardless->gateway->billingRequests()->get(
$event['links']['billing_request']
);
$payment = $this->go_cardless->gateway->payments()->get(
$billing_request->payment_request->links->payment
);
if ($billing_request->status === 'fulfilled') {
$this->processSuccessfulPayment($payment);
}
}
}