Charge a bank account
Process ACH payments to debit funds from customer bank accounts
An ACH sale debits a customer's bank account. You send it to POST /v1/transactions, like a card sale, with a bank account token or the account details in payment. An ACH sale can return Pending (P), and its result arrives later in a transaction webhook. For how to handle a Pending result, see Handle synchronous and asynchronous results.
The following diagram shows the ACH-specific part: on some connections, the bank can return a payment after it's approved, and the transaction changes from A to D:
sequenceDiagram
participant P as Your platform
participant Z as Preczn
participant C as Connection
P->>Z: POST /v1/transactions (sale, bank account)
Z-->>P: Response with P
Note over Z,C: The ACH network processes the debit
Z-->>P: transaction.approved or transaction.declined webhook
opt The bank returns the payment (some connections)
C-->>Z: Returned
Z-->>P: transaction.declined webhook
end
Before you start, make sure you have the following:
- A merchant with a connection that accepts ACH. See the ACH column in Supported connections. When the merchant's plan routes the sale, Preczn sends it to a connection in the plan that accepts ACH.
- An endpoint subscribed to transaction events. See Subscribe to webhooks.
- A bank account token. To create one, see Server-side bank account tokenization. To charge account details without a token, see the Charge account details section.
Charge a bank account token
To charge a bank account token, complete the following steps:
-
Send
POST /v1/transactionswithtypeset tosale, themerchantId, theamountin cents, and the token inpayment.token.The sale uses the account holder's name stored on the token. When you send
firstName,lastName,accountBusinessName, orachMandate, the sale uses your value and Preczn stores it on the token. See Overwriting existing data.{ "type": "sale", "merchantId": "mid_test_{merchantId}", "amount": 5000, "payment": { "token": "tkn_test_{tokenId}" } }{ "id": "txn_test_{transactionId}", "type": "sale", "amount": 5000, "currency": "USD", "merchantId": "mid_test_{merchantId}", "authorization": { "status": "P", "processorCode": "{processorCode}", "processorMessage": "{processorMessage}" }, "payment": { "token": "tkn_test_{tokenId}", "type": "personalChecking" } }This response is abbreviated. For every field, see Process Transaction.
-
Check
authorization.statusin the response. If it'sP, store the transactionidand wait for the transaction webhook. See Pending transactions.
If the request returns 400, look up the message in ACH errors.
Charge account details
To charge an account that you haven't tokenized, send the account details in payment.bankAccount, with the account holder's name. Add the ?tokenize=true query parameter to save the account for later charges. When the sale is approved or pending, the response returns a multi-use token in payment.token.
To charge account details, complete the following steps:
-
Send
POST /v1/transactions?tokenize=truewithtypeset tosaleand the account inpayment.bankAccount. A personal account needsfirstNameandlastName. A corporate account needsaccountBusinessName, or both names. The following request uses the approved test bank account from Test data.{ "type": "sale", "merchantId": "mid_test_{merchantId}", "amount": 5000, "firstName": "{firstName}", "lastName": "{lastName}", "payment": { "bankAccount": { "type": "personalChecking", "account": "123456789", "routing": "987654321", "bankCountry": "USA" } } }{ "id": "txn_test_{transactionId}", "type": "sale", "amount": 5000, "currency": "USD", "merchantId": "mid_test_{merchantId}", "authorization": { "status": "P", "processorCode": "{processorCode}", "processorMessage": "{processorMessage}" }, "payment": { "token": "tkn_test_{tokenId}" } }This response is abbreviated. For every field, see Process Transaction.
-
Check
authorization.status. If it'sP, store the transactionidand wait for the transaction webhook. See Pending transactions. -
If the status is
AorP, store thepayment.tokenvalue with the customer's record, and discard the account and routing numbers.
Next
To return the payment after it settles, see Refund an ACH payment.
Updated 11 days ago
