6

I am doing fresh setup on Magento Cloud server and facing below issue.

Issue: Page break with error while redirecting to Cart page.

Error shown on Browser

Steps followed :

  • Add product into Cart
  • Click on "Shopping Cart" from message when added to cart or redirect from cart icon
  • Redirect to the cart "/checkout/cart/" landed with attached error.

Note: I have multi-store setup for different regions and this error occurs when I work with different store websites , like au/checkout/cart/ or us/checkout/cart/ . The default store works well without any error.

Environment Details:

  • Magento Cloud Server
  • Magento 2.4

When I check the logs, I found below errors

[2020-09-01 06:35:06] report.ERROR: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway). [] []

[2020-09-01 06:35:06] report.ERROR: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway). [] [] [2020-09-01 06:35:06] report.ERROR: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway). [] [] [2020-09-01 06:35:06] report.ERROR: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway). [] [] [2020-09-01 06:35:06] report.ERROR: Braintree\Configuration::merchantId needs to be set (or accessToken needs to be passed to Braintree\Gateway). [] [] [2020-09-01 06:35:06] report.CRITICAL: TypeError: explode() expects parameter 2 to be string, null given in /app/vendor/paypal/module-braintree-core/Model/Lpm/Config.php:125 Stack trace: #0 /app/vendor/paypal/module-braintree-core/Model/Lpm/Config.php(125): explode(',', NULL) #1 /app/vendor/paypal/module-braintree-core/Model/Lpm/Ui/ConfigProvider.php(39): PayPal\Braintree\Model\Lpm\Config->getAllowedMethods() #2 /app/vendor/magento/module-checkout/Model/CompositeConfigProvider.php(39): PayPal\Braintree\Model\Lpm\Ui\ConfigProvider->getConfig() #3 /app/vendor/magento/module-checkout/Block/Cart/Shipping.php(84): Magento\Checkout\Model\CompositeConfigProvider->getConfig() #4 /app/vendor/magento/module-checkout/Block/Cart/Shipping.php(120): Magento\Checkout\Block\Cart\Shipping->getCheckoutConfig() #5 /app/vendor/magento/module-checkout/view/frontend/templates/cart/shipping.phtml(36): Magento\Checkout\Block\Cart\Shipping->getSerializedCheckoutConfig() #6 /app/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/app/vendor/mag...') #7 /app/vendor/magento/framework/View/Element/Template.php(273): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart\Shipping), '/app/vendor/mag...', Array) #8 /app/vendor/magento/framework/View/Element/Template.php(303): Magento\Framework\View\Element\Template->fetchView('/app/vendor/mag...') #9 /app/vendor/magento/framework/View/Element/AbstractBlock.php(1111): Magento\Framework\View\Element\Template->_toHtml() #10 /app/vendor/magento/framework/View/Element/AbstractBlock.php(1115): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element{closure}() #11 /app/vendor/magento/framework/View/Element/AbstractBlock.php(675): Magento\Framework\View\Element\AbstractBlock->_loadCache() #12 /app/vendor/magento/framework/View/Layout.php(566): Magento\Framework\View\Element\AbstractBlock->toHtml() #13 /app/vendor/magento/framework/View/Layout.php(542): Magento\Framework\View\Layout->_renderBlock('checkout.cart.s...') #14 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.s...') #15 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('checkout.cart.s...', false) #16 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('cart.summary', false) #17 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('cart.summary') #18 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('cart.summary', false) #19 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('checkout.cart.c...', false) #20 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.c...') #21 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('checkout.cart.c...', false) #22 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('checkout.cart.i...', false) #23 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart.i...') #24 /app/vendor/magento/framework/View/Element/AbstractBlock.php(522): Magento\Framework\View\Layout->renderElement('checkout.cart.i...', true) #25 /app/vendor/magento/module-checkout/view/frontend/templates/cart.phtml(16): Magento\Framework\View\Element\AbstractBlock->getChildHtml('with-items') #26 /app/vendor/magento/framework/View/TemplateEngine/Php.php(71): include('/app/vendor/mag...') #27 /app/vendor/magento/framework/View/Element/Template.php(273): Magento\Framework\View\TemplateEngine\Php->render(Object(Magento\Checkout\Block\Cart), '/app/vendor/mag...', Array) #28 /app/vendor/magento/framework/View/Element/Template.php(303): Magento\Framework\View\Element\Template->fetchView('/app/vendor/mag...') #29 /app/vendor/magento/framework/View/Element/AbstractBlock.php(1111): Magento\Framework\View\Element\Template->_toHtml() #30 /app/vendor/magento/framework/View/Element/AbstractBlock.php(1115): Magento\Framework\View\Element\AbstractBlock->Magento\Framework\View\Element{closure}() #31 /app/vendor/magento/framework/View/Element/AbstractBlock.php(675): Magento\Framework\View\Element\AbstractBlock->_loadCache() #32 /app/vendor/magento/framework/View/Layout.php(566): Magento\Framework\View\Element\AbstractBlock->toHtml() #33 /app/vendor/magento/framework/View/Layout.php(542): Magento\Framework\View\Layout->_renderBlock('checkout.cart') #34 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('checkout.cart') #35 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('checkout.cart', false) #36 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('content', false) #37 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('content') #38 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('content', false) #39 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('main', false) #40 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('main') #41 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('main', false) #42 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('columns', false) #43 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('columns') #44 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('columns', false) #45 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('main.content', false) #46 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('main.content') #47 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('main.content', false) #48 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('page.wrapper', false) #49 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('page.wrapper') #50 /app/vendor/magento/framework/View/Layout.php(594): Magento\Framework\View\Layout->renderElement('page.wrapper', false) #51 /app/vendor/magento/framework/View/Layout.php(544): Magento\Framework\View\Layout->_renderContainer('root', false) #52 /app/vendor/magento/framework/View/Layout.php(497): Magento\Framework\View\Layout->renderNonCachedElement('root') #53 /app/vendor/magento/framework/View/Layout.php(963): Magento\Framework\View\Layout->renderElement('root') #54 /app/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Layout->getOutput() #55 /app/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Layout\Interceptor->___callParent('getOutput', Array) #56 /app/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Layout\Interceptor->Magento\Framework\Interception{closure}() #57 /app/generated/code/Magento/Framework/View/Layout/Interceptor.php(65): Magento\Framework\View\Layout\Interceptor->___callPlugins('getOutput', Array, Array) #58 /app/vendor/magento/framework/View/Result/Page.php(258): Magento\Framework\View\Layout\Interceptor->getOutput() #59 /app/vendor/magento/framework/View/Result/Layout.php(171): Magento\Framework\View\Result\Page->render(Object(Magento\Framework\App\Response\Http\Interceptor)) #60 /app/vendor/magento/framework/Interception/Interceptor.php(58): Magento\Framework\View\Result\Layout->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor)) #61 /app/vendor/magento/framework/Interception/Interceptor.php(138): Magento\Framework\View\Result\Page\Interceptor->___callParent('renderResult', Array) #62 /app/vendor/magento/framework/Interception/Interceptor.php(153): Magento\Framework\View\Result\Page\Interceptor->Magento\Framework\Interception{closure}(Object(Magento\Framework\App\Response\Http\Interceptor)) #63 /app/generated/code/Magento/Framework/View/Result/Page/Interceptor.php(26): Magento\Framework\View\Result\Page\Interceptor->___callPlugins('renderResult', Array, Array) #64 /app/vendor/magento/framework/App/Http.php(120): Magento\Framework\View\Result\Page\Interceptor->renderResult(Object(Magento\Framework\App\Response\Http\Interceptor)) #65 /app/vendor/magento/framework/App/Bootstrap.php(263): Magento\Framework\App\Http->launch() #66 /app/pub/index.php(40): Magento\Framework\App\Bootstrap->run(Object(Magento\Framework\App\Http\Interceptor)) #67 {main} [] []

