1. Payment Gateway
TrustPay
en
  • en
  • zh
  • Integration Guide
  • Payment Gateway
    • Payment Callback Specification
    • Enums
    • Risk Control – Merchant Integration
    • C21 Suport Regions
      • TrustPay Supported Billing Countries and US/Canada Regions
    • Card Direct Payin
      POST
    • Cashier Payin
      POST
    • Payment Callback
      POST
    • Balance
      POST
    • Order Query
      POST
    • Order Refund
      POST
    • Fee Query
      POST
  • 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
      POST
    • List Cardholders
      POST
    • Assign Physical Cards
      POST
    • List Assigned Physical Cards
      POST
    • Query Card Balance
      POST
    • Query Card Transactions
      POST
    • Query Account
      POST
    • Card Charge
      POST
  • Schemas
    • VCardDetail
    • VOrderDetail
  1. Payment Gateway

Payment Callback Specification

Callback Request#

Request Method#

Method: POST
Content-Type: application/json
URL: notify_url configured by the merchant when creating the order

Request Headers#

Content-Type: application/json

Request Body Format#

The callback request body is in JSON format and contains order information and a signature field.

Callback Data Structure#

Field Description#

Common Fields#

Field NameTypeRequiredDescription
typeint64YesOrder type: 0 = Payin (Collection), 1 = Payout (Disbursement)
merchant_idint64YesMerchant ID
order_nostringYesMerchant order number
statusint64YesOrder status (see status definitions)
reasonstringYesReason description (English)
pay_timestringNoPayment time
signstringYesSignature (MD5, lowercase hexadecimal)

Amount Fields#

All amount fields are numeric (decimal.Decimal). When serialized to JSON, values are numbers with two decimal places.
Field NameTypeRequiredDescription
order_amountdecimal.DecimalYesOrder amount
paid_amountdecimal.DecimalNoActual paid amount
balance_amountdecimal.DecimalNoSettlement amount (net amount credited to merchant)
refund_amountdecimal.DecimalNoRefund amount
feedecimal.DecimalNoTransaction fee

Refund Fields#

Field NameTypeRequiredDescription
merchant_refund_nostring[]NoAll merchant refund numbers associated with this payin order, from refunds.

Status Definitions#

For details, see: Order Status

Amount Field Response Rules#

Depending on order status and payment type, different amount fields are returned.

1. Failed / Timeout Status (status = 3 or 4)#

✅ order_amount
❌ No other amount fields

2. Payin Refunding Status (type = 0, status = 9)#

✅ order_amount
✅ merchant_refund_no
❌ paid_amount, balance_amount, fee, and pay_time are not included

3. Payin Refund Status (type = 0, status = 7 or 8)#

✅ order_amount
✅ refund_amount
✅ merchant_refund_no
❌ paid_amount, balance_amount, fee, and pay_time are not included

4. Payin Success Status (type = 0, status = 5)#

✅ order_amount
✅ paid_amount
✅ balance_amount = paid_amount - fee
✅ fee
✅ pay_time

5. Payout Success Status (type = 1, status = 2)#

✅ order_amount
✅ paid_amount
✅ balance_amount = paid_amount + fee
✅ fee
✅ pay_time

Signature Rules#

1.
Exclude sign field: The sign field itself is not included in signature calculation
2.
Filter empty values: Exclude fields with empty values (null, empty string)
3.
Sort by key name: Sort all fields in lexicographical order by key
4.
Build query string: Format key1=value1&key2=value2
5.
Append secret key: Append &secret=YOUR_SECRET_KEY
6.
Calculate MD5: Compute MD5 hash and output lowercase hexadecimal
Array fields such as merchant_refund_no are included in the signature as their JSON string representation, for example ["refund_1","refund_2"].

Signature Calculation Example#

Callback payload:
{
  "type": 0,
  "merchant_id": 1001,
  "order_no": "ORDER_123456",
  "order_amount": 100.50,
  "paid_amount": 100.50,
  "balance_amount": 98.50,
  "fee": 2.00,
  "status": 5,
  "reason": "Payment successful"
}
Secret Key: test_secret_key_12345_abcdefghijklmnop
Step 1: Exclude sign field
Step 2: Filter empty values
Step 3: Sort by key
balance_amount=98.5
fee=2
merchant_id=1001
order_amount=100.5
order_no=ORDER_123456
paid_amount=100.5
reason=Payment successful
status=5
type=0
Step 4: Build query string
balance_amount=98.5&fee=2&merchant_id=1001&order_amount=100.5&order_no=ORDER_123456&paid_amount=100.5&reason=Payment successful&status=5&type=0
Step 5: Append secret key
balance_amount=98.5&fee=2&merchant_id=1001&order_amount=100.5&order_no=ORDER_123456&paid_amount=100.5&reason=Payment successful&status=5&type=0&secret=test_secret_key_12345_abcdefghijklmnop
Step 6: Calculate MD5
29fa2ad03349c534baafd36094e23c7f

Signature Example Code#

Go#

FAQ#

If signature verification fails, please ensure that numeric amount fields are serialized consistently and trailing zeros are not omitted incorrectly.
Modified at 2026-05-26 16:14:45
Previous
Integration Guide
Next
Enums
Built with