Connecting Braintree and Salesforce using Chargent
Easily connect Braintree and Salesforce with Chargent,the leading payments app on the Salesforce AppExchange. See all Braintree transactions, manage refunds, send payment links and more, all inside Salesforce.
Contact us for a no-obligation 30 day trial, and see for yourself!
- Installation and Configuration
- Add a Braintree Gateway record in Salesforce using Chargent’s Gateway Wizard
- Testing using Chargent Anywhere
- Test Credit Card Details:
- Sending Live Transactions from a Salesforce Sandbox
- Going Live
- Merchant Account ID
- Field Mapping
- Transaction Sync
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.
Installation and Configuration
- Install both the Chargent Base Package and Chargent Transaction Package into your Salesforce org.
- Configure Chargent according to the Quick Start Guide.
- Click the gear icon on the top right and select Settings
- Under Security select Remote Site Settings
- Locate Braintree_Live and click edit
- Check the Active box
- Click Save
- Do the same for Braintree_Live
- Get a Braintree test account by signing up at https://www.braintreepayments.com/sandbox
For Chargent versions prior to 5.57 you may need to activate the Remote Site Settings in Salesforce if they aren’t already active for Braintree.
Add a Braintree Gateway record in Salesforce using Chargent’s Gateway Wizard
- Click on the App Launcher on the top left side in Salesforce.
- Select Chargent as the App
- Select the Chargent Settings Tab
- Choose Chargent Setup Wizard
- 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)
- Select Braintree as your Payment gateway.
- Select Test Transactions for testing in Sandbox or Live Transactions if you are looking to process real time payments in Production.
- 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.
Other information that will be asked:
- Will you be using tokenization? (recommended)
- 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.
- Click the [PaymentConsole] button
- If you are using multiple gateways select your gateway from the dropdown otherwise continue to step 3
- Enter all the Billing Information and click [Next]
- Enter in a test credit card number, expiration date, and CVC code based on the Braintree test credit cards below.
- 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.
- Click the [Send Payment Request] button
- If you have multiple Payment Request templates set up you will first choose what template you want to use.
- Enter an email address where you want to send the test Payment Request along with any amount.
- Enter a Contact name (Optional)
- Click the [Send Request] button
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.
You should receive a green box confirmation
Test Credit Card Details:
|Test Value||Card Type|
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|
|378734493671000||American Express||processor declined|
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).
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 go here:
- Setup your payment gateway in Production via the instructions above - v5.40 or older or using the Gateway Setup Wizard in current versions
- 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.
Here are some useful fields and their mappings between the Chargent software in Salesforce and the Braintree system.
|Gateway ID||<||Transaction ID|
|Token||<||Payment Method Token|
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.
- submitted for settlement
- settlement declined
- settlement pending
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.