cancel
Showing results for 
Search instead for 
Did you mean: 

Magento is breaking in Braintree Configuration

Magento is breaking in Braintree Configuration

Hi All 

 

Magento is giving null error in braintree configuration, even disabled , enable , tried all the things . When i click on edit cart getting exception on ui  and seeing following in debug logs 

 

[2020-09-13 21:36:51] main.CRITICAL: TypeError: explode() expects parameter 2 to be string, null given in /var/www/html/magento2/vendor/paypal/module-braintree-core/Model/Lpm/Config.php:135

Stack trace:

#0 /var/www/html/magento2/vendor/paypal/module-braintree-core/Model/Lpm/Config.php(135): explode()

#1 /var/www/html/magento2/vendor/paypal/module-braintree-core/Model/Lpm/Ui/ConfigProvider.php(45): PayPal\Braintree\Model\Lpm\Config->getAllowedMethods()

#2 /var/www/html/magento2/vendor/magento/module-checkout/Model/CompositeConfigProvider.php(39): PayPal\Braintree\Model\Lpm\Ui\ConfigProvider->getConfig()

#3 /var/www/html/magento2/vendor/magento/module-checkout/Block/Cart/Shipping.php(84): Magento\Checkout\Model\CompositeConfigProvider->getConfig()

#4 /var/www/html/magento2/vendor/magento/module-checkout/Block/Cart/Shipping.php(120): Magento\Checkout\Block\Cart\Shipping->getCheckoutConfig()

#

Looks like error is getting null in local payment allowed methods but even setting no is not resolving the error. 

 

 

8 REPLIES 8

Re: Magento is breaking in Braintree Configuration

Hi,

 

I have the same issue after I disabled "Check/Money Order" and enable "Bank Transfer" in Store->Configuration->Sales->Payment Methods.  I don't know why, I can't change the settings in the "Default Config".  I can only change the settings in the "Main Website".

Re: Magento is breaking in Braintree Configuration

Yes, we have same issue, I would try to change this setting under Stores > Configuration > Sales > Payment Methods > Braintree Payments > PayPal through Braintree to Yes, the after checkout page not working.
My error is :
Uncaught TypeError: explode() expects parameter 2 to be string, null given in /vendor/gene/module-braintree/Model/Lpm/Config.php:127

Re: Magento is breaking in Braintree Configuration

Hi all,

 

It looks there is a bug in the module-braintree-core.  I don't know what is the meaning of the $this->storeConfigResolver and don't know when it will be assigned.  I added a null check to workaround the problem.   You may refer to the following code and replace the method getAllowedMethods in /vendor/paypal/module-braintree-core/Model/Lpm/Config.php.

 

// replace the getAllowedMethods in

// /vendor/paypal/module-braintree-core/Model/Lpm/Config.php

 

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;

}

Re: Magento is breaking in Braintree Configuration

Hi @paulyipredb509,

 

Many thanks for this - we hit the same issue and your workaround seems to have worked for us.

 

Has this been raised as an official bug anywhere?

 

Andy

Re: Magento is breaking in Braintree Configuration

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.

 

https://i.stack.imgur.com/CjgxO.png 

Re: Magento is breaking in Braintree Configuration

Beautiful workaround. Worked like a charm!

My only concern is this should be fixed in core magento and we should not be modifying this piece of code. Thank you so much for your solution.

Re: Magento is breaking in Braintree Configuration

Hi all.

 

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.

 

Removing of this row fixed the issue.

 

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

Re: Magento is breaking in Braintree Configuration

Hi,
Braintree offers a fully customizable checkout experience with fraud detection and PayPal integration. Braintree reduces the PCI compliance burden for merchants because the transaction takes place on the Braintree system.
If you are upgrading to 2.4.x from an earlier version of Magento with the Braintree extension from Magento Marketplace installed,

See the Magento 2.4 Migration Notes:- https://docs.magento.com/user-guide/payment/braintree.html