Sandbox testing

Braintree Marketplace webhooks

Sub-merchant approval

To trigger a SubMerchantAccountApproved confirmation webhook, provide the following constant as the first name of the Sub Merchant:

Ruby
Copy
Copied
result = gateway.merchant_account.create(
  :individual => {
    :first_name => Braintree::Test::MerchantAccount::Approve,
    # ...
  },
  # ...
)
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

Sub-merchant decline

To trigger a SubMerchantAccountDeclined confirmation webhook, provide an error code for the first name of the sub-merchant. You will receive the provided error in the webhook.

For example, this would trigger the Applicant declined due to OFAC error:

Ruby
Copy
Copied
result = gateway.merchant_account.create(
  :individual => {
    :first_name => Braintree::ErrorCodes::MerchantAccount::ApplicantDetails::DeclinedOFAC,
    # ...
  }
)
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

See our Ruby library for a list of errors.

Disbursement exceptions

For use by Braintree Marketplace merchants only. To trigger a disbursement exception webhook, first create a merchant account with one of the following constants as its ID:

Ruby
Copy
Copied
Braintree::Test::MerchantAccount::InsufficientFundsContactUs
Braintree::Test::MerchantAccount::AccountNotAuthorizedContactUs
Braintree::Test::MerchantAccount::BankRejectedUpdateFundingInformation
Braintree::Test::MerchantAccount::BankRejectedNone

Each ID correlates with a combination of exception_message and follow_up_action.

You will then receive a disbursement exception webhook within 24 hours whenever you call Transaction.sale() using that merchant account.

Bank routing numbers

Bank routing numbers must pass a checksum, much like credit card numbers. The following routing numbers are valid, and can be passed to the sandbox:

  • 071101307
  • 071000013

Go live

important

Your sandbox account is not linked to your production account in any way. Nothing created in the sandbox will transfer to production. This includes processing options and recurring billing settings. Your login information, merchant ID, and API keys will also be different.

Create an API user

Production API credentials, including your API keys, must be entered into your server-side code to connect API calls to the Braintree gateway. While each user in your gateway has their own unique set of API keys, only one set can be included in your integration.

We do not recommend including an individual user's API credentials. If you ever need to delete or suspend that user, this could break your connection to Braintree and result in failed transactions.

Instead, create a new user specifically designated as the API user, whose API keys can be used for your integration. This user should be set up with an email address that is not associated with a single employee and should have Account Admin permissions in order to avoid issues such as an authorization error.

Get production credentials

Log into your production account as the API user to obtain your API credentials. You'll need the:

  • Production merchant ID
  • Production public key
  • Production private key

Keep in mind that public and private keys are both environment- and user-specific.

Update production account settings

Make sure your production account settings mirror the ones in your tested sandbox configuration. Be sure to recreate any recurring billing plans or settings if you plan to use recurring billing in production.

Update live server configuration

In your server code, update your configuration to production values:

Ruby
Copy
Copied
gateway = Braintree::Gateway.new(
  :environment => :production,
  :merchant_id => "use_your_merchant_id",
  :public_key => "use_your_public_key",
  :private_key => "use_your_private_key",
)
This code snippet now uses gateway instance methods instead of class-level methods. Learn more.

Once you have updated these values and configured your preferred processing settings, the live production environment will function similarly to the sandbox environment you've been using for development. Learn more about the differences between production and the sandbox.

On the client side, no configuration updates are needed when you make the switch to production – your client obtains its client token from your server, which is all the configuration it needs.

note

If you have an iOS integration, verify that your released code does not use an offline client token by ensuring that you do not import BTClient+Offline.h. Once this is confirmed, you can publish to the App Store.

Test transactions in production

It is important to test your production account by creating a couple of low-value sale transactions for each of the payment method types you plan to accept. Be sure to submit the transactions for settlement, and then confirm that the funds have deposited into your bank account. This typically happens a few days after they have settled.

important

Real payment methods must be used in the production environment. Test values from the sandbox testing page will not work. This means that every test transaction that you allow to settle in your production account will debit funds from the associated payment method and fees will be assessed. Be sure to test with reasonable amounts and only run a limited number of transactions.

Still have questions?

If you can’t find an answer, contact our Support team