跳转到主要内容

5 分钟完成首笔收款

Quick Reference

What在 A55 沙箱(sandbox)中完成首笔信用卡收款
Why在编写生产代码之前,端到端验证您的集成配置
Reading Time5 分钟
Difficulty初级
Prerequisites沙箱凭证(client_id + client_secret)

概览

本指南将引导您完成完整流程:认证、创建 wallet(钱包)、发起信用卡收款并查看结果。所有命令均在沙箱中运行——不会产生真实资金流动。

测试卡

Card NumberBrandScenarioExpected Status
4111 1111 1111 1111Visa支付成功confirmed
4000 0000 0000 0002Visa卡片被拒declined
4000 0000 0000 0069Visa处理错误error

步骤

1

获取沙箱凭证

发送邮件至 tech.services@a55.tech 申请沙箱访问权限。您将收到:

凭证说明
client_idOAuth2(开放授权)客户端标识符
client_secretOAuth2 客户端密钥
entity_uuid您的实体标识符
merchant_uuid您的商户标识符

将它们存储为环境变量:

export A55_CLIENT_ID="your_client_id"
export A55_CLIENT_SECRET="your_client_secret"
2

获取访问令牌

A55 使用 OAuth2 client_credentials(客户端凭证)授权模式。用您的凭证换取 Bearer Token(持有者令牌)。

curl -s -X POST "https://auth.sandbox.a55.tech/oauth2/token" \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=client_credentials" \
-d "client_id=${A55_CLIENT_ID}" \
-d "client_secret=${A55_CLIENT_SECRET}" \
-d "scope=api/readwrite" | python3 -m json.tool

保存令牌:

export A55_ACCESS_TOKEN="eyJhbGciOiJSUzI1NiIs..."
3

创建钱包

钱包将收款记录归组到单个实体下。在创建收款之前,您需要先创建一个钱包。

curl -s -X POST "https://sandbox.api.a55.tech/api/v1/bank/wallet/" \
-H "Authorization: Bearer ${A55_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"name": "我的第一个钱包"
}' | python3 -m json.tool

响应:

{
"uuid": "wal_a1b2c3d4-e5f6-7890-abcd-ef1234567890",
"name": "我的第一个钱包",
"status": "active",
"created_at": "2026-03-21T12:00:00Z"
}
4

创建信用卡收款

向收款 endpoint(端点)发送 POST 请求,使用测试卡 4111 1111 1111 1111

curl -s -X POST "https://sandbox.api.a55.tech/api/v1/bank/wallet/charge/" \
-H "Authorization: Bearer ${A55_ACCESS_TOKEN}" \
-H "Content-Type: application/json" \
-d '{
"amount": "100.00",
"currency": "BRL",
"type_charge": "credit_card",
"card": {
"number": "4111111111111111",
"holder_name": "测试持卡人",
"expiration_month": "12",
"expiration_year": "2030",
"cvv": "123"
},
"payer": {
"name": "测试用户",
"email": "zhangwei@example.com",
"document": "12345678909",
"document_type": "CPF"
},
"description": "快速入门测试收款"
}' | python3 -m json.tool

响应:

{
"uuid": "chg_f1e2d3c4-b5a6-7890-fedc-ba0987654321",
"status": "confirmed",
"amount": "100.00",
"currency": "BRL",
"type_charge": "credit_card",
"created_at": "2026-03-21T12:01:00Z"
}
5

查询收款状态

查询收款记录以确认最终状态。

CHARGE_UUID="chg_f1e2d3c4-b5a6-7890-fedc-ba0987654321"

curl -s -X GET "https://sandbox.api.a55.tech/api/v1/bank/wallet/charge/?charge_uuid=${CHARGE_UUID}" \
-H "Authorization: Bearer ${A55_ACCESS_TOKEN}" | python3 -m json.tool
创建收款时的幕后流程
  1. A55 接收您的收款请求并验证所有字段
  2. 根据卡片 BIN(银行识别号)、币种和商户配置,将请求路由到最佳可用收单机构(acquirer)
  3. 收单机构通过卡组织(Visa/Mastercard)处理授权
  4. A55 同步返回授权结果
  5. 如果您配置了 webhook_url,A55 会异步发送包含最终状态的通知

后续步骤