USAePay Salesforce Integration Chargent

Integrating USAePay with Salesforce using Chargent

Easily connect USAePay and Salesforce with Chargent,

the leading payments app on the Salesforce AppExchange. See all USAePay 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!


USAePay has provided a secure credit card and check processing gateway for over 15 years. The gateway supports all major credit card platforms and most leading check platforms. The gateway is Level 1 PC1 compliant, enforcing the latest and strictest security requirements for the payment industry. USAePay is processor agnostic, providing an interface to 10 different credit card processing networks and 12 different check processing networks.

Integration of USAePay with Chargent Payment Processing for Salesforce allows the ability to provide a seamless process for completing payment for orders managed in Salesforce. The connection of Salesforce and USAePay allows real-time and recurring payments between the two systems. Chargent will tokenize the credit cards and stores them in Salesforce for future use by the merchant (ACH/eChecks are not tokenized through USAePay). See Setting Up Salesforce For Integration for additional information on the gateway.


Configure your USAePay account

This section contains the procedures for configuring your USAePay account prior to setting up the integration in Salesforce. Each subsection under this section contains a separate procedure, however, the procedures must be completed in the order presented.

  1. If you don’t already have a USAePay Sandbox account you should register for one at Fill out all fields and click Register new account. Note: You will receive an Email containing your sandbox (test) credentials.

  2. When you receive your credentials you should log into your sandbox using the credentials received in step 1 at

  3. Click Settings in Merchant’s console.

  4. Click Source Keys

  5. Click Add API Key

  6. Enter Name and Pin. Click Apply

  7. Click Save



  • This Key and Pin will be used for Testing the Integration.
  • Test Mode needs to be disabled in order for testing to work correctly. Enabling Test Mode will return a response of Approved for all transactions rather than the response messages listed for the test credit card numbers below in Testing.

Prior to setting up USAePay in Salesforce

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

  2. Configure Chargent according to the Quick Start Guide.

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

    • Click the gear icon on the top right and select Settings
    • Under Security select Remote Site Settings
    • Locate USAePAY_Test and click edit
    • Check the Active box
    • Click Save
    • Do the same for USAePAY_Live

Setting Up Salesforce For Integration with USAePay

Add a USAePay 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 settings

  7. Do you have a Payment Gateway account - Select Yes

  8. Select USAePay as your Payment gateway.

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

  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 USAePay account.

    • Source Key:This is your USAePay Source Key
    • PIN This is the PIN you chose when configuring your USAePay gateway in the previous step.

Other information that will be asked:

  • Will you be using tokenization? (recommended)

  • What currency will you be using? (USD, CAN, etc.)

  • What payment methods will you be accepting?

  • Credit cards and/or ACH (electronic check)

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

Direct Debit Network (version 6.15 and higher)

Starting with Chargent version 6.15, you can now select the Bank Account network for your region during the gateway setup process. This will allow for the correct Direct Debit Network fields to be displayed on Payment Requests and Payment Console based on your region.

You have the following Direct Debit Networks to choose from based on your region.

  • US - ACH (also known as echeck or electronic check)
  • Canada - EFT (ACSS) Electronic Funds Transfer
  • Australia - BECS
  • Europe - SEPA

Select the Payment Methods You Accept

Once you have your Direct Debit Network set, you will see the appropriate field names on your Payment Request that are sent as well as your internal Payment Console.

Payment Request Bank Account

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 USAePay test credit cards below. If you are testing ACH you can use the USAePay Bank Account test numbers.
  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 USAePay credit cards or bank account testing numbers to complete the payform and submit the payment. 

You should receive a green box showing Approved.

Card Bank Payment

You should receive a green box confirmation

Card Bank payment

Testing Credit Card Data

USAePay uses different credit card numbers to simulate different response types. For full testing of all response types, please see the USAePay testing page on their website. Below will be some common credit card test cards with common response messages.

The following credit cards will return with approved transaction status regardless of amount: Note: All of the credit card numbers have the expiration date 09/19.

Note: Enabling Test Mode in the USAePay Configuration will return a response of Approved for all transactions rather than the response messages listed for the test credit card numbers below in Testing.

Credit Card Number CVV Response Message
4000100011112224 123 Approved
4000300011112220 Any Declined
4000300211112228 Any Do Not Honor
4000300611112224 Any Insufficient Funds
4000301311112225 Any Decline for CVV Failure

Testing ACH (electronic check)

Since tokenization for ACH (electronic check) isn’t supported through Chargent’s integration, you will need to setup a seperate gateway that is specific to ACH.

