> ## Documentation Index
> Fetch the complete documentation index at: https://xaferapi.apacx.io/llms.txt
> Use this file to discover all available pages before exploring further.

# 存币通知回调

`NOTIFY_DEPOSITED` (type=1)

当用户向其在WaaS中的存币地址存入数字货币时，WaaS会通过此回调通知您存币操作的详细信息，商户需要在响应中告诉 WaaS 是否接受了此回调。

### 请求参数

WaaS发送的请求是经过**RSA加密的Base64字符串**，商户需要使用公钥解密后才能获取以下业务参数：

<ResponseField name="存币回调请求参数" type="object">
  <Expandable title="查看完整参数列表">
    <ResponseField name="txId" type="String" required="是" example="b00a4aa3d6426f6409a83ae72a79de5b559a2c339ebc89b8b75427c2600978e3">
      区块链交易Hash
    </ResponseField>

    <ResponseField name="chainName" type="String" required="是" example="TRON">
      链名称，比如TRON、ETH、BSC......
    </ResponseField>

    <ResponseField name="symbol" type="String" required="是" example="TRX">
      代币符号，比如USDT、USDC、PHT....
    </ResponseField>

    <ResponseField name="amount" type="String" required="是" example="2.500000000000">
      存币金额
    </ResponseField>

    <ResponseField name="fromAddress" type="String" required="是" example="TGDHyoMpgDQj4DmoZdwJP2FSkSG4DEchnK">
      存币来源地址(用户的外部地址)
    </ResponseField>

    <ResponseField name="toAddress" type="String" required="是" example="TYLdkix4wqk1wLXbqbxrrY1oi1mHEM6uwP">
      存币目标地址(用户在WaaS中的存币地址)
    </ResponseField>

    <ResponseField name="riskLevelFrom" type="Integer" required="是" example="3">
      来源地址风险评分(0-100)
    </ResponseField>

    <ResponseField name="riskLevelTo" type="Integer" required="是" example="3">
      目标地址风险评分(0-100)
    </ResponseField>

    <ResponseField name="txIndex" type="Integer" required="是" example="">
      交易索引
    </ResponseField>

    <ResponseField name="newAddress" type="string" required="是" example="TYLdkix4wqk1wLXbqbxrrY1oi1mHEM6uwP">
      新地址，type为4时代替toAddress
    </ResponseField>
  </Expandable>
</ResponseField>

### 响应参数

商户处理完回调后，需返回 JSON 格式的响应体。其中 `data` 字段需返回 **RSA加密的Base64字符串**（使用 WaaS 提供的公钥加密），其余字段为明文：

<ResponseField name="存币回调响应参数" type="object">
  <Expandable title="查看完整参数列表">
    <ResponseField name="apiKey" type="String" required="是" example="88c47568-8d24-4983-9b4c-y1ec8b939e9b">
      商户的唯一 API 标识符
    </ResponseField>

    <ResponseField name="data" type="String" required="是" example="i2H9eQf22gLnJoTeo1WbWVR6wmNv/Ryom5UjTPm4yM2aeuQUkpsErZAY...">
      加密的业务数据,比如：i2H9eQf22gLnJoTeo1WbWVR6wmNv(具体可参考右侧示例)

      由以下原始业务参数加密生成：

      **type** (Integer) : 回调类型

      **trackingId** (String) : 业务事件标识符

      **txId** (String) : 区块链交易Hash

      **txIndex** (Integer) : 交易在区块中的序号

      **chainName** (String) : 区块链名称

      **symbol** (String) : 代币符号

      **amount** (Integer) : 存款金额

      **fromAddress** (String) : 存款来源地址

      **toAddress** (String) : 存款目标地址

      **requestUUID** (String) : 请求的唯一标识符号，商户在响应中需要同样返回相同的requestUUID以帮助 WaaS 确认

      **tenantUserId** (String) : 发起存款的用户ID(在商户系统中，并非WaaS系统中)
    </ResponseField>

    <ResponseField name="errCode" type="Integer" required="是" example="0">
      全局处理状态码：
      `0`=成功，非`0`=失败
    </ResponseField>

    <ResponseField name="message" type="String" required="是" example="">
      错误详情（失败时必填）：

      * 成功时可返回空字符串
      * 失败时需描述具体错误
    </ResponseField>
  </Expandable>
</ResponseField>

***

<RequestExample>
  ```mdx 加密前原始业务请求参数
  {
    "requestUUID": "fbd70fb4-c302-4228-bd61-6326e0539551",
    "chainName": "TRON",
    "symbol": "TRX",
    "amount": "2.500000000000",
    "business": 0,
    "toAddress": "TYLdkix4wqk1wLXbqbxrrY1oi1mHEM6uwP",
    "fromAddress": "TGDHyoMpgDQj4DmoZdwJP2FSkSG4DEchnK",
    "riskLevelTo": 3,
    "riskLevelFrom": 3,
    "txId": "b00a4aa3d6426f6409a83ae72a79de5b559a2c339ebc89b8b75427c2600978e3",
    "tenantUserId": "2049",
    "type": 1,
    "txIndex": -1,
    "newAddress": "TYLdkix4wqk1wLXbqbxrrY1oi1mHEM6uwP",
    "trackingId": "6484"
  }
  ```
</RequestExample>

<ResponseExample>
  ```mdx 解密后的响应参数结构
  {
    "apiKey": "88c47568-8d24-4983-9b4c-y1ec8b939e9b",
    "data": "{\"type\":1,\"callBackId\":null,\"trackingId\":\"6484\",\"state\":null,\"txId\":\"b00a4aa3d6426f6409a83ae72a79de5b559a2c339ebc89b8b75427c2600978e3\",\"txIndex\":-1,\"chainName\":\"TRON\",\"symbol\":\"TRX\",\"amount\":\"2.500000000000\",\"fromAddress\":\"TGDHyoMpgDQj4DmoZdwJP2FSkSG4DEchnK\",\"toAddress\":\"TYLdkix4wqk1wLXbqbxrrY1oi1mHEM6uwP\",\"tenantType\":null,\"requestUUID\":\"fbd70fb4-c302-4228-bd61-6326e0539551\",\"tenantUserId\":\"2049\"}",
    "errCode": 0,
    "message": ""
  }
  ```
</ResponseExample>
