Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

theantichris's avatar

Braintree\Configuration::merchantId needs to be set

I am getting that error when going to the registration route for my Spark application.

I am using Homestead on Windows 10 and installed Spark using the Composer method for Windows.

I have this in my .env file:

BRAINTREE_MODEL=AMP\User BRAINTREE_ENV=sandbox BRAINTREE_MERCHANT_ID=id_copied_from_braintree_dashboard BRAINTREE_KEY=public_key_copied_from_braintree_dashboard BRAINTREE_SECRET=private_key_copied_from_braintree_dashboard

0 likes
13 replies
theantichris's avatar

Thank you for responding. I do have the values copied into my .env file as shown in the original thread. I didn't leave the specific values in for security reasons. They are exact copy and pastes of the values from the Braintree dashboard.

ejdelmonico's avatar

The reason I stated that is because the error message basically says you have the wrong merchant_id for sandbox. So, the culprit is probably an incorrect key or Braintree setup. Although, I don't use Windows so it may be some kind of odd issue related to that.

theantichris's avatar

@bashy I saw that solution while researching it and tried it out. It did not seem to make a difference. Is there a particular setting in php.ini that it needs to go after?

bashy's avatar

@theantichris Actually, you're right, doesn't work. Can you show me the Braintree::generate() function?

1 like
theantichris's avatar

@bashy

generate() is being called in Laravel\Spark\Configuration on line 22.

'braintreeToken' => Spark::billsUsingBraintree() ? BraintreeClientToken::generate() : null,

Nothing is being passed in so params is empty.

theantichris's avatar

I decided to scrap the project and rebuild it in case I missed something. I guess I did because it is working now.

bashy's avatar

Strange one. We only had an issue on the production server which is why I thought it was the PHP setup but I think we tried that then found another solution. Maybe something like config:cache.

Jantlap's avatar

You need to add this to your config.services file:

'braintree' => [ 'model' => App\User::class, 'env' => env('BRAINTREE_ENV'), 'merchant_id' => env('BRAINTREE_MERCHANT_ID'), 'key' => env('BRAINTREE_KEY'), 'secret' => env('BRAINTREE_SECRET'), ],

7 likes
astrit's avatar

Hi everbody,

If you still having the same problem please check at config/service.php if you have 'braintree' => [ 'model' => App\User::class, 'env' => env('BRAINTREE_ENV'), 'merchant_id' => env('BRAINTREE_MERCHANT_ID'), 'key' => env('BRAINTREE_PUBLIC_KEY'), 'secret' => env('BRAINTREE_PRIVATE_KEY'), ], if you dont have it just add it and remove stripe and it will work

ale's avatar

In my case, the problem was from Config file Cache. For some reason Laravel did not generate the config cache from command: php artisan config:cache .

I solved deleting config cache:

php artisan config:clear

But the real problem in my case was Laravel config cache generation.

I hope it's useful.

Please or to participate in this conversation.