Magento 2 – Type Error with Braintree PayPal Button

braintreemagento2magento2.3

I override the braintree module after that I'm getting this error. can anyone help me.

Magento\Framework\Exception\RuntimeException): Type Error occurred when creating object: Magento\Braintree\Block\Paypal\Button

Best Answer

In your custom module, app/code/Module/Namespace/etc/di.xml

<?xml version="1.0"?>
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:ObjectManager/etc/config.xsd">
    <preference for="Magento/Braintree/Model/Ui/ConfigProvider" type="your/file/path" />
</config>

Then place the ConfigProvider.php in Module\Namespace\Model\Ui\ path.

Then in that file rewrite,

namespace Module\Namespace\Model\Ui;


/**
 * Class Form
 */

class ConfigProvider extends \Magento\Braintree\Model\Ui\ConfigProvider
{

    public function YourFunction()
    {
          #your code
    }

}
Related Topic