Integrating Braintree Salesforce using Chargent


Braintree, a PayPal Company, is a leader in online and mobile payments, providing extensive tools for developers and multiple different payment type options. Braintree was founded in 2007, acquired Venmo for mobile payments in 2012, and was acquired by PayPal in 2013.

With Chargent Payment Processing for Salesforce’s prebuilt Braintree integration, you can now connect Salesforce to Braintree in just a few steps. You can then take advantage of Chargent’s many features for automating and streamlining payment processes inside Salesforce, including subscription management, embedded Charge, Authorize, Refund and Void buttons for real-time payment management, payment request emails you can send to your customers to capture or update billing details, and more. All of these features initiate transactions directly from your Salesforce account to your Braintree account.

Connect Braintree and Salesforce with Chargent

See all Braintree transactions, manage refunds, send payment links and more, all inside Salesforce with Chargent, the top rated payments app on the Salesforce AppExchange.

Not yet a Chargent customer?

Contact us for a no-obligation 30 day trial, and see for yourself!

Installation and Configuration

  1. Install both the Chargent Base Package and Chargent Transaction Package into your Salesforce org using our package installation manager.
  2. Configure Chargent according to the Installation and Setup Guide.
  1. Get a Braintree test account by signing up at

Add a Braintree Gateway record in Salesforce using Chargent’s Gateway Wizard

  1. Click on the App Launcher on the top left side in Salesforce.
  2. Select Chargent as the App
  3. Select the Chargent Settings Tab
  4. Choose Chargent Setup Wizard
  5. Do you have a Payment Gateway account – Select Yes (selecting No, if you don’t already have a payment gateway account, will allow you to choose from either Vantiv or Braintree as your payment gateway)
  6. Select Braintree as your Payment gateway.
  7. Select Test Transactions for testing in Sandbox or Live Transactions if you are looking to process real time payments in Production.
  8. Follow the prompts to configure your gateway.

You will need the following information:

  • Add your credentials based on your Sandbox (Test) or Production Live Braintree account.
    • Merchant ID
    • Private Key
    • Public Key
      • Go under Settings and select API Keys
        api keys
      • Click the “View” option under Private Key to display the Merchant ID, Private Key and Public Key.

Other information that will be asked:

  • What currency will you be using? (USD, CAD, etc..)
  • Do you want to enable Payment Console (premium feature with Platform Edition)Note: if you don’t already have access, clicking yes will request a Feature Request Key for your Org.
  • Will you be doing Recurring Billing (also known as subscription billing, or installment payments). If yes, we recommend 3am your local time.
  • What payment methods will you be accepting?
    • Credit Cards
    • Credit Card types will you be accepting? (Visa, Mastercard, etc…)
  • Payment Console Setup (Premium feature for Platform Edition)
    • Show Charge Button
    • Show / Create Update Token Button
    • Show Authorize Button

Testing using Chargent Anywhere

Testing with Payment Console

To test using the Payment Console, you want to navigate to any record in your Sandbox that has the Chargent Anywhere Component enabled.

  1. Click the [PaymentConsole] button
  2. If you are using multiple gateways select your gateway from the dropdown otherwise continue to step 3
  3. Enter all the Billing Information and click [Next]
  4. Enter in a test credit card number, expiration date, and CVC code based on the Braintree test credit cards below.
  5. Click the [Charge] button.

You should receive a green box showing Approved.


Testing using Payment Request

To test using a Payment Request you want to be sure you have the Chargent Payment Request feature set up as outlined in our documentation.

  1. Click the [Send Payment Request] button
  2. If you have multiple Payment Request templates set up you will first choose what template you want to use.
  3. Enter an email address where you want to send the test Payment Request along with any amount.
  4. Enter a Contact name (Optional)
  5. Click the [Send Request] button

Send Payment Request

When you receive the email, click the secure link for the Payment Request. Use one of Braintree credit cards to complete the payform and submit the payment.

Card Bank Payment

You should receive a green box confirmation

Card Bank payment

Test Credit Card Details:

Test Value Card Type
378282246310005 American Express
371449635398431 American Express
6011111111111117 Discover
3530111333300000 JCB
6304000000000000 Maestro
5555555555554444 Mastercard
4111111111111111 Visa
4005519200000004 Visa
4009348888881881 Visa
4012000033330026 Visa
4012000077777777 Visa
4012888888881881 Visa
4217651111111119 Visa
4500600000000061 Visa

Unsuccessful credit card verification

The following credit card numbers will simulate an unsuccessful card verification response. Verifying a card is different than creating a transaction. To trigger an unsuccessful transaction, adjust the Charge Amount of the transaction.

Test Value Card Type Verification Response
4000111111111115 Visa processor declined
5105105105105100 MasterCard processor declined
378734493671000 American Express processor declined
6011000990139424 Discover processor declined
3566002020360505 JCB failed (3000)

Sending Live Transactions from a Salesforce Sandbox

When Chargent is installed in a Salesforce Sandbox, transactions are always sent to the payment gateway’s test / sandbox / development environment, regardless of whether Chargent’s Test Endpoint checkbox is checked. This is done as a security precaution, to prevent real transactions from being accidentally sent from a Salesforce Sandbox.

When Chargent is installed in a production or developer Salesforce org, the Test Endpoint checkbox on the Gateway record will select between sending to the payment gateway’s live and test environments. (There are a few exceptions, such as Stripe, which has a single endpoint to send transactions to, and different credentials for live versus test transactions).

If you wish to send live transactions from a Salesforce Sandbox, as a final step in testing, simply use Chargent’s Endpoint Override field on the Gateway record, and enter the production endpoint of your chosen gateway there.

Here is the production endpoint URL for Chargent’s integration with Braintree:

