taiwan-logistics-skill 1.2.2 → 1.3.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 (46) hide show
  1. package/README.md +132 -132
  2. package/assets/taiwan-logistics/CLAUDE.md +147 -137
  3. package/assets/taiwan-logistics/EXAMPLES.md +3258 -3258
  4. package/assets/taiwan-logistics/README.md +132 -132
  5. package/assets/taiwan-logistics/SKILL.md +845 -845
  6. package/assets/taiwan-logistics/data/field-mappings.csv +23 -27
  7. package/assets/taiwan-logistics/data/logistics-types.csv +29 -25
  8. package/assets/taiwan-logistics/data/operations.csv +32 -32
  9. package/assets/taiwan-logistics/data/providers.csv +20 -15
  10. package/assets/taiwan-logistics/data/status-codes.csv +89 -35
  11. package/assets/taiwan-logistics/examples/ecpay-logistics-cvs-example.py +175 -175
  12. package/assets/taiwan-logistics/examples/newebpay-logistics-cvs-example.py +524 -524
  13. package/assets/taiwan-logistics/examples/payuni-logistics-cvs-example.py +605 -605
  14. package/assets/taiwan-logistics/examples/store-map-integration-example.html +573 -573
  15. package/assets/taiwan-logistics/references/NEWEBPAY_LOGISTICS_REFERENCE.md +774 -774
  16. package/assets/taiwan-logistics/references/carrier-direct-access.md +134 -0
  17. package/assets/taiwan-logistics/references/ecpay-logistics-api.md +536 -536
  18. package/assets/taiwan-logistics/references/ezship-logistics-api.md +103 -0
  19. package/assets/taiwan-logistics/references/hct-logistics-api.md +1102 -1102
  20. package/assets/taiwan-logistics/references/lalamove-logistics-api.md +138 -0
  21. package/assets/taiwan-logistics/references/paynow-logistics-api.md +1670 -1670
  22. package/assets/taiwan-logistics/references/payuni-logistics-api.md +712 -712
  23. package/assets/taiwan-logistics/references/pchomepay-logistics-api.md +1154 -1154
  24. package/assets/taiwan-logistics/references/smilepay-logistics-api.md +1332 -1332
  25. package/assets/taiwan-logistics/scripts/core.py +276 -276
  26. package/assets/taiwan-logistics/scripts/generate-logistics-service.py +1248 -1248
  27. package/assets/taiwan-logistics/scripts/recommend.py +370 -364
  28. package/assets/taiwan-logistics/scripts/search.py +127 -127
  29. package/assets/taiwan-logistics/scripts/test_logistics.py +300 -300
  30. package/assets/templates/base/quick-reference.md +74 -74
  31. package/assets/templates/base/skill-content.md +845 -845
  32. package/assets/templates/platforms/agent.json +26 -26
  33. package/assets/templates/platforms/claude.json +26 -26
  34. package/assets/templates/platforms/codebuddy.json +25 -25
  35. package/assets/templates/platforms/codex.json +26 -26
  36. package/assets/templates/platforms/continue.json +25 -25
  37. package/assets/templates/platforms/copilot.json +25 -25
  38. package/assets/templates/platforms/cursor.json +26 -26
  39. package/assets/templates/platforms/gemini.json +25 -25
  40. package/assets/templates/platforms/kiro.json +25 -25
  41. package/assets/templates/platforms/opencode.json +25 -25
  42. package/assets/templates/platforms/qoder.json +25 -25
  43. package/assets/templates/platforms/roocode.json +25 -25
  44. package/assets/templates/platforms/trae.json +25 -25
  45. package/assets/templates/platforms/windsurf.json +25 -25
  46. package/package.json +65 -65
