imsafu API

身份认证

如果API需要进行身份验证,应使用Bearer令牌。

Authorization: Bearer {SECRET}

当身份验证失败时的响应示例:

{
  "error": "access denied"
}

错误对象

标准化的错误对象如下:

{
  "error": "错误消息"
}

API 地址

  • 生产环境:https://allowpay-api-mainnet.fly.dev/v1
  • 开发环境:https://allowpay-api-devnet.fly.dev/v1

API 列表

创建存款支付

AUTH: required

POST: /depositPay

请求:

{
    "payment": {
        // 商家的唯一orderID
        // 错误:如果存在具有此orderID的现有支付。
        "orderID": "0x1234",
        // 接收此支付的地址
        "receiver": "0x1F2C9c99361528F1E612F4378d52700d1aFDdC12",
        // 用于接收此付款的 Solana 地址(代币账户所有者)
        "solanaReceiver": "DEVWatx97Eg6W7oZi77Yt1oXzZsEypfFBDxpN1ySh7u8",
        // 支付金额,以截断的小数字符串形式表示(保留2位小数)。
        "amount": "123.12",
        // 支付的货币,可选,默认为USD
        // 如果提供了RMB,则将以汇率转换为USD的金额(以RMB为单位)。
        "currency": "RMB",
        // 此支付的截止日期,使用ISO-8601日期格式,默认为当前时间6小时后
        // 可选
        "deadline": "2023-04-03T03:05:43.167Z"
    },
    // 支付成功或失败的 Webhook
    "notifyURL": "https://merchant.com/notify",
    // notifyData 将包含在 Webhook 请求体和 GET 请求体中
    // 可选
    "notifyData": "merchant-order-id: 123-4213"
}

响应:

{
  "status": "success",
  "payment": {
    "payID": "pay_01GZ8FYDR1E7VNM1J85EP4T0EG",
    "orderID": "0x1234",
    "receiver": "0x1F2C9c99361528F1E612F4378d52700d1aFDdC12",
    "amount": "123.12",
    "maxFeeAmount": "1.0",
    "deadline": "2023-04-03T03:05:43.167Z"
  },
  "solana": {
    "receiver": "DEVWatx97Eg6W7oZi77Yt1oXzZsEypfFBDxpN1ySh7u8",
  },
}

错误:

{
  // 错误消息
  "error": "invalid payment request"
}

根据支付ID查询支付信息

GET: /depositPays/:payID

响应:

{
  "status": "success",
  "payment": {
    "payID": "pay_01GZ8FYDR1E7VNM1J85EP4T0EG",
    "orderID": "0x1234",
    "receiver": "0x1F2C9c99361528F1E612F4378d52700d1aFDdC12",
    "amount": "123.12",
    "originalAmount": "123.12",
    "maxFeeAmount": "1.0",
    "deadline": "2023-04-03T03:05:43.167Z"
  },
  "owner": "0x1F2C9c99361528F1E612F4378d52700d1aFDdC12",
  "depositAddress": "0x1F2C9c99361528F1E612F4378d52700d1aFDdC12",
  "callID": 1,
  "receiveTx": {
    "chain": {
      "id": 1,
      "symbol": "ETH",
      "name": "Ethereum"
    },
    "txID": "0xabc123",
    "confirmedAt": "2023-04-03T03:05:43.167Z",
    "amount": "123.12",
    "feeAmount": "0.1",
    "token": {
      "symbol": "ETH",
      "address": "0x123abc"
    }
  },
  "deposits": [
    {
      "chainID": 1,
      "token": "0x123"
    },
    {
      "chainID": 2,
      "token": "0x456"
    }
  ],
  "notifyData": "merchant-order-id: 123-4213",
  // 如果通过 Solana 进行支付,可使用 `solana.receiveTx`
  "solana": {
    "receiver": "DEVWatx97Eg6W7oZi77Yt1oXzZsEypfFBDxpN1ySh7u8",
    "depositAddress": "7jVXXfMR4xW1dVho5ev5QPCiGXKTFqunWzdsnMVwaxxQ",
    "receiveTx": {
      "chain": {
          "name": "solana",
      },
      "txID": "3YuRCgZG96xduZaph6b8qNBLydftehU1QENrvnS7noVG3CYnsRiEKPjpJ1vx7FgZ19ARhHFRWbZ8bacQt5KhRMKV",
      "confirmedAt": "2023-05-22T08:34:30.001181Z",
      "amount": "2",
      "feeAmount": "0",
      "token": {
        "symbol": "USDT",
        "address": "USDTb1h66DadwB77q1Q94p23KYK96fHynTCrdive32d"
      }
    },
    "deposits": [{
      "token": "USDTb1h66DadwB77q1Q94p23KYK96fHynTCrdive32d",
      "tokenAccount": "7jVXXfMR4xW1dVho5ev5QPCiGXKTFqunWzdsnMVwaxxQ"
    }]
  }
}

通知钩子

POST: ${notifyURL}

请求体:

{
  "payment": {
    "payID": "pay_01GZ8FYDR1E7VNM1J85EP4T0EG"
  },
  "notifyData": "merchant-order-id: 123-4213"
}

客户端应返回状态码200,并可以返回任何响应类型或内容。

附录

商家限制:

  • 每个密钥最多可以有 10,000 个待处理 payment。
Last Updated:
Contributors: xavierdiff