跳转到内容

6. API Documentation(托管收银台模式)

推荐: 您可以使用 infini-skill 更快接入 Infini API。该 Skill 提供开箱即用的接入能力,可帮助您先完成托管收银台流程接入,再按需参考下方原始 API 文档。

托管收银台模式是 Infini 最推荐的接入方式。商户只需创建订单、跳转 checkout_url 并处理 Webhook,即可完成支付集成。本章节仅包含托管收银台模式的 API 文档与对应字段说明。

企业卡接口请查看 卡 API 文档。卡接口现在使用独立的 /v2/cards 前缀。

组织资金接口请查看 资金 API 文档。资金接口使用独立的 /v2/funds 前缀。

所有接口前缀:

/v2/acquiring

6.1 查询支持的支付币种(List Supported Payment Currencies)

GET /v2/acquiring/currency

返回当前收单支付支持的区块链网络与代币组合。请使用本接口生成或校验支付币种选项,避免在客户端维护固定列表。

Headers

X-API-Key-ID: {key_id}
X-API-Timestamp: {unix_seconds}
X-API-Nonce: {nonce}
Digest: SHA-256={body_hash_base64}
Authorization: Ed25519 signature="{signature}"

本接口没有查询参数或请求体。

Response 示例

{
  "list": [
    {
      "chain": "TRON",
      "token_id": "USDT",
      "contract": "TXLAQ63Xg1NAzckPwKHvzw7CSEmLMEqcdj"
    },
    {
      "chain": "ETHEREUM",
      "token_id": "USDC",
      "contract": "0xA0b86991c6218b36c1d19d4a2e9eb0ce3606eb48"
    }
  ]
}
字段类型说明
listarray支持的区块链网络与代币组合
list[].chainstring区块链网络名称
list[].token_idstring代币标识符
list[].contractstring代币合约地址(如适用)

注意: 沙箱环境与生产环境支持的币种可能不同,请始终以目标环境接口返回的数据为准。

6.2 创建订单(Create Order)

POST /v2/acquiring/order

用于创建订单,并返回托管收银台的访问 URL (checkout_url)。

Headers

Content-Type: application/json
X-API-Key-ID: {key_id}
X-API-Timestamp: {unix_seconds}
X-API-Nonce: {nonce}
Digest: SHA-256={body_hash_base64}
Authorization: Ed25519 signature="{signature}"

Request Body

字段类型必填说明
amountstring/number是订单金额(最多 6 位小数)。加密货币收单金额必须大于 0.1;法币支付方式的金额最低为 16
request_idstring是商户自定义生成的幂等 key(UUID)。重复传入相同 request_id 时,直接返回已有订单,不会新建订单
client_referencestring否商户自定义订单号,建议保持唯一
order_descstring否订单描述
expires_innumber否订单过期相对时间(Unix 秒);不传则使用后台默认值
merchant_aliasstring否收银台账单名称(覆盖后台配置)
success_urlstring否订单支付成功跳转回商户地址
failure_urlstring否订单支付失败跳转回商户地址
pay_methodsarray of integers否支付方式:[1] 加密货币,[2] 卡支付,[3] Binance Pay 支付,[5] Apple Pay,[6] Google Pay,[1,2,3,5,6] 全部都支持。默认使用商户配置
emailstring否付款人邮箱(可选)。若传入须为有效邮箱地址;服务端会规范化为小写
currencystring否订单货币 (USD, EUR, KWR, GBP, SGD, JPY, AUD, HKD), 默认为USD

最小金额: 加密货币收单订单金额必须大于 0.1;法币支付方式(卡支付、Apple Pay 和 Google Pay)的金额最低为 16。

Response 示例

{
  "order_id": "10290d05-xxxx",
  "request_id": "your request_id",
  "checkout_url": "https://checkout.infini.money/pay/xxxx",
  "client_reference": "client_reference"
}

幂等性(Idempotency)

本接口在同一商户下对 request_id 提供幂等保障:

  • 若已存在相同 request_id 的订单,接口直接返回该订单信息(order_id、checkout_url 等),而不会新建订单。
  • 适合网络超时或客户端失败后的安全重试:使用相同的 request_id 再次请求,会得到同一笔订单结果。

6.3 查询订单(Query Order)

GET /v2/acquiring/order?order_id ={order_id}

返回订单的实时状态信息。

Order Status 字段说明

status - 订单处理状态

数据库存储字段,记录订单的处理状态。

值说明
pending待支付
processing处理中(已收到部分资金)
paid已支付
partial_paid部分支付已过期
expired已过期未支付

Response 示例

{
  "order_id": "ord-123",
  "status": "processing",
  "amount": "100",
  "currency": "USD",
  "amount_confirming": "0",
  "amount_confirmed": "0.5",
  "expires_at": 1763512195,
  "created_at": 1763512000,
  "exception_tags": ["wrong_currency"],
  "client_reference": "ORDER-001",
  "email": "user@example.com"
}
字段类型说明
emailstring创建订单时提交的付款人邮箱(未传入时不返回)

