taiwan-payment-skill 1.0.0

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.
Files changed (37) hide show
  1. package/README.md +197 -0
  2. package/assets/taiwan-payment/CLAUDE.md +297 -0
  3. package/assets/taiwan-payment/EXAMPLES.md +1425 -0
  4. package/assets/taiwan-payment/README.md +306 -0
  5. package/assets/taiwan-payment/SKILL.md +857 -0
  6. package/assets/taiwan-payment/data/error-codes.csv +20 -0
  7. package/assets/taiwan-payment/data/field-mappings.csv +15 -0
  8. package/assets/taiwan-payment/data/operations.csv +8 -0
  9. package/assets/taiwan-payment/data/payment-methods.csv +24 -0
  10. package/assets/taiwan-payment/data/providers.csv +4 -0
  11. package/assets/taiwan-payment/data/reasoning.csv +32 -0
  12. package/assets/taiwan-payment/data/troubleshooting.csv +18 -0
  13. package/assets/taiwan-payment/references/ecpay-payment-api.md +880 -0
  14. package/assets/taiwan-payment/references/newebpay-payment-api.md +677 -0
  15. package/assets/taiwan-payment/references/payuni-payment-api.md +997 -0
  16. package/assets/taiwan-payment/scripts/core.py +288 -0
  17. package/assets/taiwan-payment/scripts/recommend.py +269 -0
  18. package/assets/taiwan-payment/scripts/search.py +185 -0
  19. package/assets/taiwan-payment/scripts/test_payment.py +358 -0
  20. package/assets/templates/base/quick-reference.md +370 -0
  21. package/assets/templates/base/skill-content.md +851 -0
  22. package/assets/templates/platforms/antigravity.json +25 -0
  23. package/assets/templates/platforms/claude.json +26 -0
  24. package/assets/templates/platforms/codebuddy.json +25 -0
  25. package/assets/templates/platforms/codex.json +25 -0
  26. package/assets/templates/platforms/continue.json +25 -0
  27. package/assets/templates/platforms/copilot.json +25 -0
  28. package/assets/templates/platforms/cursor.json +25 -0
  29. package/assets/templates/platforms/gemini.json +25 -0
  30. package/assets/templates/platforms/kiro.json +25 -0
  31. package/assets/templates/platforms/opencode.json +25 -0
  32. package/assets/templates/platforms/qoder.json +25 -0
  33. package/assets/templates/platforms/roocode.json +25 -0
  34. package/assets/templates/platforms/trae.json +25 -0
  35. package/assets/templates/platforms/windsurf.json +25 -0
  36. package/dist/index.js +17095 -0
  37. package/package.json +58 -0
