@waffo/waffo-node 2.0.2 → 2.0.4

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/package.json CHANGED
@@ -1,13 +1,10 @@
1
1
  {
2
2
  "name": "@waffo/waffo-node",
3
- "version": "2.0.2",
4
- "description": "Official Node.js SDK for the Waffo payment platform. Supports order management, refunds, and secure RSA-signed API communication.",
3
+ "version": "2.0.4",
4
+ "description": "Official Waffo PSP Node.js SDK",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",
7
7
  "types": "./dist/index.d.ts",
8
- "files": [
9
- "dist"
10
- ],
11
8
  "exports": {
12
9
  ".": {
13
10
  "types": "./dist/index.d.ts",
@@ -15,62 +12,50 @@
15
12
  "require": "./dist/index.js"
16
13
  }
17
14
  },
15
+ "files": [
16
+ "dist",
17
+ "README.md",
18
+ "LICENSE"
19
+ ],
20
+ "engines": {
21
+ "node": ">=18.0.0"
22
+ },
18
23
  "scripts": {
19
24
  "build": "tsup",
20
- "clean": "rm -rf dist",
21
- "prepublishOnly": "npm run clean && npm run build",
25
+ "dev": "tsup --watch",
22
26
  "test": "vitest run",
23
27
  "test:watch": "vitest",
24
28
  "test:coverage": "vitest run --coverage",
25
- "lint": "eslint src",
26
- "lint:fix": "eslint src --fix",
27
- "format": "prettier --write \"src/**/*.ts\"",
28
- "format:check": "prettier --check \"src/**/*.ts\"",
29
- "prepare": "husky"
29
+ "lint": "eslint src --ext .ts",
30
+ "typecheck": "tsc --noEmit",
31
+ "prepublishOnly": "npm run build && npm test"
30
32
  },
31
33
  "keywords": [
32
34
  "waffo",
33
35
  "payment",
36
+ "psp",
37
+ "subscription",
34
38
  "sdk",
35
- "nodejs",
36
- "typescript",
37
39
  "ewallet",
38
- "payment-gateway",
39
- "rsa",
40
- "api-client"
40
+ "payment-gateway"
41
41
  ],
42
- "author": "Waffo <support@waffo.com> (https://waffo.com)",
42
+ "author": "Waffo <merchant.support@waffo.com>",
43
43
  "license": "MIT",
44
44
  "repository": {
45
45
  "type": "git",
46
- "url": "git+https://github.com/waffo-com/waffo-node.git"
46
+ "url": "https://github.com/waffo-com/waffo-sdk"
47
47
  },
48
+ "homepage": "https://github.com/waffo-com/waffo-sdk/tree/main/packages/waffo-node",
48
49
  "bugs": {
49
- "url": "https://github.com/waffo-com/waffo-node/issues"
50
- },
51
- "homepage": "https://github.com/waffo-com/waffo-node#readme",
52
- "engines": {
53
- "node": ">=18.0.0"
54
- },
55
- "lint-staged": {
56
- "src/**/*.ts": [
57
- "eslint --fix",
58
- "prettier --write"
59
- ]
50
+ "url": "https://github.com/waffo-com/waffo-sdk/issues"
60
51
  },
61
52
  "devDependencies": {
62
- "@eslint/js": "^9.39.2",
63
- "@types/node": "^25.0.3",
64
- "@vitest/coverage-v8": "^2.1.8",
65
- "eslint": "^9.39.2",
66
- "eslint-config-prettier": "^10.1.8",
67
- "eslint-plugin-prettier": "^5.5.4",
68
- "husky": "^9.1.7",
69
- "lint-staged": "^16.2.7",
70
- "prettier": "^3.7.4",
71
- "tsup": "^8.5.1",
72
- "typescript": "^5.9.3",
73
- "typescript-eslint": "^8.50.1",
74
- "vitest": "^2.1.8"
53
+ "@types/node": "^20.0.0",
54
+ "typescript": "^5.3.0",
55
+ "tsup": "^8.0.0",
56
+ "vitest": "^1.0.0",
57
+ "eslint": "^8.56.0",
58
+ "@typescript-eslint/eslint-plugin": "^6.19.0",
59
+ "@typescript-eslint/parser": "^6.19.0"
75
60
  }
76
61
  }
