API文档
网站服务端只需增量读取收款记录,并按付款用户名、金额和收款时间为用户到账。
- 基础地址
https://zebrapay.cloud
快速接入
- 在后台「网站 API」生成密钥,并只保存在客户网站服务端。
- 请求头传入
Authorization: Bearer <API 密钥>。 - 第一次请求使用
after=0,以后保存并使用响应里的nextCursor。
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。 |
{
"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
}
接口还会返回采集辅助字段,客户接入时可以忽略。
到账规则
- 只自动处理
status=ready的记录。 - 用
payerAccount找到客户网站用户,再核对amountFen和receivedAt。 - 以
merchantId + eventId做唯一约束,避免重复到账。 status=needs_review表示没有识别到正确手机号或邮箱,或采集存在异常,由客户自行处理。
斑马个人收款通会把“付款用户名+金额+收款时间”完全相同的记录视为同一笔,只向客户返回一次。
必要字段
| 字段 | 说明 |
|---|---|
eventId | 收款事件唯一编号,用于防止重复到账。 |
payerAccount | 中国大陆手机号、小写邮箱或 null。为 null 时必须人工处理。 |
amountFen | 收款金额,单位为分;1290 表示 ¥12.90。 |
receivedAt | 收款页面显示的时间,ISO 8601 北京时间,例如 2026-11-28T10:37+08:00。 |
status | ready 可进入自动到账;needs_review 需要人工处理。 |
reviewReasons | 需要人工处理的原因数组,可直接保存并展示。 |
nextCursor | 下一次增量读取使用的游标。 |
hasMore | 为 true 时立即继续读取下一页。 |
网络错误、429 或 5xx 时保留原游标后重试;整页记录和新游标必须在同一个数据库事务中保存。