斑马个人收款通 返回后台

API文档

网站服务端只需增量读取收款记录,并按付款用户名、金额和收款时间为用户到账。

基础地址
https://zebrapay.cloud

快速接入

  1. 在后台「网站 API」生成密钥,并只保存在客户网站服务端。
  2. 请求头传入 Authorization: Bearer <API 密钥>。
  3. 第一次请求使用 after=0,以后保存并使用响应里的 nextCursor。
Node.js 服务端示例JavaScript
const cursor = await loadCursor() ?? "0";
const response = await fetch(
  `https://zebrapay.cloud/v1/receipts?after=${cursor}&limit=50`,
  { headers: { Authorization: `Bearer ${process.env.ZEBRAPAY_READ_KEY}` } },
);

if (!response.ok) throw new Error(`Zebrapay HTTP ${response.status}`);
const page = await response.json();

await database.transaction(async tx => {
  for (const receipt of page.receipts) {
    if (receipt.status === "ready") {
      await tx.creditOnce({
        eventId: receipt.eventId,
        account: receipt.payerAccount,
        amountFen: receipt.amountFen,
        paidAt: receipt.receivedAt,
      });
    } else {
      await tx.saveForReview(receipt);
    }
  }
  await tx.saveCursor(page.nextCursor);
});

读取收款

GET/v1/receipts?after=0&limit=50
查询参数
参数说明
after上次保存的游标;首次传 0。
limit每次读取数量,范围 1–100,建议 50。
响应中的接入必需字段JSON
{
  "merchantId": "5d451b6a-a018-4a8c-95f4-b52aec968832",
  "receipts": [
    {
      "cursor": "1",
      "eventId": "a0854a12-987b-4e4a-8d23-45074e17ad00",
      "payerAccount": "buyer@example.com",
      "amountFen": 1290,
      "receivedAt": "2026-11-28T10:37+08:00",
      "status": "ready",
      "reviewReasons": []
    }
  ],
  "nextCursor": "1",
  "hasMore": false
}

接口还会返回采集辅助字段,客户接入时可以忽略。

到账规则

  1. 只自动处理 status=ready 的记录。
  2. 用 payerAccount 找到客户网站用户,再核对 amountFen 和 receivedAt。
  3. 以 merchantId + eventId 做唯一约束,避免重复到账。
  4. status=needs_review 表示没有识别到正确手机号或邮箱,或采集存在异常,由客户自行处理。

斑马个人收款通会把“付款用户名+金额+收款时间”完全相同的记录视为同一笔,只向客户返回一次。

必要字段

客户接入需要使用的字段
字段说明
eventId收款事件唯一编号,用于防止重复到账。
payerAccount中国大陆手机号、小写邮箱或 null。为 null 时必须人工处理。
amountFen收款金额,单位为分;1290 表示 ¥12.90。
receivedAt收款页面显示的时间,ISO 8601 北京时间,例如 2026-11-28T10:37+08:00。
statusready 可进入自动到账;needs_review 需要人工处理。
reviewReasons需要人工处理的原因数组,可直接保存并展示。
nextCursor下一次增量读取使用的游标。
hasMore为 true 时立即继续读取下一页。

网络错误、429 或 5xx 时保留原游标后重试;整页记录和新游标必须在同一个数据库事务中保存。