package/README.ja.md DELETED
@@ -1,580 +0,0 @@
1
- # Waffo PSP Node.js SDK
2
-
3
- Waffo PSP(決済サービスプロバイダー)アクワイアリングサービスの公式Node.js SDKです。このSDKは、RSA署名によるセキュアなAPI通信と、決済アクワイアリング操作のための包括的な型定義を提供します。
4
-
5
- **言語**: [English](./README.md) | [中文](./README.zh-CN.md) | [日本語](./README.ja.md)
6
-
7
- ## クイックスタート
8
-
9
- ```typescript
10
- import {
11
- Waffo,
12
- Environment,
13
- CurrencyCode,
14
- ProductName,
15
- } from '@waffo/waffo-node';
16
-
17
- // 1. SDKを初期化
18
- const waffo = new Waffo({
19
- apiKey: 'your-api-key',
20
- privateKey: 'your-base64-encoded-private-key',
21
- environment: Environment.SANDBOX,
22
- });
23
-
24
- // 2. 注文を作成
25
- const result = await waffo.order.create({
26
- paymentRequestId: 'REQ_001',
27
- merchantOrderId: 'ORDER_001',
28
- orderCurrency: CurrencyCode.IDR,
29
- orderAmount: '100000',
30
- orderDescription: '商品購入',
31
- notifyUrl: 'https://merchant.com/notify',
32
- merchantInfo: { merchantId: 'your-merchant-id' },
33
- userInfo: {
34
- userId: 'user_001',
35
- userEmail: 'user@example.com',
36
- },
37
- paymentInfo: {
38
- productName: ProductName.ONE_TIME_PAYMENT,
39
- payMethodType: 'EWALLET',
40
- payMethodName: 'DANA',
41
- },
42
- });
43
-
44
- // 3. レスポンスを処理
45
- if (result.success) {
46
- console.log('注文作成成功:', result.data);
47
- // ユーザーを決済ページにリダイレクト
48
- if (result.data?.orderAction) {
49
- const action = JSON.parse(result.data.orderAction);
50
- window.location.href = action.webUrl;
51
- }
52
- }
53
- ```
54
-
55
- > **ヒント**:新しいRSAキーペアが必要ですか?`Waffo.generateKeyPair()` で作成できます:
56
- > ```typescript
57
- > const keyPair = Waffo.generateKeyPair();
58
- > console.log(keyPair.privateKey); // 安全に保管し、SDK初期化に使用
59
- > console.log(keyPair.publicKey); // Waffoに共有
60
- > ```
61
-
62
- ## 特徴
63
-
64
- - RSA-2048によるリクエスト署名とレスポンス検証
65
- - TypeScriptの完全な型定義サポート
66
- - 本番環境での依存関係ゼロ(Node.js組み込みの`crypto`モジュールのみ使用)
67
- - サンドボックス環境と本番環境のサポート
68
- - デュアルモジュール形式サポート(ESM/CommonJS)
69
- - 注文管理(作成、照会、キャンセル、返金、キャプチャ)
70
- - サブスクリプション管理(作成、照会、キャンセル、管理URL取得)
71
- - 返金ステータス照会
72
- - 加盟店設定照会(取引限度額、日次限度額)
73
- - 決済方法設定照会(利用可否、メンテナンス期間)
74
- - 自動署名検証とイベントルーティングを備えたWebhookハンドラー
75
- - Webhook署名検証ユーティリティ
76
- - カスタムAPIリクエスト用の直接HTTPクライアントアクセス
77
- - リクエストタイムスタンプパラメータの自動デフォルト値
78
-
79
- ## タイムスタンプパラメータの自動デフォルト値
80
-
81
- すべてのタイムスタンプパラメータ(`orderRequestedAt`、`requestedAt`、`captureRequestedAt`)は**オプション**であり、指定しない場合は自動的に現在時刻(`new Date().toISOString()`)が設定されます:
82
-
83
- ```typescript
84
- // タイムスタンプは自動的に現在時刻に設定
85
- await waffo.order.create({
86
- paymentRequestId: 'REQ_001',
87
- merchantOrderId: 'ORDER_001',
88
- // ... その他の必須フィールド
89
- // orderRequestedAt は自動設定
90
- });
91
-
92
- // または明示的にカスタムタイムスタンプを指定
93
- await waffo.order.create({
94
- paymentRequestId: 'REQ_001',
95
- merchantOrderId: 'ORDER_001',
96
- orderRequestedAt: '2025-01-01T00:00:00.000Z', // カスタムタイムスタンプ
97
- // ... その他の必須フィールド
98
- });
99
- ```
100
-
101
- この機能は以下に適用されます:
102
- - `CreateOrderParams.orderRequestedAt`
103
- - `CancelOrderParams.orderRequestedAt`
104
- - `RefundOrderParams.requestedAt`
105
- - `CaptureOrderParams.captureRequestedAt`
106
- - `CreateSubscriptionParams.requestedAt`
107
- - `CancelSubscriptionParams.requestedAt`
108
-
109
- ## インストール
110
-
111
- ```bash
112
- npm install @waffo/waffo-node
113
- ```
114
-
115
- ## 使用方法
116
-
117
- ### SDKの初期化
118
-
119
- ```typescript
120
- import { Waffo, Environment } from '@waffo/waffo-node';
121
-
122
- const waffo = new Waffo({
123
- apiKey: 'your-api-key',
124
- privateKey: 'your-base64-encoded-private-key',
125
- environment: Environment.SANDBOX, // または Environment.PRODUCTION
126
- });
127
- ```
128
-
129
- ### RSAキーペアの生成
130
-
131
- ```typescript
132
- import { Waffo } from '@waffo/waffo-node';
133
-
134
- const keyPair = Waffo.generateKeyPair();
135
- console.log(keyPair.privateKey); // Base64エンコードされたPKCS8秘密鍵
136
- console.log(keyPair.publicKey); // Base64エンコードされたX509公開鍵
137
- ```
138
-
139
- ### 注文の作成
140
-
141
- ```typescript
142
- const result = await waffo.order.create({
143
- paymentRequestId: 'REQ_001',
144
- merchantOrderId: 'ORDER_001',
145
- orderCurrency: CurrencyCode.IDR,
146
- orderAmount: '100000',
147
- orderDescription: '商品購入',
148
- notifyUrl: 'https://merchant.com/notify',
149
- merchantInfo: {
150
- merchantId: 'your-merchant-id',
151
- },
152
- userInfo: {
153
- userId: 'user_001',
154
- userEmail: 'user@example.com',
155
- userPhone: '+62-81234567890',
156
- userTerminal: UserTerminalType.WEB,
157
- },
158
- paymentInfo: {
159
- productName: ProductName.ONE_TIME_PAYMENT,
160
- payMethodType: 'EWALLET',
161
- payMethodName: 'DANA',
162
- },
163
- });
164
-
165
- if (result.success) {
166
- console.log('注文作成成功:', result.data);
167
- } else {
168
- console.error('エラー:', result.error);
169
- }
170
- ```
171
-
172
- ### 注文ステータスの照会
173
-
174
- ```typescript
175
- const result = await waffo.order.inquiry({
176
- acquiringOrderId: 'A202512230000001',
177
- // または paymentRequestId: 'REQ_001' を使用
178
- });
179
-
180
- if (result.success) {
181
- console.log('注文ステータス:', result.data?.orderStatus);
182
- }
183
- ```
184
-
185
- ### 注文のキャンセル
186
-
187
- ```typescript
188
- const result = await waffo.order.cancel({
189
- acquiringOrderId: 'A202512230000001',
190
- merchantId: 'your-merchant-id',
191
- // orderRequestedAt はオプション、デフォルトは現在時刻
192
- });
193
- ```
194
-
195
- ### 注文の返金
196
-
197
- ```typescript
198
- const result = await waffo.order.refund({
199
- refundRequestId: 'REFUND_001',
200
- acquiringOrderId: 'A202512230000001',
201
- merchantId: 'your-merchant-id',
202
- refundAmount: '50000',
203
- refundReason: 'お客様からの返金リクエスト',
204
- refundNotifyUrl: 'https://merchant.com/refund-notify',
205
- // requestedAt はオプション、デフォルトは現在時刻
206
- });
207
- ```
208
-
209
- ### 返金ステータスの照会
210
-
211
- ```typescript
212
- const result = await waffo.refund.inquiry({
213
- refundRequestId: 'REFUND_001',
214
- // または acquiringRefundOrderId: 'R202512230000001' を使用
215
- });
216
-
217
- if (result.success) {
218
- console.log('返金ステータス:', result.data?.refundStatus);
219
- }
220
- ```
221
-
222
- ### 事前承認済み決済のキャプチャ
223
-
224
- ```typescript
225
- const result = await waffo.order.capture({
226
- acquiringOrderId: 'A202512230000001',
227
- merchantId: 'your-merchant-id',
228
- captureAmount: '100000',
229
- // captureRequestedAt はオプション、デフォルトは現在時刻
230
- });
231
- ```
232
-
233
- ### サブスクリプションの作成
234
-
235
- ```typescript
236
- const result = await waffo.subscription.create({
237
- subscriptionRequest: 'SUB_REQ_001',
238
- merchantSubscriptionId: 'MERCHANT_SUB_001',
239
- currency: CurrencyCode.PHP,
240
- amount: '100',
241
- productInfo: {
242
- periodType: PeriodType.MONTHLY,
243
- periodInterval: '1',
244
- numberOfPeriod: '12',
245
- description: '月額サブスクリプション',
246
- },
247
- paymentInfo: {
248
- productName: ProductName.SUBSCRIPTION,
249
- payMethodType: 'EWALLET',
250
- payMethodName: 'GCASH',
251
- },
252
- merchantInfo: { merchantId: 'your-merchant-id' },
253
- userInfo: {
254
- userId: 'user_001',
255
- userEmail: 'user@example.com',
256
- },
257
- goodsInfo: {
258
- goodsId: 'GOODS_001',
259
- goodsName: 'プレミアムプラン',
260
- },
261
- notifyUrl: 'https://merchant.com/subscription/notify',
262
- // requestedAt はオプション、デフォルトは現在時刻
263
- });
264
-
265
- if (result.success) {
266
- console.log('サブスクリプション作成成功:', result.data);
267
- // ユーザーをサブスクリプション契約完了ページにリダイレクト
268
- if (result.data?.subscriptionAction?.webUrl) {
269
- window.location.href = result.data.subscriptionAction.webUrl;
270
- }
271
- }
272
- ```
273
-
274
- ### サブスクリプションステータスの照会
275
-
276
- ```typescript
277
- const result = await waffo.subscription.inquiry({
278
- merchantId: 'your-merchant-id',
279
- subscriptionId: 'SUB_202512230000001',
280
- paymentDetails: '1', // 支払い履歴を含める
281
- });
282
-
283
- if (result.success) {
284
- console.log('サブスクリプションステータス:', result.data?.subscriptionStatus);
285
- }
286
- ```
287
-
288
- ### サブスクリプションのキャンセル
289
-
290
- ```typescript
291
- const result = await waffo.subscription.cancel({
292
- merchantId: 'your-merchant-id',
293
- subscriptionId: 'SUB_202512230000001',
294
- // requestedAt はオプション、デフォルトは現在時刻
295
- });
296
- ```
297
-
298
- ### サブスクリプション管理URLの取得
299
-
300
- ```typescript
301
- const result = await waffo.subscription.manage({
302
- subscriptionId: 'SUB_202512230000001',
303
- // または subscriptionRequest: 'SUB_REQ_001' を使用
304
- });
305
-
306
- if (result.success) {
307
- console.log('管理URL:', result.data?.managementUrl);
308
- console.log('有効期限:', result.data?.expiresAt);
309
- // ユーザーをサブスクリプション管理ページにリダイレクト
310
- window.location.href = result.data?.managementUrl;
311
- }
312
- ```
313
-
314
- ### 加盟店設定の照会
315
-
316
- ```typescript
317
- const result = await waffo.merchantConfig.inquiry({
318
- merchantId: 'your-merchant-id',
319
- });
320
-
321
- if (result.success) {
322
- console.log('日次限度額:', result.data?.totalDailyLimit);
323
- console.log('残り日次限度額:', result.data?.remainingDailyLimit);
324
- console.log('取引限度額:', result.data?.transactionLimit);
325
- }
326
- ```
327
-
328
- ### 決済方法設定の照会
329
-
330
- ```typescript
331
- const result = await waffo.payMethodConfig.inquiry({
332
- merchantId: 'your-merchant-id',
333
- });
334
-
335
- if (result.success) {
336
- result.data?.payMethodDetails.forEach(method => {
337
- console.log(`${method.payMethodName}: ${method.currentStatus === '1' ? '利用可能' : '利用不可'}`);
338
- if (method.fixedMaintenanceRules) {
339
- console.log('メンテナンス期間:', method.fixedMaintenanceRules);
340
- }
341
- });
342
- }
343
- ```
344
-
345
- ### Webhookハンドラー
346
-
347
- SDKには、署名検証、イベントルーティング、レスポンス署名を自動的に処理する組み込みのWebhookハンドラーが用意されています:
348
-
349
- ```typescript
350
- // Webhookハンドラー内で
351
- app.post('/webhook', async (req, res) => {
352
- const signature = req.headers['x-signature'] as string;
353
- const body = JSON.stringify(req.body);
354
-
355
- const result = await waffo.webhook.handle(body, signature, {
356
- onPayment: async ({ notification }) => {
357
- console.log('支払いステータス:', notification.result.orderStatus);
358
- // 支払い通知を処理
359
- },
360
- onRefund: async ({ notification }) => {
361
- console.log('返金ステータス:', notification.result.refundStatus);
362
- // 返金通知を処理
363
- },
364
- onSubscriptionStatus: async ({ notification }) => {
365
- console.log('サブスクリプションステータス:', notification.result.subscriptionStatus);
366
- // サブスクリプションステータス変更を処理
367
- },
368
- onSubscriptionPayment: async ({ notification }) => {
369
- console.log('サブスクリプション決済:', notification.result.orderStatus);
370
- // サブスクリプション定期決済を処理
371
- },
372
- onError: async (error) => {
373
- console.error('Webhookエラー:', error.message);
374
- },
375
- });
376
-
377
- return res.json(result.response);
378
- });
379
- ```
380
-
381
- ### 手動Webhook署名検証
382
-
383
- より細かい制御が必要な場合は、低レベルのWebhookユーティリティを使用できます:
384
-
385
- ```typescript
386
- import {
387
- verifyWebhookSignature,
388
- buildSuccessResponse,
389
- buildFailedResponse,
390
- isPaymentNotification,
391
- isRefundNotification,
392
- } from '@waffo/waffo-node';
393
-
394
- // Webhookハンドラー内で
395
- app.post('/webhook', (req, res) => {
396
- const signature = req.headers['x-signature'];
397
- const body = JSON.stringify(req.body);
398
-
399
- // 署名を検証
400
- const verifyResult = verifyWebhookSignature(body, signature, waffoPublicKey);
401
-
402
- if (!verifyResult.valid) {
403
- return res.json(buildFailedResponse('署名検証に失敗しました', merchantPrivateKey));
404
- }
405
-
406
- // 通知タイプに応じて処理
407
- const notification = verifyResult.notification;
408
-
409
- if (isPaymentNotification(notification)) {
410
- // 支払い通知を処理
411
- console.log('支払いステータス:', notification.result.orderStatus);
412
- } else if (isRefundNotification(notification)) {
413
- // 返金通知を処理
414
- console.log('返金ステータス:', notification.result.refundStatus);
415
- }
416
-
417
- // 成功レスポンスを返す
418
- return res.json(buildSuccessResponse(merchantPrivateKey));
419
- });
420
- ```
421
-
422
- ### 直接HTTPクライアントアクセス
423
-
424
- SDKメソッドでカバーされていないカスタムAPIリクエスト用:
425
-
426
- ```typescript
427
- const response = await waffo.httpClient.post<CustomResponseType>('/custom/endpoint', {
428
- body: { key: 'value' }
429
- });
430
-
431
- if (response.success) {
432
- console.log(response.data);
433
- }
434
- ```
435
-
436
- ## 設定オプション
437
-
438
- | オプション | 型 | 必須 | デフォルト | 説明 |
439
- |-----------|------|------|----------|------|
440
- | `apiKey` | string | はい | - | Waffoから提供されるAPIキー |
441
- | `privateKey` | string | はい | - | Base64エンコードされたPKCS8秘密鍵 |
442
- | `waffoPublicKey` | string | いいえ | 組み込み公開鍵 | レスポンス検証用のカスタムWaffo公開鍵 |
443
- | `environment` | Environment | いいえ | PRODUCTION | API環境(SANDBOXまたはPRODUCTION) |
444
- | `timeout` | number | いいえ | 30000 | リクエストタイムアウト(ミリ秒) |
445
- | `logger` | Logger | いいえ | - | デバッグ用のロガーインスタンス(`console`も使用可能) |
446
-
447
- ## APIレスポンス形式
448
-
449
- すべてのAPIメソッドは`ApiResponse<T>`オブジェクトを返します:
450
-
451
- ```typescript
452
- interface ApiResponse<T> {
453
- success: boolean; // リクエストが成功したかどうか
454
- statusCode: number; // HTTPステータスコード
455
- data?: T; // レスポンスデータ(成功時)
456
- error?: string; // エラーメッセージ(失敗時)
457
- }
458
- ```
459
-
460
- ## 型定義
461
-
462
- SDKは包括的なTypeScript型定義をエクスポートします:
463
-
464
- - `Environment` - SDK環境列挙型
465
- - `CountryCode` - ISO 3166-1 alpha-3国コード
466
- - `CurrencyCode` - ISO 4217通貨コード
467
- - `ProductName` - 決済商品タイプ列挙型(ONE_TIME_PAYMENT、SUBSCRIPTION)
468
- - `payMethodType` - 決済方法カテゴリ(文字列: "EWALLET"、"CREDITCARD"、"BANKTRANSFER"、"ONLINE_BANKING"、"DIGITAL_BANKING"、"OTC"、"DEBITCARD")
469
- - `payMethodName` - 具体的な決済方法(文字列: "OVO"、"DANA"、"GOPAY"、"GCASH"、"CC_VISA"、"CC_MASTERCARD"、"VA_BCA"、"VA_BNI" など)
470
- - `OrderStatus` - 注文ステータス列挙型(PAY_IN_PROGRESS、AUTHORIZATION_REQUIRED、PAY_SUCCESS、ORDER_CLOSE など)
471
- - `RefundStatus` - 返金ステータス列挙型(REFUND_IN_PROGRESS、ORDER_PARTIALLY_REFUNDED、ORDER_FULLY_REFUNDED、ORDER_REFUND_FAILED)
472
- - `SubscriptionStatus` - サブスクリプションステータス列挙型(AUTHORIZATION_REQUIRED、ACTIVE、PAUSED、MERCHANT_CANCELLED など)
473
- - `PeriodType` - サブスクリプション期間タイプ列挙型(DAILY、WEEKLY、MONTHLY、YEARLY)
474
- - `UserTerminalType` - ユーザー端末タイプ列挙型(WEB、APP、IN_WALLET_APP、IN_MINI_PROGRAM)
475
- - すべてのAPI操作のリクエスト/レスポンスインターフェース
476
-
477
- ## 開発
478
-
479
- ```bash
480
- # 依存関係のインストール
481
- npm install
482
-
483
- # ビルド(ESMとCJSの両方を生成)
484
- npm run build
485
-
486
- # テストの実行
487
- npm test
488
-
489
- # カバレッジレポート付きテストの実行
490
- npm run test:coverage
491
-
492
- # ウォッチモードでテストを実行
493
- npm run test:watch
494
-
495
- # コードの静的解析
496
- npm run lint
497
-
498
- # コードの静的解析と自動修正
499
- npm run lint:fix
500
-
501
- # コードのフォーマット
502
- npm run format
503
-
504
- # フォーマットのチェック
505
- npm run format:check
506
- ```
507
-
508
- ### コード品質
509
-
510
- このプロジェクトでは以下のツールを使用しています:
511
- - **ESLint** - TypeScript対応のコード静的解析
512
- - **Prettier** - コードフォーマッター
513
- - **Husky** - Gitフック
514
- - **lint-staged** - ステージされたファイルに対するリンター実行
515
-
516
- コミット時に、pre-commitフックがステージされた `.ts` ファイルに対してESLintとPrettierを自動的に実行します。
517
-
518
- ### E2Eテストの実行
519
-
520
- E2Eテストには Waffo サンドボックス環境の認証情報が必要です。SDKは異なるテストシナリオ用に複数の加盟店設定をサポートし、公式のWaffoテストケースドキュメントに基づいた包括的なテストカバレッジを提供します。
521
-
522
- ```bash
523
- # テンプレートをコピーして認証情報を入力
524
- cp .env.template .env
525
- # .env ファイルを編集して認証情報を入力
526
- ```
527
-
528
- 環境変数:
529
-
530
- | 変数名 | 必須 | 説明 |
531
- |--------|------|------|
532
- | `WAFFO_PUBLIC_KEY` | いいえ | 署名検証用のWaffo公開鍵(共通) |
533
- | `ACQUIRING_MERCHANT_ID` | はい* | 決済/注文テスト用の加盟店ID |
534
- | `ACQUIRING_API_KEY` | はい* | 決済/注文テスト用のAPIキー |
535
- | `ACQUIRING_MERCHANT_PRIVATE_KEY` | はい* | 決済/注文テスト用の秘密鍵 |
536
- | `SUBSCRIPTION_MERCHANT_ID` | はい** | サブスクリプションテスト用の加盟店ID |
537
- | `SUBSCRIPTION_API_KEY` | はい** | サブスクリプションテスト用のAPIキー |
538
- | `SUBSCRIPTION_MERCHANT_PRIVATE_KEY` | はい** | サブスクリプションテスト用の秘密鍵 |
539
-
540
- \* 決済/注文E2Eテストの実行に必要
541
- \** サブスクリプションE2Eテストの実行に必要
542
-
543
- **E2Eテストカバレッジ:**
544
-
545
- | モジュール | テストケース |
546
- |------------|--------------|
547
- | 注文作成 | 決済成功/失敗、チャネル拒否 (C0005)、冪等性エラー (A0011)、システムエラー (C0001)、不明ステータス (E0001) |
548
- | 注文照会 | 決済前/決済後の照会 |
549
- | 注文キャンセル | 決済前キャンセル、チャネル非対応 (A0015)、決済済み (A0013) |
550
- | 返金注文 | 全額/部分返金、パラメータ検証 (A0003)、返金ルール (A0014) |
551
- | サブスクリプション作成 | サブスクリプション成功/失敗、次期決済シミュレーション |
552
- | サブスクリプションキャンセル | 加盟店起動キャンセル |
553
- | Webhook通知 | 決済、返金、サブスクリプション通知の署名検証 |
554
-
555
- **サンドボックス金額トリガールール:**
556
-
557
- | 金額パターン | エラーコード | 説明 |
558
- |--------------|--------------|------|
559
- | 9, 90, 990, 1990, 19990 | C0005 | チャネル拒否 |
560
- | 9.1, 91, 991, 1991, 19991 | C0001 | システムエラー |
561
- | 9.2, 92, 992, 1992, 19992 | E0001 | 不明ステータス |
562
- | 9.3, 93, 993, 1993, 19993 | C0001 | キャンセルシステムエラー |
563
- | 9.4, 94, 994, 1994, 19994 | E0001 | キャンセル不明ステータス |
564
- | 9.5, 95, 995, 1995, 19995 | C0001 | 返金システムエラー |
565
- | 9.6, 96, 996, 1996, 199996 | E0001 | 返金不明ステータス |
566
-
567
- ```bash
568
- # すべてのテストを実行
569
- npm test
570
- ```
571
-
572
- ## ビルド出力
573
-
574
- SDKは [tsup](https://tsup.egoist.dev/) でビルドされ、以下のファイルを出力します:
575
-
576
- | ファイル | 形式 | 説明 |
577
- |---------|------|------|
578
- | `dist/index.js` | CommonJS | `require()` インポート用 |
579
- | `dist/index.mjs` | ESM | `import` 文用 |
580
- | `dist/index.d.ts` | TypeScript | 型宣言ファイル |