AppFrontier Salesforce Integration Chargent

Integrating and Salesforce using Chargent

This guide shows you how you can easily connect the payment gateway to Salesforce using Chargent, in order to charge credit cards directly from Salesforce, either via embedded buttons or scheduled batches for recurring payments.

Note: This is primarily a synchronous integration, meaning that transactions sent to from Salesforce will receive the responses (approved / declined with related information) and store them in Salesforce, but transactions that are not initiated from Salesforce will not be synced from to Salesforce.

Once your connection between and Salesforce is up and running with Chargent, however, we don't expect that you should need to initiate any transactions from (or really log into for any reason other than needing to update address verification settings (AVS) or similar).

  1. Install Chargent Payment Processing for Salesforce into your Salesforce org.
    • Note that Chargent is a paid application, but it has a 30 day trial.

  2. Configure Chargent according to the step by step documentation.

  3. Initial Testing

  4. We recommend first creating an Sandbox account, which is a separate, free account for testing purposes.
    • will instantly generate test API credentials for you

  5. Add a Gateway record for

    1. Navigate to the Gateways tab in Chargent and click New

    2. Add Gateway record to Salesforce

    3. Select as the record type from the list of prebuilt payment gateway integrations.

    4. Complete the gateway record as follows:
      1. Gateway Name - Anything you choose, for example " Sandbox" or " Test"
      2. Merchant ID - the API Login ID provided by
      3. Merchant Security Key - the Transaction Key provided by
      4. Active and Test Endpoint should both remain checked
      5. Click Save Gateway settings in Salesforce

  6. Create a test transaction record in Salesforce.
    • Chargent Payment Processing for Salesforce embeds its payment fields in either the Salesforce Opportunity, Case or Chargent Orders (custom) object. For this documentation we will be using the Chargent Orders object because it is a stand alone object, but the fields are the same as those you would add to the Opportunity or Case page layout in Salesforce should you choose to use one of those packages.

    1. Create a new Order record and enter sample data to run a test transaction.
      1. Name
      2. Amount
      3. Billing Address
      4.'s suggested test credit card numbers, which are also emailed to you and are as follows:

        1. American Express Test Card: 370000000000002
        2. Discover Test Card: 6011000000000012
        3. Visa Test Card: 4007000000027
        4. Visa Test Card: 4012888818888
        5. MasterCard Test Card: 5424000000000015
        6. Visa Test Card: 4222222222222 (response code will = dollar amount charged)

      5. Any expiration date in the future in the format MM / YYYY

    2. By default, passing address or CVC data with the card number will cause the address and CVC checks to succeed.

    3. If you have more than one Active gateway record in Chargent (which you probably will not at this point), you will need to specify which one to use in the Order record. Otherwise, you can leave the gateway lookup field blank (and may wish to hide it from the page layout in the future since users should not need to access it).

    4. Although Chargent Payment Processing for Salesforce supports both credit card and ACH / eCheck payments from Salesforce, you need to have eCheck enabled on your account, so for this demo we are going to run test credit card transactions.

    Salesforce order record with gateway

  7. Run a test transaction
    1. Click the "Charge" button in your newly created Salesforce order record. You should receive a popup in a few moments with the response from

    2. Approved Notification in Salesforce

    3. When you click Ok on the popup dialog box, the Salesforce page will refresh and you can then scroll down and see the Transactions related list, with the response and the Gateway ID that was sent back to Salesforce by

    4. Transaction Record related list in Salesforce

    5. Sign into the test Merchant interface to check the test transaction under Search : Unsettled Transactions.

    6. Unsettled Transactions in merchant interface

    7. You also likely received a sample confirmation email, similar to what you will receive when you run live transactions. Once you go into production with Chargent, if you fill out the Billing Email field in Salesforce that Chargent provides, your customers will also receive an email receipt at that address.

    8. Email Receipt

  8. Your connection between Salesforce and is now set up and working. Let's proceed to the final tests before the system goes live.

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

    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 into Production

    There are many more options for customizing how Chargent works within Salesforce beyond the basic connection described above. Once you have configured Chargent to your satisfaction, and have fully set up and tested any automation or integration with other business processes that you wish, it is time to move into production.

  10. Optional: Keep the Sandbox Gateway for future testing

    1. Chargent allows you to have multiple gateway records, so you may wish to keep the initial gateway we set up earlier for future testing.
    2. Click Edit on your Sandbox / Developer account gateway
    3. Uncheck the Active checkbox, so no transactions are accidentally sent to this test gateway
    4. Click Save

  11. Add a Gateway record for

    1. Navigate to the Gateways tab in Chargent and click New

    2. Select as the record type from the list of prebuilt payment gateway integrations.

  12. Complete the gateway record as follows:

    1. Gateway Name - Anything you choose, for example " Live"
    2. Merchant ID - the API Login ID provided by
    3. Merchant Security Key - the Transaction Key provided by
    4. Active should be checked
    5. Test Endpoint should NOT be checked - test endpoint will send transactions to the test/sandbox server instead of the live server
    6. Click Save

    To find your production credentials, log into your LIVE Merchant Interface web site. Go to Account : Settings and look for the API Login ID and Transaction Key link. You can also create a new Transaction Key there if you wish. API Login ID and Transaction Key link in merchant interface

  13. Testing with Live Credentials

    1. During this next phase, we will be using your real credentials (rather than the developer sandbox we used in the first part), but setting to Test mode, so the transactions we send will only be test transactions.

    2. Note: If other integrations or departments in your company are already using the account, you should NOT put the account in test mode. If the account is already in use, you may need to skip this step proceed to step 12.

    3. IMPORTANT: Go to Account : Settings and look for the Test Mode link in the Security Settings area.

      • Click the button Turn Test On
      • Again, do not put your Live account into test mode if there are other users connecting to it (for example, a web site ecommerce integration or accounting person using the virtual terminal). Test Mode in merchant interface

    4. Run some test transactions using your live credentials in test mode.

    Please Note: When processing test transactions in Test Mode, will return a transaction ID of "0." This means you cannot test follow-on transactions, for example, credits, voids, etc., while in Test Mode, because the original transactions will not have the required Transaction IDs (stored in the Gateway ID field in Chargent). To test follow-on transactions, you can process a test transaction with any valid credit card number in live mode.

  14. If your testing in the live environment is successful, you are ready for the third and final phase, running Live transactions.

    1. Ensure Test mode is turned off in the Merchant Interface
    2. You can now run live transactions using valid credit card numbers

      • If you wish to test some live transactions, you can void them immediately after, to prevent the transactions from settling. Just go to the transaction record in Salesforce and click the Void button.

      • Voiding a Salesforce transaction from

      • If you do run live transactions as a test, it is recommended to make them very low amounts to minimize any impact, in the event you forget to void them.

      • Note: Live transactions will incur the per transaction fee (around 30 cents depending on your pricing), so you may wish to limit the number of live transactions run as tests

      • For Visa live transaction tests, you can submit $0.00 transactions

      • To test the AVS or CCV responses in the live environment, you will need to submit live transactions with correct street address, ZIP Code and Card Code information to generate successful responses, and incorrect street address, ZIP Code and Card Code information to generate other responses. You can void successful transactions immediately to prevent live test transactions from being processed.

  15. Congratulations! You have now successfully integrated Salesforce and, via the Chargent Payment Processing for Salesforce app. You can now process one-time or recurring credit card payments through directly from Salesforce.

  16. 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 receive 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 documentation, the following are the various transaction status values for 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.

  • couldnotvoid
  • communicationerror
  • declined
  • expired
  • failedreview
  • generalerror
  • refundsettledsuccessfully
  • settledsuccessfully
  • settlementerror
  • Voided also retrieves transaction settlement time from gateway response. It is stored in the ‘Settlement Time’ field.