6.4 查询订单列表

GET /v2/acquiring/order/list?page=1&page_size=10

使用 Ed25519 签名;查询串必须参与签名。

重新签发收银台 Token

POST /v2/acquiring/order/token/reissue

为已有订单重新签发收银台 URL 和 token。使用具备 order.create 权限的 Ed25519 凭据,并对实际发送的 JSON 请求体和完整路径签名。

请求体:

{"order_id":"ord-123"}

响应 data:

{
  "order_id": "ord-123",
  "checkout_url": "https://checkout.infini.money/pay/xxxx",
  "token": "eyJhbGciOiJIUzI1NiIs..."
}

token 在原订单到期后 10 分钟失效。重签不会延长订单可支付时间,超过该 token 截止时间后无法重签。

6.5 支付单接口(高级功能)

注意: 对于大多数商户,您只需要创建订单并跳转到收银台 URL 即可。以下支付单接口为可选功能,需要额外的开发工作。它们允许您以编程方式创建和管理支付单,而不是使用托管收银台。

创建支付单

POST /v2/acquiring/payment

以编程方式为订单创建支付单。

Request Body:

  • order_id (string, 必填): 订单 ID
  • chain (string, 必填): 区块链网络名称
  • token_id (string, 必填): 代币标识符
  • payment_method (integer, 可选): 支付方式(目前仅支持 1,表示加密货币支付)

Response:

{
  "payment_id": "pay-123",
  "amount": "100.00",
  "address": "0x1234567890abcdef1234567890abcdef12345678",
  "expires_at": 1763512195
}

查询支付单

GET /v2/acquiring/payment?payment_id={payment_id}

查询支付单详情,包括交易历史。

查询订单支付单列表

GET /v2/acquiring/payment/list?order_id={order_id}

获取与订单关联的所有支付单记录。

6.6 创建订阅(Create Subscription)

POST /v2/acquiring/subscription

用于创建订阅,并返回托管收银台的访问 URL (checkout_url)。首次支付订单将同时创建。

Headers

Content-Type: application/json
X-API-Key-ID: {key_id}
X-API-Timestamp: {unix_seconds}
X-API-Nonce: {nonce}
Digest: SHA-256={body_hash_base64}
Authorization: Ed25519 signature="{signature}"

Request Body

字段类型必填说明
amountstring/number是订单法币金额(最多 6 位小数)
request_idstring是商户自定义生成的幂等key,UUID 格式
client_referencestring否商户自定义订单号
expires_innumber否订单过期相对时间(Unix 秒);不传则使用后台默认值
merchant_aliasstring否收银台账单名称(覆盖后台配置)
success_urlstring否支付成功跳转回商户地址
failure_urlstring否支付失败跳转回商户地址
pay_methodsarray of integers否支付方式:[1] 加密货币,[2] 卡支付,[3] Binance Pay。默认使用商户配置。Binance Pay 订阅条件见下方
subscriptionobject是订阅参数(见下方)

subscription 对象:

字段类型必填说明
merchant_sub_idstring是商户自定义订阅 ID(同一商户下必须唯一)
plan_namestring是订阅计划名称
amountstring/number是后续每期扣款金额(最多 6 位小数)
interval_unitstring是扣款周期单位:DAY 或 MONTH
interval_countinteger是每个扣款周期的间隔数量
payer_emailstring是付款人邮箱(用于发送续费 Invoice 通知)
invoice_lead_daysinteger是周期结束前提前发送续费 Invoice 的天数(最小:0)。invoice 模式下必填
invoice_due_daysinteger是Invoice 创建后的到期天数(最小:1)。invoice 模式下必填
first_billing_timeinteger否可选。首次续费时间的 Unix 时间戳。付款人授权 Binance Pay 时还有额外限制
subscription_end_atinteger否订阅终止时间,Unix 时间戳(0 = 永不终止)
canceled_urlstring否退订后的跳转 URL

Response 示例

{
  "order_id": "10290d05-xxxx",
  "request_id": "your request_id",
  "client_reference": "client_reference",
  "checkout_url": "https://checkout.infini.money/subscription/xxxx",
  "token": "eyJhbGciOiJIUzI1NiIs...",
  "direct_debit_eligible": true,
  "subscription": {
    "subscription_id": "sub-xxxx",
    "merchant_sub_id": "msub_001",
    "status": "pending"
  }
}

Binance Pay 订阅

本接口创建的仍然是 Invoice 订阅。Binance Pay 订阅是在这笔订阅上追加的授权:付款人在首期收银台选择 Binance Pay,并同意之后自动续费。授权成功后,后续周期通过 Binance Pay 扣款。

