Fix fatal error in checkout if no api keys #828
Closed
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR touches code in the following areas (Check what is applicable):
Frontend
Please describe the bug/feature/etc this PR contains:
Fix fatal error in the checkout if the API key is not provided or wrong configured.
Steps to reproduce:
Install the module on a fresh instance and go to checkout. Checkout is not loading at all due to an exception.
Stack trace:
[2024-11-26T14:18:14.740156+00:00] main.CRITICAL: Mollie\Api\Exceptions\ApiException: [2024-11-26T14:18:14+0000] Invalid API key: ''. An API key must start with 'test_' or
'live_' and must be at least 30 characters long. in /var/www/projects/magento2/vendor/mollie/mollie-api-php/src/MollieApiClient.php:519
Stack trace:
#0 /var/www/projects/magento2/vendor/mollie/magento2/Service/Mollie/MollieApiClient.php(74): Mollie\Api\MollieApiClient->setApiKey('')
#1 /var/www/projects/magento2/vendor/mollie/magento2/Service/Mollie/MollieApiClient.php(60): Mollie\Payment\Service\Mollie\MollieApiClient->loadByApiKey('')
#2 /var/www/projects/clarusmagento2/vendor/mollie/magento2/Model/MollieConfigProvider.php(226): Mollie\Payment\Service\Mollie\MollieApiClient->loadByStore()
#3 /var/www/projects/magento2/vendor/mollie/magento2/Model/MollieConfigProvider.php(180): Mollie\Payment\Model\MollieConfigProvider->getIssuers('mollie_methods_...', Array)
#4 /var/www/projects/magento2/vendor/magento/module-checkout/Model/CompositeConfigProvider.php(39): Mollie\Payment\Model\MollieConfigProvider->getConfig()
#5 /var/www/projects/magento2/vendor/magento/module-checkout/Block/Onepage.php(106): Magento\Checkout\Model\CompositeConfigProvider->getConfig()
#6 /var/www/projects/magento2/generated/code/Magento/Checkout/Block/Onepage/Interceptor.php(41): Magento\Checkout\Block\Onepage->getCheckoutConfig()
#7 /var/www/projects/magento2vendor/magento/module-checkout/Block/Onepage.php(128): Magento\Checkout\Block\Onepage\Interceptor->getCheckoutConfig()
#8 /var/www/projects/clarusmagento2/generated/code/Magento/Checkout/Block/Onepage/Interceptor.php(59): Magento\Checkout\Block\Onepage->getSerializedCheckoutConfig()
#9 /var/www/projects/magento2/vendor/magento/module-checkout/view/frontend/templates/onepage.phtml(27): Magento\Checkout\Block\Onepage\Interceptor->getSerializedCheckoutConfig()