Skip to Content
Docs

Integrate payout

Link a customer's US bank account with Plaid, then send payouts to it by ACH, RTP, or FedNow with Pay.com.js and the REST API.

Link a customer's bank account with Plaid, then send payouts to it. You link the account with Pay.com.js and send the payout with the REST API. Before you start, make sure US bank account payouts are enabled on your Pay.com account. See the US bank account overview for prerequisites.

Your server creates the setup session and the payout, and your page opens Plaid Link.

  1. 1

    Create a setup session

    Send POST /v1/sessions/setup from your server. Include payment_method_types: ["us_bank_account"], "payout": true, setup_future_usage: "off_session", and the customer's billing details. payout: true marks this as a payout setup session and checks payout support for the method. Without it, the saved bank account can later be rejected by POST /v1/payouts with Payouts are not allowed.

    The response includes a client_secret. Pass it to your frontend.

    curl https://api.sandbox.pay.com/v1/sessions/setup \
      -u ':sk-pay-com-sandbox-…' \
      -H "Content-Type: application/json" \
      -H "idempotency-key: $(uuidgen)" \
      -d '{
        "payment_method_types": ["us_bank_account"],
        "payout": true,
        "customer_reference_id": "your-customer-id",
        "setup_future_usage": "off_session",
        "billing_details": {
          "email": "jane.smith@example.com",
          "name": "Jane Smith",
          "phone": "+12025551234",
          "dob": "1990-01-01",
          "address": {
            "line1": "123 Main St",
            "city": "New York",
            "postal_code": "10001",
            "country": "US"
          }
        }
      }'
  2. 2

    Initialize the SDK and render a button

    On your frontend, initialize Pay.com.js with your merchant ID as the identifier, then create a checkout with the client_secret from Step 1. Attach checkout.headless('us_bank_account') to your button's click handler to open Plaid Link in a new tab.

    <button id="link-bank-btn">Link bank account</button>
    import Pay from '@pay-com/js'
    
    const pay = await Pay.com({
      identifier: '<YOUR_MERCHANT_ID>', // your Pay.com merchant ID, not the session ID
    })
    
    const checkout = pay.checkout({
      clientSecret: 'eyJhbGciOiJIUzUxMiJ9...', // client_secret from your server
      onSuccess: (result) => {
        console.log('Bank account linked:', result)
        // Notify your server with result.transaction (the setup session ID)
        // so your server can retrieve GET /v1/sessions/setup/{id}
      },
      onFailure: (error) => {
        console.error('Linking failed:', error.message)
      },
    })
    
    document.getElementById('link-bank-btn').addEventListener('click', async () => {
      try {
        await checkout.headless('us_bank_account')
      } catch (error) {
        console.error('Linking failed:', error.message)
      }
    })

    identifier is your Pay.com merchant ID (in the Pay.com dashboard, under Developers), not the setup session ID. The session is identified by the client_secret you pass to pay.checkout(). Create a new setup session on your server for each customer that needs to link their bank account.

  3. 3

    Retrieve the payment method ID

    After the customer completes the Plaid flow, onSuccess fires and Pay.com sends a setup_session.completed webhook. Call GET /v1/sessions/setup/{id} from your server with the setup session ID from Step 1, confirm status is completed, and read payment_method for the newly linked pm_us_bank_account_... ID. Store this ID on the customer record as the destination for future payouts.

    curl https://api.sandbox.pay.com/v1/sessions/setup/ss_717689445138038784 \
      -u ':sk-pay-com-sandbox-…'

    To display masked bank account metadata (bank name, account type, last four digits) in your UI, retrieve all saved methods for the customer with GET /v1/customers/{customer_reference_id}/payment_methods and match by id.

  4. 4

    Create a payout

    Send POST /v1/payouts from your server using the pm_us_bank_account_... ID as destination, with a unique idempotency-key. Amounts are in minor units (the smallest currency unit), so 10000 is $100.00 USD.

    To control the transfer rail, pass payout_method_options.us_bank_account. Set rail to ach, rtp, or fednow. For ACH, set ach_payment_type to next_day or same_day. Set fallback_to_ach: true to fall back to same-day ACH when RTP isn't available. FedNow payouts always fall back to ACH.

    ACH bank account payouts must be explicitly enabled on your Pay.com account before this step works. Card payout enablement doesn't cover bank account payouts. If you receive "Payouts are not allowed", contact your account manager to enable ACH payouts.

    curl https://api.sandbox.pay.com/v1/payouts \
      -u ':sk-pay-com-sandbox-…' \
      -H "Content-Type: application/json" \
      -H "idempotency-key: $(uuidgen)" \
      -d '{
        "amount": 10000,
        "currency": "usd",
        "destination": "pm_us_bank_account_717695840956713984",
        "reference": "payout-order-001",
        "payout_method_options": {
          "us_bank_account": {
            "rail": "rtp",
            "fallback_to_ach": true,
            "ach_payment_type": "same_day"
          }
        }
      }'

    An ACH payout is created with status: "pending", and webhooks deliver its outcome. Pay.com sends payout.succeeded when the payout is sent to the customer's bank, payout.failed if it's declined or canceled, and payout.returned if the bank sends it back, usually within 2 business days. Until a pending ACH payout is sent to the bank, you can cancel it with POST /v1/payouts/{id}/cancel. A payout on RTP or FedNow can't be canceled. See Track and manage payouts.

Testing

Test against https://api.sandbox.pay.com/v1 with your sk-pay-com-sandbox- API key. Sandbox transactions never move real funds. See Environments. In the sandbox, Plaid Link runs against Plaid's test environment, so use Plaid's test credentials.

Plaid test credentials:

Plaid Link opens with a phone number prompt. There are two paths through the Plaid test flow:

Use this path for faster testing. The onSuccess callback fires immediately after account selection.

FieldValue
Phone number415-555-0011
OTP code123456

After entering the OTP, select any account shown. Plaid presents test accounts such as "Plaid Saving" from "Tartan Bank".

Test scenarios

To test account linking, enter phone 415-555-0011 and OTP 123456, select an account, and confirm GET /v1/sessions/setup/{id} returns status: "completed" with a pm_us_bank_account_... ID in payment_method. For sandbox payout outcome amounts (202 succeeded, 303 failed, 505 immediate failure) and simulated returns (POST /v1/payouts/{id}/simulate/return), see Test and go live.

Next steps

Was this page helpful?