Any help would be highly appreciated.

Thanks

4
  • did you get any solution. I am also getting the same error.
    – Joshi
    Sep 14, 2020 at 21:04
  • 1
    Unfortunately, not yet.. will update you if i'll find it.
    – Ups
    Sep 16, 2020 at 3:19
  • @Ups did you find the issue? Oct 1, 2020 at 20:22
  • Answer by @Sergey Uskov above fixed it for me. A null entry had sneaked into core_config_data. Nov 10, 2021 at 2:58

5 Answers 5

6

I faced with this issue also. But in my case disabling of modules is not a solution because we use it for paypal.

But I found what causing this error - "payment/braintree_local_payment/allowed methods" row in "core_config_data" with value=NULL.

It appeared when I saved settings for other payment method in website scope.

Removing of this row fixed the issue.

Issue didn't appeared again after this when I saved payments again.

2
  • 1
    Same problem here. Fixed. Thank you! Mar 23, 2021 at 8:51
  • Small typo: missing underscore in "allowed_methods" Jan 13, 2022 at 20:47
3

Thank you @duntuk and @Will Wright for giving efforts to solve this issue. much appreciated.

This issue was due to Braintree modules in Magento 2.4.0 and the following solutions I found for this issue.

Please Note: If you want to disable the module , you cannot make changes directly to the files in the cloud environment as it is read-only.

You must follow the standard deployment workflow to make any changes:

  1. Make any changes in your local environment
    • bin/magento module:disable PayPal_Braintree PayPal_BraintreeGraphQl
      OR
    • You can set the PayPal_Braintree and PayPal_BraintreeGraphQl module status to '0' in app/etc/config.php using the branch you want to update.
  2. Push/commit the changes to the desired environment, then redeploy

Please refer to the following for more details:

I choose the 2nd option to disable these modules as I don't need them and that fixed my problem.

Thanks

2
bin/magento module:disable PayPal_Braintree PayPal_BraintreeGraphQl

Also if you only have a single site setup "default" you should go into the database "core_config_data" and remove all scope="website" or just the ones relating to "%braintree%"

1

None of the other solutions quite worked for me.

I had to patch the following function to make it more defensive. This is obviously not ideal as it is a core Magento 2 module.

Path to file: /vendor/paypal/module-braintree-core/Model/Lpm/Config.php:119

public function getAllowedMethods(): array
{
    $this->allowedMethods = [];
    $allowedMethods = [];
    if ($this->getValue(self::KEY_ALLOWED_METHODS,$this->storeConfigResolver->getStoreId()))
    {
        $allowedMethods = explode(',',$this->getValue(self::KEY_ALLOWED_METHODS,$this->storeConfigResolver->getStoreId()));
    }
    foreach ($allowedMethods as $allowedMethod) {
        $this->allowedMethods[] = [
            'method' => $allowedMethod,
            'label' => constant('self::LABEL_'.strtoupper($allowedMethod)),
            'countries' => constant('self::COUNTRIES_'.strtoupper($allowedMethod))
        ];
    }
    return $this->allowedMethods;

}
0

Magento 2.4.1 has the following populated by default, I suspect that the merchant ID field you have is empty, it was for me, if you put in the value testmode it then works correctly.

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.