概述
GatePay 提供多种对账工具,用于保障账户准确性:- 余额查询:按币种返回实时可用余额
- 订单手续费查询:按订单核验手续费和结算金额
- 资金流水查询:按交易跟踪所有资金变动
余额查询
余额查询接口可按币种返回商户支付账户的可用余额。对于结算、出款和风控决策,应以实时查询结果为准。常见使用场景
- 结算前校验:发起结算前确认可用余额
- 期末余额快照:在营业结束时记录余额,用于会计核对
- 运营监控:实时余额告警与阈值监控
- Multi-currency management: Track balances across different currencies
API 参考
接口:GET /v1/pay/balance/query
Institutional 接口: POST /payment/open/institution/v1/balance
请求 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
currencies | array | No | List of currency codes to query (e.g., [“USDT”, “BTC”, “USD”]) |
响应 字段
| 字段 | 类型 | 说明 |
|---|---|---|
currency | string | 币种 code |
available | string | Balance available for immediate use |
hold | string | Amount held by pending 订单s or 出款s |
total | string | Total balance (available + hold) |
last_updated | timestamp | Timestamp of last balance update |
Example 请求
Example 响应
Integration 步骤
- Call the balance query API using
GET /v1/pay/balance/querywith desired currencies - Store balances by currency in your 商户’s local accounting system
- Compare with local records to identify discrepancies
- Alert on thresholds if balance falls below operational minimums
订单手续费查询
The 订单 fee query API provides detailed fee breakdown and settlement amounts at the individual 订单 level. Use this for financial 对账 and exception investigation.常见使用场景
- Financial 对账: Verify fees match 商户 expectations
- Multiple or partial payments: Reconcile complex 订单 scenarios
- Exception investigation: Identify fee anomalies or discrepancies
- Settlement confirmation: Confirm amounts before initiating 出款
API 参考
接口:GET /api/open/v1/pay/order/fee/query
请求 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
orderId | string | Conditional | GatePay 订单 ID |
merchant_order_no | string | Conditional | 商户-generated 订单 number |
orderId or merchant_order_no (at least one required).
响应 字段
| 字段 | 类型 | 说明 |
|---|---|---|
orderId | string | GatePay 订单 ID |
merchant_order_no | string | 商户 订单 number |
orderAmount | string | Original 订单 amount |
payAmount | string | Amount customer paid |
settlementAmount | string | Amount credited to 商户 account |
gatewayFee | string | GatePay processing fee |
networkFee | string | Blockchain network fee (if applicable) |
discountAmount | string | Discounts or rebates applied |
currency | string | Settlement currency |
status | string | Order status |
created_at | timestamp | Order creation time |
settled_at | timestamp | Settlement completion time |
Example 请求
Example 响应
Integration 步骤
- Call the 订单 fee query API using
GET /api/open/v1/pay/order/fee/querywith 订单 identifier - Store the query result alongside your local 订单 master data
- Compare settlement amounts with expected values
- Flag discrepancies for manual review if fee structure differs
资金流水查询
The 资金 账本 query provides a complete 交易 history of all 资金 movements in and out of the 商户 account. This is essential for audit trails and comprehensive 对账.常见使用场景
- End-of-day 对账: Aggregate all 资金 movements for the day
- Audit tracing: Track 资金 origins and destinations for compliance
- Exception investigation: Identify timing issues or missing 交易s
- Financial reporting: Generate detailed movement reports by type and currency
API 参考
接口:GET /v1/pay/bill/orderlist
Institutional 接口: GET /payment/open/institution/v1/pay/bill/orderlist
请求 参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
start_time | timestamp | No | Start of time range (UTC milliseconds) |
end_time | timestamp | No | End of time range (UTC milliseconds) |
page | integer | No | Page number for pagination (1-indexed, default 1) |
limit | integer | No | Records per page (default 20, max 100) |
currency | string | No | Filter by currency code |
type | string | No | Filter by 交易 type (see enumeration below) |
order_id | string | No | Filter by related 订单 ID |
响应 字段
| 字段 | 类型 | 说明 |
|---|---|---|
ledger_id | string | Unique 账本 entry identifier (use as deduplication key) |
type | string | Transaction type (see enumeration below) |
currency | string | 币种 of 交易 |
amount | string | Transaction amount (positive or negative) |
balance_before | string | Balance before 交易 |
balance_after | string | Balance after 交易 |
business_id | string | Related 订单, re资金, transfer, or 出款 ID |
description | string | Human-readable description |
created_at | timestamp | Transaction timestamp (UTC milliseconds) |
metadata | object | Additional context (e.g., fee breakdown) |
Transaction 类型 Enumeration
| 类型 | Direction | 说明 |
|---|---|---|
PAYMENT | Inbound | Customer payment received |
PAYOUT | Outbound | Settlement to 商户’s bank account |
REFUND | Outbound | Re资金 issued to customer |
TRANSFER_IN | Inbound | Funds transferred from institution master account |
TRANSFER_OUT | Outbound | Funds transferred to 子账户 or peer account |
CHARGE | Outbound | Platform commission or fee deduction |
SWAP | Neutral | 币种 conversion (may show as two entries) |
ADJUSTMENT | Variable | Manual adjustment (credit or debit) |
DEPOSIT | Inbound | Direct deposit by 商户 |
Example 请求
Example 响应
Integration 步骤
- Pull 资金 账本 records by time range with pagination using
GET /v1/pay/bill/orderlist - Persist 账本 records in your database using
ledger_idas the primary deduplication key - Associate 账本 records with business 订单s using
business_idand metadata - Generate 对账 summaries aggregated by:
- 币种
- Transaction type
- Date or time bucket
- Related business entity (订单, re资金, transfer, etc.)
- Compare with local records to identify discrepancies
- Flag unmatched records for investigation
Recommended End-of-Day 对账 Flow
Follow this step-by-step process for comprehensive daily 对账:步骤 1: Capture Account Balance Snapshot
- Available balance
- Hold amount
- Total balance
- Snapshot timestamp
步骤 2: Pull Funds Ledger Records
ledger_id.
步骤 3: Pull Order Fees and Settlement Amounts
For each 订单 settled during the day:步骤 4: Match and Reconcile Records
Create a 对账 table with the following structure:| Ledger ID | 类型 | 币种 | Amount | Business ID | Matched | Notes |
|---|---|---|---|---|---|---|
| LED_001 | PAYMENT | USDT | +500 | ORD_123 | ✓ | Matched with 订单 |
| LED_002 | REFUND | USDT | -100 | REF_456 | ✓ | Matched with re资金 |
| LED_003 | TRANSFER_OUT | USDT | -1000 | TRN_789 | ✓ | Institution transfer |
- Match PAYMENT 账本 entries to your 订单 system using
business_id - Match REFUND entries to your re资金 system
- Match TRANSFER_OUT/IN entries to your transfer records
- Match PAYOUT entries to your settlement records
步骤 5: Generate Discrepancy Report
Identify records that do not match:| Category | Count | Details |
|---|---|---|
| Missing 账本 entries | 0 | Orders with no corresponding 账本 entry |
| Extra 账本 entries | 1 | Ledger entries with no corresponding 订单 |
| Amount mismatches | 0 | Matched records with different amounts |
| Timing discrepancies | 2 | Entries recorded on different dates |
步骤 6: Perform Manual Review
For each discrepancy:- Review the 账本 entry description and metadata
- Correlate with business records (订单s, re资金, transfers)
- Investigate timing (same-day vs. next-day settlement)
- Document resolution (matched, explained, or escalated)
步骤 7: Output 对账 Result
Generate a formal 对账 statement:Error 处理方式 and Troubleshooting
Common Issues
| Issue | Cause | Resolution |
|---|---|---|
| Balance differs from local records | Timing of settlement or fee posting | Query again after 5-10 minutes; check for pending 交易s |
| Missing 账本 entries | Delayed posting or query time range misalignment | Expand time range by 1-2 hours; 重试 query |
| Duplicate 账本 entries | Database deduplication failure | Use ledger_id as primary key to prevent duplicates |
| Fee discrepancies | Promotion, rebate, or rate change | Compare with current rate table; check for adjustments |
最佳实践
Data Persistence
- Primary Key: Use
ledger_idfor 账本 entries to ensure 幂等性 - Unique Constraints: Enforce unique constraints on (账本_id) to prevent duplicates
- Indexing: Index by (
created_at,currency,type) for fast 对账 queries
Query Optimization
- Time ranges: Query in 24-hour buckets for faster response times
- Pagination: Use
limit=100and iterate through pages to avoid timeout - Filters: Use
currencyandtypefilters to reduce result sets
Alerting and Monitoring
- Threshold alerts: Alert when available balance falls below operational minimum
- Discrepancy alerts: Alert immediately when 对账 identifies unmatched records
- Timing alerts: Alert if 账本 entries are delayed by more than 2 hours
- 回调 failure alerts: Alert if expected 回调s are not received within SLA
Documentation and Audit
- 对账 logs: Store 对账 results with timestamp and user ID
- Discrepancy tracking: Maintain audit trail of identified and resolved discrepancies
- Rate cards: Document fee structure and any promotional adjustments
- Settlement terms: Document when and how 资金 are settled to 商户 accounts

