Featured Image

Woocommerce Braintree Payment Issue

Lately I had to configure a payment gateway using Braintree and the woocommerce-gateway-paypal-powered-by-braintree plugin. Once everything was configure (API Key's and whatnot) I wanted to test it but I got the following error message: Oops, something went wrong. Please try a different payment method. 

After 5 minutes of google-ing I have found the reason why I have the error. It seems that the JS used in the official plugin is outdated.

The fix:

Open wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/includes/class-wc-gateway-braintree.php 

On line 108 you will have to replace the following code:

public function enqueue_gateway_assets() {

	if ( $this->is_available() ) {

		// braintree.js library
		wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/v2/braintree.js', array(), WC_Braintree::VERSION, true );

		parent::enqueue_gateway_assets();
	}
}

with this code:

public function enqueue_gateway_assets() {

	if ( $this->is_available() ) {

		// braintree.js library
		// wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/v2/braintree.js', array(), WC_Braintree::VERSION, true );
		wp_enqueue_script( 'braintree-js', 'https://js.braintreegateway.com/js/braintree-2.32.1.min.js', array(), WC_Braintree::VERSION, true );
		parent::enqueue_gateway_assets();
	}
}

 


Spread the word:

Sunday 25 August 2019 Marian V. Pop

Comments

Sign up & Stay Informed

Get latest blog posts, portfolio updates and more, straight into your inbox.