1. Payment Gateway
TrustPay
en
  • en
  • zh
  • Integration Guide
  • Signature Calculation
  • Payment Gateway
    • Risk Control – Merchant Integration
    • Enums
    • Payment Callback Specification
    • C21 Suport Regions
      • TrustPay Supported Billing Countries and US/Canada Regions
    • Whitelist Management
      • Add Card Whitelists
      • Query Card Whitelists
      • Query Card Whitelists Task
    • Card Direct Payin
      POST
    • Cashier Payin
      POST
    • Order Refund
      POST
    • Payment Callback
      POST
    • Balance
      POST
    • Order Query
      POST
    • Fee Query
      POST
    • Refund Query
      POST
  • Dispute Management
    • Dispute Enums
    • Dispute Alert
    • Dispute Alert Callback
    • Dispute Prevention (RDR)
    • Dispute Management(Chargeback)
    • Chargeback Callback
  • Credit Card Issuer
    • Available Card
      POST
    • Open Card
      POST
    • Open/Recharge Card Callback
      POST
    • Get Card Detail
      POST
    • Card Recharge
      POST
    • Order List
      POST
    • Card List
      POST
    • Transaction List
      POST
    • Fee Query
      POST
  • Physical Card Issuer
    • Create Cardholder
    • List Cardholders
    • Assign Physical Cards
    • List Assigned Physical Cards
    • Query Card Balance
    • Query Card Transactions
    • Query Account
    • Card Charge
  • Schemas
    • VCardDetail
    • VOrderDetail
  1. Payment Gateway

Payment Callback Specification

Payment Callback Guide#

1.
TrustPay sends a signed JSON callback to the notify_url set when the merchant submitted the order.
2.
For formal dispute and dispute-alert callbacks, see Formal Dispute Callback and Dispute Alert Callback.
3.
For virtual-card issuance and top-up callbacks, see the Credit Card Issuance chapter.
4.
For the common signing rules and sample code, see Signature Calculation.
5.
This document covers payment and refund lifecycle callbacks only.

Request#

Method: POST
Content-Type: application/json
URL: the notify_url submitted with the order

Success Response#

The merchant should return HTTP 200. Any non-200 response (including 400/500) or a timeout is treated as failure and retried.
ItemRule
SuccessHTTP 200 only
Max attempts3 (initial send + up to 2 retries)
IntervalExponential backoff, about 60s → 120s (capped at 1h)

Payment Notification Types#

typeMeaningPrimary field
0Payinnumeric status
1Payoutnumeric status
2Refundnumeric refund_status

Common Fields#

FieldTypeRequiredDescription
typeintegerYes0 = payin, 1 = payout, 2 = refund
merchant_idintegerYesTrustPay merchant ID
order_nostringYesMerchant order number
order_amountnumberYesOrder amount
statusintegerPayment callbacks onlyOrder status; see Enums
reasonstringYesResult or failure reason; may be empty
signstringYesMD5 lowercase hex signature

Amount Fields#

FieldTypeRequiredDescription
order_amountnumberYesOrder amount
paid_amountnumberNoActual paid amount
balance_amountnumberNoSettlement / balance-change amount (see each type)
refund_amountnumberNoRefund amount (see Refund Fields)
feenumberNoFee

Refund Fields#

FieldTypeRequiredDescription
merchant_refund_nostringNoMerchant refund number for this refund only
refund_statusint64No1 processing / 2 success / 3 failed / 4 rollback / 5 accounting conflict. Use this field to determine the refund result.
Amounts are JSON numbers; serialization may omit trailing zeros. When verifying the signature, use the values parsed from the callback body. Do not round or reformat amounts first.

Callback Type Examples#

1. Payin (type = 0)#

Field rules#

Scenariostatuspaid_amountbalance_amountfeepay_time
Failed / timed out3 / 4omittedomittedomittedomitted
Success (not refunded)e.g. 5 / 6presentpaid_amount - feepresentpresent (if unsettled and pay_time is missing, current UTC may be used)

Example (payin, unsettled)#

