Pay-in Callback

The merchant server is called only after a pay-in completes successfully; the callback status is always completed.

Only final payment results are sent. Any HTTP 2xx response stops delivery immediately. After the first failure, the platform retries in 1 minute; after another failure, it makes a final retry in 5 minutes, for up to 3 attempts total. Callback business times use Beijing time in YYYY/MM/DD HH:mm:ss format.

POSTnotifyUrl from the create pay-in order request body

Request Headers

FieldTypeRequiredDescription
content-typeapplication/jsonYesAlways application/json.
x-callback-timestampstringYesCallback timestamp in milliseconds.
x-callback-noncestringYesCallback nonce.
x-callback-signaturestringYesHMAC-SHA256(apiKey, timestamp + "." + nonce + "." + rawBody)。
x-callback-signature-algorithmstringYesAlways HMAC-SHA256.
x-callback-signature-versionstringYesAlways v1.

Request Parameters

FieldTypeRequiredDescription
merchantUidstringYesMerchant UID.
orderNostringYesPlatform order number.
merchantOrderNostring | nullYesMerchant order number.
bindKeystring | nullYesBinding key for member recharge. Usually empty for shared pay-in orders.
chainCodestring | nullYesThe network for this order.
tokenSymbolstring | nullYesThe token for this order.
txHashstring | nullYesMatched transaction hash; null before detection.
expectedAmountstring | nullYesOrder amount.
paidAmountstringYesActual paid amount.
fromAddressstring | nullYesSender address.
statusstringYesFinal successful pay-in status; always completed.
modestringYesOrder mode: shared or exclusive.
businessTypestringYesOrder business type.
serviceFeeUsdstringNoService fee for this pay-in.
feeBalanceAfterUsdstringNoFee account balance after charging.
payerRiskStatusstringYesPayer risk assessment status.
payerRiskLabelstring | nullYesPayer risk assessment label.

Request Example

{
  "merchantUid": "880001",
  "orderNo": "PI1776193200123ABCD1234",
  "merchantOrderNo": "M202604150001",
  "bindKey": null,
  "expectedAmount": "100.000000",
  "paidAmount": "100.000000",
  "chainCode": "TRON",
  "tokenSymbol": "USDT",
  "txHash": "f7f17891f52c35d0c93170f0d12bb347ac16ab34853b4bc8dcf7fd0a8c9aa321",
  "fromAddress": "TS7b7iD8G2PaPqK1TqSmLJ9nrrYH4oKX1S",
  "status": "completed",
  "mode": "shared",
  "businessType": "fixed",
  "serviceFeeUsd": "0.000000",
  "feeBalanceAfterUsd": "10.000000",
  "payerRiskStatus": "low_risk",
  "payerRiskLabel": "低风险"
}

Response Fields

FieldTypeRequiredDescription
HTTP Status200-299YesAny 2xx response is treated as success.
Response Bodystring | jsonNoThe response body can be customized.

Response Example

HTTP/1.1 200 OK
Content-Type: application/json

{
  "ok": true
}

Code Examples

Run: save Java as UUGateExample.java (UUGateCallback.java for callbacks) and use java filename; PHP: php example.php; Go: go run example.go; Node.js: node example.mjs. Callback verifiers read the raw body from standard input.

import { createHmac, timingSafeEqual } from 'node:crypto';

function required(name) {
  const value = process.env[name]?.trim();
  if (!value) throw new Error(name + ' is required');
  return value;
}
const key = required('UUGATE_API_KEY');
const timestamp = required('UUGATE_CALLBACK_TIMESTAMP'), nonce = required('UUGATE_CALLBACK_NONCE');
const signature = required('UUGATE_CALLBACK_SIGNATURE');
const chunks = [];
for await (const chunk of process.stdin) chunks.push(chunk);
const rawBody = Buffer.concat(chunks);
const expected = createHmac('sha256', key).update(timestamp + '.' + nonce + '.', 'utf8').update(rawBody).digest();
const actual = Buffer.from(signature, 'hex');
if (!/^[a-fA-F0-9]{64}$/.test(signature) || actual.length !== expected.length || !timingSafeEqual(expected, actual))
  throw new Error('Invalid callback signature');
console.log('VERIFIED');

Notes

  • Callback verification uses apiKey, not the OpenAPI x-signature request header.
  • After verification, match the merchant, order, asset, network and amount. Persist payment and business results transactionally and idempotently by platform order number before returning 2xx; repeated notifications must not duplicate credits or fulfillment.
  • For member recharge, use bindKey directly as the member identifier so you do not need an extra orderNo-to-member mapping table.
  • This code only verifies callbacks. Pass the raw request body to standard input and map callback headers to UUGATE_CALLBACK_TIMESTAMP, UUGATE_CALLBACK_NONCE and UUGATE_CALLBACK_SIGNATURE. UUGATE_API_KEY must be the key used to create the order. Then validate the order and persist it idempotently in a transaction before returning HTTP 2xx.