- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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".
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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;
}
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.
- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.