@@ -1,175 +1,175 @@
1
- #!/usr/bin/env python3
2
- """
3
- ECPay 超商取貨範例
4
- 示範如何使用 ECPay 物流 API 建立、查詢、列印超商取貨訂單
5
- """
6
-
7
- import hashlib
8
- import urllib.parse
9
- from datetime import datetime
10
-
11
-
12
- class ECPayLogistics:
13
- """ECPay 物流 API 封裝"""
14
-
15
- def __init__(self, merchant_id, hash_key, hash_iv, test_mode=True):
16
- self.merchant_id = merchant_id
17
- self.hash_key = hash_key
18
- self.hash_iv = hash_iv
19
- self.api_url = "https://logistics-stage.ecpay.com.tw" if test_mode else "https://logistics.ecpay.com.tw"
20
-
21
- def create_check_mac_value(self, params):
22
- """生成 CheckMacValue"""
23
- # 1. 參數排序
24
- sorted_params = sorted(params.items())
25
-
26
- # 2. 串接字串
27
- param_str = "&".join([f"{k}={v}" for k, v in sorted_params])
28
-
29
- # 3. 加上 HashKey 和 HashIV
30
- raw_str = f"HashKey={self.hash_key}&{param_str}&HashIV={self.hash_iv}"
31
-
32
- # 4. URL Encode
33
- encoded_str = urllib.parse.quote(raw_str, safe="")
34
-
35
- # 5. 轉小寫
36
- encoded_str = encoded_str.lower()
37
-
38
- # 6. SHA256 加密
39
- hash_value = hashlib.sha256(encoded_str.encode('utf-8')).hexdigest()
40
-
41
- # 7. 轉大寫
42
- return hash_value.upper()
43
-
44
- def create_cvs_order(self, order_id, goods_name, goods_amount, receiver_name,
45
- receiver_phone, receiver_store_id, logistics_sub_type="UNIMARTC2C"):
46
- """建立超商取貨訂單"""
47
- params = {
48
- "MerchantID": self.merchant_id,
49
- "MerchantTradeNo": order_id,
50
- "MerchantTradeDate": datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
51
- "LogisticsType": "CVS",
52
- "LogisticsSubType": logistics_sub_type, # UNIMARTC2C, FAMIC2C, HILIFEC2C
53
- "GoodsAmount": goods_amount,
54
- "GoodsName": goods_name,
55
- "SenderName": "測試商家",
56
- "SenderPhone": "0212345678",
57
- "SenderCellPhone": "0912345678",
58
- "ReceiverName": receiver_name,
59
- "ReceiverCellPhone": receiver_phone,
60
- "ReceiverStoreID": receiver_store_id,
61
- "ServerReplyURL": "https://yourdomain.com/logistics/callback",
62
- "IsCollection": "N", # 是否代收貨款
63
- "Temperature": "0001", # 常溫
64
- "Distance": "00", # 距離
65
- "Specification": "0001", # 60cm
66
- }
67
-
68
- # 生成 CheckMacValue
69
- params["CheckMacValue"] = self.create_check_mac_value(params)
70
-
71
- return params
72
-
73
- def query_order(self, logistics_id):
74
- """查詢物流訂單"""
75
- params = {
76
- "MerchantID": self.merchant_id,
77
- "AllPayLogisticsID": logistics_id,
78
- "TimeStamp": str(int(datetime.now().timestamp())),
79
- }
80
-
81
- params["CheckMacValue"] = self.create_check_mac_value(params)
82
-
83
- return params
84
-
85
- def print_order(self, logistics_id):
86
- """列印託運單"""
87
- params = {
88
- "MerchantID": self.merchant_id,
89
- "AllPayLogisticsID": logistics_id,
90
- }
91
-
92
- params["CheckMacValue"] = self.create_check_mac_value(params)
93
-
94
- return params
95
-
96
-
97
- def example_create_order():
98
- """範例1: 建立超商取貨訂單"""
99
- print("\n=== 範例1: 建立超商取貨訂單 ===\n")
100
-
101
- # 初始化 ECPay
102
- ecpay = ECPayLogistics(
103
- merchant_id="2000132", # 測試商店代號
104
- hash_key="5294y06JbISpM5x9", # 測試 HashKey
105
- hash_iv="v77hoKGq4kWxNNIS", # 測試 HashIV
106
- test_mode=True
107
- )
108
-
109
- # 建立訂單
110
- order_id = f"ORDER{int(datetime.now().timestamp())}"
111
- params = ecpay.create_cvs_order(
112
- order_id=order_id,
113
- goods_name="測試商品",
114
- goods_amount=100,
115
- receiver_name="王小明",
116
- receiver_phone="0912345678",
117
- receiver_store_id="991182", # 7-11 門市代號
118
- logistics_sub_type="UNIMARTC2C" # 7-11 店到店
119
- )
120
-
121
- print("訂單參數:")
122
- for key, value in params.items():
123
- print(f" {key}: {value}")
124
-
125
-
126
- def example_query_order():
127
- """範例2: 查詢物流訂單"""
128
- print("\n=== 範例2: 查詢物流訂單 ===\n")
129
-
130
- ecpay = ECPayLogistics(
131
- merchant_id="2000132",
132
- hash_key="5294y06JbISpM5x9",
133
- hash_iv="v77hoKGq4kWxNNIS",
134
- test_mode=True
135
- )
136
-
137
- # 查詢訂單 (使用物流交易編號)
138
- logistics_id = "10001234567" # 綠界物流交易編號
139
- params = ecpay.query_order(logistics_id)
140
-
141
- print("查詢參數:")
142
- for key, value in params.items():
143
- print(f" {key}: {value}")
144
-
145
-
146
- def example_print_order():
147
- """範例3: 列印託運單"""
148
- print("\n=== 範例3: 列印託運單 ===\n")
149
-
150
- ecpay = ECPayLogistics(
151
- merchant_id="2000132",
152
- hash_key="5294y06JbISpM5x9",
153
- hash_iv="v77hoKGq4kWxNNIS",
154
- test_mode=True
155
- )
156
-
157
- # 列印託運單
158
- logistics_id = "10001234567"
159
- params = ecpay.print_order(logistics_id)
160
-
161
- print("列印參數:")
162
- for key, value in params.items():
163
- print(f" {key}: {value}")
164
-
165
-
166
- if __name__ == "__main__":
167
- print("ECPay 物流 API 範例")
168
- print("=" * 50)
169
-
170
- example_create_order()
171
- example_query_order()
172
- example_print_order()
173
-
174
- print("\n" + "=" * 50)
175
- print("範例執行完成")
1
+ #!/usr/bin/env python3
2
+ """
3
+ ECPay 超商取貨範例
4
+ 示範如何使用 ECPay 物流 API 建立、查詢、列印超商取貨訂單
5
+ """
6
+
7
+ import hashlib
8
+ import urllib.parse
9
+ from datetime import datetime
10
+
11
+
12
+ class ECPayLogistics:
13
+ """ECPay 物流 API 封裝"""
14
+
15
+ def __init__(self, merchant_id, hash_key, hash_iv, test_mode=True):
16
+ self.merchant_id = merchant_id
17
+ self.hash_key = hash_key
18
+ self.hash_iv = hash_iv
19
+ self.api_url = "https://logistics-stage.ecpay.com.tw" if test_mode else "https://logistics.ecpay.com.tw"
20
+
21
+ def create_check_mac_value(self, params):
22
+ """生成 CheckMacValue"""
23
+ # 1. 參數排序
24
+ sorted_params = sorted(params.items())
25
+
26
+ # 2. 串接字串
27
+ param_str = "&".join([f"{k}={v}" for k, v in sorted_params])
28
+
29
+ # 3. 加上 HashKey 和 HashIV
30
+ raw_str = f"HashKey={self.hash_key}&{param_str}&HashIV={self.hash_iv}"
31
+
32
+ # 4. URL Encode
33
+ encoded_str = urllib.parse.quote(raw_str, safe="")
34
+
35
+ # 5. 轉小寫
36
+ encoded_str = encoded_str.lower()
37
+
38
+ # 6. SHA256 加密
39
+ hash_value = hashlib.sha256(encoded_str.encode('utf-8')).hexdigest()
40
+
41
+ # 7. 轉大寫
42
+ return hash_value.upper()
43
+
44
+ def create_cvs_order(self, order_id, goods_name, goods_amount, receiver_name,
45
+ receiver_phone, receiver_store_id, logistics_sub_type="UNIMARTC2C"):
46
+ """建立超商取貨訂單"""
47
+ params = {
48
+ "MerchantID": self.merchant_id,
49
+ "MerchantTradeNo": order_id,
50
+ "MerchantTradeDate": datetime.now().strftime("%Y/%m/%d %H:%M:%S"),
51
+ "LogisticsType": "CVS",
52
+ "LogisticsSubType": logistics_sub_type, # UNIMARTC2C, FAMIC2C, HILIFEC2C
53
+ "GoodsAmount": goods_amount,
54
+ "GoodsName": goods_name,
55
+ "SenderName": "測試商家",
56
+ "SenderPhone": "0212345678",
57
+ "SenderCellPhone": "0912345678",
58
+ "ReceiverName": receiver_name,
59
+ "ReceiverCellPhone": receiver_phone,
60
+ "ReceiverStoreID": receiver_store_id,
61
+ "ServerReplyURL": "https://yourdomain.com/logistics/callback",
62
+ "IsCollection": "N", # 是否代收貨款
63
+ "Temperature": "0001", # 常溫
64
+ "Distance": "00", # 距離
65
+ "Specification": "0001", # 60cm
66
+ }
67
+
68
+ # 生成 CheckMacValue
69
+ params["CheckMacValue"] = self.create_check_mac_value(params)
70
+
71
+ return params
72
+
73
+ def query_order(self, logistics_id):
74
+ """查詢物流訂單"""
75
+ params = {
76
+ "MerchantID": self.merchant_id,
77
+ "AllPayLogisticsID": logistics_id,
78
+ "TimeStamp": str(int(datetime.now().timestamp())),
79
+ }
80
+
81
+ params["CheckMacValue"] = self.create_check_mac_value(params)
82
+
83
+ return params
84
+
85
+ def print_order(self, logistics_id):
86
+ """列印託運單"""
87
+ params = {
88
+ "MerchantID": self.merchant_id,
89
+ "AllPayLogisticsID": logistics_id,
90
+ }
91
+
92
+ params["CheckMacValue"] = self.create_check_mac_value(params)
93
+
94
+ return params
95
+
96
+
97
+ def example_create_order():
98
+ """範例1: 建立超商取貨訂單"""
99
+ print("\n=== 範例1: 建立超商取貨訂單 ===\n")
100
+
101
+ # 初始化 ECPay
102
+ ecpay = ECPayLogistics(
103
+ merchant_id="2000132", # 測試商店代號
104
+ hash_key="5294y06JbISpM5x9", # 測試 HashKey
105
+ hash_iv="v77hoKGq4kWxNNIS", # 測試 HashIV
106
+ test_mode=True
107
+ )
108
+
109
+ # 建立訂單
110
+ order_id = f"ORDER{int(datetime.now().timestamp())}"
111
+ params = ecpay.create_cvs_order(
112
+ order_id=order_id,
113
+ goods_name="測試商品",
114
+ goods_amount=100,
115
+ receiver_name="王小明",
116
+ receiver_phone="0912345678",
117
+ receiver_store_id="991182", # 7-11 門市代號
118
+ logistics_sub_type="UNIMARTC2C" # 7-11 店到店
119
+ )
120
+
121
+ print("訂單參數:")
122
+ for key, value in params.items():
123
+ print(f" {key}: {value}")
124
+
125
+
126
+ def example_query_order():
127
+ """範例2: 查詢物流訂單"""
128
+ print("\n=== 範例2: 查詢物流訂單 ===\n")
129
+
130
+ ecpay = ECPayLogistics(
131
+ merchant_id="2000132",
132
+ hash_key="5294y06JbISpM5x9",
133
+ hash_iv="v77hoKGq4kWxNNIS",
134
+ test_mode=True
135
+ )
136
+
137
+ # 查詢訂單 (使用物流交易編號)
138
+ logistics_id = "10001234567" # 綠界物流交易編號
139
+ params = ecpay.query_order(logistics_id)
140
+
141
+ print("查詢參數:")
142
+ for key, value in params.items():
143
+ print(f" {key}: {value}")
144
+
145
+
146
+ def example_print_order():
147
+ """範例3: 列印託運單"""
148
+ print("\n=== 範例3: 列印託運單 ===\n")
149
+
150
+ ecpay = ECPayLogistics(
151
+ merchant_id="2000132",
152
+ hash_key="5294y06JbISpM5x9",
153
+ hash_iv="v77hoKGq4kWxNNIS",
154
+ test_mode=True
155
+ )
156
+
157
+ # 列印託運單
158
+ logistics_id = "10001234567"
159
+ params = ecpay.print_order(logistics_id)
160
+
161
+ print("列印參數:")
162
+ for key, value in params.items():
163
+ print(f" {key}: {value}")
164
+
165
+
166
+ if __name__ == "__main__":
167
+ print("ECPay 物流 API 範例")
168
+ print("=" * 50)
169
+
170
+ example_create_order()
171
+ example_query_order()
172
+ example_print_order()
173
+
174
+ print("\n" + "=" * 50)
175
+ print("範例執行完成")