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:


Charge a bank account token

To charge a bank account token, complete the following steps:

  1. Send POST /v1/transactions with type set to sale, the merchantId, the amount in cents, and the token in payment.token.

    The sale uses the account holder's name stored on the token. When you send firstName, lastName, accountBusinessName, or achMandate, 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.

  2. Check authorization.status in the response. If it's P, store the transaction id and 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:

  1. Send POST /v1/transactions?tokenize=true with type set to sale and the account in payment.bankAccount. A personal account needs firstName and lastName. A corporate account needs accountBusinessName, 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.

  2. Check authorization.status. If it's P, store the transaction id and wait for the transaction webhook. See Pending transactions.

  3. If the status is A or P, store the payment.token value 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.


Did this page help you?