Skip to content

结算 ​

即将上线

本页的结算接口生产环境暂未提供,调用会返回 404。上线后删除本说明。

接口说明
POST /v1/terminals/{id}/settle发起批次结算(即将上线)
GET /v1/settlements结算列表(即将上线)
GET /v1/settlements/{id}查询结算(即将上线)

批次结算(批结)将终端当前批次的刷卡交易提交收单机构清算。结算前,成功交易可撤销、可调整小费;结算后只能退款。

发起批次结算 ​

http
POST /v1/terminals/{id}/settle
项目要求
鉴权仅服务端密钥
幂等以请求体中的 request_id 去重

请求参数

参数类型必填说明
request_idString是请求唯一标识。相同值返回同一结算记录,replayed=true,不会重复结算

请求示例

bash
curl https://api.kuvex.com/v1/terminals/KV100023/settle \
  -H "Authorization: Bearer $KUVEX_SECRET_KEY" \
  -H "Content-Type: application/json" \
  -d '{"request_id": "close-2026-11-30"}'

响应:202 Accepted,返回 status=pending 的结算记录,字段见结算字段。受理后终端断线的,请求在终端重新连接后下发。

结果事件

事件说明
settlement.completed结算成功
settlement.failed结算失败,原因见 failure_code,可重新发起
settlement.review_required结果未知,或 10 分钟内未收到终端结果(含终端持续离线)。不得按失败处理;后续收到结果时转为 succeeded 或 failed 并发送对应事件

错误码

HTTP错误码说明可重试
409settlement_blocked终端存在处理中的交易或未上送的离线交易是
409terminal_offline终端离线是
409settlement_in_progress该终端上一次结算尚无结果是

结算列表 ​

http
GET /v1/settlements

按发起时间倒序返回最近的结算记录。

项目要求
鉴权服务端密钥

查询参数

参数类型必填说明
terminal_idString否按终端过滤
limitint否返回条数,1–100,默认 20

查询结算 ​

http
GET /v1/settlements/{id}
项目要求
鉴权服务端密钥

响应:200 OK

json
{
  "object": "settlement",
  "id": "stl_7nW2kQ9tX4mV1pL8sR3b",
  "terminal_id": "KV100023",
  "status": "succeeded",
  "initiated_by": "api",
  "request_id": "close-2026-11-30",
  "failure_code": null,
  "period_start": "2026-11-29T23:02:10Z",
  "requested_at": "2026-11-30T23:01:44Z",
  "finished_at": "2026-11-30T23:01:52Z",
  "totals_basis": "kuvex_ledger",
  "totals": {
    "card_cents": 184250,
    "cash_cents": 0,
    "gift_cents": 0,
    "tip_cents": 21400,
    "refund_cents": 1200,
    "tx_count": 63,
    "unsettled_count": 0
  },
  "livemode": true
}

结算字段 ​

字段类型说明
idString结算 ID,stl_ 前缀
terminal_idString终端 ID
statusStringpending 处理中、succeeded 成功、failed 失败、review 结果未知
initiated_byStringapi:商户发起;kuvex:Kuvex 技术支持发起
request_idString发起时传入的请求标识
failure_codeString失败原因
period_startString上一次成功结算的发起时间;首次结算为 null
requested_atString本次发起时间
finished_atString收到结果的时间
totals_basisString汇总口径,固定 kuvex_ledger
totalsObject本批次汇总,见下表
replayedboolean仅发起接口返回:request_id 重复时为 true
livemodebooleantrue 正式环境

totals 字段(单位:分):

字段类型说明
card_centsint刷卡批准金额
cash_centsint现金金额
gift_centsint礼品卡金额
tip_centsint小费金额
refund_centsint退款金额
tx_countint计入金额的交易笔数
unsettled_countint发起时结果未定的交易笔数(review、offline_approved 等),不计入金额

totals 为发起结算时的快照,统计范围为该终端 period_start 至 requested_at 之间创建的交易,按发起时刻的状态计算,之后发生的退款不计入。该数据来源于 Kuvex 交易记录,收单机构实际清算金额以对账为准。

若某次结算处于 review 时又发起新的结算,新结算从最近一次成功结算起算;前一次后续确认成功时,两次 totals 存在重叠。