@@ -0,0 +1,370 @@
1
+ # 快速參考 (Quick Reference)
2
+
3
+ > 此文件為 Claude 專用快速參考,提供金流服務商比較表、常用代碼片段、快速查找表。
4
+
5
+ ## 三家服務商快速比較
6
+
7
+ | 特性 | 綠界 ECPay | 藍新 NewebPay | 統一 PAYUNi |
8
+ |------|-----------|--------------|------------|
9
+ | **加密方式** | URL Encode + SHA256 | AES-256-CBC + SHA256 雙層 | AES-256-GCM + SHA256 |
10
+ | **API 風格** | Form POST | Form POST + AES | RESTful JSON |
11
+ | **內容格式** | application/x-www-form-urlencoded | application/x-www-form-urlencoded | application/json |
12
+ | **市佔率** | 🥇 最高 | 🥈 高 | 🥉 中等 |
13
+ | **支付方式** | 11 種 | 13 種 | 8 種 |
14
+ | **文檔品質** | ⭐⭐⭐⭐⭐ | ⭐⭐⭐⭐ | ⭐⭐⭐ |
15
+ | **測試環境** | ✅ 完整 | ✅ 完整 | ✅ 完整 |
16
+ | **最佳用途** | 高交易量電商 | 多元支付需求 | 新創 API 開發 |
17
+
18
+ ## 常用代碼片段
19
+
20
+ ### ECPay - 快速建立訂單
21
+
22
+ ```typescript
23
+ import crypto from 'crypto'
24
+
25
+ // 1. 生成 CheckMacValue
26
+ function generateECPayCheckMac(params: Record<string, any>, hashKey: string, hashIV: string): string {
27
+ const { CheckMacValue, ...cleanParams } = params
28
+ const sortedKeys = Object.keys(cleanParams).sort()
29
+ const paramString = sortedKeys.map(k => `${k}=${cleanParams[k]}`).join('&')
30
+ const rawString = `HashKey=${hashKey}&${paramString}&HashIV=${hashIV}`
31
+ const encoded = encodeURIComponent(rawString).toLowerCase()
32
+ return crypto.createHash('sha256').update(encoded).digest('hex').toUpperCase()
33
+ }
34
+
35
+ // 2. 建立訂單參數
36
+ const orderParams = {
37
+ MerchantID: '3002607',
38
+ MerchantTradeNo: 'ORD' + Date.now(),
39
+ MerchantTradeDate: new Date().toISOString().replace(/[-:T]/g, '').slice(0, 14),
40
+ PaymentType: 'aio',
41
+ TotalAmount: 1000,
42
+ TradeDesc: '商品描述',
43
+ ItemName: '商品名稱',
44
+ ReturnURL: 'https://yourdomain.com/api/payment/callback',
45
+ ChoosePayment: 'Credit',
46
+ EncryptType: 1
47
+ }
48
+ orderParams.CheckMacValue = generateECPayCheckMac(orderParams, hashKey, hashIV)
49
+
50
+ // 3. POST 到 https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5
51
+ ```
52
+
53
+ ### NewebPay - 快速建立訂單
54
+
55
+ ```typescript
56
+ import crypto from 'crypto'
57
+
58
+ // 1. AES 加密
59
+ function encryptNewebPay(data: Record<string, any>, hashKey: string, hashIV: string) {
60
+ const queryString = new URLSearchParams(data).toString()
61
+ const cipher = crypto.createCipheriv('aes-256-cbc', hashKey, hashIV)
62
+ cipher.setAutoPadding(true)
63
+ let encrypted = cipher.update(queryString, 'utf8', 'hex')
64
+ encrypted += cipher.final('hex')
65
+
66
+ const tradeSha = crypto
67
+ .createHash('sha256')
68
+ .update(`HashKey=${hashKey}&${encrypted}&HashIV=${hashIV}`)
69
+ .digest('hex')
70
+ .toUpperCase()
71
+
72
+ return { TradeInfo: encrypted, TradeSha: tradeSha }
73
+ }
74
+
75
+ // 2. 建立訂單參數
76
+ const orderData = {
77
+ MerchantID: 'YOUR_MERCHANT_ID',
78
+ RespondType: 'JSON',
79
+ TimeStamp: Math.floor(Date.now() / 1000).toString(),
80
+ Version: '2.0',
81
+ MerchantOrderNo: 'ORD' + Date.now(),
82
+ Amt: 1000,
83
+ ItemDesc: '商品描述',
84
+ Email: 'customer@example.com',
85
+ NotifyURL: 'https://yourdomain.com/api/payment/callback',
86
+ ReturnURL: 'https://yourdomain.com/payment/result'
87
+ }
88
+
89
+ const encrypted = encryptNewebPay(orderData, hashKey, hashIV)
90
+
91
+ // 3. POST 到 https://ccore.newebpay.com/MPG/mpg_gateway
92
+ // Body: MerchantID, TradeInfo, TradeSha, Version
93
+ ```
94
+
95
+ ### PAYUNi - 快速建立訂單
96
+
97
+ ```typescript
98
+ import crypto from 'crypto'
99
+
100
+ // 1. AES-GCM 加密
101
+ function encryptPAYUNi(data: Record<string, any>, hashKey: string, hashIV: string) {
102
+ const jsonString = JSON.stringify(data)
103
+ const cipher = crypto.createCipheriv('aes-256-gcm', hashKey, hashIV)
104
+ let encrypted = cipher.update(jsonString, 'utf8', 'hex')
105
+ encrypted += cipher.final('hex')
106
+ const authTag = cipher.getAuthTag().toString('hex')
107
+ const encryptInfo = encrypted + authTag
108
+
109
+ const hashInfo = crypto
110
+ .createHash('sha256')
111
+ .update(`HashKey=${hashKey}&${encryptInfo}&HashIV=${hashIV}`)
112
+ .digest('hex')
113
+ .toUpperCase()
114
+
115
+ return { EncryptInfo: encryptInfo, HashInfo: hashInfo }
116
+ }
117
+
118
+ // 2. 建立訂單參數
119
+ const orderData = {
120
+ MerchantID: 'YOUR_MERCHANT_ID',
121
+ MerchantTradeNo: 'ORD' + Date.now(),
122
+ MerchantTradeDate: new Date().toISOString().slice(0, 19).replace('T', ' '),
123
+ TotalAmount: 1000,
124
+ TradeDesc: '商品描述',
125
+ ItemName: '商品名稱',
126
+ NotifyURL: 'https://yourdomain.com/api/payment/callback',
127
+ ReturnURL: 'https://yourdomain.com/payment/result'
128
+ }
129
+
130
+ const encrypted = encryptPAYUNi(orderData, hashKey, hashIV)
131
+
132
+ // 3. POST 到 https://sandbox-api.payuni.com.tw/api/upp
133
+ // Body: MerchantID, EncryptInfo, HashInfo
134
+ ```
135
+
136
+ ## 付款方式對照表
137
+
138
+ | 付款方式 | ECPay | NewebPay | PAYUNi | 備註 |
139
+ |---------|-------|----------|--------|------|
140
+ | 信用卡一次付清 | `Credit` | `CREDIT` | `credit` | 最常用 |
141
+ | 信用卡分期 | `Credit` + InstallmentFlag | `CREDIT` + InstFlag | `credit` + Installment | 需最低 1000 元 |
142
+ | 信用卡定期 | `Credit` + PeriodType | `CREDIT` + PeriodType | `credit` + Period | 訂閱制 |
143
+ | ATM 虛擬帳號 | `ATM` | `VACC=1` | `atm` | 1-3 天 |
144
+ | 網路 ATM | `WebATM` | `WEBATM=1` | `webatm` | 即時 |
145
+ | 超商代碼 | `CVS` | `CVS=1` | `cvs` | 30-20,000 |
146
+ | 超商條碼 | `BARCODE` | `BARCODE=1` | `barcode` | 20-40,000 |
147
+ | Apple Pay | `ApplePay` | `APPLEPAY=1` | `applepay` | 需申請 |
148
+ | Google Pay | `GooglePay` | `GOOGLEPAY=1` | `googlepay` | 需申請 |
149
+ | LINE Pay | `LINEPAY` | `LINEPAY=1` | ❌ | NewebPay 最佳 |
150
+ | 台灣 Pay | `TWQR` | `P2G=1` | `taiwanpay` | 最高 49,999 |
151
+ | BNPL 無卡分期 | `BNPL` | ❌ | ❌ | ECPay 獨家 |
152
+ | AFTEE 先享後付 | ❌ | ❌ | `aftee` | PAYUNi 獨家 |
153
+
154
+ ## 錯誤碼快速查找
155
+
156
+ ### ECPay 常見錯誤
157
+
158
+ | 錯誤碼 | 說明 | 解決方案 |
159
+ |-------|------|---------|
160
+ | `10100058` | CheckMacValue 錯誤 | 檢查參數排序、URL Encode |
161
+ | `10100003` | 訂單編號重複 | 使用唯一的 MerchantTradeNo |
162
+ | `10100047` | 金額不符 | 檢查 TotalAmount 是否正整數 |
163
+ | `10100073` | 商品名稱錯誤 | ItemName 不可為空 |
164
+ | `10200095` | 付款逾時 | 重新建立訂單 |
165
+
166
+ ### NewebPay 常見錯誤
167
+
168
+ | 錯誤碼 | 說明 | 解決方案 |
169
+ |-------|------|---------|
170
+ | `TRA10001` | 交易失敗 | 檢查加密參數 |
171
+ | `TRA10002` | CheckValue 錯誤 | 檢查 TradeSha 計算 |
172
+ | `TRA10003` | 訂單不存在 | 檢查 MerchantOrderNo |
173
+ | `TRA10004` | 金額錯誤 | 檢查 Amt 是否正整數 |
174
+ | `TRA10005` | 商店代號錯誤 | 檢查 MerchantID |
175
+
176
+ ### PAYUNi 常見錯誤
177
+
178
+ | 錯誤碼 | 說明 | 解決方案 |
179
+ |-------|------|---------|
180
+ | `ER0001` | 參數錯誤 | 檢查必填欄位 |
181
+ | `ER0002` | 簽章錯誤 | 檢查 HashInfo 計算 |
182
+ | `ER0003` | 訂單重複 | 使用唯一訂單號 |
183
+ | `ER0004` | 金額錯誤 | 檢查 TotalAmount |
184
+ | `ER0005` | 商店不存在 | 檢查 MerchantID |
185
+
186
+ ## 測試資料快速複製
187
+
188
+ ### ECPay 測試環境
189
+ ```
190
+ MerchantID: 3002607
191
+ HashKey: pwFHCqoQZGmho4w6
192
+ HashIV: EkRm7iFT261dpevs
193
+ 測試 URL: https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5
194
+ 測試卡號: 4311-9522-2222-2222
195
+ 有效期: 任意未來月年 (如 12/28)
196
+ CVV: 任意 3 碼 (如 123)
197
+ ```
198
+
199
+ ### NewebPay 測試環境
200
+ ```
201
+ 測試 URL: https://ccore.newebpay.com/MPG/mpg_gateway
202
+ 測試卡號: 4000-2211-1111-1111
203
+ 有效期: 任意未來月年 (如 12/28)
204
+ CVV: 任意 3 碼 (如 123)
205
+ 後台: https://cwww.newebpay.com/
206
+ 注意: 需先申請測試帳號
207
+ ```
208
+
209
+ ### PAYUNi 測試環境
210
+ ```
211
+ 測試 URL: https://sandbox-api.payuni.com.tw/api/upp
212
+ 後台: https://sandbox.payuni.com.tw/
213
+ 注意: 需先申請測試帳號
214
+ ```
215
+
216
+ ## 欄位對照表
217
+
218
+ | 用途 | ECPay | NewebPay | PAYUNi |
219
+ |-----|-------|----------|--------|
220
+ | 商店代號 | `MerchantID` | `MerchantID` | `MerchantID` |
221
+ | 訂單編號 | `MerchantTradeNo` | `MerchantOrderNo` | `MerchantTradeNo` |
222
+ | 訂單日期 | `MerchantTradeDate` | `TimeStamp` | `MerchantTradeDate` |
223
+ | 訂單金額 | `TotalAmount` | `Amt` | `TotalAmount` |
224
+ | 商品名稱 | `ItemName` | `ItemDesc` | `ItemName` |
225
+ | 商品描述 | `TradeDesc` | `ItemDesc` | `TradeDesc` |
226
+ | 付款通知 URL | `ReturnURL` | `NotifyURL` | `NotifyURL` |
227
+ | 完成導向 URL | `OrderResultURL` | `ReturnURL` | `ReturnURL` |
228
+ | 付款方式 | `ChoosePayment` | 多個開關 | `PaymentType` |
229
+ | 簽章 | `CheckMacValue` | `TradeSha` | `HashInfo` |
230
+ | 加密資料 | - | `TradeInfo` | `EncryptInfo` |
231
+
232
+ ## 回呼驗證範例
233
+
234
+ ### ECPay 回呼驗證
235
+ ```typescript
236
+ export async function POST(request: Request) {
237
+ const formData = await request.formData()
238
+ const params = Object.fromEntries(formData)
239
+
240
+ // 驗證簽章
241
+ const receivedMac = params.CheckMacValue
242
+ const calculatedMac = generateECPayCheckMac(params, hashKey, hashIV)
243
+
244
+ if (receivedMac !== calculatedMac) {
245
+ return new Response('0|CheckMacValue Error')
246
+ }
247
+
248
+ // 更新訂單
249
+ // ...
250
+
251
+ return new Response('1|OK')
252
+ }
253
+ ```
254
+
255
+ ### NewebPay 回呼驗證
256
+ ```typescript
257
+ export async function POST(request: Request) {
258
+ const formData = await request.formData()
259
+ const tradeInfo = formData.get('TradeInfo') as string
260
+ const tradeSha = formData.get('TradeSha') as string
261
+
262
+ // 驗證 TradeSha
263
+ const calculatedSha = crypto
264
+ .createHash('sha256')
265
+ .update(`HashKey=${hashKey}&${tradeInfo}&HashIV=${hashIV}`)
266
+ .digest('hex')
267
+ .toUpperCase()
268
+
269
+ if (tradeSha !== calculatedSha) {
270
+ return Response.json({ Status: 'ERROR', Message: 'CheckValue Error' })
271
+ }
272
+
273
+ // 解密 TradeInfo
274
+ const decrypted = decryptNewebPay(tradeInfo, hashKey, hashIV)
275
+
276
+ // 更新訂單
277
+ // ...
278
+
279
+ return Response.json({ Status: 'SUCCESS' })
280
+ }
281
+ ```
282
+
283
+ ### PAYUNi 回呼驗證
284
+ ```typescript
285
+ export async function POST(request: Request) {
286
+ const body = await request.json()
287
+ const { EncryptInfo, HashInfo } = body
288
+
289
+ // 驗證 HashInfo
290
+ const calculatedHash = crypto
291
+ .createHash('sha256')
292
+ .update(`HashKey=${hashKey}&${EncryptInfo}&HashIV=${hashIV}`)
293
+ .digest('hex')
294
+ .toUpperCase()
295
+
296
+ if (HashInfo !== calculatedHash) {
297
+ return Response.json({ Status: 'ERROR', Message: 'Hash Error' })
298
+ }
299
+
300
+ // 解密 EncryptInfo
301
+ const decrypted = decryptPAYUNi(EncryptInfo, hashKey, hashIV)
302
+
303
+ // 更新訂單
304
+ // ...
305
+
306
+ return Response.json({ Status: 'SUCCESS' })
307
+ }
308
+ ```
309
+
310
+ ## 智能工具快速使用
311
+
312
+ ```bash
313
+ # 搜索錯誤碼
314
+ python scripts/search.py "10100058" --domain error
315
+
316
+ # 推薦服務商
317
+ python scripts/recommend.py "電商 高交易量"
318
+
319
+ # 測試連線
320
+ python scripts/test_payment.py ecpay
321
+ ```
322
+
323
+ ## 前端表單提交範例
324
+
325
+ ```typescript
326
+ // 通用表單提交函數
327
+ function submitPaymentForm(action: string, params: Record<string, string>) {
328
+ const form = document.createElement('form')
329
+ form.method = 'POST'
330
+ form.action = action
331
+ form.target = '_self'
332
+
333
+ Object.entries(params).forEach(([key, value]) => {
334
+ const input = document.createElement('input')
335
+ input.type = 'hidden'
336
+ input.name = key
337
+ input.value = value
338
+ form.appendChild(input)
339
+ })
340
+
341
+ document.body.appendChild(form)
342
+ form.submit()
343
+ }
344
+
345
+ // ECPay 使用
346
+ submitPaymentForm('https://payment-stage.ecpay.com.tw/Cashier/AioCheckOut/V5', orderParams)
347
+
348
+ // NewebPay 使用
349
+ submitPaymentForm('https://ccore.newebpay.com/MPG/mpg_gateway', {
350
+ MerchantID: merchantID,
351
+ TradeInfo: encrypted.TradeInfo,
352
+ TradeSha: encrypted.TradeSha,
353
+ Version: '2.0'
354
+ })
355
+
356
+ // PAYUNi 使用 (JSON POST,不用表單)
357
+ fetch('https://sandbox-api.payuni.com.tw/api/upp', {
358
+ method: 'POST',
359
+ headers: { 'Content-Type': 'application/json' },
360
+ body: JSON.stringify({
361
+ MerchantID: merchantID,
362
+ EncryptInfo: encrypted.EncryptInfo,
363
+ HashInfo: encrypted.HashInfo
364
+ })
365
+ })
366
+ ```
367
+
368
+ ---
369
+
370
+ 最後更新:2026/01/29