Paypal with Braintree saying "Merchant account not found"

This error can also be caused by a gotcha that's easy to miss but simple to fix.

To initialise your client, you generate a client token on your server. When generating this you can optionally pass in a merchant account ID - for example in Java:

ClientTokenRequest clientTokenRequest = new ClientTokenRequest()
                                              .customerId(aCustomerId)
                                              .merchantAccountId(anAccountId);
String clientToken = gateway.clientToken().generate(clientTokenRequest);

There is a subtle but important difference between your merchant ID and the merchant account ID:

From the Braintree Control Panel reference:

Your merchant ID is a unique identifier for your entire gateway account and one of the four API credentials. This value is required for certain actions, such as connecting your API calls to the Braintree gateway or setting up third-party shopping carts.

Your merchant account ID is a unique identifier for a specific merchant account in your gateway. It is used to specify which merchant account to use when creating a transaction, creating a subscription, verifying a payment method, or generating a client token.

Supplying the wrong merchant account ID at client token creation time won't produce an error until you try to perform certain actions, for example, making a payment method request using the paypal vault flow, in which case your client will receive a "422 Unprocessable entity" response with the "Merchant account not found" error message.


In my case it was an issue with my sandbox account, and I solved the same with communicating with braintree support.

ME : I have setup a Braintree sandbox account to make test PayPal payments. The userid is [email protected] I am able to test hosted fields properly using this account, however I get Merchant account not found when I try to use the same client for PayPal. Can you please help me if I am missing any configuration?

Braintree Support : Your Sandbox merchant accounts don't have PayPal enabled which could explain the error you are witnessing. I added PayPal as processor for your default merchant account (MobikonDefault). Please try again and if the problem appears again, I would need you to provide your ClientToken API call and the exact time you reproduced the issue (including timezone).

ME : Thanks, that worked. Although I would like to know if I can do this configuration myself. I did not find any path to do so.

Braintree Support : Thanks for reaching back out to us. Currently, there is no way to set this up from the merchant side - this is a direct configuration on our backend that we have to set up (the one that Elvis set up for you).