Skip to main content

Overview

GatePay payout capabilities enable merchants to distribute funds to multiple recipients in a single batch operation. Common use cases include:
  • Commission distribution to affiliates or partners
  • Merchant settlement and revenue sharing
  • Batch fund transfers to user wallets
  • Royalty payments
  • Refunds and chargebacks
In this guide, the terms “payout”, “withdrawal”, and “merchant-side fund transfer” all refer to the same outbound transfer capability. To keep the reading experience consistent, this page uses “payout” as the primary label.

Prerequisites

Before integrating payout capabilities, you must complete the following setup steps:
  1. Application Creation: Create a GatePay application in the merchant dashboard
  2. Retrieve ClientId: Obtain your ClientId for API authentication
  3. Signing Key Configuration: Configure your signing key for request authentication
  4. Callback URL Configuration: Set up your callback endpoint for asynchronous notifications
For detailed setup instructions, see Overview and Authentication and Security.

Payout Integration Steps

Step 1: Query Fees and Limits

Before creating any payout batch, query the current fee structure and amount limits. These values may change dynamically and should not be cached. Request:
This endpoint retrieves:
  • Current withdrawal fees
  • Minimum and maximum payout amounts
  • Per-transaction limits
  • Daily payout limits
Operationally, this step should be treated as more than a fee check. It is also the safest pre-flight validation before order creation, because it confirms the current payout path is available for the intended amount and conditions.

Step 2: Create a Batch Payout

Create a batch containing one or more sub-orders (recipient withdrawal requests). Each batch is identified by a unique batch_id.

Minimum Integration Path

Operationally, the minimum payout path is usually:
  1. call POST /v1/pay/withdraw/query to retrieve current fees and limits
  2. call POST /v1/pay/withdraw to create the batch
  3. process the payout callback notifications
  4. use query endpoints as fallback confirmation when needed
For first-time merchants, it is best to validate the full lifecycle with a single sub-order before expanding to large batches.

Step 3: Receive Callbacks and Track Status

GatePay sends asynchronous callbacks to your configured callback URL. These callbacks report both batch-level status and individual sub-order status. Callback Order:
  1. Initial callback when batch is created (INIT status)
  2. Processing callback when batch enters processing (PROCESSING status)
  3. Final callback with completion status (SUCCESS, PARTIAL, or FAIL)

Step 4: Reconciliation and Fallback Queries

Use the query API as a fallback mechanism for:
  • Verifying callback delivery
  • Reconciling accounts
  • Investigating failed transactions
  • Confirming final status
If your business has strict confirmation requirements, it is helpful to treat “callback received” and “query confirmed” as two separate checkpoints rather than relying on only one of them.

Callbacks First, Query as Fallback

GatePay’s payout system prioritizes asynchronous callbacks for reliability and performance: Best Practice: Implement callback handling as your primary status update mechanism. Use the query API only for fallback verification or periodic reconciliation. For detailed callback information, signing, and verification procedures, see Notification. If you want to understand the callback status combinations first, continue with Notification.

Idempotency and Reconciliation

GatePay uses two key identifiers for idempotency and reconciliation: Idempotency Guarantee: If you resubmit a batch with the same merchant_withdraw_id values, GatePay will detect duplicates and prevent double-payments. From the merchant system perspective, merchant_withdraw_id is best treated as a business reconciliation key rather than only as a technical idempotency field. That makes support handling, manual investigation, and ledger matching easier later.

Batch and Sub-Order Statuses

Batch Status Lifecycle

A batch progresses through the following states:

Sub-Order Status

Each withdrawal within a batch has its own status:

Callback Payload Structure

Main Batch Callback Payload

When a batch status changes, GatePay sends a callback with the following main-order fields:

Sub-Order Array Callback Payload

Each callback includes a suborders array with detailed information about individual withdrawals:

Fee Type Clarification

  • Fee Type 0 (Internal Deduction): Fee is deducted from the merchant’s account; the full amount is sent to the recipient.
  • Fee Type 1 (External Deduction): Fee is deducted from the withdrawal amount; the recipient receives amount - fee.

Error Handling

Common Error Codes

When creating or processing payouts, you may encounter the following error codes:

Error Response Handling

When an error occurs, GatePay returns an error response with:
  • Error Code: Numeric identifier for the error
  • Error Message: Human-readable description
  • Details: Additional context (if available)
Implement retry logic with exponential backoff for transient errors (network issues, timeouts). For permanent errors (insufficient balance, invalid parameters), address the underlying issue before retrying.

Reconciliation and Auditing

Account Balance Reconciliation

Regularly reconcile your GatePay merchant account balance against your internal records:
  1. Query Fees Before Each Payout: Get current fee rates
  2. Track Batch Status: Monitor batch and sub-order status via callbacks
  3. Audit Amounts: Verify amount, fee, and done_amount match your expectations
  4. Reconcile Daily: Use query APIs to reconcile at end of day
For detailed reconciliation procedures, see Balance.

Investigating Failed Payouts

If a sub-order fails:
  1. Check Sub-Order Status: Query the batch to get status for each sub-order
  2. Review Error Details: Look for error reason in callback or query response
  3. Verify Recipient Address: Ensure wallet address is valid for the specified chain
  4. Check Recipient Chain: Confirm the recipient’s wallet supports the specified blockchain
  5. Retry If Transient: For temporary failures, resubmit with a new batch_id and same merchant_withdraw_id

Query Payout Results

Request:
Query detailed results for a specific payout batch. This endpoint returns:
  • Batch status and metadata
  • Sub-order array with individual results
  • Fee information
  • Transaction hashes for on-chain verification
Use this endpoint for:
  • Fallback verification if callbacks are delayed
  • Periodic reconciliation
  • Detailed audit trails
  • Support and investigation

Request Signing and Validation

All payout requests must use the standard GatePay signing mechanism. For request signing, signature generation, and callback verification details, see Authentication and Security. Key signing requirements:
  • Compute HMAC-SHA512 with the Payment API Secret using the timestamp\nnonce\nbody\n signing string
  • Include the computed signature in the X-GatePay-Signature header
  • Verify callbacks with the same Payment API Secret and signing rules

Best Practices

  1. Query Fees Dynamically: Always query current fees before creating a batch; do not cache fee values.
  2. Use Unique Identifiers: Assign unique merchant_withdraw_id and batch_id values to prevent duplicates and enable idempotency.
  3. Implement Callback Handling: Set up robust callback processing for real-time status updates.
  4. Monitor Batch Status: Track batches through their lifecycle; alert on PARTIAL or FAIL status.
  5. Verify Transactions On-Chain: For critical payouts, verify txHash on the blockchain explorer.
  6. Reconcile Daily: Reconcile your internal account balance against GatePay records daily.
  7. Handle Errors Gracefully: Implement proper error handling with exponential backoff for retries.
  8. Secure Your Signing Key: Protect your signing key; never expose it in logs or to unauthorized parties.
  9. Validate Recipient Addresses: Perform basic validation (checksum, format) on recipient addresses before submission.
  10. Plan for Rate Limits: Be aware of API rate limits; implement request queuing for large batch operations.