Paypal button not appearing with Braintree and WooCommerce

When trying to use Braintree with Paypal on my WooCommerce installation, I kept running into issues. Using Braintree by itself would work fine, but as soon as I enabled Paypal as well I received this following error on the checkout page.

Oops, something went wrong. Please try a different payment method.

The Paypal button would also not appear.

In some instances, in the Developer Console you might see this error:

PayPal error
Error: This PayPal integration does not support this currency
    at Object.i [as create] (https://js.braintreegateway.com/v2/braintree.js?ver=2.0.4:9:18677)
    at new r (https://js.braintreegateway.com/v2/braintree.js?ver=2.0.4:7:10202)
    at https://js.braintreegateway.com/v2/braintree.js?ver=2.0.4:7:13693
    at https://js.braintreegateway.com/v2/braintree.js?ver=2.0.4:3:25968
    at c.(anonymous function) (https://js.braintreegateway.com/v2/braintree.js?ver=2.0.4:3:26971)
    at https://api.braintreegateway.com/merchants/

The problem is that the JS library linked from the WooCommerce plugin is very old and doesn’t support many of the new Braintree features. (And this is the official plugin from WooCommerce…)

To fix the issue, you’ll need to make some changes to the plugin. Be aware: these will be overwritten on a plugin upgrade, and you may need to re-fix the issue.

Edit the file wp-content/plugins/woocommerce-gateway-paypal-powered-by-braintree/includes/class-wc-gateway-braintree.php :

Comment out line 108, and add in line 109 as below. You might want to check for the latest Braintree library.

	/**
	 * Enqueue the Braintree.js library prior to enqueueing gateway scripts
	 *
	 * @since 3.0.0
	 * @see SV_WC_Payment_Gateway::enqueue_scripts()
	 * @return bool
	 */
	public function enqueue_gateway_assets() {

		if ( $this->is_available() ) {

			// braintree.js library
			// COMMENT THIS OUT 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();
		}
	}

Test it, and everything should be working!

My Braintree plugin setup looks like this. I didn’t need to add a Merchant Account ID to get this to work:

5 thoughts on “Paypal button not appearing with Braintree and WooCommerce

  1. This solution doesn’t work on my website. Do I need to setup merchant account in Braintree dashboard or not?
    Thanks in advance.

    1. Under Account > Merchant Account Info, you need the Merchant ID, but you don’t need the Merchant Account ID.

      Yes it’s very confusing!

Leave a Reply

Your email address will not be published. Required fields are marked *