跳转到主要内容

创建钱包

Quick Reference

What创建绑定商户和货币的钱包
Why钱包是基础——没有钱包,就无法收费,无法收款
Reading Time5 分钟
Difficulty初级
Prerequisites身份验证 → 实体 UUID → 客户 ID
POST/api/v1/bank/wallet/Bearer Token创建新钱包

何时使用此端点

没有钱包有钱包
无法处理任何收费通过信用卡、PIX、Boleto、SPEI 等 8 种以上方式收款
没有余额跟踪按商户按货币实时查看余额
没有结算容器自动结算分组和付款
商户没有 API 凭证可选自动生成 client_id / client_secret 供商户自助使用
无法按货币隔离资金独立的 BRL、MXN、CLP、ARS 钱包,实现清晰的多币种账务

实体层级


身份验证

需要 Bearer 令牌。请参阅身份验证

请求体

字段类型必填说明
entity_uuidstring (UUID)账户实体标识符——您公司的 UUID
customer_idstring您系统中的内部客户 ID
currencystringISO 4217 货币代码:BRLMXNCLPARS
namestring钱包显示名称(在仪表板和报表中展示)
emailstring与此钱包关联的邮箱地址
create_credentialsbooleantrue 为此钱包生成 OAuth client_idclient_secret
merchant_uuidstring将此钱包关联到现有商户。省略则自动创建

代码示例

curl -s -X POST https://core-manager.a55.tech/api/v1/bank/wallet/ \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entity_uuid": "550e8400-e29b-41d4-a716-446655440000",
"customer_id": "cust_12345",
"currency": "BRL",
"name": "圣保罗门店——BRL",
"email": "financeiro@loja-sp.com.br",
"create_credentials": true,
"merchant_uuid": "6ba7b810-9dad-11d1-80b4-00c04fd430c8"
}'

响应

成功 (200 OK)

create_credentials: true 时,响应包含一个 credentials 对象,其中含有此钱包专属的 OAuth 密钥。

{
"wallet_uuid": "f47ac10b-58cc-4372-a567-0e02b2c3d479",
"entity_uuid": "550e8400-e29b-41d4-a716-446655440000",
"merchant_uuid": "6ba7b810-9dad-11d1-80b4-00c04fd430c8",
"customer_id": "cust_12345",
"currency": "BRL",
"name": "圣保罗门店——BRL",
"email": "financeiro@loja-sp.com.br",
"credentials": {
"client_id": "3f8a2b1c-9d4e-5f6a-7b8c-0d1e2f3a4b5c",
"client_secret": "sk_live_a55_7k9m2nP4qR6sT8uV0wX1yZ3",
"grant_type": "client_credentials",
"scopes": [
"wallet:read",
"wallet:write",
"charge:create",
"charge:read"
]
}
}

响应字段

字段类型说明
wallet_uuidstring (UUID)钱包唯一标识符——在所有收费和余额调用中使用
entity_uuidstring (UUID)父实体
merchant_uuidstring (UUID)关联商户
customer_idstring您的内部客户 ID
currencystringISO 4217 货币代码
namestring钱包显示名称
emailstring钱包邮箱
credentialsobject仅在 create_credentials: true 时返回
credentials.client_idstring用于 Cognito 令牌交换的 OAuth 客户端 ID
credentials.client_secretstringOAuth 客户端密钥——请安全存储,仅显示一次
credentials.grant_typestring始终为 client_credentials
credentials.scopesstring[]此钱包允许的 API 权限范围

错误响应

{
"error": "validation_error",
"message": "Wallet already exists for this merchant and currency",
"code": "errors.wallet.already_exists"
}
状态码错误码说明解决方法
400validation_error缺少或无效的字段检查必填字段和类型
401unauthorized无效或过期的 Bearer 令牌刷新您的访问令牌
409errors.wallet.already_exists此商户和货币的钱包已存在使用现有钱包或选择其他货币

完整示例——多币种设置

为在巴西和墨西哥运营的商户创建钱包:

# BRL 钱包
curl -s -X POST https://core-manager.a55.tech/api/v1/bank/wallet/ \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entity_uuid": "550e8400-e29b-41d4-a716-446655440000",
"customer_id": "cust_12345",
"currency": "BRL",
"name": "拉美商店——BRL",
"email": "finance@latamstore.com",
"create_credentials": true
}'

# MXN 钱包(相同实体、相同客户)
curl -s -X POST https://core-manager.a55.tech/api/v1/bank/wallet/ \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{
"entity_uuid": "550e8400-e29b-41d4-a716-446655440000",
"customer_id": "cust_12345",
"currency": "MXN",
"name": "拉美商店——MXN",
"email": "finance@latamstore.com",
"create_credentials": false
}'

提示

请立即存储凭证

create_credentials: true 时,client_secret 仅返回一次。创建后请立即将其存储到密钥管理器(AWS Secrets Manager、HashiCorp Vault、Azure Key Vault)中。A55 之后无法再次获取——您需要轮换凭证。

每个商户每种货币一个钱包

A55 对 merchant_uuid + currency 强制执行唯一约束。如果您的商户同时运营 BRL 和 MXN,请创建两个钱包。这可以按货币清晰地隔离余额、结算和报表。

凭证与平台令牌的区别

钱包凭证允许商户直接调用 API(例如创建收费、查看余额)。您的平台令牌(实体级别)可以操作所有钱包。请根据您的架构选择:集中式平台调用 vs. 委托式商户访问。