Note that the domain must be present in the Remote Site Settings (for standard Chargent integrations it should be already present).

Using the Credit Amount field and Credit action in Chargent, you may now send payments / credits to ACH bank accounts. Note that this must be done using a 2-step process wherein you first tokenize the bank account, then send the payment.

Credit Amount field and Credit action in Chargent

Going Live

Once you have completed some test transactions to see how Chargent works, you are almost ready to go live.

If you will be doing recurring or subscription billing, you should have the option to set up the recurring batch when you setup your gateway. If not, you should set up the Apex batch and a few records with the Chargent recurring fields set correctly, so you can use the test Braintree gateway to be sure that everything is configured properly and behaves as you expect before going live with real customer transactions.

In addition, at this point you can complete any customizations to the Chargent system or Salesforce configuration you might want to do, such as workflow automation, email template customization, triggers, etc.

To process real transactions with Braintree from Salesforce, you will need to deactivate the test gateway record (uncheck the Active field), and create a new live Gateway record in Salesforce with the production credentials provided by Braintree.

Note that the Sandbox and Production accounts are completely separate, so you will need to make sure any settings in Sandbox are reapplied in your Production account.

If you have not applied for a Braintree production account, you can sign up here.

  1. Setup your payment gateway in Production via the instructions above – v5.40 or older or using the Gateway Setup Wizard in current versions
  2. Create a Transaction Record using real credit card data

You may wish to test a few live transaction with a real credit card, just to make sure everything is working smoothly.

Real credit card numbers must be used in production. The test cards for the Sandbox will not work.

Run small dollar amount transactions — you can either VOID them immediately after, to minimize any impact, or allow them to settle to confirm the small amounts are deposited into your bank account

Using your own or company credit cards for live tests is recommended, as customers could still see notifications of a charge even if voided

Note that Transaction fees are incurred in the live environment, so extensive testing in production is not recommended. Run a small number of small value transactions to complete your testing.

Merchant Account ID

In Chargent version 4.81 and newer, a single Braintree gateway can have multiple merchant accounts to process transactions for different businesses or currencies. Each merchant account within a gateway can be identified by its unique Merchant Account ID. This is different from the Merchant ID, which is a unique identifier for your entire gateway account.

You can use this ID to create multiple gateway records in Chargent, so as to specify a merchant account when creating a transaction. If you have a single merchant account, it is not necessary to specify a merchant account ID, but for customers using Braintree to support transactions in multiple currencies, multiple Merchant Account IDs are required.

if you populate the Username field on the Chargent Gateway record, we will send that to the Merchant Account Id in Braintree, to identify the sub account that should receive the transaction. If the Username field is not populated with a Merchant Account ID, then we just send Braintree the default Merchant Account ID.


All Chargent transactions sent from Salesforce to Braintree use tokenization to protect sensitive data and reduce PCI compliance scope.

When credit card numbers and other details are sent by Chargent from Salesforce to Braintree, Braintree stores that data securely and returns a Payment Method Token, which can be used for future transactions. Chargent stores this in the Token field, and it does not represent a security risk, as it can be only used to reference stored data within Braintree.

Be sure to consult our Salesforce PCI Guide for information on configuring how credit card data is deleted from Salesforce after submission to Braintree, or consider our features like Payment Console, which can generate Braintree tokens from Salesforce in-memory (without ever being saved to the Salesforce database), to reduce your PCI compliance scope even further.

Field Mapping

Here are some useful fields and their mappings between the Chargent software in Salesforce and the Braintree system.

Salesforce Direction Braintree
Gateway ID < Transaction ID
Token < Payment Method Token

Transaction Sync

Chargent has always sent charges and authorizations to the payment gateways, and recorded the result in a real-time Transaction in Salesforce. Chargent can also update Salesforce records long after the initial transaction.

Two fields, Transaction Status and Settlement Date can now be updated through a daily scheduled batch in Salesforce.

Possible values of the Transaction Status are either final or non-final. It the status is final, then no more updates will occur for that transaction. Also, batches will not pick up any transaction having a final status.

The Settlement Date field stores the date and time when the Transaction Status is changed to final (such as “Settled” or “Voided”), after which it will no longer receives any updates.

To schedule the batch, navigate to Setup > Develop > Apex classes, and then click the Schedule Apex button. Add the following to the scheduled batches


As shown in the Braintree documentation, the following are the various transaction status values for Braintree Transactions. Use some of the values to learn when a transaction has been declined, and take appropriate action within Salesforce—such as sending an email or assigning a follow-up task.

  • authorization_expired
  • settlement_declined
  • settled
  • voided
  • processor_declined
  • gateway_rejected
  • failed
  • voided
  • submitted for settlement
  • settling
  • settled
  • settlement declined
  • settlement pending

Payment Methods Accepted

Chargent supports both Credit Card and Bank Account payments (via ACH). However, when using the Braintree gateway, you can only process ACH payments using the USD currency.

ACH transactions are not enabled by default in your Braintree Sandbox Account. For more information, see Braintree: Enable ACH Transactions in Sandbox.

ACH Validation

Chargent supports ACH Validation through the Lyons Account Verification Service, allowing you to validate US bank accounts on the Automated Clearing House (ACH) network before attempting a transaction. This validation confirms that the bank account & routing numbers exist and the account is available for payment transactions, satisfying NACHA’s mandate – Supplementing Fraud Detection Standards for Web Debits. We strongly recommend that all ACH customers implement ACH Validation.

For more information about implementing validation for your ACH transactions, see our ACH Validation documentation.

You have now completed the integration of Salesforce and the Braintree service with Chargent. You can begin processing one-time or recurring credit card payments through Braintree directly from Salesforce.

If you have any questions or need assistance, please contact us.