The following list of test check information is made available for testing check processing functionality on our Sandbox system. The account data should not be used in production.

Any other combination of 9 digit routing number and account number will return an approval.

Routing Account Amount Response Reason
987654321 Any Any Error Invalid routing Number
Any Any 5.99 Decline Returned check for this accoun
Any Any 9999.99 Manager Approval Warning: You have exceeded your allocated monthly transaction volume

All approved transactions will be moved to “submitted” at 5pm PST and on the following day at 8am PST will move to “settled”. The following account numbers will trigger returns at 8am on the 3rd day.

Routing Account Amount Response Reason
Any 10178101 Any Returned R01: Insufficient Funds
Any 10178102 Any Returned R02: Account Closed
Any 10178103 Any Returned R03: No Account/Unable to Locate Account
Any 10178104 Any Returned R04: Invalid Account Number

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 USAePay:

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

This section contains the procedure for making the integration available for production systems. This procedure should not occur until the testing procedure described in Testing the Integration is successful.

Setting Up USAePay Live Integration

USAePay works through resellers and does not provide payment gateway accounts directly to merchants. If you don’t already have a USAePay account contact our sales team to obtain one. You can also sign up for a payment processing account with any other USAePay reseller.

Similar to the Sandbox setup, you will receive the credentials for signing into your Merchant Console. Once you have the email and credentials login to your USAePay account.

  1. Click Settings in Merchant’s console.

  2. Click Source Keys

  3. Click Add Source

  4. Enter Name and Pin. Click Apply.

  5. test chargent

Understanding Transactions

When a successful transaction is generated in USAePay from Chargent / Salesforce, a Transaction record is created in Salesforce with the results. This transaction record contains a complete set of data returned from USAePay, such as the type of transaction (Charge, Authorize, Refund or Void), the Response Message (Approved, Declined, Error) as well as various response and result codes (detailed below).

The Salesforce Transaction Gateway Date shows the date and time it was submitted to USAePay, and Chargent’s Gateway ID field in Salesforce corresponds to the Transaction ID in USAePay for use in reconciling systems.

A Transaction Record from Chargent in Salesforce:

transaction record

The Corresponding Transaction record in USAePay:



If you haven’t already set up tokenization during the initial configuration of your USAePay account in Salesforce, this section will assist you in setting it up. USAePay uses a token system in order to maximize security of credit card data.

  1. In the top left corner click on the App Launcher

  2. Search and select Gateways

  3. Click on USAePay

  4. Click Edit

  5. Check the box that Says Tokenization

  6. Under the Credit Card / Bank Account handling field choose one of the following.

    • Never Clear

    • Clear After Successful Charge

    • Clear After All Transactions

    • Clear When Token is Present (recommended)

  7. Click Save.

  8. record type

NOTE: The token is stored in Chargent's Token field in Salesforce after your first successful transaction, and the credit card fields are handled as specified in the procedure

If you are using Chargent’s API, Payment Console or Payment Request features, credit cards are never saved to Salesforce but are instead tokenized in memory.

Field Mapping

Salesforce field Direction USAePay Field
Gateway ID < Transaction ID
Token < Customer Code
Order Information > Comment
Invoice Number > Invoice Number
Chargent Order record ID > Order ID

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:


As shown in the USAePay documentation, the following are the various transaction status values for USAePay 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.

  • queued

  • pending

  • submitted

  • funded

  • settled

  • error

  • voided

  • returned

  • timed out

  • manager approval req.

Common Errors

Gateway Message: “Customer Name Not Submitted”

  • Make sure you have the Name and Billing Address completed in your Chargent Order record. Incomplete information can create this error.

Specified Source Key Not Found:

  • This error means you have entered incorrect credentials for your USAePay gateway account, or are sending to the incorrect server.

Make sure that "Test Endpoint" is unchecked in the Chargent Gateway record if you are trying to send to your Production USAePay account.

If you wish to run some live tests from a Salesforce Sandbox, note that the "Test Endpoint" functionality is disabled for security purposes there.

Use the "Endpoint Override" field on the gateway record, with the reference gateway for value This will allow you to gain access and process a transaction.

Transaction Authentication Failed

  • This indicates that either your USAePay key / pin combination entered in the Chargent Gateway record in Salesforce are incorrect, or that you may be sending to the wrong environment to match your credentials. When using the USAePay Sandbox for testing, make sure “Test Endpoint” is checked in the Gateway record, and for production usage make sure it is unchecked.

Testing Decline Transactions keep showing as Approved

  • You want to make sure you have the Test Mode unchecked in your Source Key settings in USAePay.

source info