taiwan-logistics-skill 1.4.10 → 1.4.12

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 (43) hide show
  1. package/README.md +103 -106
  2. package/assets/taiwan-logistics/CLAUDE.md +1 -1
  3. package/assets/taiwan-logistics/EXAMPLES.md +37 -26
  4. package/assets/taiwan-logistics/README.md +103 -106
  5. package/assets/taiwan-logistics/README.zh-TW.md +139 -0
  6. package/assets/taiwan-logistics/SKILL.md +116 -681
  7. package/assets/taiwan-logistics/data/field-mappings.csv +23 -23
  8. package/assets/taiwan-logistics/data/logistics-types.csv +58 -57
  9. package/assets/taiwan-logistics/data/operations.csv +53 -51
  10. package/assets/taiwan-logistics/data/pending.csv +34 -0
  11. package/assets/taiwan-logistics/data/providers.csv +21 -21
  12. package/assets/taiwan-logistics/data/status-codes.csv +976 -964
  13. package/assets/taiwan-logistics/evals/RESULTS.md +32 -0
  14. package/assets/taiwan-logistics/evals/cases.json +159 -0
  15. package/assets/taiwan-logistics/evals/grade.py +121 -0
  16. package/assets/taiwan-logistics/examples/ecpay-logistics-cvs-example.py +2 -3
  17. package/assets/taiwan-logistics/examples/hct-logistics-example.py +121 -104
  18. package/assets/taiwan-logistics/examples/newebpay-logistics-cvs-example.py +51 -64
  19. package/assets/taiwan-logistics/examples/pchomepay-logistics-cvs-example.py +4 -4
  20. package/assets/taiwan-logistics/examples/smilepay-logistics-cvs-example.py +127 -92
  21. package/assets/taiwan-logistics/examples/store-map-integration-example.html +0 -7
  22. package/assets/taiwan-logistics/references/NEWEBPAY_LOGISTICS_REFERENCE.md +65 -28
  23. package/assets/taiwan-logistics/references/audit-20261117.md +241 -0
  24. package/assets/taiwan-logistics/references/carrier-direct-access.md +22 -18
  25. package/assets/taiwan-logistics/references/ecpay-logistics-api.md +140 -85
  26. package/assets/taiwan-logistics/references/ezship-logistics-api.md +4 -4
  27. package/assets/taiwan-logistics/references/hct-logistics-api.md +28 -15
  28. package/assets/taiwan-logistics/references/implementation-guide.md +667 -0
  29. package/assets/taiwan-logistics/references/lalamove-logistics-api.md +53 -16
  30. package/assets/taiwan-logistics/references/ondemand-delivery.md +36 -24
  31. package/assets/taiwan-logistics/references/paynow-logistics-api.md +56 -9
  32. package/assets/taiwan-logistics/references/payuni-logistics-api.md +22 -14
  33. package/assets/taiwan-logistics/references/pchomepay-logistics-api.md +46 -42
  34. package/assets/taiwan-logistics/references/smilepay-logistics-api.md +44 -33
  35. package/assets/taiwan-logistics/requirements.txt +4 -0
  36. package/assets/taiwan-logistics/scripts/check_numbers.py +226 -0
  37. package/assets/taiwan-logistics/scripts/core.py +17 -0
  38. package/assets/taiwan-logistics/scripts/search.py +17 -2
  39. package/assets/taiwan-logistics/scripts/test_logistics.py +12 -4
  40. package/assets/taiwan-logistics/scripts/test_skill.py +202 -0
  41. package/assets/templates/base/skill-content.md +129 -694
  42. package/dist/index.js +10 -1
  43. package/package.json +1 -1
package/README.md CHANGED
@@ -1,142 +1,139 @@
1
- <h1 align="center">taiwan-logistics-skill</h1>
1
+ # taiwan-logistics
2
2
 
3
- <h3 align="center">台灣物流 AI 開發技能包</h3>
3
+ A Claude skill for integrating Taiwan logistics APIs: convenience-store pickup, home delivery, store-map selection, cash on delivery and shipment tracking, based on each provider's official documentation.
4
4
 
