Magento – Magento 2 Braintree Payment Method Error For Second Website

braintreemagento2multi-websitepayment-methods

I've set 2 websites us and uk.

Signed up for Braintree sandbox account.

Created 2 Merchant Account ID.

1- uk_maid.

2- us_maid.

Magento admin Stores->Configuration->Sales->Payment Method on the left changed Store View: uk_website then configured Braintree entered all details plus Merchant ID = uk_maid saved.

Again same process as above but Merchant ID will be us_maid:

Magento admin Stores->Configuration->Sales->Payment Method on the left changed Store View: us_website then configured Braintree entered all the details and Merchant ID = us_maid saved.

Placed order in uk website everything works payment were taken and appear in my sanbox Braintree dashboard under the uk_maid which is set to default.

Now using us website in ../checkout/#payment as soon as check radio box Braintree as payment option :
enter image description here

In console:
enter image description here

I don't get it why can't use alternative merchant id for us website?

Is this a bug? Anyone have had this set up any experienced the issue?
Thanks.

Best Answer

I had similar issue.

For me direct place where the issue happened is here:

vendor/braintree/braintree_php/lib/Braintree/Http.php : 175

$response = curl_exec($curl);
file_put_contents('/var/www/magento/var/log/braintree.log', $response . "\n", FILE_APPEND);

And response was:

<errors>Unauthorized</errors>

How I solved it I really don't know. Let me explain what was configured and what I did:

In magento backend there are two settings:

Merchant ID and Merchant Account ID Pay attention! These are two DIFFERENT settings.

Let's move to braintree website. https://sandbox.braintreegateway.com/merchants/*************/merchant_accounts/info

You may see:

Merchant ID

Your merchant ID is a unique identifier for your entire gateway account. This value is required to connect your API calls to the Braintree gateway.

Merchant Accounts

Below is a list of payment methods and currencies you are currently accepting. The merchant account ID is a unique identifier for a specific merchant account in your gateway, and is used to specify which merchant account to use when creating a transaction.

Now let's move to

Braintree website / Settings / User and Roles / {edit any role}

Scroll to the bottom and you will see:

Merchant Accounts

Allow the user to search for and manipulate transactions and disputes tied to the following merchant accounts (in accordance with their roles):

All

(If 'All' is selected, any merchant accounts added in the future will be added to the user automatically)

All Sub-merchant Accounts

{Here are your merchant accounts}

I'm not sure but I think you need to select checkbox "All" and on magento side leave Merchant Account ID field !!empty. (Or put save value, as configured in braintree account)

As for me it started working after I selected "All" and made empty field. BUT! When I filled this value again to doublecheck - the issue didn't reproduce anymore. So I can't 100% be sure, that this is silver bullet.

Related Topic