AppFrontier

☰ Menu

Braintree Salesforce Integration Chargent


Connecting Braintree and Salesforce using Chargent


Overview


Braintree, a PayPal Company, is a leader in online and mobile payments, providing extensive tools for developers, multiple different payment type options, and one-touch mobile payments. 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.


Braintree Logo


 

Setup


  1. Install both the Base Package and a Transaction Package of Chargent Payment Processing for Salesforce into your Salesforce org.

    • Choose Chargent Orders, Opportunities (SFA), or Cases for the second piece that you install, which determines where the Chargent billing fields live in Salesforce.

  2. Trial and Pricing Information

    • Chargent is a paid application, but there is a 30 day free trial that includes our responsive support, no signup required. You can also install Chargent into your Salesforce Sandbox for an extended development period.

  3. Configure Chargent according to the documentation.


    • If you have any questions, we are here to help. Just email us on our support site (best for error messages or more detailed architectural questions) or call +1-415-275-1115 x2

     

    Testing


  4. If you do not already have a Braintree sandbox account for testing, sign up for one at https://www.braintreepayments.com/get-started

  5. Create a Payment Gateway Record in Salesforce for testing Braintree

    • Switch to the Chargent app in Salesforce (top right corner menu)
    • Go to the Gateways tab (click the + beside the tabs if you don't see it)
    • Click New
    • Select Braintree as the record type from the drop-down list of Salesforce payment gateway integration options that Chargent provides.

  6. Your Braintree Sandbox keys can be found on the Home page / Dashboard once you log into Braintree.

  7. Fill out the gateway record in Salesforce as follows:

    • Gateway Name: Your choice, for example "Braintree Test"
    • Merchant ID: Braintree Sandbox Merchant ID
    • Merchant Security Key: Braintree Sandbox Private Key
    • Merchant Reference: Braintree Sandbox Public Key
    • Test Endpoint should be checked
    • Active should be checked
    • Use Tokenization should be checked
    • Click Save

    Braintree Gateway Setup in Salesforce

  8. Merchant Account ID -- 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 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.

  9. Create a test record in Salesforce to run some test credit card transactions

    • This will allow you to see how Chargent operates inside of Salesforce, and test to ensure that Salesforce is setup correctly to connect to the Braintree gateway.

  10. Create a New Chargent Order, Opportunity, or Case record (depending on which of the 3 Chargent Transaction packages you installed). Enter data in the following fields:

    • Billing First Name, Billing Last Name, Billing Address, Billing State, Billing Zip, Billing Country should be completed
    • Billing Email

    • Subotal (or Amount if using Opportunities / Cases).
      • Alternately, you can check Manual Charge and then enter a value in the Charge Amount field.

    • Payment Type
    • Card Type
    • Card Number, Card Expiration Month, Card Expiration Year (see below for test cards)

    Braintree Test Order Setup in Salesforce


  11. Braintree Test Cards

    • Keep in mind that Braintree's Sandbox environment will only work with test credit card numbers. Some test numbers will produce approvals, and others will produce declines. The Charge Amount field passed from Chargent to Braintree will also produce different types of Gateway responses.

    • Please see Braintree's documentation for full details.

    • No credit card errors
      These test credit card numbers will not trigger specific credit card errors, although that does not mean that your test transaction will be successful. The Charge Amount can trigger other types of gateway responses.

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

    Successful Braintree Transaction in Salesforce


  12. Click the Charge button

    • You will receive a popup window stating the test transaction results
    • After you click OK in the dialog box, the Salesforce page will refresh
    • You can then view the Transaction details from the related list near the bottom of the page in Salesforce, and compare them to the Transactions listed in the Braintree Sandbox.

    Transaction List in Salesforce


    Transaction List in Braintree


    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 full endpoint URL must be entered in the Endpoint Override field, and 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 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://apply.braintreegateway.com/

    To set up Chargent and Salesforce to go live, simply do the following:

  13. Create a Payment Gateway Record in Salesforce for live Braintree transactions

    • Switch to the Chargent app in Salesforce (top right corner menu)
    • Go to the Gateways tab (click the + beside the tabs if you don't see it)
    • Click New
    • Select Braintree as the record type from the drop-down list of Salesforce payment gateway integration options that Chargent provides. Chargent uses Authorize.net emulation mode to connect to Braintree.

  14. Fill out the gateway record in Salesforce as follows:

    • Gateway Name: Your choice, for example "Braintree Test"
    • Merchant ID: Braintree Production Merchant ID
    • Merchant Security Key: Production Sandbox Private Key
    • Merchant Reference: Braintree Production Public Key
    • Active should be checked
    • Use Tokenization should be checked
    • Click Save

    Braintree Gateway Setup in Salesforce


  15. 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 numbes 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.

     

    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

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.


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. These are the batch names:

  • ChargentOrders.scheduledBatchUpdateTransactionStatus()
  • ChargentCases.scheduledBatchUpdateTransactionStatus()
  • ChargentSFA.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 followup task.

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