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.
Contact us for a no-obligation 30 day trial, and see for yourself!
- Configure your USAePay account
- Prior to setting up USAePay in Salesforce
- Setting Up Salesforce For Integration with USAePay
- Add a USAePay Gateway record in Salesforce using Chargent’s Gateway Wizard
- Add a USAePay Gateway record in Salesforce (Chargent versions prior to 5.40)
- Testing the Integration
- Sending Live Transactions from a Salesforce Sandbox
- Going Live
- Understanding Transactions
- Field Mapping
- Transaction Sync
- Common Errors
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.
- If you don’t already have a USAePay Sandbox account you should register for one at https://sandbox.usaepay.com/_developer/app/register. Fill out all fields and click Register new account. Note: You will receive an Email containing your sandbox (test) credentials.
- When you receive your credentials you should log into your sandbox using the credentials received in step 1 at https://sandbox.usaepay.com/login.
- Click Settings in Merchant’s console.
- Click Source Keys
- Click Add API Key
- Enter Name and Pin. Click Apply
- 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
- Install both the Base Package and the Chargent Orders Transaction Package into your Salesforce org.
- 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.
- 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
- Select USAePay as your Payment gateway.
- Select Test Transactions for testing or Live Transactions if you are looking to process real payments.
- 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
Add a USAePay Gateway record in Salesforce (Chargent versions prior to 5.40)
- Click on the AppLauncher on the top left side in Salesforce.
- In the Search for apps or items box, Search for Gateways and select
- Click New and select USAePay as the Gateway Type
- Map the following fields in Chargent with your credentials from USAePay:
- Merchant ID: USAePay Source Keyy
- Merchant Security Key: USAePay Source PIN
- Check the Active box - To make the Gateway active
- Use Tokenization - If you are planning on using USAePay 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
- 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.
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 capture them.
- 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
- Show Charge Button
- Show Authorize Button
Your Gateway page should look similar to the figure below. Click the Save button to commit your changes.
Testing the Integration
Now that you have created the USAePay 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
- Click on the App Launcher in the top left side and select Chargent as the App.
- Click the Chargent Orders Tab.
- Click on New
- Enter in the following information:
- Account: The Account the Chargent Order should be associated with.
- Payment Type should be either credit card or check depending on if you are testing credit cards or ACH (electronic check)
- 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 checkbox to enter a specific amount. If you are entering Subtotal, Tax, and Shipping then the Charge Amount will be automatically calculated and the Manual Charge box does not need to be checked).
- Credit Card Number = See USAePay test credit card information. USAePay uses different test credit card numbers to determine the response message and whether it’s approved or declined for specific reasons. For ACH testing see USAePay’s Test ACH Account and Routing Numbers..
- Card type (Visa, MasterCard, etc..) or Bank Account Type for ACH (Checking or Savings).
- Card Expiration Month and Card Expiration Year should be in the future
You should receive a popup that shows the test transaction was approved.
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|
|4000300211112228||Any||Do Not Honor|
|4000301311112225||Any||Decline for CVV Failure|
Testing ACH (electronic check)
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.
|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.
|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).
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.
- Click Settings in Merchant’s console.
- Click Source Keys
- Click Add Source
- Enter Name and Pin. Click Apply.
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:
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.
- In the top left corner click on the App Launcher
- Search and select Gateways
- Click on USAePay
- Click Edit
- Check the box that Says Tokenization
- 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)
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.
|Salesforce field||Direction||USAePay Field|
|Gateway ID||<||Transaction ID|
|Invoice Number||>||Invoice Number|
|Chargent Order record ID||>||Order ID|
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.
- timed out
- manager approval req.
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 https://www.usaepay.com/gate 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.