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
Prerequisites
Before integrating payout capabilities, you must complete the following setup steps:- Application Creation: Create a GatePay application in the merchant dashboard
- Retrieve ClientId: Obtain your
ClientIdfor API authentication - Signing Key Configuration: Configure your signing key for request authentication
- Callback URL Configuration: Set up your callback endpoint for asynchronous notifications
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:- Current withdrawal fees
- Minimum and maximum payout amounts
- Per-transaction limits
- Daily payout limits
Step 2: Create a Batch Payout
Create a batch containing one or more sub-orders (recipient withdrawal requests). Each batch is identified by a uniquebatch_id.
Minimum Integration Path
Operationally, the minimum payout path is usually:- call
POST /v1/pay/withdraw/queryto retrieve current fees and limits - call
POST /v1/pay/withdrawto create the batch - process the payout callback notifications
- use query endpoints as fallback confirmation when needed
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:- Initial callback when batch is created (
INITstatus) - Processing callback when batch enters processing (
PROCESSINGstatus) - Final callback with completion status (
SUCCESS,PARTIAL, orFAIL)
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
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 asuborders 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
amountis 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)
Reconciliation and Auditing
Account Balance Reconciliation
Regularly reconcile your GatePay merchant account balance against your internal records:- Query Fees Before Each Payout: Get current fee rates
- Track Batch Status: Monitor batch and sub-order status via callbacks
- Audit Amounts: Verify
amount,fee, anddone_amountmatch your expectations - Reconcile Daily: Use query APIs to reconcile at end of day
Investigating Failed Payouts
If a sub-order fails:- Check Sub-Order Status: Query the batch to get
statusfor each sub-order - Review Error Details: Look for error reason in callback or query response
- Verify Recipient Address: Ensure wallet address is valid for the specified chain
- Check Recipient Chain: Confirm the recipient’s wallet supports the specified blockchain
- Retry If Transient: For temporary failures, resubmit with a new
batch_idand samemerchant_withdraw_id
Query Payout Results
Request:- Batch status and metadata
- Sub-order array with individual results
- Fee information
- Transaction hashes for on-chain verification
- 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\nsigning string - Include the computed signature in the
X-GatePay-Signatureheader - Verify callbacks with the same Payment API Secret and signing rules
Best Practices
- Query Fees Dynamically: Always query current fees before creating a batch; do not cache fee values.
- Use Unique Identifiers: Assign unique
merchant_withdraw_idandbatch_idvalues to prevent duplicates and enable idempotency. - Implement Callback Handling: Set up robust callback processing for real-time status updates.
- Monitor Batch Status: Track batches through their lifecycle; alert on
PARTIALorFAILstatus. - Verify Transactions On-Chain: For critical payouts, verify
txHashon the blockchain explorer. - Reconcile Daily: Reconcile your internal account balance against GatePay records daily.
- Handle Errors Gracefully: Implement proper error handling with exponential backoff for retries.
- Secure Your Signing Key: Protect your signing key; never expose it in logs or to unauthorized parties.
- Validate Recipient Addresses: Perform basic validation (checksum, format) on recipient addresses before submission.
- Plan for Rate Limits: Be aware of API rate limits; implement request queuing for large batch operations.

