模拟分期付款
GET
/api/v1/bank/public/charge/{uuid}/simulate-installment公共端点
此端点由结账页面或 SDK 调用,用于向付款人展示可用的分期付款选项。无需 Bearer token——收费 UUID 提供上下文。
请求头
| 请求头 | 值 | 必填 |
|---|---|---|
Accept | application/json | 推荐 |
路径参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
uuid | string (UUID) | 是 | 用于模拟分期的收费 UUID |
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
charge_uuid | string | 收费标识符 |
total_amount | number | 原始收费金额 |
currency | string | 货币代码 |
installments | array | 可用的分期选项 |
installments[].count | integer | 分期期数(1、2、3、…12) |
installments[].installment_value | number | 每期金额 |
installments[].total_amount | number | 含利息总额(如适用) |
installments[].interest_rate | number | 月利率(0 表示免息) |
installments[].interest_free | boolean | 此选项是否免息 |
HTTP 状态码
| 状态码 | 说明 |
|---|---|
| 200 | 分期模拟已返回 |
| 404 | 收费未找到或已过期 |
| 422 | 收费类型不支持分期付款 |
| 429 | 超出请求频率限制 |
| 500 | 服务器内部错误 |
代码示例
- cURL
- Python
- Node.js
curl -s -X GET "https://core-manager.a55.tech/api/v1/bank/public/charge/a1b2c3d4-e5f6-7890-abcd-ef1234567890/simulate-installment"
import requests
charge_uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
try:
response = requests.get(
f"https://core-manager.a55.tech/api/v1/bank/public/charge/{charge_uuid}/simulate-installment",
)
response.raise_for_status()
sim = response.json()
for opt in sim["installments"]:
label = "免息" if opt["interest_free"] else f"{opt['interest_rate']}%/月"
print(f"{opt['count']}x R$ {opt['installment_value']:.2f} ({label})")
except requests.exceptions.HTTPError as e:
print(f"HTTP {e.response.status_code}: {e.response.json()}")
except requests.exceptions.RequestException as e:
print(f"请求失败:{e}")
const chargeUuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890";
try {
const response = await fetch(
`https://core-manager.a55.tech/api/v1/bank/public/charge/${chargeUuid}/simulate-installment`
);
if (!response.ok) throw new Error(`请求失败(HTTP ${response.status}):${await response.text()}`);
const sim = await response.json();
for (const opt of sim.installments) {
const label = opt.interest_free ? "免息" : `${opt.interest_rate}%/月`;
console.log(`${opt.count}x R$ ${opt.installment_value.toFixed(2)} (${label})`);
}
} catch (error) {
console.error("模拟失败:", error.message);
}
错误响应示例
{
"status": "error",
"message": [
{
"code": "CHARGE_NOT_FOUND",
"source": "simulation",
"description": "Charge a1b2c3d4-e5f6-7890-abcd-ef1234567890 not found or expired"
}
]
}