From a708daf112affef86fbb05259fe73385660992bc Mon Sep 17 00:00:00 2001 From: Michiel Gerritsen Date: Mon, 4 Nov 2024 16:03:40 +0100 Subject: [PATCH] Bugfix: Catch getIssuer api key errors --- Model/MollieConfigProvider.php | 10 ++++++++-- .../Mollie/Wrapper/MollieApiClientFallbackWrapper.php | 7 +++++++ 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Model/MollieConfigProvider.php b/Model/MollieConfigProvider.php index 1fe2abd595c..8d6bffd1152 100644 --- a/Model/MollieConfigProvider.php +++ b/Model/MollieConfigProvider.php @@ -223,10 +223,16 @@ public function getActiveMethods(CartInterface $cart = null): array private function getIssuers(string $code, array $config): array { - $mollieApi = $this->mollieApiClient->loadByStore(); $issuerListType = $this->config->getIssuerListType($code, $this->storeManager->getStore()->getId()); $config['payment']['issuersListType'][$code] = $issuerListType; - $config['payment']['issuers'][$code] = $this->getIssuers->execute($mollieApi, $code, $issuerListType); + + try { + $mollieApi = $this->mollieApiClient->loadByStore(); + $config['payment']['issuers'][$code] = $this->getIssuers->execute($mollieApi, $code, $issuerListType); + } catch (\Exception $exception) { + $this->config->addTolog('error', 'Unable to load issuers: ' . $exception->getMessage()); + $config['payment']['issuers'][$code] = []; + } return $config; } diff --git a/Service/Mollie/Wrapper/MollieApiClientFallbackWrapper.php b/Service/Mollie/Wrapper/MollieApiClientFallbackWrapper.php index 14fcc22994a..2249b5857df 100644 --- a/Service/Mollie/Wrapper/MollieApiClientFallbackWrapper.php +++ b/Service/Mollie/Wrapper/MollieApiClientFallbackWrapper.php @@ -2,10 +2,17 @@ namespace Mollie\Payment\Service\Mollie\Wrapper; +use Mollie\Api\Exceptions\ApiException; +use Mollie\Api\Exceptions\IncompatiblePlatform; use Mollie\Api\MollieApiClient; class MollieApiClientFallbackWrapper extends MollieApiClient { + /** + * @throws ApiException If there's an API error during initialization. + * @throws IncompatiblePlatform If the platform is not compatible. + * @return void + */ public function initializeEndpoints() { parent::initializeEndpoints();