创建响应里的 direct_debit_eligible 在金额和周期条件满足时为 true。付款人要完成授权,必须同时满足以下全部条件:

  • 商户已开通 Binance Pay。在 pay_methods 中传入 3,或不传 pay_methods 以使用商户配置。
  • 首期支付金额大于 0。
  • 首期金额和每一期续费金额都不超过 200 USD。其他币种按创建订阅时锁定的汇率折算。
  • 扣款周期长于 7 天。DAY 的 interval_count 必须大于 7。MONTH 的 interval_count 必须在 1 到 24 之间。一个月按 28 天计算。
  • plan_name 不超过 32 个字符。如果传了 success_url 或 failure_url,各自不超过 256 个字符。
  • 如果传了 first_billing_time,付款人授权 Binance Pay 时,该时间仍至少在 3 天之后。MONTH 周期下,该时间的 UTC 日期必须在 1 到 28 日之间。
  • 如果传了 subscription_end_at,它不能晚于付款人授权 Binance Pay 之后的 1095 天。
  • 付款人在首期支付时选择 Binance Pay。

宽限期不阻止这次授权。付款人授权 Binance Pay 后,宽限期会被清掉。

任一条件不满足时,选择 Binance Pay 不会开通 Binance Pay 订阅。订阅仍按 Invoice 方式续费,并可以用其他已开通的支付方式完成支付。

6.7 查询订阅(Query Subscription)

GET /v2/acquiring/subscription?merchant_sub_id={merchant_sub_id}

根据商户订阅 ID 查询订阅详情。

订阅状态字段说明

值说明
pending等待首次支付
active订阅生效中
canceled已取消

Response 示例

{
  "subscription_id": "sub-xxxx",
  "merchant_sub_id": "msub_001",
  "plan_name": "Monthly Plan",
  "trigger_method": "invoice",
  "status": "active",
  "currency": "USD",
  "first_amount": "10.00",
  "amount": "9.99",
  "interval_unit": "MONTH",
  "interval_count": 1,
  "current_period_start": 1740000000,
  "current_period_end": 1742678400,
  "subscription_end_at": 0,
  "next_invoice_at": 1742592000,
  "payer_email": "user@example.com",
  "created_at": 1740000000,
  "updated_at": 1740000100
}

6.8 取消订阅(Cancel Subscription)

POST /v2/acquiring/subscription/cancel

用于取消一个有效的订阅。取消后,订阅在当前计费周期结束前仍然可用。

Request Body

字段类型必填说明
merchant_sub_idstring是商户自定义订阅 ID
cancel_reasonstring是取消原因:user_request(用户请求)、by_merchant_api(商户 API 调用)、by_operation(运营操作)
notestring否可选的取消备注

Response 示例

{
  "subscription_id": "sub-xxxx",
  "merchant_sub_id": "msub_001",
  "status": "canceled",
  "canceled_at": 1742678400,
  "cancel_reason": "by_merchant_api"
}

6.9 Webhook(订单与订阅状态回调)

商户可在后台配置 Webhook 接收地址。订单或订阅状态变化时,Infini 会主动推送以下事件:

订单事件:

  • order.created
  • order.processing
  • order.completed
  • order.expired
  • order.late_payment

订阅事件:

  • subscription.update
  • subscription.cancel

Webhook Headers

Header说明
X-Webhook-TimestampUnix 时间戳
X-Webhook-Event-Id事件唯一 ID
X-Webhook-SignatureWebhook HMAC 签名

Webhook Payload 示例

{
  "event": "order.completed",
  "order_id": "ord-123",
  "client_reference": "ORDER-001",
  "amount": "100",
  "currency": "USD",
  "status": "paid",
  "amount_confirmed": "100",
  "amount_confirming": "0",
  "created_at": 1763512195,
  "updated_at": 1763512573,
  "exception_tags": []
}

Subscription Webhook Payload 示例

{
  "event": "subscription.update",
  "subscription_id": "sub-xxxx",
  "merchant_sub_id": "msub_001",
  "plan_name": "Monthly Plan",
  "trigger_method": "invoice",
  "status": "active",
  "currency": "USD",
  "amount": "9.99",
  "interval_unit": "MONTH",
  "interval_count": 1,
  "payer_email": "user@example.com",
  "current_period_start": 1740000000,
  "current_period_end": 1742678400,
  "next_invoice_at": 1742592000,
  "cancel_reason": "by_merchant_api",
  "canceled_at": 1742678400,
  "created_at": 1740000000,
  "updated_at": 1740000100
}

注意: next_invoice_at、cancel_reason 和 canceled_at 仅在对应值存在时才包含。例如,cancel_reason 和 canceled_at 仅出现在 subscription.cancel 事件中。

Webhook 验签方法请参考 章节 4:授权与安全机制。

6.10 错误码(Error Codes)

所有错误返回格式:

{
  "code": 40001,
  "message": "Invalid request",
  "detail": "expires_at must be greater than current timestamp"
}

常见错误码

HTTPCode描述
40040003amount 必须为正数
40040006amount 必须大于 0.1
401401Ed25519 认证失败
40440401订单不存在
40940902client_reference 重复
40940906订单已过期
40443000订阅不存在
40043002订阅已取消

6.11 Go 接入示例

请使用认证文档中的本地 Go 示例创建订单、查询订单和列表。收到 checkout_url 后跳转收银台;支付结果通过独立的 Webhook 协议处理。