{
  "type": 0,
  "merchant_id": 8820250900009,
  "order_no": "MCH-PAYIN-20260513-001",
  "order_amount": 500.00,
  "paid_amount": 500.00,
  "balance_amount": 492.50,
  "fee": 7.50,
  "status": 5,
  "reason": "payment received",
  "pay_time": "2026-05-13T08:30:00Z",
  "sign": "..."
}

2. Payout (type = 1)#

Field rules#

Scenariopaid_amountbalance_amount
Failed / timed outomittedomitted
Otherorder.paid_amountpaid_amount + fee (payout convention)

Example#

{
  "type": 1,
  "merchant_id": 8820250900009,
  "order_no": "MCH-PAYOUT-20260513-001",
  "order_amount": 1000.00,
  "paid_amount": 1000.00,
  "balance_amount": 1003.00,
  "fee": 3.00,
  "status": 2,
  "reason": "payout success",
  "pay_time": "2026-05-13T09:00:00Z",
  "sign": "..."
}

3. Refund (type = 2)#

Field rules#

FieldRule
typeAlways 2
order_noOriginal payment merchant order number (no extra payment_order_no)
merchant_refund_noMerchant refund number for this refund (present on the normal path; may be omitted if no matching refund record is found)
refund_statusDetermines the refund result; see the table below
refund_amountProcessing / failed: amount of this refund; success (automatic path): usually the cumulative refunded amount on the original payment
statusOrder-side display: processing 9; full success 7; partial success 8; failed = restored original payment status (e.g. 5 / 6 / 17), not always 3
paid_amount / balance_amount / fee / pay_timeAll omitted

Enum values#

refund_statusMeaning
1processing
2success
3failed
4rollback
5accounting_conflict

Examples#

Processing
{
  "type": 2,
  "merchant_id": 8820250900009,
  "order_no": "TPC_PAY_202508130001",
  "order_amount": 20.00,
  "refund_amount": 20.00,
  "merchant_refund_no": "TPC_REFUND_202508130001",
  "refund_status": 1,
  "status": 9,
  "reason": "refund processing",
  "sign": "..."
}
Full success
{
  "type": 2,
  "merchant_id": 8820250900009,
  "order_no": "TPC_PAY_202508130001",
  "order_amount": 20.00,
  "refund_amount": 20.00,
  "merchant_refund_no": "TPC_REFUND_202508130001",
  "refund_status": 2,
  "status": 7,
  "reason": "refund completed",
  "sign": "..."
}
Partial success
{
  "type": 2,
  "merchant_id": 8820250900009,
  "order_no": "TPC_PAY_202508130001",
  "order_amount": 100.00,
  "refund_amount": 30.00,
  "merchant_refund_no": "TPC_REFUND_202508130002",
  "refund_status": 2,
  "status": 8,
  "reason": "refund completed",
  "sign": "..."
}
Failed
{
  "type": 2,
  "merchant_id": 8820250900009,
  "order_no": "TPC_PAY_202508130001",
  "order_amount": 20.00,
  "refund_amount": 20.00,
  "merchant_refund_no": "TPC_REFUND_202508130001",
  "refund_status": 3,
  "status": 5,
  "reason": "channel rejected refund",
  "sign": "..."
}

Recommended Decision Logic (Conservative)#

if type == 2:
  refund_status=1 → keep processing
  refund_status=2 and merchant_refund_no plus amount match this refund → success
  refund_status=3 → failed
  status ∈ {5, 6, 17} only, without refund_status=3 → do not auto-fail
If the create API returns 7/8 → do not treat as success by itself; wait for webhook / query cross-check

Signature Verification#

Verify sign before processing any callback. Every non-empty field in the actual payload is included in the signature.
For the string to sign, examples, and JavaScript / Go reference implementations, see Signature Calculation.

Security Checklist#

Accept callbacks over HTTPS only.
Verify the signature before updating business state.
Confirm merchant_id belongs to the current recipient.
Run an idempotency check before applying a payment or refund change.
Do not log the merchant secret or the full unsigned string.
Keep the raw callback body for audit; mask any card data.
Modified at 2026-08-29 06:35:09
Previous
Enums
Next
TrustPay Supported Billing Countries and US/Canada Regions
Built with