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.
Link the account and send a payout
Your server creates the setup session and the payout, and your page opens Plaid Link.
- 1
Create a setup session
Send
POST /v1/sessions/setupfrom your server. Includepayment_method_types: ["us_bank_account"],"payout": true,setup_future_usage: "off_session", and the customer's billing details.payout: truemarks this as a payout setup session and checks payout support for the method. Without it, the saved bank account can later be rejected byPOST /v1/payoutswithPayouts 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" } } }'{ "id": "ss_717689445138038784", "resource": "setup_session", "client_secret": "eyJhbGciOiJIUzUxMiJ9...", "customer": "cust_717689313483032577", "customer_reference_id": "your-customer-id", "payment_method_types": ["us_bank_account"], "setup_future_usage": "off_session", "status": "open", "test_mode": true } - 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 theclient_secretfrom Step 1. Attachcheckout.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) } }) - 3
Retrieve the payment method ID
After the customer completes the Plaid flow,
onSuccessfires and Pay.com sends asetup_session.completedwebhook. CallGET /v1/sessions/setup/{id}from your server with the setup session ID from Step 1, confirmstatusiscompleted, and readpayment_methodfor the newly linkedpm_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-…'{ "id": "ss_717689445138038784", "resource": "setup_session", "customer": "cust_717689313483032577", "customer_reference_id": "your-customer-id", "payment_method": "pm_us_bank_account_717695840956713984", "status": "completed", "test_mode": true }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_methodsand match byid. - 4
Create a payout
Send
POST /v1/payoutsfrom your server using thepm_us_bank_account_...ID asdestination, with a uniqueidempotency-key. Amounts are in minor units (the smallest currency unit), so10000is $100.00 USD.To control the transfer rail, pass
payout_method_options.us_bank_account. Setrailtoach,rtp, orfednow. For ACH, setach_payment_typetonext_dayorsame_day. Setfallback_to_ach: trueto fall back to same-day ACH when RTP isn't available. FedNow payouts always fall back to ACH.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" } } }'{ "id": "po_709068516191371264", "resource": "payout", "amount": 10000, "amount_human_readable": "100.00", "currency": "usd", "payment_method": "pm_us_bank_account_717695840956713984", "payment_method_details": { "type": "us_bank_account", "us_bank_account": { "account_holder_name": "Jane Smith", "account_holder_type": "individual", "account_type": "savings", "bank_name": "Tartan Bank", "country": "US", "currency": "USD", "last4": "1111", "routing_number": "011401533" } }, "reference": "payout-order-001", "status": "pending", "test_mode": true }An ACH payout is created with
status: "pending", and webhooks deliver its outcome. Pay.com sendspayout.succeededwhen the payout is sent to the customer's bank,payout.failedif it's declined or canceled, andpayout.returnedif the bank sends it back, usually within 2 business days. Until a pending ACH payout is sent to the bank, you can cancel it withPOST /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.
| Field | Value |
|---|---|
| Phone number | 415-555-0011 |
| OTP code | 123456 |
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
- Track and manage payouts: Monitor payout webhooks, cancel pending ACH transfers, and handle bank returns.
- Test and go live: Run sandbox payout test cases and prepare for live processing.