Skip to Content
Docs

Let recipients choose a payout method

Let recipients pick a saved payout method or add a new one with Universal checkout or Headless checkout, then pay out from your server.

When the recipient chooses how to get paid, they select a saved payout method or add a new one on your website. Your server creates a payout setup session, your frontend presents the choice with Pay.com.js, and your server sends the payout to the method they selected. If you already have the recipient's payout details, create a payout directly instead.

Set up payout method selection

Your server creates the setup session and submits the payout, while your frontend displays the payout method options.

  1. 1

    Check enabled payout methods

    Your account manager enables payout methods in the sandbox and live environments. Call GET /v1/merchants/current/payment_method_options to list enabled payout methods in payout_method_options.types, which is separate from the types enabled for incoming payments.

  2. 2

    Create a payout setup session

    From your server, create a setup session with POST /v1/sessions/setup, passing the recipient's customer_reference_id and "payout": true. The session offers only enabled payout methods, either all enabled types or the subset you specify in payment_method_types. Requesting a method that isn't enabled for payouts returns an error.

    curl https://api.sandbox.pay.com/v1/sessions/setup \
      -u ':sk-pay-com-sandbox-…' \
      -H "Content-Type: application/json" \
      -H "idempotency-key: $(uuidgen)" \
      -d '{
        "customer_reference_id": "user_10",
        "payout": true
      }'

    Associate the session's id with the recipient on your server and pass client_secret to your frontend. Only this response returns client_secret, and it stays valid for the lifetime of the session (60 minutes by default unless you set duration). For US bank account payouts, also include the recipient's billing_details. See US bank account.

  3. 3

    Display payout method options

    On your frontend, initialize a checkout with pay.checkout(), passing clientSecret and your onSuccess and onFailure callbacks. Then render the choice using Universal checkout or Headless checkout.

    Call checkout.universal() with a container element to render Pay.com's hosted form. The form displays the recipient's saved payout methods and lets them add any payout method enabled for the session.

    import Pay from '@pay-com/js';
    
    const pay = await Pay.com({ identifier: '<YOUR_MERCHANT_ID>' });
    const checkout = pay.checkout({
      clientSecret,
      onSuccess: async (result) => {
        // Notify your server with result.transaction (setup session ID)
        await fetch('/api/payout-setup-complete', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({ setupSessionId: result.transaction }),
        });
      },
      onFailure: (error) => {
        console.error('Payout setup failed:', error.message);
      },
    });
    
    checkout.universal({ container: '#payout-container' });

    When the recipient saves a method, onSuccess receives the setup session ID in transaction and the saved method in paymentMethod. Notify your server to confirm the session.

  4. 4

    Confirm the choice and pay out

    Verify the recipient's choice on your server rather than trusting an ID sent from the browser. Only pay out to a saved payment method whose flow_directions.payout is true.

    1. Retrieve the setup session with GET /v1/sessions/setup/{id} when your frontend notifies your server, or when the setup_session.completed webhook arrives.
    2. Confirm that status is completed and customer_reference_id matches your recipient. Read payment_method for the selected method ID.
    3. Call POST /v1/payouts with that ID as destination and a unique idempotency-key. Amounts are in minor units (for example, 10000 is $100.00 USD).
    {
      "id": "ss_747110684277344256",
      "resource": "setup_session",
      "customer": "cust_747110680854791169",
      "customer_reference_id": "user_10",
      "payment_method": "pm_card_747113042071782400",
      "status": "completed",
      "test_mode": true
    }

    Handle the response as documented in Create a payout, then track the payout to its final status.

Next steps

Was this page helpful?