创建独享钱包

为指定 bindKey 创建一条专属收款地址,后续该地址上的入账会长期归属于这个 bindKey。

如果传入 notifyUrl,这条专属地址后续自动生成的充值订单会优先回调到这个地址,适合每个站点或应用分别接收会员充值通知。

POST/openapi/payin/exclusive-bindings

请求头

字段名称字段类型是否必填说明
x-api-keystring是商户 API Key,使用商户后台 API 接入页面中的 mch_ 开头字符串。
x-merchant-uidstring是商户 UID。
x-timestampstring是13 位毫秒时间戳,默认允许和服务器时间相差 5 分钟。
x-noncestring是每次请求唯一的随机字符串,最长 128 位,重复使用会被拒绝。
x-signaturestring是使用 HMAC-SHA256 生成的十六进制签名,签名原文由 Merchant UID、时间戳、nonce、请求方法、路径、规范化 query 和规范化 body 组成。

接口参数

字段名称字段类型是否必填说明
chainCodestring是链编码,支持 TRON / BSC / SOL。
tokenSymbolstring是代币符号。
bindKeystring是商户侧唯一绑定键。 最长 128 个字符。
labelstring否绑定备注。 最长 100 个字符。
notifyUrlstring否该专属地址的独立回调地址。后续地址入账自动生成订单时,优先回调到这里。 最长 500 个字符;禁止私网、回环和不安全目标。

请求示例

{
  "chainCode": "TRON",
  "tokenSymbol": "USDT",
  "bindKey": "USER_90001",
  "label": "VIP User 90001",
  "notifyUrl": "https://merchant.example.com/api/uugate/member-topup-notify"
}

接口返回

字段名称字段类型是否必填说明
bindingIdnumber是绑定记录 ID。
chainCodestring是链编码。
tokenSymbolstring是代币符号。
bindKeystring是绑定键。
addressIdnumber是地址 ID。
addressstring是专属收款地址。
addressTypestring是固定为 exclusive。
notifyUrlstring | null是当前绑定使用的专属回调地址。
statusstring是绑定状态。

返回示例

{
  "bindingId": 70031,
  "chainCode": "TRON",
  "tokenSymbol": "USDT",
  "bindKey": "USER_90001",
  "addressId": 31088,
  "address": "TQ3sCY8k9h7G9UsApY3JPt5VDpNKr2kJ1E",
  "addressType": "exclusive",
  "notifyUrl": "https://merchant.example.com/api/uugate/member-topup-notify",
  "status": "active"
}

代码示例

运行:Java 保存为 UUGateExample.java(回调为 UUGateCallback.java),使用 java 文件名;PHP 保存为 example.php,使用 php example.php;Go 保存为 example.go,使用 go run example.go;Node.js 保存为 example.mjs,使用 node example.mjs。回调原文从标准输入读取。

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

function required(name) {
  const value = process.env[name]?.trim();
  if (!value) throw new Error(name + ' is required');
  return value;
}
const uid = required("UUGATE_MERCHANT_UID"), key = required("UUGATE_API_KEY");
const timestamp = String(Date.now()), nonce = randomBytes(16).toString("hex");
const method = 'POST', path = '/openapi/payin/exclusive-bindings';
const canonicalQuery = '', canonicalBody = "{\"bindKey\":\"USER_90001\",\"chainCode\":\"TRON\",\"label\":\"VIP User 90001\",\"notifyUrl\":\"https://merchant.example.com/api/uugate/member-topup-notify\",\"tokenSymbol\":\"USDT\"}";
const payload = [uid, timestamp, nonce, method, path, canonicalQuery, canonicalBody].join('\n');
const signature = createHmac('sha256', key).update(payload, 'utf8').digest('hex');
const base = (process.env.UUGATE_BASE_URL || 'https://api.uugate.com').replace(/\/+$/, '');
const response = await fetch(base + path, {
  method, redirect: 'error', signal: AbortSignal.timeout(30000),
  headers: { 'Content-Type': 'application/json', 'x-api-key': key, 'x-merchant-uid': uid,
    'x-timestamp': timestamp, 'x-nonce': nonce, 'x-signature': signature },
  ...(canonicalBody ? { body: canonicalBody } : {}),
});
const raw = await response.text();
if (!response.ok) throw new Error('HTTP ' + response.status + ': ' + (raw || 'empty response body'));
JSON.parse(raw);
console.log(raw);

说明

  • 如同一 bindKey 重复创建,平台会幂等返回原有绑定和地址,适合直接按“get or create”方式接入。
  • 会员充值场景建议在绑定时就传入 notifyUrl,这样后续专属地址任意金额入账都会直接回调到对应站点或应用。
  • 四种语言使用相同的接口路径、参数和返回合同。示例从环境变量 UUGATE_MERCHANT_UID、UUGATE_API_KEY 读取凭据;UUGATE_BASE_URL 默认 https://api.uugate.com。
  • 示例中的 canonicalBody 已按字段名排序并压缩为 JSON;修改参数后须递归排序对象字段,数组顺序保持,使用 UTF-8 且不额外转义斜杠或 Unicode。金额使用字符串,boolean 使用 true / false。
  • 成功响应直接返回业务对象,没有统一的 code / data 外层。先判断 HTTP 状态,再处理正文;普通业务错误返回 code、message、data、requestId,安全拒绝可能只有 HTTP 401 / 403 和空正文。
  • 网络超时或 HTTP 5xx 后先查询订单,不自动重复创建或提交付款;每次新请求重新生成 timestamp、nonce 和签名。