diff --git a/app/Http/Controllers/Gateways/GoCardlessController.php b/app/Http/Controllers/Gateways/GoCardlessController.php index 10ba88b915e0..dff6ca5c0d4b 100644 --- a/app/Http/Controllers/Gateways/GoCardlessController.php +++ b/app/Http/Controllers/Gateways/GoCardlessController.php @@ -20,6 +20,7 @@ class GoCardlessController extends Controller { public function ibpRedirect(IbpRequest $request) { + return $request ->getCompanyGateway() ->driver($request->getClient()) diff --git a/app/PaymentDrivers/GoCardless/InstantBankPay.php b/app/PaymentDrivers/GoCardless/InstantBankPay.php index ff0e43db48e7..c286e1c1b0aa 100644 --- a/app/PaymentDrivers/GoCardless/InstantBankPay.php +++ b/app/PaymentDrivers/GoCardless/InstantBankPay.php @@ -95,12 +95,15 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface public function paymentResponse($request) { + $this->go_cardless->setPaymentHash( $request->getPaymentHash() ); $this->go_cardless->init(); + nlog($request->all()); + try { $billing_request = $this->go_cardless->gateway->billingRequests()->get( $this->go_cardless->payment_hash->data->billing_request @@ -117,12 +120,13 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface return $this->processSuccessfulPayment($payment); } - if ($billing_request->status === 'submitted') { + if (in_array($billing_request->status, ['fulfilling', 'submitted'])) { return $this->processPendingPayment($payment); } $this->processUnsuccessfulPayment($payment); } catch (\Exception $exception) { + throw new PaymentFailed( $exception->getMessage(), $exception->getCode() @@ -158,7 +162,7 @@ class InstantBankPay implements MethodInterface, LivewireMethodInterface $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]); } diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index 67dce0892ed8..3e88487e5c91 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -256,7 +256,7 @@ class GoCardlessPaymentDriver extends BaseDriver $this->init(); nlog('GoCardless Event'); - + nlog($request->all()); if (! $request->has('events')) { nlog('No GoCardless events to process in response?'); @@ -266,7 +266,10 @@ class GoCardlessPaymentDriver extends BaseDriver sleep(1); 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'); $payment = Payment::query()