Skip to content

Commit de53dff

Browse files
DoBest888claude
andcommitted
feat: v3.2.0 — 新增 Account + VCard 命名空间(4 语言)
- account:GET /balance、/deposit-address(X-API-Key + X-Secret-Key) - vcard:读(info/bins/cards/transactions/orders/order/remark)双密钥; 开卡/充值/注销/卡详情/验证码 走 header 式 HMAC 签名 (X-Signature = HMAC-SHA256(apiSecret, ts+nonce+method+path+rawQuery+body), POST body-raw 保证签名串与字节一致) - 新增配置 apiKey/apiSecret(MPK 商户密钥,两模块共用) - 新增 verifyWebhook(params, secret) 校验平台主动推送的虚拟卡事件签名 - go/node/python/php 全部 bump 3.1.0 → 3.2.0;README/CHANGELOG 同步 Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 55d086e commit de53dff

20 files changed

Lines changed: 1646 additions & 15 deletions

File tree

CHANGELOG.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,20 @@
22

33
本仓库遵循 [Keep a Changelog](https://keepachangelog.com/zh-CN/1.1.0/)[Semantic Versioning](https://semver.org/lang/zh-CN/).
44

5+
## [3.2.0] - 2026-06-28
6+
7+
### 新增
8+
9+
- 4 个语言 SDK 全部新增 **`.account` namespace** — 账户(2 endpoint):
10+
- `GET /api/v1/account/balance` 账户 USD 余额(顺带 TRON 固定充值地址)
11+
- `GET /api/v1/account/deposit-address` 获取/分配 TRON 固定充值地址
12+
- 4 个语言 SDK 全部新增 **`.vcard` namespace** — 虚拟信用卡(12 endpoint):
13+
- 读(X-API-Key + X-Secret-Key):`getInfo` / `listBins` / `listCards` / `getCardTransactions` / `listOrders` / `getOrder` / `updateCardRemark`
14+
- 资金/敏感(**HMAC 头签名**):`getCardDetails` / `getCardCode`(完整卡号·CVV·有效期 / 3DS 验证码)、`openCard` / `rechargeCard` / `cancelCard`
15+
- 新增配置项 `apiKey` / `apiSecret`(MPK 商户密钥,Account 与 VCard 共用)
16+
- **新增 header 式 HMAC 签名**:`X-Signature = HMAC-SHA256(apiSecret, timestamp + nonce + method + path + rawQuery + body)`,头 `X-Key-ID / X-Timestamp / X-Nonce / X-Signature`;POST 采用 body-raw 机制(签名串与实际字节一致)
17+
- 新增各语言 **`verifyWebhook(params, secret)`** — 校验平台主动推送的虚拟卡 webhook 事件签名(开卡/充值/注销/新交易/新验证码),复刻后端 HMAC 验签 + 提示 sign_ts/nonce 防重放
18+
519
## [3.1.0] - 2026-05-23
620

721
### 新增

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
**面向开发者的综合数字基础服务平台 · 官方多语言 SDK**
66

77
[![License: MIT](https://img.shields.io/badge/License-MIT-blue.svg)](./LICENSE)
8-
[![v3.0.0](https://img.shields.io/badge/version-3.0.0-blue.svg)](./CHANGELOG.md)
8+
[![v3.2.0](https://img.shields.io/badge/version-3.2.0-blue.svg)](./CHANGELOG.md)
99
[![Website](https://img.shields.io/badge/website-nexcores.net-2563eb.svg)](https://nexcores.net)
1010
[![Docs](https://img.shields.io/badge/docs-online-22c55e.svg)](https://nexcores.net/docs)
1111

@@ -98,6 +98,8 @@ NexCore 平台共 **9 个业务模块**,本 SDK 当前覆盖**核心 4 个**(其
9898
| 汇率 Exchange | `/api/v1/rate` / `/api/v1/rates*` / `/api/v1/convert` | X-App-Key + X-App-Secret | **5** |
9999
| 能量租赁 Energy | `/api/v1/energy/*` | X-API-Key + X-Secret-Key | **8** |
100100
| SMTP 聚合 Smtp | `/api/v1/smtp/*` | Authorization: Bearer smk_xxx | **5** |
101+
| 账户 Account | `/api/v1/account/*` | X-API-Key + X-Secret-Key | **2** |
102+
| 虚拟信用卡 VCard | `/api/v1/vcard/*` | 读=X-API-Key+X-Secret-Key;开卡/充值/注销/卡详情/验证码=HMAC 头签名 | **12** |
101103

102104
所有 endpoint 完全对照 [`/docs`](https://nexcores.net/docs) 在线文档,字段命名与后端 100% 一致.
103105

@@ -299,7 +301,7 @@ raw, err := c.Payment.CreateOrder(map[string]any{
299301

300302
## 版本
301303

302-
当前 SDK 版本:**v3.0.0**(跟主仓库 v3.x 主线一致)
304+
当前 SDK 版本:**v3.2.0**(跟主仓库 v3.x 主线一致)
303305

304306
## 反馈
305307

go/account.go

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
package nexcore
2+
3+
import (
4+
"encoding/json"
5+
)
6+
7+
// AccountNamespace implements the v1 账户 read endpoints.
8+
//
9+
// 对应 NexCore 账户模块的公开只读接口:
10+
//
11+
// GET /api/v1/account/balance GetBalance 查询账户余额
12+
// GET /api/v1/account/deposit-address GetDepositAddress 查询/获取充值地址
13+
//
14+
// 鉴权:X-API-Key + X-Secret-Key 双 header(用 cfg.APIKey / cfg.APISecret).
15+
// account 与 vcard 命名空间共用同一对 MPK 商户密钥.
16+
type AccountNamespace struct {
17+
c *Client
18+
}
19+
20+
// headers 构造 X-API-Key + X-Secret-Key(复用与 energy 一致的双密钥读模式).
21+
func (n *AccountNamespace) headers() (map[string]string, error) {
22+
if n.c.cfg.APIKey == "" || n.c.cfg.APISecret == "" {
23+
return nil, &Error{Message: "APIKey / APISecret not configured", Code: -1}
24+
}
25+
return map[string]string{
26+
"X-API-Key": n.c.cfg.APIKey,
27+
"X-Secret-Key": n.c.cfg.APISecret,
28+
}, nil
29+
}
30+
31+
// GetBalance returns the account balance.
32+
//
33+
// GET /api/v1/account/balance
34+
func (n *AccountNamespace) GetBalance() (json.RawMessage, error) {
35+
h, err := n.headers()
36+
if err != nil {
37+
return nil, err
38+
}
39+
return n.c.transport.do("GET", "/api/v1/account/balance", &requestOpts{Headers: h})
40+
}
41+
42+
// GetDepositAddress returns the account deposit address(es).
43+
//
44+
// GET /api/v1/account/deposit-address
45+
func (n *AccountNamespace) GetDepositAddress() (json.RawMessage, error) {
46+
h, err := n.headers()
47+
if err != nil {
48+
return nil, err
49+
}
50+
return n.c.transport.do("GET", "/api/v1/account/deposit-address", &requestOpts{Headers: h})
51+
}

go/client.go

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,13 @@ type Config struct {
3232
// WithdrawPlatformPublicKeyPEM 平台 RSA 公钥 PEM(用于回调验签,可选).
3333
WithdrawPlatformPublicKeyPEM string
3434

35+
// APIKey 商户 API Key(MPK 商户密钥的 key 部分);account 与 vcard 命名空间共用.
36+
// 双密钥读场景作为 X-API-Key,HMAC 签名写场景作为 X-Key-ID.
37+
APIKey string
38+
// APISecret 商户 API Secret(MPK 商户密钥的 secret 部分);account 与 vcard 命名空间共用.
39+
// 双密钥读场景作为 X-Secret-Key,HMAC 签名写场景作为 HMAC-SHA256 的密钥.
40+
APISecret string
41+
3542
// Timeout HTTP 超时,默认 30s.
3643
Timeout time.Duration
3744

@@ -47,6 +54,8 @@ type Config struct {
4754
// c.Exchange - 汇率
4855
// c.Energy - TRON 能量租赁
4956
// c.SMTP - SMTP 聚合
57+
// c.Account - 账户(余额 / 充值地址)
58+
// c.VCard - 虚拟信用卡
5059
//
5160
// 所有方法返回 json.RawMessage,业务方自行 json.Unmarshal 到具体 struct.
5261
type Client struct {
@@ -63,6 +72,10 @@ type Client struct {
6372
SMTP *SMTPNamespace
6473
// Withdraw 提币命名空间(多链收款业务的资金出库端,RSA-2048 签名)
6574
Withdraw *WithdrawNamespace
75+
// Account 账户命名空间(余额 / 充值地址,双密钥读)
76+
Account *AccountNamespace
77+
// VCard 虚拟信用卡命名空间(读用双密钥,开卡/充值/注销/敏感信息用 HMAC 签名)
78+
VCard *VCardNamespace
6679
}
6780

6881
// NewClient creates a new NexCore client.
@@ -94,5 +107,7 @@ func NewClient(cfg Config) *Client {
94107
c.Energy = &EnergyNamespace{c: c}
95108
c.SMTP = &SMTPNamespace{c: c}
96109
c.Withdraw = &WithdrawNamespace{c: c}
110+
c.Account = &AccountNamespace{c: c}
111+
c.VCard = &VCardNamespace{c: c}
97112
return c
98113
}

go/doc.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
// - client.Exchange — 汇率(X-App-Key + X-App-Secret header)
88
// - client.Energy — TRON 能量租赁(X-API-Key + X-Secret-Key)
99
// - client.SMTP — SMTP 聚合(Bearer Token)
10+
// - client.Account — 账户余额 / 充值地址(X-API-Key + X-Secret-Key)
11+
// - client.VCard — 虚拟信用卡(读用双密钥;开卡/充值/注销/敏感信息用 HMAC 签名)
1012
//
1113
// 使用:
1214
//
@@ -39,4 +41,4 @@
3941
package nexcore
4042

4143
// Version is the SDK version, kept in sync with the public repository tags.
42-
const Version = "3.1.0"
44+
const Version = "3.2.0"

0 commit comments

Comments
 (0)