Magento2 Braintree Module Error – How to Resolve

magento2payment-gatewaypayment-methodsphp-7

Using the standard / included Braintree payment method – i get the following error on Safari console when at the Checkout page for payment.
The payment method is not shown on checkout, the others are (i.e paypal, cheque etc)

[Error] TypeError: undefined is not an object (evaluating 'this.messageContainer.addErrorMessage')

initObservablecc-form.js:159

initObservable
(anonymous function)
initialize
(anonymous function)
_super
initialize
(anonymous function)
_super
initialize
(anonymous function)
constr
initComponent
fire
fireWith
(anonymous function)
fire
fireWith
(anonymous function)
(anonymous function)
execCb
check
(anonymous function)
(anonymous function)
(anonymous function)
each
emit
check
(anonymous function)
(anonymous function)
(anonymous function)
each
emit
check
(anonymous function)
(anonymous function)
(anonymous function)
each
emit
check
(anonymous function)
(anonymous function)
(anonymous function)
each
emit
check
enable
init
callGetModule
completeLoad
onScriptLoad

What I have tried:

Apache, Ngnix, Litespeed webservers
PHP7.0.* & 5.6.16+

The only time I have had it working was using apache+php5.6.18 using mod_php but never using FPM; Never had php70 working with it regardless of install type.

It seems like it wants to throw and error on screen but can't ?

Has anyone had any success with Braintree payment method? Did you encounter this error? IF so did you get around it?

Best Answer

Hi we have had exactly the same issue. We have tested on apache & nginx php5.6 and above only.. not php5.5.

Although the braintree composer requires php 5.5/5.6/7.0.0 It seems that the braintree payment method will only work with php 5.6.

We noted that for php 5.6 tokens are successfully generated but for php 7.0.0 and 7.0.3 they are not. The keys are encrypted in php 7.0.0 and above (which they are not in php5.6) and so braintree can not decrypt them and so the payment method can not initialise and in turn will not show on the checkout.

Although the keys are encrypted magento still saves the unencrypted keys in the database, we have had a quick play and can get it to work on php 7.0.0 by editing core files to test, but we have not had a chance to to figure out a proper solution.

Hope this helps.

Related Topic