Testing ACH
While ACH transfers provide a relatively simple way to transfer funds between two accounts at different banks, we recommend that you understand and test the various scenarios you may encounter while using this payment rail before launching your application.
Testing in Sandbox
The sandbox environment includes an ACH Simulations feature that allows an ACH object to be programmatically moved into the various states you will encounter in production funds movement. It also allows for customization of the settlement time for ACH debit transfers to allow for more rapid testing than could be done with production transfers.
Simulating ACH Transfers
Simulating an ACH transfer involves two steps:
- Create an ACH object to use for the simulation using the
/ach
endpoint - Update the ACH using the
/simulations
endpoint
ACH Simulation Types
Simulation Type | Description |
---|---|
ach.processing_sent | Simulate an ACH being sent by validating, processing, and sending the ACH immediately. If an ACH fails validation or processing, the ACH is instead updated to an error status. |
ach.processing_returned | Simulate an ACH being returned by validating, processing, sending, and returning the ACH immediately. Similarly to processing_sent, any validation or processing failure will cause the ACH status to be updated to error. |
ach.incoming_ach | Simulate an incoming credit or debit (externally originated) ACH. |
How to Create an ACH Object for Simulation Testing
Before you can submit a new simulation request, you must first create a new ACH object. Simulation requests and ACH objects should have a 1:1 relationship.
To create a new ACH object for use with simulations, use the standard /ach
endpoint to create a new object that includes the following parameter(s) in the userdata
field.
Parameter | Type | Required? | Description |
---|---|---|---|
manual | boolean | Required | A value of true indicates that this ACH should not be processed until a simulation request is received. |
scheduled_settlement | integer | Only applicable to debit ACHs. The number of minutes to wait after the simulation is submitted to capture the ACH request. Defaults to 15 minutes if unset. |
Sandbox Test Scenarios
The recommendations below represent common ACH scenarios you may want to test before launching your application in a production environment.
- Originated ACH credit
- Originated ACH debit
- Incoming ACH credit
- Incoming ACH debit
- Returned ACH credit
- Returned ACH debit
- Originated ACH credit from an account with insufficient funds
Example ACH Simulation
In the following example, we will create an ACH debit for $100, then use the ach.processing_sent
simulation to process the ACH and move it to a sent status.
1. Create an ACH
The request below will create an ACH debit for $100. For help in understanding the body of ACH requests, see the guide on how to transfer funds using ACH.
In the userdata
field, the manual
flag tells the system to wait for a simulation request before processing this transaction, and the scheduled_settlement
value of “0” determines that when that request is received, it will wait 0 minutes before settling.
$ curl -u $API_KEY_ID:$API_SECRET_KEY https://api.sandbox.treasuryprime.com/ach \
-H 'Content-Type: application/json' \
-d '{
"account_id": "acct_1234567890",
"amount": "100.00",
"counterparty_id": "cp_0987654321",
"direction": "debit",
"sec_code": "ccd",
"userdata": {
"manual": true,
"scheduled_settlement": 0
}
}'
2. Simulate sent
Status
sent
StatusNow that you have created an ACH object to use for simulations, you can now coerce ACH we created in the previous step directly to a status of sent
using the ach.processing.sent
simulation type.
Next, ensure that you pass the in the id of the ACH you created in the previous step in the ach_id
property of the simulation
sub-object.
$ curl -u $API_KEY_ID:$API_SECRET_KEY https://api.sandbox.treasuryprime.com/simulation \
-H 'Content-Type: application/json' \
-d '{
"type": "ach.processing_sent",
"simulation": {
"ach_id":"ach_11hqswhmf3zzcs"
}
}'
Testing in Production
Best practice for testing in production involves creating low-value ACH transfers that mimic the actions you expect your users to take within your application. The recommendations below may or may not apply based on your use cases, and are meant to serve as general guidelines. They may not represent complete test coverage for your specific implementation.
Test Subject | Description |
---|---|
Originated ACH credit | Verify receipt of funds by the receiving account. |
Originated ACH debit | Verify receipt of funds in the originating account, then review and understand settlement times for ACH debit transfers. |
Incoming ACH credit | Initiate an ACH credit from an external account to an account on the Treasury Prime platform, and verify receipt of funds in the receiving account. |
Incoming ACH debit | Initiate an ACH debit from an external account to an account on the Treasury Prime platform, then verify the withdrawal of funds from the Treasury Prime account, and the deposit of funds in the originating account. |
Originated ACH Credit from an account with insufficient funds | Originate an ACH credit for a greater amount than is available in the funding account to trigger an insufficient funds failure. |
ACH Debit from an account with insufficient funds | Originate an ACH debit for a greater amount than is available in the funding account to trigger an insufficient funds failure and a return. |
ACH Timing | Test the usage and settlement times for standard and sameday ACH transfers (if being used). |
Updated 6 months ago