支付收费(SDK)
POST
/api/v1/bank/public/charge/{uuid}/pay公共端点
此端点由 A55Pay SDK 从付款人的浏览器调用。不需要 Bearer token——收费 UUID 作为授权上下文。您的后端先创建收费,然后前端 SDK 调用此端点。
请求头
| 请求头 | 值 | 必填 |
|---|---|---|
Content-Type | application/json | 是 |
路径参数
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
uuid | string (UUID) | 是 | 由创建收费返回的收费 UUID |
请求体
| 字段 | 类型 | 必填 | 说明 |
|---|---|---|---|
card_number | string | 是 | 卡号(PAN) |
card_name | string | 是 | 持卡人姓名 |
card_expiry_month | string | 是 | 到期月份 MM |
card_expiry_year | string | 是 | 到期年份 YYYY |
card_cvv | string | 是 | 卡片验证码 |
payer_tax_id | string | 是 | 付款人税务 ID(CPF、RFC、RUT) |
device_info | object | 否 | 用于 3DS 的浏览器指纹信息(参见创建收费) |
响应字段
| 字段 | 类型 | 说明 |
|---|---|---|
charge_uuid | string | 收费标识符 |
status | string | confirmed、pending(需要 3DS)或 error |
url_3ds | string | 3DS 挑战重定向 URL(当 status: "pending" 时) |
message | array/null | 当 status: "error" 时的错误详情 |
HTTP 状态码
| 状态码 | 说明 |
|---|---|
| 200 | 支付已处理或 3DS 挑战已发起 |
| 400 | 卡片数据无效或缺少必填字段 |
| 404 | 收费未找到或已过期 |
| 409 | 收费已支付或已取消 |
| 422 | 验证错误(卡片无效、已过期) |
| 429 | 超出请求频率限制 |
| 500 | 服务器内部错误 |
代码示例
- cURL
- Python
- Node.js
curl -s -X POST "https://core-manager.a55.tech/api/v1/bank/public/charge/a1b2c3d4-e5f6-7890-abcd-ef1234567890/pay" \
-H "Content-Type: application/json" \
-d '{
"card_number": "4024007153763191",
"card_name": "张伟",
"card_expiry_month": "12",
"card_expiry_year": "2030",
"card_cvv": "123",
"payer_tax_id": "123.456.789-09"
}'
import requests
charge_uuid = "a1b2c3d4-e5f6-7890-abcd-ef1234567890"
try:
response = requests.post(
f"https://core-manager.a55.tech/api/v1/bank/public/charge/{charge_uuid}/pay",
json={
"card_number": "4024007153763191",
"card_name": "张伟",
"card_expiry_month": "12",
"card_expiry_year": "2030",
"card_cvv": "123",
"payer_tax_id": "123.456.789-09",
},
headers={"Content-Type": "application/json"},
)
response.raise_for_status()
result = response.json()
if result["status"] == "pending":
print(f"3DS 重定向:{result['url_3ds']}")
else:
print(f"支付:{result['status']}")
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}/pay`,
{
method: "POST",
headers: { "Content-Type": "application/json" },
body: JSON.stringify({
card_number: "4024007153763191",
card_name: "张伟",
card_expiry_month: "12",
card_expiry_year: "2030",
card_cvv: "123",
payer_tax_id: "123.456.789-09",
}),
}
);
if (!response.ok) throw new Error(`请求失败(HTTP ${response.status}):${await response.text()}`);
const result = await response.json();
if (result.status === "pending") {
console.log(`3DS 重定向:${result.url_3ds}`);
} else {
console.log(`支付:${result.status}`);
}
} catch (error) {
console.error("支付失败:", error.message);
}
错误响应示例
{
"charge_uuid": "a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"status": "error",
"message": [
{
"code": "CARD_DECLINED",
"source": "acquirer",
"description": "Transaction declined by issuing bank"
}
]
}