AppFrontier

Braintree Salesforce Integration Chargent

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.

Not yet a Chargent customer?
Contact us for a no-obligation 30 day trial, and see for yourself!





Overview


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


  1. Install both the Chargent Base Package and Chargent Transaction Package into your Salesforce org.

  2. Configure Chargent according to the Quick Start Guide.

  3. 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.

    • 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

  4. Get a Braintree test account by signing up at https://www.braintreepayments.com/sandbox


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. applauncher

  3. Select Chargent as the App

  4. Select the Chargent Settings Tab

  5. Choose Chargent Setup Wizard

  6. chargent

  7. 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)

  8. Select Braintree as your Payment gateway.

  9. Select Test Transactions for testing in Sandbox or Live Transactions if you are looking to process real time payments in Production.

  10. 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.

      • generate

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 and/or ACH (electronic check)
    • 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


Add a Braintree Gateway record in Salesforce (Chargent versions prior to 5.40)


  1. Click on the AppLauncher on the top left side in Salesforce.

  2. applauncher

  3. In the Search for apps or items box, Search for Gateways and select

  4. gateways

  5. Click New and select Braintree as the Gateway Type

  6. Map the following fields in Chargent with your credentials from Braintree:

    • Merchant ID: Merchant ID with Braintree

    • Merchant Security Key: Private Key from Braintree

    • Merchant Reference: Public Key from Braintree

      • 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.

      • generate2

  7. Setup the following Gateway fields

    • Check the Active box - To make the Gateway active

    • Use Tokenization - If you are planning on using Braintree tokenization (recommended)

    • Available Card Types - Select the cards you will be accepting (this is based on your gateway settings and what card types they can process - Visa, Mastercard, American Express, etc..)

    • Available Payment Methods - Will you be accepting just Credit Cards or ACH (also known as electronic check, e-check, or direct debit)

    • Available Currencies - What currencies will you accept (this is based on your payment gateway and the currencies they accept payment in.

    • Credit Card / Bank Account Data Handling - This lets Chargent know when to clear the information in Salesforce. You have 4 options.

      • Never Clear
      • Clear After Successful Charge
      • Clear After All Transactions
      • Clear When Token is Present (recommended)

      • braintree

When using Payment Requests or Payment Console the following should also be set. Please note these features come with Sites and Platform edition & require activation in your Production Org.


  • Available PR Transaction Types

    • Charge Full Amount - Charges the credit card immediately

    • Authorize Full Amount - This option won’t charge the card but only holds the funds available until you charge the card.

    • Authorize Minimum Amount - This option won’t charge the card but only holds the minimum amount that your gateway will allow. You will need to charge the correct amount in order to capture the transaction

    • PR

      charge

    • Show Charge Button

    • Show Authorize Button


Testing


Now that you have created the Braintree gateway record in Salesforce, it is time to run some test transactions to ensure it was set up correctly, and understand how Chargent works to charge credit cards within Salesforce.

Create a Chargent Order in Salesforce to run test transactions

  1. Click on the App Launcher in the top left side and select Chargent as the App.

  2. search

  3. Click the Chargent Orders Tab.

  4. Click on New

  5. Enter in the following information:

    • Account: The Account the Chargent Order should be associated with.

    • Gateway should be Vantiv ( if you are using multiple active gateways)

    • Charge Type should be either credit card or Check depending on if you are testing credit cards or electronic check (ACH or direct debit)

    • Billing Information

      • Billing First Name
      • Billing Last Name
      • Billing Address
      • Billing City
      • Billing State / Province
      • Billing Zip Code / Postal Code
      • Billing Email Address (if you want to test the email receipt that gets triggered upon a successful transaction)

    • Charge Amount (check the Manual Charge if you are testing a specific amount. If you are entering Subtotal, Tax, and Shipping then the Charge Amount will default to the Balance Due and the Manual Charge box should not be checked)

    • Credit Card Number = See Test Credit Card Details below

    • Card type (Visa, MasterCard, etc..)

    • Card Expiration Month and Card Expiration Year should be in the future

    • ORD

      payment

      billing

  6. Click Save

    You can now test the Charge button to process the test transaction.

  7. When you click the Charge button you will receive a pop-up asking for the CSC (Card Security Code). This can be any 3 digits for Visa, MasterCard or Discover or 4 digits for American Express when testing in the Sandbox.

  8. charge

  9. Press the Charge button

    You will receive a popup that shows the test transaction was approved.

  10. record


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:

https://www.braintreegateway.com/

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


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 go here:

https://www.braintreegateway.com/

  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.


Tokenization


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—for ACH transactions that are returned for non-sufficient funds (NSF), credit card authorizations that expire, and more.

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

ChargentOrders.scheduledBatchUpdateTransactionStatus()

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

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

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