Closed jamesdixon closed 6 years ago
For access tokens, when you pass in your access token, the environment is parsed from the access token value itself . The environment
in your credentials
JSON object is not necessary and ignored in this case. Hope that helps explain what is happening. We will look into adding a check to make this more obvious.
Thanks for the reply. I think it would be good to make this known in the documentation and well as adding a check. I realize it may not be a common scenario to test against a copy of the production database, but we figured environment
would be respected.
We've elected to add a warning message when you start up with an invalid environment for the access token. The next major version will error.
We'll update this issue when the warning has been added and released.
This is fixed (finally) in version 2.11.0 https://github.com/braintree/braintree_node/blob/master/CHANGELOG.md#2110
General information
Issue description
For background, we use Braintree Auth to bill our client's customers on their behalf.
When doing final testing for a new release, we will typically bring down a copy of our production database and load it into our staging environment. I typically overwrite any production braintree credentials stored with ones that were created in the braintree sandbox. However, I accidentally forgot to do this and was surprised when a number of charges were created on live accounts. I would have thought that production credentials wouldn't work in the sandbox. When I contacted braintree support, they told me just that.
Looking at my code, I can see that I'm setting the
environment
param when connecting to braintree gateway on behalf of my customer. However, if I use credentials that were created on production, the transaction still goes through on production rather than the sandbox specified.Here's my code:
Note that if I log
Braintree.Environment[process.env.BT_ENVIRONMENT]
it resolves to{"server":"api.sandbox.braintreegateway.com","port":"443","authUrl":"https://auth.sandbox.venmo.com","ssl":true}
Am I missing something here?
Thanks!