5
- <p align="center">
6
- <strong>7 家物流 aggregator + HCT 新竹物流直連 + 2 家即時配送</strong>
7
- </p>
5
+ [![npm version](https://img.shields.io/npm/v/taiwan-logistics-skill)](https://www.npmjs.com/package/taiwan-logistics-skill)
6
+ [![License: MIT](https://img.shields.io/github/license/Moksa1123/taiwan-ecommerce-toolkit)](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/LICENSE)
8
7
 
9
- <p align="center">
10
- ECPay · NewebPay · PAYUNi · SmilePay · PChomePay · PayNow · ezShip · HCT 直連 · Lalamove · pandago
11
- </p>
8
+ English | [繁體中文](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/taiwan-logistics/README.zh-TW.md)
12
9
 
13
- <p align="center">
14
- <a href="https://www.npmjs.com/package/taiwan-logistics-skill"><img src="https://img.shields.io/npm/v/taiwan-logistics-skill?style=flat-square&logo=npm" alt="npm version"></a>
15
- <a href="https://www.npmjs.com/package/taiwan-logistics-skill"><img src="https://img.shields.io/npm/dm/taiwan-logistics-skill?style=flat-square&label=downloads" alt="npm downloads"></a>
16
- <img src="https://img.shields.io/badge/providers-10-success?style=flat-square" alt="10 Providers">
17
- <img src="https://img.shields.io/badge/AI%20platforms-14-blue?style=flat-square" alt="14 AI Platforms">
18
- <a href="https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/LICENSE"><img src="https://img.shields.io/github/license/Moksa1123/taiwan-ecommerce-toolkit?style=flat-square" alt="License"></a>
19
- </p>
10
+ This is an unofficial project. It is not affiliated with or endorsed by ECPay, NewebPay, PAYUNi, SmilePay, PChomePay, PayNow, ezShip, HCT, Lalamove, pandago, the convenience-store chains or any other company named here. Brand names are written the way each company writes them and belong to their owners.
20
11
 
21
- <p align="center">
22
- <a href="https://paypal.me/cccsubcom"><img src="https://img.shields.io/badge/PayPal-支持開發-00457C?style=for-the-badge&logo=paypal&logoColor=white" alt="PayPal"></a>
23
- </p>
12
+ ## What it does
24
13
 
25
- ---
14
+ - Covers 7 aggregators with a logistics API (ECPay, NewebPay, PAYUNi, SmilePay, PChomePay, PayNow, ezShip), the HCT direct carrier API, and on-demand delivery (Lalamove, pandago).
15
+ - Gives Claude each provider's signing and encryption rules (MD5 CheckMacValue, AES-256-CBC, AES-256-GCM, 3DES) with runnable Python examples.
16
+ - Searches 1126 rows of data offline with `scripts/search.py`: providers, API operations, logistics types, field mappings and shipment status codes.
17
+ - Generates a service module for a provider (`scripts/generate-logistics-service.py`) and suggests a provider from plain-language requirements (`scripts/recommend.py`).
18
+ - Covers convenience-store pickup (7-ELEVEN, FamilyMart, Hi-Life, OK mart), home delivery, cold chain, store-map selectors, cash on delivery and tracking.
26
19
 
27
- ## 安裝
20
+ ## When to use
28
21
 
29
- ```bash
30
- npm install -g taiwan-logistics-skill
31
- ```
22
+ Use it when you are:
32
23
 
33
- ## 快速開始
24
+ - building a shipping flow with convenience-store pickup or home delivery;
25
+ - adding a store-map selector to a checkout;
26
+ - creating shipments, printing labels or reading status callbacks;
27
+ - looking up what a logistics status code means, or choosing a provider.
34
28
 
35
- ```bash
36
- cd /path/to/your/project
29
+ Use something else for:
30
+
31
+ - collecting payment, including the payment side of ECPay, NewebPay or PAYUNi: use [taiwan-payment](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/tree/main/taiwan-payment);
32
+ - issuing e-invoices: use [taiwan-invoice](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/tree/main/taiwan-invoice);
33
+ - shipping outside Taiwan, or a carrier contract that has no public API: not covered (the skill says so instead of guessing).
34
+
35
+ ## Install
36
+
37
+ Requirements: Python 3 for the scripts, which use only the standard library. The files in `examples/` and the network options of `scripts/test_logistics.py` also need `pycryptodome` (AES, 3DES) and `requests`; install them with `pip install -r requirements.txt`. Node.js 18 or later is needed only for the npx installer. Works on Windows, macOS and Linux.
37
38
 
38
- taiwan-logistics init # 互動式
39
- taiwan-logistics init --ai claude # Claude Code
40
- taiwan-logistics init --ai all # 全部安裝
39
+ Claude Code plugin (installs all three Taiwan skills: invoice, payment, logistics):
40
+
41
+ ```text
42
+ /plugin marketplace add Moksa1123/taiwan-ecommerce-toolkit
43
+ /plugin install taiwan-ecommerce@taiwan-ecommerce-toolkit
41
44
  ```
42
45
 
43
- 安裝完後,在 AI 助手用自然語言:
46
+ npx (copies the skill into the current project; `--ai` also accepts other agents such as `cursor` or `codex`, `--global` installs into your home directory):
44
47
 
48
+ ```bash
49
+ npx taiwan-logistics-skill@1.4.12 init --ai claude
45
50
  ```
46
- 查詢台北市信義區的 7-11 取貨點,整合 ECPay 物流
47
- 建立 SmilePay 黑貓宅急便冷凍 C2C 訂單,COD 1000 元
48
- PChomePay 7-11 取貨付款,金額 1500 元,notify URL 設好
49
- PayNow 7-11 大宗寄倉,使用 3DES 加密
50
- HCT 直連 API 傳入託運資料,逆物流單獨處理
51
+
52
+ Manual copy:
53
+
54
+ ```bash
55
+ git clone https://github.com/Moksa1123/taiwan-ecommerce-toolkit.git
56
+ cp -r taiwan-ecommerce-toolkit/taiwan-logistics ~/.claude/skills/
51
57
  ```
52
58
 
53
- ---
59
+ ## Quick start
54
60
 
55
- ## 物流服務商
61
+ Ask Claude, for example:
56
62
 
57
- | 服務商 | 類型 | 加密 / 認證 | 特色 |
58
- |---|---|---|---|
59
- | **ECPay 綠界** | aggregator | MD5 CheckMacValue | B2C 7-11(含冷凍)/全家/萊爾富;C2C 四大超商;宅配黑貓/中華郵政 |
60
- | **NewebPay 藍新** | aggregator | AES-256-CBC + SHA256 | B2C 僅 7-11;C2C 四大超商;無宅配 |
61
- | **PAYUNi 統一** | aggregator | AES-256-GCM + SHA256 | 7-11 常溫/冷凍 + T-Cat 常溫/冷藏/冷凍(溫控配送最完整) |
62
- | **SmilePay 速買配** | aggregator | Verify_key + 加權檢核碼 | Pay_zg 矩陣 51/52/55/56/81/82/83,含逆物流 |
63
- | **PChomePay 拍錢包** | aggregator | HTTP Basic Auth → token | 金物流二合一、7-11/全家/萊爾富取貨付款 |
64
- | **PayNow 立吉富** | aggregator | **3DES/ECB/Zero-Padding** | 11 條產品線(含海外配送);不同於金流端 AES |
65
- | **ezShip 台灣便利配** | aggregator | 無簽章(`su_id` 帳號綁定) | 全家/萊爾富/OK、宅配、店港澳;不含 7-11 |
66
- | **HCT 新竹物流** | **direct carrier API** | 申請後提供金鑰 | 收錄的聚合商都沒有新竹物流選項,只能直連 |
67
- | **Lalamove** | 即時配送 | HMAC-SHA256 自簽 | 先報價後下單(報價 5 分鐘效期) |
68
- | **pandago** | 即時配送 | OAuth 2.0 + RSA 簽 JWT assertion | 同城即時配送 |
69
-
70
- ## 技能包內容
63
+ - "Add ECPay convenience-store pickup with a store map to my checkout, in Python."
64
+ - "Create a PAYUNi home-delivery shipment and download the label."
65
+ - "What does ECPay logistics status 2073 mean?"
66
+
67
+ Or search the data yourself from the skill folder:
71
68
 
69
+ ```bash
70
+ python3 scripts/search.py "2073" --domain status --max 1
72
71
  ```
73
- taiwan-logistics/
74
- ├── SKILL.md # AI 技能主文檔
75
- ├── EXAMPLES.md # 實戰範例集
76
- ├── references/ # 各服務商 API 規格
77
- │ ├── ecpay-logistics-api.md
78
- │ ├── NEWEBPAY_LOGISTICS_REFERENCE.md
79
- │ ├── payuni-logistics-api.md
80
- │ ├── smilepay-logistics-api.md # Pay_zg 矩陣
81
- │ ├── pchomepay-logistics-api.md # NDJSON 對帳 parser
82
- │ ├── paynow-logistics-api.md # Logistic_service 產品線
83
- │ ├── ezship-logistics-api.md
84
- │ ├── hct-logistics-api.md # 直連 HCT
85
- │ ├── lalamove-logistics-api.md
86
- │ ├── ondemand-delivery.md # Lalamove / pandago
87
- │ └── carrier-direct-access.md # 無公開 API 的物流業者與替代路徑
88
- ├── examples/ # Python 範例
89
- └── data/ # search / recommend 使用的 CSV
90
- ├── providers.csv # 可串接 + 僅供查詢
91
- ├── operations.csv
92
- ├── logistics-types.csv # 各家實際參數值(子類型/溫層/代收上限)
93
- ├── status-codes.csv # 跨服務商狀態碼
94
- └── field-mappings.csv # 欄位對照
72
+
73
+ Expected output (shortened):
74
+
75
+ ```text
76
+ 搜索查詢: '2073' (域: status)
77
+ [1] 分數: 7.62 | 域: status
78
+ provider: ecpay
79
+ code: 2073
80
+ status_zh: 包裹配達取件門市
81
+ category: at_store
82
+ description: 物流商:UNIMART、UNIMARTC2C、HILIFE、HILIFEC2C
83
+ doc_url: https://developers.ecpay.com.tw/7380/
84
+ trust: 官方文件
95
85
  ```
96
86
 
97
- ## CLI 指令
87
+ ## Trigger phrases
98
88
 
99
- ```bash
100
- taiwan-logistics list # 列出 AI 平台
101
- taiwan-logistics info # 技能資訊
102
- taiwan-logistics update # 檢查更新
103
- taiwan-logistics init --force # 覆蓋安裝
104
- taiwan-logistics init --global # 全域安裝
105
- ```
89
+ English: Taiwan logistics, CVS pickup, convenience-store pickup, store-to-store shipping, store map, home delivery, cold chain, cash on delivery, shipment tracking, logistics status code, HCT, Lalamove, on-demand delivery.
90
+
91
+ 中文:物流串接、超商取貨、店到店、大宗寄倉、取貨付款、電子地圖選店、宅配、冷凍、物流狀態碼、托運單、新竹物流、即時配送。
106
92
 
107
- ## 14 個 AI 平台支援
93
+ ## What it runs and connects to
108
94
 
109
- Claude Code · Cursor · Windsurf · Antigravity · GitHub Copilot · Kiro · Codex · Qoder · Cline · Gemini · Trae · OpenCode · Continue · CodeBuddy
95
+ The skill is Markdown documentation, CSV data and local Python scripts. It never sends data anywhere on its own. Network calls happen only when you run a connectivity option of the test script or run an example file.
110
96
 
111
- ## 物流類型支援矩陣
97
+ | Script | What it does | Network | Files written |
98
+ |---|---|---|---|
99
+ | `scripts/search.py` | Searches `data/*.csv` | None | None |
100
+ | `scripts/recommend.py` | Suggests a provider from `data/*.csv` | None | None |
101
+ | `scripts/generate-logistics-service.py` | Prints a Python or TypeScript module for a provider | None | None (writes to standard output) |
102
+ | `scripts/test_logistics.py` | Known-answer test of ECPay signing; offline by default | `--live`: HEAD request to the sandbox of ECPay (`logistics-stage.ecpay.com.tw`), NewebPay (`ccore.newebpay.com`) and PAYUNi (`sandbox-api.payuni.com.tw`). `--create` and `--query`: POST to the ECPay logistics sandbox | None |
103
+ | `scripts/check_numbers.py` | Checks that every number in `SKILL.md` and these READMEs matches the data | None | With `--fix`, those three files |
104
+ | `scripts/test_skill.py` | Self-test; runs the checks above offline | None | None |
105
+ | `examples/*.py` | Reference clients for each provider | When run directly, calls the sandbox or production host defined at the top of that file | None |
106
+ | `examples/store-map-integration-example.html` | Store-map sample page and server code | None by itself; callback URLs are placeholders | None |
112
107
 
113
- 依各家官方規格整理,實際參數值見 `data/logistics-types.csv`。
108
+ Credentials (merchant ID, HashKey and HashIV, API keys and secrets, carrier account numbers) are supplied by you in your own code or configuration, for example environment variables. The repository stores no real credentials. Test values that appear in the docs and scripts are the providers' published sandbox values.
114
109
 
115
- | 服務商 | 7-11 | 全家 | 萊爾富 | OK | 黑貓 | 其他 |
116
- |---|---|---|---|---|---|---|
117
- | ECPay | B2C(含冷凍)+ C2C | B2C + C2C | B2C + C2C | C2C | 常溫/冷藏/冷凍 | 中華郵政 |
118
- | NewebPay | B2C + C2C | C2C | C2C | C2C | — | — |
119
- | PAYUNi | B2C + C2C(常溫/冷凍) | — | — | — | 常溫/冷凍/冷藏 | — |
120
- | SmilePay | B2C + C2C | C2C | — | — | 含逆物流 | — |
121
- | PChomePay | 取貨付款 | 取貨付款 | 取貨付款 | — | — | — |
122
- | PayNow | B2C + C2C(含冷凍) | B2C + C2C(含冷凍) | C2C | C2C | 宅配、到店 | 7-11 海外 |
123
- | ezShip | — | C2C | C2C | C2C | — | 宅配、店港澳 |
124
- | HCT 直連 | — | — | — | — | — | 新竹物流 |
110
+ ## How it's verified
125
111
 
126
- ## 相關套件
112
+ - Data source: official provider API documentation, PDF specifications and SDKs. Every source is registered in [`sources/official-sources.json`](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/sources/official-sources.json), and each data row carries `doc_url` and `trust`.
113
+ - Self-test: `python3 scripts/test_skill.py` runs 42 checks, 0 failures (run on 2026-11-17).
114
+ - Evals: on the 11 scored questions, Claude answered 11 correctly with the skill and 0 without it. See [`evals/RESULTS.md`](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/taiwan-logistics/evals/RESULTS.md).
115
+ - CI runs `scripts/verify-examples.py`, which compares the example code byte for byte with expected values produced by the providers' own SDKs and spec samples ([`tests/vectors/`](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/tree/main/tests/vectors)).
127
116
 
128
- 本套件是 **[Taiwan E-Commerce Toolkit](https://github.com/Moksa1123/taiwan-ecommerce-toolkit)** 的一部分:
117
+ ## Limits
129
118
 
130
- - [taiwan-invoice-skill](https://www.npmjs.com/package/taiwan-invoice-skill) — 7 家電子發票加值中心 + 財政部大平台查詢
131
- - [taiwan-payment-skill](https://www.npmjs.com/package/taiwan-payment-skill) — 14 家金流
119
+ - Convenience-store chains, T-cat, Chunghwa Post and other carriers without a public API are listed only so Claude can say so; reach them through an aggregator.
120
+ - Lalamove and pandago have references but no runnable example. HCT documentation is available only after applying to HCT.
121
+ - `test_logistics.py --create` and `--query` work with ECPay only; NewebPay and PAYUNi need your own merchant account.
122
+ - Known gaps are tracked in [`data/pending.csv`](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/taiwan-logistics/data/pending.csv).
132
123
 
133
- ## 授權
124
+ ## Repo layout
134
125
 
135
- [MIT License](https://github.com/Moksa1123/taiwan-ecommerce-toolkit/blob/main/LICENSE)
126
+ ```text
127
+ taiwan-logistics/
128
+ ├── SKILL.md # instructions Claude reads
129
+ ├── EXAMPLES.md # longer code examples
130
+ ├── references/ # one API reference per provider, on-demand overview
131
+ ├── examples/ # runnable Python clients and a store-map page
132
+ ├── data/ # CSV data for search.py and recommend.py; pending.csv
133
+ ├── scripts/ # search, recommend, generator, tests, number check
134
+ └── evals/ # eval questions, grader and results
135
+ ```
136
136
 
137
- ---
137
+ ## License & author
138
138
 
139
- <p align="center">
140
- <sub>Made by <strong>Moksa</strong></sub><br>
141
- <sub>service@moksaweb.com</sub>
142
- </p>
139
+ MIT License. Made by Moksa ([moksaweb.com](https://moksaweb.com)). Part of [Taiwan E-commerce Toolkit](https://github.com/Moksa1123/taiwan-ecommerce-toolkit).
@@ -130,7 +130,7 @@ When modifying files:
130
130
  | NewebPay 藍新 | AES-256-CBC + SHA256 | HashData = SHA256(`HashKey=..&EncryptData&HashIV=..`);送出欄位帶 `_`,回應不帶 |
131
131
  | PAYUNi 統一 | AES-256-GCM + SHA256 | EncryptInfo = hex(base64(密文) + `:::` + base64(tag));HashInfo = SHA256(HashKey + EncryptInfo + HashIV) |
132
132
  | SmilePay 速買配 | Verify_key + Mid_smilepay 加權檢核碼 | No AES; shared secret |
133
- | PChomePay 拍錢包 | HTTP Basic Auth → 8h pcpay-token | Same as payment side |
133
+ | PChomePay支付連 | HTTP Basic Auth → 8h pcpay-token;Notify 須 3 秒內回 `success` | Same as payment side |
134
134
  | PayNow 立吉富 | **3DES (TripleDES) / ECB / Zero-Padding → Base64** | Key = `1234567890` + Password + `123456`(24 bytes);ECB 不使用 IV;PassCode = SHA1;**不同於金流端的動態 AES-256** |
135
135
  | HCT 直連 | 自訂加密(金鑰申請後提供) | C# sample code only |
136
136
 
@@ -1088,7 +1088,10 @@ const logistics = new NewebPayLogistics({
1088
1088
  */
1089
1089
  app.post('/callback/shipment-status', async (req, res) => {
1090
1090
  try {
1091
- const { Status, Message, EncryptData_, HashData_, UID_, Version_ } = req.body;
1091
+ const { Status, Message, UID_, Version_ } = req.body;
1092
+ // 規格書表格帶底線,官方範例 notify_url.php 讀無底線,兩種都讀
1093
+ const EncryptData_ = req.body.EncryptData_ ?? req.body.EncryptData;
1094
+ const HashData_ = req.body.HashData_ ?? req.body.HashData;
1092
1095
 
1093
1096
  console.log('Received notification:', {
1094
1097
  Status,
@@ -1099,7 +1102,7 @@ app.post('/callback/shipment-status', async (req, res) => {
1099
1102
 
1100
1103
  if (Status !== 'SUCCESS') {
1101
1104
  console.error('Notification error:', Message);
1102
- return res.send('0|Error');
1105
+ return res.sendStatus(200);
1103
1106
  }
1104
1107
 
1105
1108
  // Decrypt data
@@ -1119,11 +1122,11 @@ app.post('/callback/shipment-status', async (req, res) => {
1119
1122
  eventTime: data.EventTime,
1120
1123
  });
1121
1124
 
1122
- // Return success
1123
- res.send('1|OK');
1125
+ // 規格書未規定回應內容,回 HTTP 200 即可
1126
+ res.sendStatus(200);
1124
1127
  } catch (error) {
1125
1128
  console.error('Callback error:', error);
1126
- res.send('0|Error');
1129
+ res.sendStatus(500);
1127
1130
  }
1128
1131
  });
1129
1132
 
@@ -1199,14 +1202,15 @@ def shipment_status_callback():
1199
1202
 
1200
1203
  status = data.get('Status')
1201
1204
  message = data.get('Message')
1202
- encrypt_data = data.get('EncryptData_')
1203
- hash_data = data.get('HashData_')
1205
+ # 規格書表格帶底線,官方範例 notify_url.php 讀無底線,兩種都讀
1206
+ encrypt_data = data.get('EncryptData_') or data.get('EncryptData')
1207
+ hash_data = data.get('HashData_') or data.get('HashData')
1204
1208
 
1205
1209
  app.logger.info(f'Received notification: {status} - {message}')
1206
1210
 
1207
1211
  if status != 'SUCCESS':
1208
1212
  app.logger.error(f'Notification error: {message}')
1209
- return '0|Error'
1213
+ return '', 200
1210
1214
 
1211
1215
  # Decrypt data
1212
1216
  decrypted = logistics.decrypt_data(encrypt_data, hash_data)
@@ -1216,12 +1220,12 @@ def shipment_status_callback():
1216
1220
  # Process the notification
1217
1221
  process_shipment_status_update(decrypted)
1218
1222
 
1219
- # Return success
1220
- return '1|OK'
1223
+ # 規格書未規定回應內容,回 HTTP 200 即可
1224
+ return '', 200
1221
1225
 
1222
1226
  except Exception as e:
1223
1227
  app.logger.error(f'Callback error: {str(e)}')
1224
- return '0|Error'
1228
+ return '', 500
1225
1229
 
1226
1230
 
1227
1231
  def process_shipment_status_update(data: Dict[str, any]):
@@ -1507,7 +1511,7 @@ import axios from 'axios';
1507
1511
 
1508
1512
  interface CreateCVSShipmentRequest {
1509
1513
  merTradeNo: string;
1510
- logisticsSubType: 'FAMIC2C' | 'UNIMARTC2C' | 'HILIFEC2C' | 'OKMARTC2C';
1514
+ logisticsSubType: 'FAMIC2C' | 'UNIMARTC2C' | 'HILIFEC2C';
1511
1515
  goodsAmount: number;
1512
1516
  goodsName: string;
1513
1517
  senderName: string;
@@ -1564,9 +1568,13 @@ class ECPayCVSLogistics extends ECPayLogistics {
1564
1568
  }
1565
1569
  );
1566
1570
 
1567
- // Parse response (1=key&value format)
1571
+ // Parse response: "1|key=value&key=value" on success, "0|ErrorMessage" on failure
1572
+ const [flag, body = ''] = String(response.data).split(/\|(.*)/s);
1573
+ if (flag !== '1') {
1574
+ throw new Error(`Create shipment failed: ${body}`);
1575
+ }
1568
1576
  const result: Record<string, string> = {};
1569
- response.data.split('&').forEach((item: string) => {
1577
+ body.split('&').forEach((item: string) => {
1570
1578
  const [key, value] = item.split('=');
1571
1579
  if (key && value) {
1572
1580
  result[key] = decodeURIComponent(value);
@@ -1632,7 +1640,7 @@ from dataclasses import dataclass
1632
1640
  class CVSShipmentData:
1633
1641
  """CVS C2C 物流訂單資料"""
1634
1642
  mer_trade_no: str
1635
- logistics_sub_type: Literal['FAMIC2C', 'UNIMARTC2C', 'HILIFEC2C', 'OKMARTC2C']
1643
+ logistics_sub_type: Literal['FAMIC2C', 'UNIMARTC2C', 'HILIFEC2C']
1636
1644
  goods_amount: int
1637
1645
  goods_name: str
1638
1646
  sender_name: str
@@ -1665,11 +1673,10 @@ class ECPayCVSLogistics(ECPayLogistics):
1665
1673
  - FAMIC2C: 全家店到店
1666
1674
  - UNIMARTC2C: 7-11 交貨便
1667
1675
  - HILIFEC2C: 萊爾富店到店
1668
- - OKMARTC2C: OK 店到店(OK 只有 C2C)
1669
1676
 
1670
1677
  回傳碼:
1671
1678
  - 300: 訂單建立成功 (尚未寄貨)
1672
- - 2001: 訂單建立成功 (門市已出貨)
1679
+ - 2001: 訂單傳送超商成功
1673
1680
  """
1674
1681
 
1675
1682
  def create_cvs_shipment(
@@ -1740,9 +1747,12 @@ class ECPayCVSLogistics(ECPayLogistics):
1740
1747
  except requests.RequestException as e:
1741
1748
  raise Exception(f"API 請求失敗: {str(e)}")
1742
1749
 
1743
- # 解析回應 (格式: key1=value1&key2=value2)
1750
+ # 解析回應(成功:1|key1=value1&key2=value2;失敗:0|錯誤訊息)
1751
+ flag, _, body = response.text.partition('|')
1752
+ if flag != '1':
1753
+ return CVSShipmentResponse(success=False, rtn_code='', rtn_msg=body, raw={})
1744
1754
  result = {}
1745
- for item in response.text.split('&'):
1755
+ for item in body.split('&'):
1746
1756
  if '=' in item:
1747
1757
  key, value = item.split('=', 1)
1748
1758
  result[key] = urllib.parse.unquote(value)
@@ -1966,7 +1976,7 @@ class ECPayQueryLogistics extends ECPayLogistics {
1966
1976
  data['CheckMacValue'] = this.generateCheckMacValue(data);
1967
1977
 
1968
1978
  const response = await axios.post(
1969
- `${this.baseUrl}/Helper/QueryLogisticsTradeInfo/V2`,
1979
+ `${this.baseUrl}/Helper/QueryLogisticsTradeInfo/V5`,
1970
1980
  new URLSearchParams(data),
1971
1981
  {
1972
1982
  headers: {
@@ -1987,9 +1997,10 @@ class ECPayQueryLogistics extends ECPayLogistics {
1987
1997
  merchantTradeNo: result.MerchantTradeNo,
1988
1998
  goodsAmount: result.GoodsAmount,
1989
1999
  logisticsStatus: result.LogisticsStatus,
1990
- receiverName: result.ReceiverName,
1991
- receiverStoreID: result.ReceiverStoreID,
1992
- updateStatusDate: result.UpdateStatusDate,
2000
+ logisticsType: result.LogisticsType,
2001
+ shipmentNo: result.ShipmentNo,
2002
+ bookingNote: result.BookingNote,
2003
+ tradeDate: result.TradeDate,
1993
2004
  };
1994
2005
  }
1995
2006
  }
@@ -2541,12 +2552,12 @@ SmilePay 透過 `Pay_zg` 矩陣編碼涵蓋 7-11/全家 + 黑貓三大配送:
2541
2552
  ### 三大要點
2542
2553
 
2543
2554
  1. **Pay_subzg**:`7NET` 對應 7-11、`FAMI` 對應全家。
2544
- 2. **回應是 XML**:用 `xml.etree.ElementTree` parse;常用欄位 `Status` / `PaymentNo` / `Smseid` / `Storeid`。
2545
- 3. **電子地圖選店**:先導轉到 `LogisticsEmap.asp`,客戶選完門市後 SmilePay 會 redirect 回 RtURL 並帶 storeid/storename。
2555
+ 2. **回應是 XML**:用 `xml.etree.ElementTree` parse;取號回 `Status` / `Desc` / `SmilePayNO`,C2C 第二階段回 `paymentno` + `validationno`(根元素 `<SmilePayC2C>`),失敗時 `Status` 為負數。
2556
+ 3. **電子地圖選店**:導轉到 `LogisticsEmap.asp?method=GET&TypesServer=…&TypesInterface=…&tempvar=…&url=…`,選完門市後 SmilePay 帶 `storeid`/`storename`/`storeaddress`/`typesserver`(全小寫)回到 `url`。
2546
2557
 
2547
2558
  ---
2548
2559
 
2549
- ## PChomePay 拍錢包物流範例
2560
+ ## PChomePay支付連物流範例
2550
2561
 
2551
2562
  ⚠️ Notify IP 必加白名單:**`113.196.231.190`**。
2552
2563