跳转到主要内容

创建订阅

POST/api/v1/bank/wallet/charge/Bearer Token
通过收款端点创建订阅

订阅是通过在创建收款请求体中包含 subscription 对象来创建的。首次收款会立即处理,后续收款将根据计费周期自动创建。


请求头

请求头必填
AuthorizationBearer {A55_ACCESS_TOKEN}
Content-Typeapplication/json
Idempotency-Key(幂等键)UUID v4建议

请求体

所有创建收款的字段均适用,另加 subscription 对象:

字段类型必填说明
type_chargestring必须为 credit_carddebit_card
subscription.cyclestring计费周期——见下表
subscription.end_datestring结束日期 YYYY-MM-DD(省略则为无限期)

计费周期

周期说明收款频率
weekly每 7 天52 次/年
biweekly每 14 天26 次/年
monthly每月同一天12 次/年
quarterly每 3 个月4 次/年
semiannually每 6 个月2 次/年
yearly每年一次1 次/年

响应字段

所有创建收款的响应字段,另加:

字段类型说明
subscription.subscription_uuidstring唯一订阅标识符
subscription.cyclestring计费周期
subscription.statusstring创建时为 active
subscription.next_charge_datestring下次自动收款日期
subscription.end_datestring订阅结束日期(无限期时为 null)

HTTP 状态码

状态码说明
200订阅已创建且首次收款已处理
400无效的订阅周期或缺少必填字段
401Bearer Token(持有者令牌)无效或已过期
403该钱包权限不足
404钱包未找到
409重复(相同的 Idempotency-Key)
422验证错误(无效卡片、周期、日期)
429超出速率限制
500服务器内部错误 - 请使用指数退避重试

代码示例

curl -s -X POST https://core-manager.a55.tech/api/v1/bank/wallet/charge/ \
-H "Authorization: Bearer $A55_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-H "Idempotency-Key: aa0e8400-e29b-41d4-a716-446655440005" \
-d '{
"wallet_uuid": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"merchant_id": "11111111-1111-1111-1111-111111111111",
"payer_name": "张伟",
"payer_email": "zhangwei@example.com",
"payer_tax_id": "123.456.789-09",
"payer_cell_phone": "+5511999999999",
"installment_value": 49.90,
"installment_count": 1,
"currency": "BRL",
"due_date": "2026-12-31",
"description": "高级计划——月度订阅",
"type_charge": "credit_card",
"card_number": "4024007153763191",
"card_name": "张伟",
"card_expiry_month": "12",
"card_expiry_year": "2030",
"card_cvv": "123",
"subscription": {
"cycle": "monthly",
"end_date": "2027-12-31"
},
"webhook_url": "https://your-app.com/webhooks/a55",
"payer_address": {
"street": "Av. Paulista",
"address_number": "1000",
"complement": "Sala 101",
"neighborhood": "Bela Vista",
"city": "São Paulo",
"state": "SP",
"postal_code": "01310-100",
"country": "BR"
}
}'

错误响应示例

{
"charge_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "error",
"message": [
{
"code": "INVALID_SUBSCRIPTION_CYCLE",
"source": "subscription",
"description": "Cycle 'daily' is not supported. Use: weekly, biweekly, monthly, quarterly, semiannually, yearly"
}
]
}