Fixes for instant bank payment

This commit is contained in:
David Bomba 2024-09-05 19:41:21 +10:00
parent 2082d2bf8a
commit 7bf7ae1d31
3 changed files with 12 additions and 4 deletions

View File

@ -20,6 +20,7 @@ class GoCardlessController extends Controller
{ {
public function ibpRedirect(IbpRequest $request) public function ibpRedirect(IbpRequest $request)
{ {
return $request return $request
->getCompanyGateway() ->getCompanyGateway()
->driver($request->getClient()) ->driver($request->getClient())

View File

@ -95,12 +95,15 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
public function paymentResponse($request) public function paymentResponse($request)
{ {
$this->go_cardless->setPaymentHash( $this->go_cardless->setPaymentHash(
$request->getPaymentHash() $request->getPaymentHash()
); );
$this->go_cardless->init(); $this->go_cardless->init();
nlog($request->all());
try { try {
$billing_request = $this->go_cardless->gateway->billingRequests()->get( $billing_request = $this->go_cardless->gateway->billingRequests()->get(
$this->go_cardless->payment_hash->data->billing_request $this->go_cardless->payment_hash->data->billing_request
@ -117,12 +120,13 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
return $this->processSuccessfulPayment($payment); return $this->processSuccessfulPayment($payment);
} }
if ($billing_request->status === 'submitted') { if (in_array($billing_request->status, ['fulfilling', 'submitted'])) {
return $this->processPendingPayment($payment); return $this->processPendingPayment($payment);
} }
$this->processUnsuccessfulPayment($payment); $this->processUnsuccessfulPayment($payment);
} catch (\Exception $exception) { } catch (\Exception $exception) {
throw new PaymentFailed( throw new PaymentFailed(
$exception->getMessage(), $exception->getMessage(),
$exception->getCode() $exception->getCode()
@ -158,7 +162,7 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface
$this->go_cardless->client->company, $this->go_cardless->client->company,
); );
return redirect()->route('client.payments.show', ['payment' => $this->go_cardless->encodePrimaryKey($payment->id)]); return redirect()->route('client.payments.show', ['payment' => $payment->hashed_id]);
} }

View File

@ -256,7 +256,7 @@ class GoCardlessPaymentDriver extends BaseDriver
$this->init(); $this->init();
nlog('GoCardless Event'); nlog('GoCardless Event');
nlog($request->all());
if (! $request->has('events')) { if (! $request->has('events')) {
nlog('No GoCardless events to process in response?'); nlog('No GoCardless events to process in response?');
@ -266,7 +266,10 @@ class GoCardlessPaymentDriver extends BaseDriver
sleep(1); sleep(1);
foreach ($request->events as $event) { foreach ($request->events as $event) {
if ($event['action'] === 'confirmed' || $event['action'] === 'paid_out') { if (
($event['resource_type'] == 'payments' && $event['action'] == 'confirmed') ||
$event['action'] === 'paid_out')
{
nlog('Searching for transaction reference'); nlog('Searching for transaction reference');
$payment = Payment::query() $payment = Payment::query()