Like all software, it is a best practice to test Automated Collections in a Sandbox environment before deploying to your Production environment. This will enable you to develop a full understanding of how this tool works.
Automated Collections is offered as part of Chargent’s Growth or Enterprise Editions. For more information, see our Pricing Page.
Once you’ve configured an Automated Collections process, you may test it using a couple of methods:
Prerequisites #
- Create an Automated Collections process to be tested.
- It is best practice to configure this process to use the ‘Rule-Based’ option in the Criteria field in order to target a specific Chargent Order record during your testing.
- Create a Chargent Order record to be used for testing.
- Ensure that the value in the AC Criteria field on your Chargent Order record matches the value in the AC Criteria Value field on the Automated Collections process to be tested.
- Configure this record so the payment fails by leveraging your payment gateway’s test details. See Forcing a Decline for more information.
- Register a token for the test card or bank account provided by your payment gateway.
- Check the Manual Charge checkbox to ensure your chosen amounts are always used for payment collection.
Notes #
- It is a best practice to test features in a Salesforce Sandbox environment before moving to Production.
- When an Automated Collections process has been triggered, the Status field on that Chargent Automated Collections record will show ‘In Progress.’ When the payment is collected in any way (for example, the Automated Collections payment retry, a payment submitted via Payment Request, or a manual payment collected in Salesforce for that record), that Automated Collections process will stop. The Status field on that Chargent Automated Collections record will switch to ‘Complete,’ and the Payment Status field on the Chargent Order record will switch back to its previous value.
Real-Time Testing #
This section will cover testing Automated Collections without manually triggering Chargent batches. This means that each stage will execute based on the Time Frame options configured. This method is recommended for instances wherein testing in a sandbox is not possible and you must test in a production environment.
Triggering Automated Collections Manually
With Chargent’s Collect Any Payment feature, users can click Start Automated Collections on the Chargent Order record to initiate an Automated Collections process.
- Navigate to the Chargent Order Record you’ve configured for your tests
- Click Start Automated Collections at the top-right portion of the screen. You may need to click the down arrow to locate the action
- Select the Automated Collection Process you’ve configured for the test
- Click Start Collections
Once complete, the Payment Status field on the Chargent Order record will switch to ‘Automated Collection.’ A related Chargent Automated Collections record will be created, as well as the Chargent Automated Collections Stage records.
Each stage will execute its configured functions (retry, email-send, or both) on the date listed in the Execute Date field of the respective Chargent Automated Collections Stage record. You can confirm this by checking the Chargent Automated Collections and Chargent Automated Collections Stage records after the batch has run for each stage’s execute date.
Forcing a Decline
If you wish to force the payment retries to fail in order to proceed through each stage, you may configure the Chargent Order record to decline using various gateway-dicated values. For example, when testing Chargent using Authorize.net test credentials, a Charge Amount of $70.02 will cause a Charge transaction to decline. Every gateway is different, so please consult your gateway’s documentation for specific instructions on how to force a decline.
Once you’ve configured the Chargent Order record to fail during payment collection tests, each payment retry configured in your Automated Collections process will also fail.
Collecting Payment via Retry
To confirm that Automated Collections payment collection retry works, update the Chargent Order record with test payment information meant for successful transactions, per your payment gateway’s testing documentation.
When Automated Collections succeeds in collecting a payment, the Status field on the Chargent Automated Collections record will change to ‘Complete,’ and the Payment Status field on the Chargent Order record will switch back to its previous value (for example, ‘Recurring’).
Triggering Automated Collections Automatically
The most common method for triggering Automated Collections is when a scheduled payment is declined, causing the Automated Collections process to begin. To leverage this approach, follow these steps:
- Ensure the AC Criteria field for the Chargent Order record is populated with the value that matches the AC Criteria Value field on the Automated Collections configuration.
- Then, configure the Chargent Order record to fail using the payment gateway testing tools described in Forcing a Decline.
- Configure the Chargent Order record to collect payment on a schedule:
- Select ‘Daily’ from the Payment Frequency picklist
- Select ‘Recurring’ from the Payment Status picklist
- Select ‘Unending’ from the Payment Stop picklist
- Select tomorrow’s date from the Payment Start Date picklist, and select the same day of the month from the Charge Date picklist
From here, the next run of the Chargent Recurring batch will result in a failed payment collection on that Chargent Order record, which will trigger the Automated Collections process. The Payment Status field on the Chargent Order record will switch to ‘Automated Collection.’ A related Chargent Automated Collections record will be created, as well as the Chargent Automated Collections Stage records.
Each stage will execute its configured functions (retry, email-send, or both) on the date listed in the Execute Date field of the respective Chargent Automated Collections Stage record. You can confirm this by checking the Chargent Automated Collections and Chargent Automated Collections Stage records after the batch has run for each stage’s execute date.
As with testing Automated Collections manually, you should test your Stages by initiating a forced decline, and test a successful retry.
Testing with Forced Batch Runs
Note: This method is recommended only in your Sandbox environment and should only to be conducted by a Salesforce Administrator. Testing in a production org may affect live Chargent Orders with payments due.
This testing method involves manually triggering the Chargent Recurring batch (ChargentOrders.TChargentBatchProcessing) as well as the Chargent Automated Collections batch (ChargentOrders.TChargentAutomatedCollectionsBatch).
Deleting Transaction records of the same date prior to triggering each stage may be necessary in order for Chargent’s batches to retry payments. This is because the Chargent batch is designed to recognize when a payment collection has already been attempted.
Triggering Automated Collections
- Ensure that the Chargent Order record on which you’re conducting the test is configured for failed payments, as described in the Prerequisites section
- Ensure that the Payment Status on the Chargent Order record is set to ‘Recurring’
- Set the Charge Date field to the current day of the month
- Set the Payment Start Date field to today
- Successful transactions on the same day may stop the recurring batch from running on this Order record. Delete all transactions, payment links, and AC records for that Chargent Order record prior to testing.
- Trigger the recurring batch by clicking the gear icon at the top-right of the screen, then clicking Developer Console
- Click Debug from the topside menu, then click Open Execute Anonymous Window
- Paste the following command in the Enter Apex Code window, then click the Execute button:
database.executeBatch(new ChargentOrders.TChargentBatchProcessing(),10); |
At this point, the Payment Status field on the Chargent Order record should switch to ‘Automated Collection.’ The Chargent Recurring Batch will no longer run against this Chargent Order record.
If the first AC Stage is configured to send an email immediately, you’ll see that email in your inbox, indicating the first Chargent Automated Collections Stage was completed. If it was scheduled to retry the payment collection, you’ll see a Transaction record for that retry.
Additionally, the following related records will be created:
- Transaction record (declined charge)
- Payment Request record (and link)
- Chargent Automated Collections record
- Chargent Automated Collections Stages records (detail records of the AC record)
The Automated Collections batch will now run against this Order record, and it looks to the Execute Date field on the Chargent Automated Collections Stage records to determine when to execute those stages.
Triggering the Next Automated Collections Stage
To trigger the next Automated Collections Stage, manually change the Execute Date field on that Automated Collections Stage record to today’s date, then navigate back to the Developer Console and run this command:
Database.executeBatch(new ChargentOrders.TChargentAutomatedCollectionsBatch(), 10); |
Repeat the steps in this section to test each stage. To test a successful payment collection, follow these steps:
- Update the Chargent Order record with payment information that will result in a successful transaction, per your payment gateway’s testing information
- Collect the payment via any method – with the payment retry configured on a Chargent Automated Collections Stage record, manually from the Chargent Order record, or via a Payment Request link
When the payment is successfully collected, the following fields on the Chargent Automated Collections record will be updated:
- Status will switch to ‘Completed’
- Payment Received will display the date of the successful payment collection
- Last Stage Executed will show the last Automated Collections Stage that was executed
- Payment Collected Via will show how the payment was collected
Additionally, the Payment Status field on the Chargent Order record will change to the value populated prior to Automated Collections triggering.
See Also
Testing Chargent
Best Practices for Testing
Setting Up Automated Collections