@h-ai/payment 0.1.0-alpha.65 → 0.1.0-alpha.67
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.en.md +14 -10
- package/README.ja.md +15 -11
- package/README.md +15 -11
- package/package.json +3 -3
package/README.en.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[Framework home](../../README.en.md) · Related modules: [@h-ai/audit](../audit/README.en.md) · [@h-ai/core](../core/README.en.md)
|
|
6
6
|
|
|
7
|
+
## Introduction
|
|
8
|
+
|
|
7
9
|
A unified payment module for WeChat Pay, Alipay, and Stripe, with provider-based server processing and payment initiation across clients.
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## Core features
|
|
10
12
|
|
|
11
13
|
| Provider | Payment scenarios |
|
|
12
14
|
| ---------- | ----------------------------------------- |
|
|
@@ -14,13 +16,15 @@ A unified payment module for WeChat Pay, Alipay, and Stripe, with provider-based
|
|
|
14
16
|
| Alipay | JSAPI / H5 / App / Native |
|
|
15
17
|
| Stripe | Checkout Session (international payments) |
|
|
16
18
|
|
|
17
|
-
##
|
|
19
|
+
## Getting started
|
|
20
|
+
|
|
21
|
+
### Dependencies
|
|
18
22
|
|
|
19
23
|
- `@h-ai/audit`: optional audit logging; payment operations are recorded automatically when audit is initialized.
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
### Quick start
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
#### Node.js server
|
|
24
28
|
|
|
25
29
|
```typescript
|
|
26
30
|
import { payment } from '@h-ai/payment'
|
|
@@ -47,7 +51,7 @@ const query = await payment.queryOrder('wechat', 'ORD001')
|
|
|
47
51
|
await payment.close()
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
#### Browser client
|
|
51
55
|
|
|
52
56
|
```typescript
|
|
53
57
|
import { invokePayment } from '@h-ai/payment/client'
|
|
@@ -56,7 +60,7 @@ import { invokePayment } from '@h-ai/payment/client'
|
|
|
56
60
|
await invokePayment(orderData)
|
|
57
61
|
```
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
### HTTP API contracts
|
|
60
64
|
|
|
61
65
|
Payment HTTP APIs are defined by `apiContract.payment` in `@h-ai/api-contract`. After composing them into the application contract, call them through the typed client:
|
|
62
66
|
|
|
@@ -69,7 +73,7 @@ const order = await api.payment.orders.create({
|
|
|
69
73
|
})
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
### Configuration
|
|
73
77
|
|
|
74
78
|
```typescript
|
|
75
79
|
await payment.init({
|
|
@@ -101,7 +105,7 @@ Amounts use minor currency units (cents) and must be positive integers. `amount`
|
|
|
101
105
|
|
|
102
106
|
All built-in provider HTTP requests have a default 15-second timeout to avoid long hangs on network failures.
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### Audit logging
|
|
105
109
|
|
|
106
110
|
Successful key payment operations automatically write audit logs through `@h-ai/audit`, without extra configuration. Audit failures produce warn logs and do not affect payment operations.
|
|
107
111
|
|
|
@@ -114,7 +118,7 @@ Successful key payment operations automatically write audit logs through `@h-ai/
|
|
|
114
118
|
|
|
115
119
|
> Order queries (`queryOrder`) are read-only and do not write audit logs.
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
### Error handling
|
|
118
122
|
|
|
119
123
|
```typescript
|
|
120
124
|
const result = await payment.createOrder('wechat', orderInput)
|
|
@@ -145,7 +149,7 @@ Common error codes:
|
|
|
145
149
|
| `HaiPaymentError.NOTIFY_PARSE_FAILED` | `hai:payment:051` | Callback parsing failed |
|
|
146
150
|
| `HaiPaymentError.CONFIG_ERROR` | `hai:payment:070` | Invalid configuration |
|
|
147
151
|
|
|
148
|
-
##
|
|
152
|
+
## Development and testing
|
|
149
153
|
|
|
150
154
|
```bash
|
|
151
155
|
pnpm --filter @h-ai/payment test
|
package/README.ja.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[フレームワークのホーム](../../README.ja.md) · 関連モジュール:[@h-ai/audit](../audit/README.ja.md) · [@h-ai/core](../core/README.ja.md)
|
|
6
6
|
|
|
7
|
+
## 概要
|
|
8
|
+
|
|
7
9
|
WeChat Pay、Alipay、Stripe に対応する統一決済モジュールです。Provider によるサーバー側の決済処理と、複数プラットフォームからの決済開始を提供します。
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## 主な機能
|
|
10
12
|
|
|
11
13
|
| Provider | 決済方式 |
|
|
12
14
|
| ---------- | -------------------------------------- |
|
|
@@ -14,13 +16,15 @@ WeChat Pay、Alipay、Stripe に対応する統一決済モジュールです。
|
|
|
14
16
|
| Alipay | JSAPI / H5 / App / Native |
|
|
15
17
|
| Stripe | Checkout Session(国際決済) |
|
|
16
18
|
|
|
17
|
-
##
|
|
19
|
+
## 使い始める
|
|
20
|
+
|
|
21
|
+
### 依存関係
|
|
18
22
|
|
|
19
23
|
- `@h-ai/audit`:任意の監査ログ。初期化済みの場合、決済操作を自動記録します。
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
### クイックスタート
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
#### Node.js サーバー
|
|
24
28
|
|
|
25
29
|
```typescript
|
|
26
30
|
import { payment } from '@h-ai/payment'
|
|
@@ -47,7 +51,7 @@ const query = await payment.queryOrder('wechat', 'ORD001')
|
|
|
47
51
|
await payment.close()
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
#### ブラウザークライアント
|
|
51
55
|
|
|
52
56
|
```typescript
|
|
53
57
|
import { invokePayment } from '@h-ai/payment/client'
|
|
@@ -56,7 +60,7 @@ import { invokePayment } from '@h-ai/payment/client'
|
|
|
56
60
|
await invokePayment(orderData)
|
|
57
61
|
```
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
### HTTP API 契約
|
|
60
64
|
|
|
61
65
|
決済 HTTP API は `@h-ai/api-contract` の `apiContract.payment` で定義します。アプリケーション contract に組み込むと、型付きクライアントで呼び出せます:
|
|
62
66
|
|
|
@@ -69,7 +73,7 @@ const order = await api.payment.orders.create({
|
|
|
69
73
|
})
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
### 設定
|
|
73
77
|
|
|
74
78
|
```typescript
|
|
75
79
|
await payment.init({
|
|
@@ -101,7 +105,7 @@ await payment.init({
|
|
|
101
105
|
|
|
102
106
|
すべての組み込み Provider の HTTP リクエストには既定で 15 秒のタイムアウトがあり、ネットワーク障害による長時間の待機を防ぎます。
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### 監査ログ
|
|
105
109
|
|
|
106
110
|
主要な決済操作が成功すると、追加設定なしで `@h-ai/audit` に監査ログを自動記録します。監査記録の失敗は warn ログのみを出力し、決済操作に影響しません。
|
|
107
111
|
|
|
@@ -114,7 +118,7 @@ await payment.init({
|
|
|
114
118
|
|
|
115
119
|
> 注文照会(`queryOrder`)は読み取り専用で、監査ログを記録しません。
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
### エラー処理
|
|
118
122
|
|
|
119
123
|
```typescript
|
|
120
124
|
const result = await payment.createOrder('wechat', orderInput)
|
|
@@ -145,12 +149,12 @@ if (!result.success) {
|
|
|
145
149
|
| `HaiPaymentError.NOTIFY_PARSE_FAILED` | `hai:payment:051` | 通知の解析に失敗 |
|
|
146
150
|
| `HaiPaymentError.CONFIG_ERROR` | `hai:payment:070` | 無効な設定 |
|
|
147
151
|
|
|
148
|
-
##
|
|
152
|
+
## 開発とテスト
|
|
149
153
|
|
|
150
154
|
```bash
|
|
151
155
|
pnpm --filter @h-ai/payment test
|
|
152
156
|
```
|
|
153
157
|
|
|
154
|
-
##
|
|
158
|
+
## ライセンス
|
|
155
159
|
|
|
156
160
|
Apache-2.0
|
package/README.md
CHANGED
|
@@ -4,9 +4,11 @@
|
|
|
4
4
|
|
|
5
5
|
[框架首页](../../README.md) · 相关模块:[@h-ai/audit](../audit/README.md) · [@h-ai/core](../core/README.md)
|
|
6
6
|
|
|
7
|
+
## 简介
|
|
8
|
+
|
|
7
9
|
统一支付模块,支持微信支付、支付宝和 Stripe,提供 Provider 模式的后端支付处理与多端客户端调起能力。
|
|
8
10
|
|
|
9
|
-
##
|
|
11
|
+
## 核心功能清单
|
|
10
12
|
|
|
11
13
|
| Provider | 支付场景 |
|
|
12
14
|
| -------- | -------------------------------- |
|
|
@@ -14,13 +16,15 @@
|
|
|
14
16
|
| 支付宝 | JSAPI / H5 / App / Native |
|
|
15
17
|
| Stripe | Checkout Session(国际支付) |
|
|
16
18
|
|
|
17
|
-
##
|
|
19
|
+
## 使用入门
|
|
20
|
+
|
|
21
|
+
### 依赖
|
|
18
22
|
|
|
19
23
|
- `@h-ai/audit` — 审计日志(支付操作自动审计),可选;已初始化时自动写入审计日志
|
|
20
24
|
|
|
21
|
-
|
|
25
|
+
### 快速开始
|
|
22
26
|
|
|
23
|
-
|
|
27
|
+
#### Node.js 服务端
|
|
24
28
|
|
|
25
29
|
```typescript
|
|
26
30
|
import { payment } from '@h-ai/payment'
|
|
@@ -47,7 +51,7 @@ const query = await payment.queryOrder('wechat', 'ORD001')
|
|
|
47
51
|
await payment.close()
|
|
48
52
|
```
|
|
49
53
|
|
|
50
|
-
|
|
54
|
+
#### 浏览器客户端
|
|
51
55
|
|
|
52
56
|
```typescript
|
|
53
57
|
import { invokePayment } from '@h-ai/payment/client'
|
|
@@ -56,7 +60,7 @@ import { invokePayment } from '@h-ai/payment/client'
|
|
|
56
60
|
await invokePayment(orderData)
|
|
57
61
|
```
|
|
58
62
|
|
|
59
|
-
|
|
63
|
+
### HTTP API 契约
|
|
60
64
|
|
|
61
65
|
支付 HTTP API 由 `@h-ai/api-contract` 的 `apiContract.payment` 定义。组合进应用 contract 后,可通过 typed client 调用:
|
|
62
66
|
|
|
@@ -69,7 +73,7 @@ const order = await api.payment.orders.create({
|
|
|
69
73
|
})
|
|
70
74
|
```
|
|
71
75
|
|
|
72
|
-
|
|
76
|
+
### 配置
|
|
73
77
|
|
|
74
78
|
```typescript
|
|
75
79
|
await payment.init({
|
|
@@ -101,7 +105,7 @@ await payment.init({
|
|
|
101
105
|
|
|
102
106
|
所有内置 Provider 的 HTTP 请求默认附带 15 秒超时,避免网络异常时长时间挂起。
|
|
103
107
|
|
|
104
|
-
|
|
108
|
+
### 审计日志
|
|
105
109
|
|
|
106
110
|
关键支付操作执行成功后会自动写入审计日志(依赖 `@h-ai/audit`),无需额外配置。审计写入失败仅输出 warn 日志,不影响支付操作。
|
|
107
111
|
|
|
@@ -114,7 +118,7 @@ await payment.init({
|
|
|
114
118
|
|
|
115
119
|
> 订单查询(`queryOrder`)为只读操作,不写审计日志。
|
|
116
120
|
|
|
117
|
-
|
|
121
|
+
### 错误处理
|
|
118
122
|
|
|
119
123
|
```typescript
|
|
120
124
|
const result = await payment.createOrder('wechat', orderInput)
|
|
@@ -145,12 +149,12 @@ if (!result.success) {
|
|
|
145
149
|
| `HaiPaymentError.NOTIFY_PARSE_FAILED` | `hai:payment:051` | 回调解析失败 |
|
|
146
150
|
| `HaiPaymentError.CONFIG_ERROR` | `hai:payment:070` | 配置无效 |
|
|
147
151
|
|
|
148
|
-
##
|
|
152
|
+
## 开发测试
|
|
149
153
|
|
|
150
154
|
```bash
|
|
151
155
|
pnpm --filter @h-ai/payment test
|
|
152
156
|
```
|
|
153
157
|
|
|
154
|
-
##
|
|
158
|
+
## 许可证
|
|
155
159
|
|
|
156
160
|
Apache-2.0
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@h-ai/payment",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.1.0-alpha.
|
|
4
|
+
"version": "0.1.0-alpha.67",
|
|
5
5
|
"description": "Hai Framework payment module for WeChat Pay, Alipay, and Stripe.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
7
7
|
"exports": {
|
|
@@ -26,8 +26,8 @@
|
|
|
26
26
|
"node": "^22.22.2 || ^24.15.0 || >=26.0.0"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@h-ai/audit": "0.1.0-alpha.
|
|
30
|
-
"@h-ai/core": "0.1.0-alpha.
|
|
29
|
+
"@h-ai/audit": "0.1.0-alpha.67",
|
|
30
|
+
"@h-ai/core": "0.1.0-alpha.67",
|
|
31
31
|
"zod": "^4.6.5"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|