From 814ac115e804d57ad1f1ea00f2ad0df907a9f3ac Mon Sep 17 00:00:00 2001 From: David Bomba Date: Tue, 3 Oct 2023 14:50:47 +1100 Subject: [PATCH] Fixes for gocardless invalid credentials --- app/PaymentDrivers/GoCardlessPaymentDriver.php | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/app/PaymentDrivers/GoCardlessPaymentDriver.php b/app/PaymentDrivers/GoCardlessPaymentDriver.php index c798c5c1e989..bd461197f663 100644 --- a/app/PaymentDrivers/GoCardlessPaymentDriver.php +++ b/app/PaymentDrivers/GoCardlessPaymentDriver.php @@ -98,10 +98,17 @@ class GoCardlessPaymentDriver extends BaseDriver public function init(): self { - $this->gateway = new \GoCardlessPro\Client([ - 'access_token' => $this->company_gateway->getConfigField('accessToken'), - 'environment' => $this->company_gateway->getConfigField('testMode') ? \GoCardlessPro\Environment::SANDBOX : \GoCardlessPro\Environment::LIVE, - ]); + try { + $this->gateway = new \GoCardlessPro\Client([ + 'access_token' => $this->company_gateway->getConfigField('accessToken'), + 'environment' => $this->company_gateway->getConfigField('testMode') ? \GoCardlessPro\Environment::SANDBOX : \GoCardlessPro\Environment::LIVE, + ]); + } + catch(\GoCardlessPro\Core\Exception\AuthenticationException $e){ + + throw new \Exception('GoCardless: Invalid Access Token', 403); + + } return $this; }