Accept an ACH debit
Debit a US bank account with a token, or with the ach object on pay.
POST /v1/transactions/pay debits a US bank account when you send an ach object, or the tokenId of a saved ACH account.
The request
- The
achobject requiresbankAccountHolder, a 9-digitroutingNumber, andaccountNumber.bankAccountTypeis optional and is one ofPersonalSavings,PersonalChecking,CorporateSavings, orCorporateChecking. amountis the total debited, including any payer fee.payerandpayerFeeare required. Send 0 forpayerFeewhen there is no payer fee.
To save the account for later, tokenize it first with POST /v1/tokens, then pay with tokenId and no ach object. You can validate the account as you save it by setting validateAccount, or beforehand with Validate a bank account.
curl -s -u "$DHANGO_KEY:$DHANGO_SECRET" \ -H "Content-Type: application/json" \ -H "accountKey: $ACCOUNT_KEY" \ -d '{"payer":"Ada Lovelace","amount":40.00,"payerFee":0,"ach":{"bankAccountHolder":"Ada Lovelace","routingNumber":"021000021","accountNumber":"123456789","bankAccountType":"PersonalChecking"}}' \ https://api.dhangodemo.com/v1/transactions/payawait fetch("https://api.dhangodemo.com/v1/transactions/pay", { method: "POST", headers: { Authorization: "Basic " + Buffer.from(process.env.DHANGO_KEY + ":" + process.env.DHANGO_SECRET).toString("base64"), "Content-Type": "application/json", accountKey: process.env.ACCOUNT_KEY }, body: JSON.stringify({ payer: "Ada Lovelace", amount: 40, payerFee: 0, ach: { bankAccountHolder: "Ada Lovelace", routingNumber: "021000021", accountNumber: "123456789", bankAccountType: "PersonalChecking" } })});import os, uuid, requestsauth = (os.environ["DHANGO_KEY"], os.environ["DHANGO_SECRET"])headers = {"accountKey": os.environ["ACCOUNT_KEY"]}response = requests.post( "https://api.dhangodemo.com/v1/transactions/pay", auth=auth, headers=headers, json={ "payer": "Ada Lovelace", "amount": 40.0, "payerFee": 0, "ach": { "bankAccountHolder": "Ada Lovelace", "routingNumber": "021000021", "accountNumber": "123456789", "bankAccountType": "PersonalChecking" } },)response.raise_for_status()payment = response.json()After the call
An ACH debit is not final when pay returns. The payment still has to be sent to the bank and funded, and the payer's bank can return it days later. Follow it with GET /v1/transactions/{id} or TransactionEvent webhooks. Transaction lifecycles shows the sequence of events.
Testing
On the Fake processor, an account number ending in 0801 is returned (R01) before batching, and one ending in 1801 is returned after batching. Any other account number with a valid routing number succeeds. See Test cards and bank accounts.
Related
- Nacha Direct Debit and Third Party Sender are two ways to run ACH. Both use this same call, and each has its own setup. See Nacha Direct Debit and Third Party Sender overview.
- Canadian bank debits use
acssinstead ofach. See ACSS.