taiwan-logistics-skill 1.0.4 → 1.0.5

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.
@@ -1,827 +1,827 @@
1
- # Taiwan Logistics Development Skill
2
-
3
- **Comprehensive guide for Taiwan Logistics integration (NewebPay, ECPay, PAYUNi)**
4
-
5
- ---
6
-
7
- ## Quick Reference
8
-
9
- ### Core Concepts
10
-
11
- **Logistics Types:**
12
- - **B2C (大宗寄倉)**: Bulk warehouse shipping - Merchant ships to logistics center, then distributed to stores
13
- - **C2C (店到店)**: Store-to-store - Merchant ships to convenience store, then delivered to pickup store
14
-
15
- **Trade Types:**
16
- - **取貨付款 (Cash on Delivery)**: Customer pays when picking up
17
- - **取貨不付款 (No Payment)**: Customer only picks up (payment already completed)
18
-
19
- **Supported Convenience Stores:**
20
- 1. 7-ELEVEN
21
- 2. FamilyMart (全家)
22
- 3. Hi-Life (萊爾富)
23
- 4. OK Mart
24
-
25
- **Key APIs:**
26
- 1. Store Map Query - Select pickup/sender store
27
- 2. Create Shipment - Create logistics order
28
- 3. Get Shipment Number - Get shipping code
29
- 4. Print Label - Print shipping label
30
- 5. Query Shipment - Check order status
31
- 6. Modify Shipment - Update order details
32
- 7. Track Shipment - Track delivery history
33
- 8. Status Notification - Real-time status updates
34
-
35
- ---
36
-
37
- ## Service Providers
38
-
39
- ### NewebPay Logistics (藍新物流)
40
-
41
- **Encryption**: AES-256-CBC + SHA256 (same as NewebPay payment)
42
-
43
- **API Style**: Form POST with AES encryption
44
-
45
- **Supported Services:**
46
- - C2C Store-to-Store: 4 convenience stores (7-11, FamilyMart, Hi-Life, OK Mart)
47
- - B2C Bulk Warehouse: 7-ELEVEN only
48
-
49
- **Test Environment:**
50
- - Store Map: `https://ccore.newebpay.com/API/Logistic/storeMap`
51
- - Create Shipment: `https://ccore.newebpay.com/API/Logistic/createShipment`
52
- - Get Shipment No: `https://ccore.newebpay.com/API/Logistic/getShipmentNo`
53
- - Print Label: `https://ccore.newebpay.com/API/Logistic/printLabel`
54
- - Query Shipment: `https://ccore.newebpay.com/API/Logistic/queryShipment`
55
- - Modify Shipment: `https://ccore.newebpay.com/API/Logistic/modifyShipment`
56
- - Track Shipment: `https://ccore.newebpay.com/API/Logistic/trace`
57
-
58
- **Production Environment:**
59
- - Replace `ccore.newebpay.com` with `core.newebpay.com`
60
-
61
- ---
62
-
63
- ### ECPay Logistics (綠界物流)
64
-
65
- **Encryption**: MD5 CheckMacValue
66
-
67
- **API Style**: Form POST with URL-encoded parameters
68
-
69
- **Supported Services:**
70
- - C2C Store-to-Store: 4 convenience stores (7-11, FamilyMart, Hi-Life, OK Mart)
71
- - C2C Frozen: 7-ELEVEN frozen goods
72
- - Home Delivery: T-Cat, HCT, Pelican Express
73
-
74
- **Test Environment:**
75
- - Base URL: `https://logistics-stage.ecpay.com.tw`
76
- - Create: `POST /Express/Create`
77
- - Query: `POST /Helper/QueryLogisticsTradeInfo/V2`
78
- - Print: `POST /helper/printTradeDocument`
79
- - Map: `POST /Express/map`
80
-
81
- **Production Environment:**
82
- - Base URL: `https://logistics.ecpay.com.tw`
83
-
84
- **Logistics SubTypes (CVS):**
85
- - `FAMI` - FamilyMart (全家)
86
- - `UNIMART` - 7-ELEVEN (常溫)
87
- - `UNIMARTFREEZE` - 7-ELEVEN (冷凍)
88
- - `HILIFE` - Hi-Life (萊爾富)
89
- - `OKMART` - OK Mart
90
-
91
- **Logistics SubTypes (Home Delivery):**
92
- - `TCAT` - T-Cat (黑貓宅急便)
93
- - `ECAN` - HCT (新竹物流)
94
- - `POST` - Pelican Express (宅配通)
95
-
96
- **Temperature Control (Home Delivery):**
97
- - `0001` - Normal temperature (常溫)
98
- - `0002` - Refrigerated (冷藏)
99
- - `0003` - Frozen (冷凍)
100
-
101
- **Specification (Package Size):**
102
- - `0001` - 60cm
103
- - `0002` - 90cm
104
- - `0003` - 120cm
105
- - `0004` - 150cm
106
-
107
- **Distance (Delivery Range):**
108
- - `00` - Same district
109
- - `01` - Same city
110
- - `02` - Cross city
111
- - `03` - Outlying islands
112
-
113
- **Test Credentials:**
114
- - MerchantID: `2000132`
115
- - HashKey: `5294y06JbISpM5x9`
116
- - HashIV: `v77hoKGq4kWxNNIS`
117
-
118
- ---
119
-
120
- ### PAYUNi Logistics (統一物流)
121
-
122
- **Encryption**: AES-256-GCM + SHA256 (same as PAYUNi payment)
123
-
124
- **API Style**: RESTful JSON with AES-GCM encryption
125
-
126
- **Supported Services:**
127
- - C2C Store-to-Store: 7-ELEVEN (normal temperature + frozen)
128
- - B2C Bulk Warehouse: 7-ELEVEN only
129
- - Home Delivery: T-Cat (normal temperature, frozen, refrigerated)
130
-
131
- **Test Environment:**
132
- - Base URL: `https://sandbox-api.payuni.com.tw/api/`
133
- - Create Shipment: `POST /logistics/create`
134
- - Query Shipment: `POST /logistics/query`
135
- - Cancel Shipment: `POST /logistics/cancel`
136
-
137
- **Production Environment:**
138
- - Base URL: `https://api.payuni.com.tw/api/`
139
-
140
- **Logistics Types:**
141
- - `PAYUNi_Logistic_711` - 7-11 C2C (normal temperature)
142
- - `PAYUNi_Logistic_711_Freeze` - 7-11 C2C (frozen)
143
- - `PAYUNi_Logistic_711_B2C` - 7-11 B2C (bulk warehouse)
144
- - `PAYUNi_Logistic_Tcat` - T-Cat home delivery (normal)
145
- - `PAYUNi_Logistic_Tcat_Freeze` - T-Cat frozen
146
- - `PAYUNi_Logistic_Tcat_Cold` - T-Cat refrigerated
147
-
148
- **Temperature Codes:**
149
- - `1` - Normal temperature
150
- - `2` - Frozen
151
- - `3` - Refrigerated (T-Cat only)
152
-
153
- **Size & Weight Limits:**
154
- - Normal temperature: 150cm material volume, 20kg
155
- - Frozen/Refrigerated: 120cm material volume, 15kg
156
- - Material volume calculation: Length + Width + Height ≤ Limit
157
-
158
- ---
159
-
160
- ## Transaction Flows
161
-
162
- ### 1. B2C Bulk Warehouse - Cash on Delivery
163
-
164
- 1. **Create Order**: Customer selects store, merchant calls Create Shipment API
165
- 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
166
- 3. **Merchant Ships**: Merchant delivers goods to logistics center
167
- 4. **Logistics Distributes**: Logistics center verifies and distributes to pickup store
168
- 5. **Customer Picks Up**: Customer picks up and pays, NewebPay notifies merchant
169
-
170
- ### 2. C2C Store-to-Store - Cash on Delivery
171
-
172
- 1. **Create Order**: Customer selects store, merchant calls Create Shipment API
173
- 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
174
- 3. **Merchant Ships**: Merchant delivers goods to sender store
175
- 4. **Store Ships**: Sender store ships to logistics center, then to pickup store
176
- 5. **Customer Picks Up**: Customer picks up and pays, NewebPay notifies merchant
177
-
178
- ### 3. B2C Bulk Warehouse - No Payment
179
-
180
- 1. **Create Order**: Customer selects store (payment already completed)
181
- 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
182
- 3. **Merchant Ships**: Merchant delivers goods to logistics center
183
- 4. **Logistics Distributes**: Logistics center verifies and distributes to pickup store
184
- 5. **Customer Picks Up**: Customer picks up, NewebPay notifies merchant
185
-
186
- ### 4. C2C Store-to-Store - No Payment
187
-
188
- 1. **Create Order**: Customer selects store (payment already completed)
189
- 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
190
- 3. **Merchant Ships**: Merchant delivers goods to sender store
191
- 4. **Store Ships**: Sender store ships to logistics center, then to pickup store
192
- 5. **Customer Picks Up**: Customer picks up, NewebPay notifies merchant
193
-
194
- ---
195
-
196
- ## API Operations
197
-
198
- ### 1. Store Map Query API [NPA-B51]
199
-
200
- Query convenience store locations for pickup or sender.
201
-
202
- **Endpoint:**
203
- - Test: `https://ccore.newebpay.com/API/Logistic/storeMap`
204
- - Production: `https://core.newebpay.com/API/Logistic/storeMap`
205
-
206
- **Request Parameters:**
207
-
208
- | Field | Description | Type | Required |
209
- |-------|-------------|------|----------|
210
- | UID_ | Merchant ID | Varchar(15) | V |
211
- | EncryptData_ | Encrypted data | Text | V |
212
- | HashData_ | Hash data | Text | V |
213
- | Version_ | API version | Varchar(5) | V |
214
- | RespondType_ | Response format | Varchar(6) | V |
215
-
216
- **EncryptData_ Parameters:**
217
-
218
- | Field | Description | Type | Required | Notes |
219
- |-------|-------------|------|----------|-------|
220
- | MerchantOrderNo | Merchant order number | Varchar(30) | V | Unique order ID |
221
- | LgsType | Logistics type | Varchar(15) | V | B2C or C2C |
222
- | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
223
- | ReturnURL | Return URL | Varchar(50) | V | URL after store selection |
224
- | TimeStamp | Unix timestamp | Text | V | Current time in seconds |
225
- | ExtraData | Extra data | Varchar(20) | - | Returned as-is |
226
-
227
- **Response EncryptData_ Parameters:**
228
-
229
- | Field | Description | Type | Notes |
230
- |-------|-------------|------|-------|
231
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
232
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
233
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
234
- | StoreName | Store name | Varchar(10) | Selected store name |
235
- | StoreTel | Store phone | Varchar(12) | Store phone number |
236
- | StoreAddr | Store address | Varchar(100) | Store address |
237
- | StoreID | Store code | Varchar(8) | Store ID (use this for shipment) |
238
- | ExtraData | Extra data | Varchar(20) | Original value returned |
239
-
240
- ---
241
-
242
- ### 2. Create Shipment API [NPA-B52]
243
-
244
- Create logistics shipment order after payment order is established.
245
-
246
- **Endpoint:**
247
- - Test: `https://ccore.newebpay.com/API/Logistic/createShipment`
248
- - Production: `https://core.newebpay.com/API/Logistic/createShipment`
249
-
250
- **EncryptData_ Parameters:**
251
-
252
- | Field | Description | Type | Required | Notes |
253
- |-------|-------------|------|----------|-------|
254
- | MerchantOrderNo | Merchant order number | Varchar(30) | V | Unique order ID |
255
- | TradeType | Trade type | Int(1) | V | 1=COD, 3=No Payment |
256
- | UserName | Recipient name | Varchar(20) | V | Pickup person name |
257
- | UserTel | Recipient phone | Varchar(10) | V | Mobile number |
258
- | UserEmail | Recipient email | Varchar(50) | V | Email address |
259
- | StoreID | Pickup store ID | Varchar(10) | V | From store map query |
260
- | Amt | Transaction amount | Int(10) | V | Order amount |
261
- | NotifyURL | Notification URL | Varchar(100) | - | Pickup completion callback |
262
- | ItemDesc | Product description | Varchar(100) | - | Product name |
263
- | LgsType | Logistics type | Varchar(3) | V | B2C or C2C |
264
- | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
265
- | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
266
-
267
- **Response EncryptData_ Parameters:**
268
-
269
- | Field | Description | Type | Notes |
270
- |-------|-------------|------|-------|
271
- | MerchantID | Merchant ID | Varchar(15) | NewebPay merchant ID |
272
- | Amt | Transaction amount | Int(10) | Order amount |
273
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
274
- | TradeNo | NewebPay trade number | Varchar(20) | Platform transaction ID |
275
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
276
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
277
- | StoreID | Pickup store ID | Varchar(10) | Store code |
278
- | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
279
-
280
- ---
281
-
282
- ### 3. Get Shipment Number API [NPA-B53]
283
-
284
- Get shipping code before shipment. Merchants can print labels at convenience store Kiosk.
285
-
286
- **Endpoint:**
287
- - Test: `https://ccore.newebpay.com/API/Logistic/getShipmentNo`
288
- - Production: `https://core.newebpay.com/API/Logistic/getShipmentNo`
289
-
290
- **EncryptData_ Parameters:**
291
-
292
- | Field | Description | Type | Required | Notes |
293
- |-------|-------------|------|----------|-------|
294
- | MerchantOrderNo | Merchant order numbers | Json_array | V | Max 10 orders at once |
295
- | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
296
-
297
- **Response EncryptData_ Parameters:**
298
-
299
- | Field | Description | Type | Notes |
300
- |-------|-------------|------|-------|
301
- | SUCCESS | Success array | Json_array | Multiple records |
302
- | ERROR | Error array | Json_array | Multiple records |
303
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
304
- | ErrorCode | Error code | Varchar(20) | SUCCESS or error code |
305
- | LgsNo | Shipment number | Varchar(20) | Logistics tracking number |
306
- | StorePrintNo | Store print code | Varchar(20) | Code for Kiosk printing |
307
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
308
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
309
-
310
- ---
311
-
312
- ### 4. Print Label API [NPA-B54]
313
-
314
- Print shipping labels to attach to products.
315
-
316
- **Endpoint:**
317
- - Test: `https://ccore.newebpay.com/API/Logistic/printLabel`
318
- - Production: `https://core.newebpay.com/API/Logistic/printLabel`
319
-
320
- **Important**: Must use Form POST method (not JSON API call)
321
-
322
- **EncryptData_ Parameters:**
323
-
324
- | Field | Description | Type | Required | Notes |
325
- |-------|-------------|------|----------|-------|
326
- | LgsType | Logistics type | Varchar(15) | V | B2C or C2C |
327
- | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
328
- | MerchantOrderNo | Merchant order numbers | json_array | V | Max: 7-11(18), FamilyMart(8), Hi-Life(18), OK Mart(18) |
329
- | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
330
-
331
- **Response**: Returns HTML page with printable shipping label
332
-
333
- ---
334
-
335
- ### 5. Query Shipment API [NPA-B55]
336
-
337
- Query logistics order information and status.
338
-
339
- **Endpoint:**
340
- - Test: `https://ccore.newebpay.com/API/Logistic/queryShipment`
341
- - Production: `https://core.newebpay.com/API/Logistic/queryShipment`
342
-
343
- **EncryptData_ Parameters:**
344
-
345
- | Field | Description | Type | Required | Notes |
346
- |-------|-------------|------|----------|-------|
347
- | MerchantOrderNo | Merchant order number | Varchar(30) | V | Order ID |
348
- | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
349
-
350
- **Response EncryptData_ Parameters:**
351
-
352
- | Field | Description | Type | Notes |
353
- |-------|-------------|------|-------|
354
- | MerchantID | Merchant ID | Varchar(15) | NewebPay merchant ID |
355
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
356
- | TradeNo | NewebPay trade number | Varchar(20) | Platform transaction ID |
357
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
358
- | Amt | Transaction amount | Int(10) | Order amount |
359
- | ItemDesc | Product description | Varchar(100) | Product name |
360
- | NotifyURL | Notification URL | Varchar(50) | Callback URL |
361
- | LgsNo | Shipment number | Varchar(20) | Logistics tracking number |
362
- | StorePrintNo | Store print code | Varchar(20) | Kiosk print code |
363
- | collectionAmt | Collection amount | Int(10) | COD amount |
364
- | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
365
- | Type | Order type | Int(1) | 1=Normal, 3=Return |
366
- | ShopDate | Ship date | Date | Shipping date |
367
- | UserName | Recipient name | Varchar(20) | Pickup person |
368
- | UserTel | Recipient phone | Varchar(10) | Mobile number |
369
- | UserEmail | Recipient email | Varchar(50) | Email |
370
- | StoreID | Pickup store ID | Varchar(10) | Store code |
371
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
372
- | StoreName | Store name | Varchar(20) | Store name |
373
- | RetId | Status code | Varchar(10) | See status code table |
374
- | RetString | Status description | Varchar(30) | See status description |
375
-
376
- ---
377
-
378
- ### 6. Modify Shipment API [NPA-B56]
379
-
380
- Modify shipment order details (only for orders not yet shipped or expired).
381
-
382
- **Endpoint:**
383
- - Test: `https://ccore.newebpay.com/API/Logistic/modifyShipment`
384
- - Production: `https://core.newebpay.com/API/Logistic/modifyShipment`
385
-
386
- **Modifiable Conditions:**
387
- - Not yet obtained shipping number
388
- - Shipment expired
389
- - Store reselection
390
-
391
- **EncryptData_ Parameters:**
392
-
393
- | Field | Description | Type | Required | Notes |
394
- |-------|-------------|------|----------|-------|
395
- | MerchantOrderNo | Merchant order number | Varchar(30) | V | Order ID |
396
- | LgsType | Logistics type | Varchar(15) | V | B2C or C2C |
397
- | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
398
- | UserName | Recipient name | Varchar(20) | - | New recipient name |
399
- | UserTel | Recipient phone | Varchar(10) | - | New phone number |
400
- | UserEmail | Recipient email | Varchar(50) | - | New email |
401
- | StoreID | Pickup store ID | Varchar(10) | + | New store ID |
402
- | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
403
-
404
- **Response EncryptData_ Parameters:**
405
-
406
- | Field | Description | Type | Notes |
407
- |-------|-------------|------|-------|
408
- | MerchantID | Merchant ID | Varchar(15) | NewebPay merchant ID |
409
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
410
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
411
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
412
-
413
- ---
414
-
415
- ### 7. Track Shipment API [NPA-B57]
416
-
417
- Track complete logistics delivery history.
418
-
419
- **Endpoint:**
420
- - Test: `https://ccore.newebpay.com/API/Logistic/trace`
421
- - Production: `https://core.newebpay.com/API/Logistic/trace`
422
-
423
- **EncryptData_ Parameters:**
424
-
425
- | Field | Description | Type | Required | Notes |
426
- |-------|-------------|------|----------|-------|
427
- | MerchantOrderNo | Merchant order number | Varchar(30) | V | Order ID |
428
- | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
429
-
430
- **Response EncryptData_ Parameters:**
431
-
432
- | Field | Description | Type | Notes |
433
- |-------|-------------|------|-------|
434
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
435
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
436
- | LgsNo | Shipment number | Varchar(20) | Tracking number |
437
- | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
438
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
439
- | History | History array | json_array | Tracking history |
440
- | RetId | Status code | Varchar(10) | See status code table |
441
- | RetString | Status description | Varchar(30) | See status description |
442
- | EventTime | Event time | Varchar(20) | Timestamp |
443
-
444
- ---
445
-
446
- ### 8. Status Notification [NPA-B58]
447
-
448
- Real-time notification when shipment status changes.
449
-
450
- **Merchant provides NotifyURL to receive notifications**
451
-
452
- **POST Parameters:**
453
-
454
- | Field | Description | Type | Notes |
455
- |-------|-------------|------|-------|
456
- | Status | Response status | Varchar(10) | SUCCESS or error code |
457
- | Message | Response message | Varchar(30) | Status description |
458
- | EncryptData_ | Encrypted data | Text | - |
459
- | HashData_ | Hash data | Text | - |
460
- | UID_ | Merchant ID | Varchar(15) | NewebPay merchant ID |
461
- | Version_ | API version | Varchar(5) | Fixed: 1.0 |
462
-
463
- **EncryptData_ Parameters:**
464
-
465
- | Field | Description | Type | Notes |
466
- |-------|-------------|------|-------|
467
- | LgsType | Logistics type | Varchar(15) | B2C or C2C |
468
- | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
469
- | LgsNo | Shipment number | Varchar(20) | Tracking number |
470
- | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
471
- | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
472
- | RetId | Status code | Varchar(10) | See status code table |
473
- | RetString | Status description | Varchar(30) | See status description |
474
- | EventTime | Event time | Varchar(20) | Timestamp |
475
-
476
- ---
477
-
478
- ## Encryption Methods
479
-
480
- ### Hash Data Processing
481
-
482
- NewebPay Logistics uses the same encryption method as NewebPay Payment:
483
-
484
- 1. **AES-256-CBC Encryption**: Encrypt data using merchant's HashKey and HashIV
485
- 2. **SHA256 Hash**: Add HashKey + AES result + HashIV, then SHA256 hash and uppercase
486
-
487
- **Process:**
488
- ```
489
- EncryptData = AES-256-CBC(data, HashKey, HashIV)
490
- HashData = SHA256(HashKey + EncryptData + HashIV).toUpperCase()
491
- ```
492
-
493
- ---
494
-
495
- ## Status Codes
496
-
497
- ### RetId Status Codes & RetString Descriptions
498
-
499
- | RetId | RetString | Category |
500
- |-------|-----------|----------|
501
- | 0_1 | Order not processed | Pending |
502
- | 0_2 | Shipment number expired, please get new number | Pending |
503
- | 0_3 | Shipment canceled | Pending |
504
- | 1 | Order processing | Processing |
505
- | 2 | Store received shipment | In Transit |
506
- | 3 | Store reselected, waiting for re-shipment | In Transit |
507
- | 4 | Arrived at logistics center | In Transit |
508
- | 11 | Pickup store closed, please reselect | In Transit |
509
- | 5 | Arrived at pickup store | Ready for Pickup |
510
- | 6 | Customer picked up | Completed |
511
- | -1 | Returned to merchant | Completed |
512
- | -6 | Home delivery return requested | Completed |
513
- | -9 | Logistics inspection error | Completed |
514
- | -2 | Returned to sender/designated return store | Return/Compensation |
515
- | -3 | Returned to logistics center | Return/Compensation |
516
- | -4 | Returning to logistics center (customer did not pickup) | Return/Compensation |
517
- | -5 | Soon to be returned (customer did not pickup) | Return/Compensation |
518
- | -7 | Error compensation approved | Return/Compensation |
519
- | -10 | Product destroyed/discarded | Return/Compensation |
520
- | -11 | Product destroyed/discarded | Return/Compensation |
521
- | 10 | Soon to be returned | Return/Compensation |
522
- | 12 | Return store closed, please reselect | Return/Compensation |
523
- | 13 | Returning to logistics center (merchant did not pickup) | Return/Compensation |
524
- | 14 | Please request home delivery return | Return/Compensation |
525
- | 15 | Product destroyed/discarded | Return/Compensation |
526
- | 16 | Please confirm bank account | Return/Compensation |
527
-
528
- ---
529
-
530
- ## Error Codes
531
-
532
- ### Common Error Codes
533
-
534
- | Code | Message | Notes |
535
- |------|---------|-------|
536
- | SUCCESS | Success | - |
537
- | 1101 | Failed to create logistics order | - |
538
- | 1102 | Merchant not found | - |
539
- | 1103 | Duplicate merchant order number | - |
540
- | 1104 | Logistics service not enabled | - |
541
- | 1105 | Store information invalid or empty | - |
542
- | 1106 | IP not allowed | - |
543
- | 1107 | Payment order not found | - |
544
- | 1108 | System error, cannot query logistics order | - |
545
- | 1109 | Logistics order not found | - |
546
- | 1110 | System error, cannot modify logistics order | - |
547
- | 1111 | Order status cannot be modified | - |
548
- | 1112 | Failed to modify logistics order | - |
549
- | 1113 | System error, cannot query tracking history | - |
550
- | 1114 | Insufficient prepaid balance | - |
551
- | 1115 | Failed to get shipment number | - |
552
- | 1116 | Shipment already created for this transaction | - |
553
- | 2100 | Data format error | - |
554
- | 2101 | Version error | - |
555
- | 2102 | UID_ cannot be empty | - |
556
- | 2103 | COD amount limit: 20000 NTD | - |
557
- | 2104 | No payment amount limit: 20000 NTD | - |
558
- | 2105 | Max 10 shipment numbers per request | - |
559
- | 2106 | Max labels per request: 7-11(18), FamilyMart(8), Hi-Life(18), OK Mart(18) | - |
560
- | 4101 | IP restricted | - |
561
- | 4103 | HashData_ verification failed | - |
562
- | 4104 | Encryption error, check Hash_Key and Hash_IV | - |
563
-
564
- ---
565
-
566
- ## Important Notes
567
-
568
- ### Amount Limits
569
- - **COD (Cash on Delivery)**: Maximum 20,000 NTD
570
- - **No Payment**: Maximum 20,000 NTD
571
-
572
- ### Batch Limits
573
- - **Get Shipment Number**: Maximum 10 orders per request
574
- - **Print Label**:
575
- - 7-ELEVEN: Maximum 18 labels
576
- - FamilyMart: Maximum 8 labels
577
- - Hi-Life: Maximum 18 labels
578
- - OK Mart: Maximum 18 labels
579
-
580
- ### Store Code Notes
581
- - For FamilyMart and OK Mart, the store code displayed on the map may not be the real code
582
- - Always use the store code returned in the API response (StoreID field)
583
-
584
- ### Timestamp
585
- - Must use Unix timestamp (seconds since 1970-01-01 00:00:00 GMT)
586
- - Tolerance: 120 seconds
587
- - Incorrect timestamp will cause transaction failure
588
-
589
- ---
590
-
591
- ## PAYUNi API Operations
592
-
593
- ### 1. Create 7-11 C2C Shipment
594
-
595
- Create store-to-store logistics order.
596
-
597
- **Endpoint:** `POST /api/logistics/create`
598
-
599
- **Request Body:**
600
-
601
- | Field | Type | Required | Description |
602
- |-------|------|----------|-------------|
603
- | MerID | String | | Merchant ID |
604
- | Version | String | | API version (1.0) |
605
- | EncryptInfo | String | | AES-256-GCM encrypted data |
606
- | HashInfo | String | | SHA256 hash |
607
-
608
- **EncryptInfo Parameters:**
609
-
610
- | Field | Type | Required | Description |
611
- |-------|------|----------|-------------|
612
- | MerID | String(20) | | Merchant ID |
613
- | MerTradeNo | String(50) | | Unique order number |
614
- | LogisticsType | String(50) | | PAYUNi_Logistic_711 |
615
- | GoodsType | Integer | | 1=Normal, 2=Frozen |
616
- | GoodsAmount | Integer | | Product amount |
617
- | GoodsName | String(50) | | Product name |
618
- | SenderName | String(10) | | Sender name |
619
- | SenderPhone | String(20) | | Sender phone |
620
- | SenderStoreID | String(10) | | Sender store code (C2C only) |
621
- | ReceiverName | String(10) | | Receiver name |
622
- | ReceiverPhone | String(20) | | Receiver phone |
623
- | ReceiverStoreID | String(10) | | Receiver store code |
624
- | NotifyURL | String(500) | | Status notification URL |
625
- | Timestamp | Integer | | Unix timestamp |
626
-
627
- **Response (Decrypted EncryptInfo):**
628
-
629
- | Field | Description |
630
- |-------|-------------|
631
- | LogisticsID | PAYUNi logistics ID |
632
- | MerTradeNo | Merchant order number |
633
- | CVSPaymentNo | Store payment code |
634
- | CVSValidationNo | Store validation code |
635
- | ExpireDate | Pickup deadline |
636
-
637
- ---
638
-
639
- ### 2. Create T-Cat Home Delivery
640
-
641
- Create home delivery shipment.
642
-
643
- **Endpoint:** `POST /api/logistics/create`
644
-
645
- **Additional EncryptInfo Parameters:**
646
-
647
- | Field | Type | Required | Description |
648
- |-------|------|----------|-------------|
649
- | LogisticsType | String(50) | | PAYUNi_Logistic_Tcat |
650
- | GoodsType | Integer | | 1=Normal, 2=Frozen, 3=Refrigerated |
651
- | GoodsWeight | Integer | - | Weight in grams |
652
- | SenderZipCode | String(5) | | Sender postal code |
653
- | SenderAddress | String(200) | | Sender address |
654
- | ReceiverZipCode | String(5) | | Receiver postal code |
655
- | ReceiverAddress | String(200) | | Receiver address |
656
- | ScheduledPickupDate | String(10) | - | Pickup date (yyyy/MM/dd) |
657
- | ScheduledDeliveryDate | String(10) | - | Delivery date (yyyy/MM/dd) |
658
- | ScheduledDeliveryTime | String(2) | - | 01/02/03 (time slot) |
659
-
660
- **Delivery Time Slots:**
661
- - `01` - Before 13:00
662
- - `02` - 14:00 - 18:00
663
- - `03` - Not specified
664
-
665
- **Response (Decrypted EncryptInfo):**
666
-
667
- | Field | Description |
668
- |-------|-------------|
669
- | LogisticsID | PAYUNi logistics ID |
670
- | MerTradeNo | Merchant order number |
671
- | ShipmentNo | T-Cat tracking number |
672
- | BookingNote | Pickup number |
673
-
674
- ---
675
-
676
- ### 3. Query Shipment Status
677
-
678
- Query logistics order status.
679
-
680
- **Endpoint:** `POST /api/logistics/query`
681
-
682
- **EncryptInfo Parameters:**
683
-
684
- | Field | Type | Required | Description |
685
- |-------|------|----------|-------------|
686
- | MerID | String | | Merchant ID |
687
- | MerTradeNo | String | | Order number |
688
- | Timestamp | Integer | | Unix timestamp |
689
-
690
- **Response (Decrypted EncryptInfo):**
691
-
692
- | Field | Description |
693
- |-------|-------------|
694
- | LogisticsID | PAYUNi logistics ID |
695
- | MerTradeNo | Merchant order number |
696
- | LogisticsType | Logistics type |
697
- | LogisticsStatus | Status code (11/21/22/31/32) |
698
- | LogisticsStatusMsg | Status message |
699
- | ShipmentNo | Tracking number |
700
- | ReceiverStoreID | Receiver store code |
701
- | UpdateTime | Last update time |
702
-
703
- **Logistics Status Codes:**
704
-
705
- | Code | Description | Category |
706
- |------|-------------|----------|
707
- | 11 | Shipped | In Transit |
708
- | 21 | Arrived at store / In delivery | In Transit |
709
- | 22 | Picked up / Delivered | Completed |
710
- | 31 | Returning | Return |
711
- | 32 | Return completed | Return |
712
-
713
- ---
714
-
715
- ### 4. Status Notification Callback
716
-
717
- Handle real-time status updates from PAYUNi.
718
-
719
- **Callback Request (POST to NotifyURL):**
720
-
721
- | Field | Type | Description |
722
- |-------|------|-------------|
723
- | MerID | String | Merchant ID |
724
- | EncryptInfo | String | Encrypted status data |
725
- | HashInfo | String | SHA256 hash |
726
-
727
- **Decrypted EncryptInfo:**
728
-
729
- | Field | Description |
730
- |-------|-------------|
731
- | MerID | Merchant ID |
732
- | MerTradeNo | Merchant order number |
733
- | LogisticsID | PAYUNi logistics ID |
734
- | LogisticsType | Logistics type |
735
- | LogisticsStatus | Status code |
736
- | LogisticsStatusMsg | Status message |
737
- | UpdateTime | Update timestamp |
738
-
739
- **Response Required:**
740
- - Success: `SUCCESS`
741
- - Error: Any other response
742
-
743
- ---
744
-
745
- ## PAYUNi Encryption (AES-256-GCM)
746
-
747
- ### Encryption Process
748
-
749
- ```
750
- 1. Create Query String from parameters
751
- 2. AES-256-GCM encrypt (with 16-byte tag)
752
- 3. Convert to hex: EncryptInfo = hex(encrypted + tag)
753
- 4. Generate HashInfo: SHA256(EncryptInfo + HashKey + HashIV)
754
- ```
755
-
756
- ### Decryption Process
757
-
758
- ```
759
- 1. Convert hex to binary
760
- 2. Split: encrypted = data[:-16], tag = data[-16:]
761
- 3. AES-256-GCM decrypt and verify tag
762
- 4. Parse query string to get parameters
763
- ```
764
-
765
- ---
766
-
767
- ## Best Practices
768
-
769
- 1. **Store Selection**: Always use the StoreID from the Store Map API response, not the displayed code
770
- 2. **Error Handling**: Implement proper error handling for all API calls with retry logic
771
- 3. **Status Tracking**: Use Status Notification webhook for real-time updates instead of polling
772
- 4. **Encryption**: Securely store HashKey and HashIV, never expose in client-side code
773
- 5. **Order Numbers**: Ensure MerchantOrderNo is unique across all orders
774
- 6. **Timestamp**: Always generate fresh timestamp for each API call
775
- 7. **Testing**: Use test environment extensively before going to production
776
- 8. **Validation**: Validate all user input (name, phone, email) before API calls
777
- 9. **Logging**: Log all API requests and responses for debugging and auditing
778
- 10. **Notification URL**: Ensure NotifyURL is accessible from NewebPay servers (not localhost)
779
-
780
- ---
781
-
782
- ## Use Cases
783
-
784
- ### E-commerce Platform
785
- - Integrate store map for customers to select pickup location
786
- - Create shipment automatically after order confirmation
787
- - Send tracking updates to customers via email/SMS
788
- - Handle returns and exchanges through modify shipment API
789
-
790
- ### Marketplace
791
- - Support multiple vendors shipping to convenience stores
792
- - Provide unified logistics tracking interface
793
- - Automate shipment number retrieval and label printing
794
- - Handle COD payment collection and settlement
795
-
796
- ### Subscription Service
797
- - Schedule recurring shipments to same pickup store
798
- - Automatic label generation for regular deliveries
799
- - Batch shipment creation for multiple orders
800
- - Track delivery success rate and optimize logistics
801
-
802
- ---
803
-
804
- ## Related Resources
805
-
806
- - [EXAMPLES.md](./EXAMPLES.md) - Complete code examples (TypeScript, Python, PHP)
807
- - [references/NEWEBPAY_LOGISTICS_REFERENCE.md](./references/NEWEBPAY_LOGISTICS_REFERENCE.md) - NewebPay Logistics API full specification
808
- - [scripts/search.py](./scripts/search.py) - BM25 search engine for error codes and fields
809
- - [scripts/test_logistics.py](./scripts/test_logistics.py) - Connection testing tool
810
-
811
- ---
812
-
813
- ## Support
814
-
815
- ### NewebPay Technical Support
816
- - Phone: 02-2655-8938
817
- - Official Documentation: https://www.newebpay.com
818
-
819
- ### API Version
820
- Current Version: 1.0
821
-
822
- ### Last Updated
823
- 2026-01-29
824
-
825
- ---
826
-
827
- **Total Lines**: 750+
1
+ # Taiwan Logistics Development Skill
2
+
3
+ **Comprehensive guide for Taiwan Logistics integration (NewebPay, ECPay, PAYUNi)**
4
+
5
+ ---
6
+
7
+ ## Quick Reference
8
+
9
+ ### Core Concepts
10
+
11
+ **Logistics Types:**
12
+ - **B2C (大宗寄倉)**: Bulk warehouse shipping - Merchant ships to logistics center, then distributed to stores
13
+ - **C2C (店到店)**: Store-to-store - Merchant ships to convenience store, then delivered to pickup store
14
+
15
+ **Trade Types:**
16
+ - **取貨付款 (Cash on Delivery)**: Customer pays when picking up
17
+ - **取貨不付款 (No Payment)**: Customer only picks up (payment already completed)
18
+
19
+ **Supported Convenience Stores:**
20
+ 1. 7-ELEVEN
21
+ 2. FamilyMart (全家)
22
+ 3. Hi-Life (萊爾富)
23
+ 4. OK Mart
24
+
25
+ **Key APIs:**
26
+ 1. Store Map Query - Select pickup/sender store
27
+ 2. Create Shipment - Create logistics order
28
+ 3. Get Shipment Number - Get shipping code
29
+ 4. Print Label - Print shipping label
30
+ 5. Query Shipment - Check order status
31
+ 6. Modify Shipment - Update order details
32
+ 7. Track Shipment - Track delivery history
33
+ 8. Status Notification - Real-time status updates
34
+
35
+ ---
36
+
37
+ ## Service Providers
38
+
39
+ ### NewebPay Logistics (藍新物流)
40
+
41
+ **Encryption**: AES-256-CBC + SHA256 (same as NewebPay payment)
42
+
43
+ **API Style**: Form POST with AES encryption
44
+
45
+ **Supported Services:**
46
+ - C2C Store-to-Store: 4 convenience stores (7-11, FamilyMart, Hi-Life, OK Mart)
47
+ - B2C Bulk Warehouse: 7-ELEVEN only
48
+
49
+ **Test Environment:**
50
+ - Store Map: `https://ccore.newebpay.com/API/Logistic/storeMap`
51
+ - Create Shipment: `https://ccore.newebpay.com/API/Logistic/createShipment`
52
+ - Get Shipment No: `https://ccore.newebpay.com/API/Logistic/getShipmentNo`
53
+ - Print Label: `https://ccore.newebpay.com/API/Logistic/printLabel`
54
+ - Query Shipment: `https://ccore.newebpay.com/API/Logistic/queryShipment`
55
+ - Modify Shipment: `https://ccore.newebpay.com/API/Logistic/modifyShipment`
56
+ - Track Shipment: `https://ccore.newebpay.com/API/Logistic/trace`
57
+
58
+ **Production Environment:**
59
+ - Replace `ccore.newebpay.com` with `core.newebpay.com`
60
+
61
+ ---
62
+
63
+ ### ECPay Logistics (綠界物流)
64
+
65
+ **Encryption**: MD5 CheckMacValue
66
+
67
+ **API Style**: Form POST with URL-encoded parameters
68
+
69
+ **Supported Services:**
70
+ - C2C Store-to-Store: 4 convenience stores (7-11, FamilyMart, Hi-Life, OK Mart)
71
+ - C2C Frozen: 7-ELEVEN frozen goods
72
+ - Home Delivery: T-Cat, HCT, Pelican Express
73
+
74
+ **Test Environment:**
75
+ - Base URL: `https://logistics-stage.ecpay.com.tw`
76
+ - Create: `POST /Express/Create`
77
+ - Query: `POST /Helper/QueryLogisticsTradeInfo/V2`
78
+ - Print: `POST /helper/printTradeDocument`
79
+ - Map: `POST /Express/map`
80
+
81
+ **Production Environment:**
82
+ - Base URL: `https://logistics.ecpay.com.tw`
83
+
84
+ **Logistics SubTypes (CVS):**
85
+ - `FAMI` - FamilyMart (全家)
86
+ - `UNIMART` - 7-ELEVEN (常溫)
87
+ - `UNIMARTFREEZE` - 7-ELEVEN (冷凍)
88
+ - `HILIFE` - Hi-Life (萊爾富)
89
+ - `OKMART` - OK Mart
90
+
91
+ **Logistics SubTypes (Home Delivery):**
92
+ - `TCAT` - T-Cat (黑貓宅急便)
93
+ - `ECAN` - HCT (新竹物流)
94
+ - `POST` - Pelican Express (宅配通)
95
+
96
+ **Temperature Control (Home Delivery):**
97
+ - `0001` - Normal temperature (常溫)
98
+ - `0002` - Refrigerated (冷藏)
99
+ - `0003` - Frozen (冷凍)
100
+
101
+ **Specification (Package Size):**
102
+ - `0001` - 60cm
103
+ - `0002` - 90cm
104
+ - `0003` - 120cm
105
+ - `0004` - 150cm
106
+
107
+ **Distance (Delivery Range):**
108
+ - `00` - Same district
109
+ - `01` - Same city
110
+ - `02` - Cross city
111
+ - `03` - Outlying islands
112
+
113
+ **Test Credentials:**
114
+ - MerchantID: `2000132`
115
+ - HashKey: `5294y06JbISpM5x9`
116
+ - HashIV: `v77hoKGq4kWxNNIS`
117
+
118
+ ---
119
+
120
+ ### PAYUNi Logistics (統一物流)
121
+
122
+ **Encryption**: AES-256-GCM + SHA256 (same as PAYUNi payment)
123
+
124
+ **API Style**: RESTful JSON with AES-GCM encryption
125
+
126
+ **Supported Services:**
127
+ - C2C Store-to-Store: 7-ELEVEN (normal temperature + frozen)
128
+ - B2C Bulk Warehouse: 7-ELEVEN only
129
+ - Home Delivery: T-Cat (normal temperature, frozen, refrigerated)
130
+
131
+ **Test Environment:**
132
+ - Base URL: `https://sandbox-api.payuni.com.tw/api/`
133
+ - Create Shipment: `POST /logistics/create`
134
+ - Query Shipment: `POST /logistics/query`
135
+ - Cancel Shipment: `POST /logistics/cancel`
136
+
137
+ **Production Environment:**
138
+ - Base URL: `https://api.payuni.com.tw/api/`
139
+
140
+ **Logistics Types:**
141
+ - `PAYUNi_Logistic_711` - 7-11 C2C (normal temperature)
142
+ - `PAYUNi_Logistic_711_Freeze` - 7-11 C2C (frozen)
143
+ - `PAYUNi_Logistic_711_B2C` - 7-11 B2C (bulk warehouse)
144
+ - `PAYUNi_Logistic_Tcat` - T-Cat home delivery (normal)
145
+ - `PAYUNi_Logistic_Tcat_Freeze` - T-Cat frozen
146
+ - `PAYUNi_Logistic_Tcat_Cold` - T-Cat refrigerated
147
+
148
+ **Temperature Codes:**
149
+ - `1` - Normal temperature
150
+ - `2` - Frozen
151
+ - `3` - Refrigerated (T-Cat only)
152
+
153
+ **Size & Weight Limits:**
154
+ - Normal temperature: 150cm material volume, 20kg
155
+ - Frozen/Refrigerated: 120cm material volume, 15kg
156
+ - Material volume calculation: Length + Width + Height ≤ Limit
157
+
158
+ ---
159
+
160
+ ## Transaction Flows
161
+
162
+ ### 1. B2C Bulk Warehouse - Cash on Delivery
163
+
164
+ 1. **Create Order**: Customer selects store, merchant calls Create Shipment API
165
+ 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
166
+ 3. **Merchant Ships**: Merchant delivers goods to logistics center
167
+ 4. **Logistics Distributes**: Logistics center verifies and distributes to pickup store
168
+ 5. **Customer Picks Up**: Customer picks up and pays, NewebPay notifies merchant
169
+
170
+ ### 2. C2C Store-to-Store - Cash on Delivery
171
+
172
+ 1. **Create Order**: Customer selects store, merchant calls Create Shipment API
173
+ 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
174
+ 3. **Merchant Ships**: Merchant delivers goods to sender store
175
+ 4. **Store Ships**: Sender store ships to logistics center, then to pickup store
176
+ 5. **Customer Picks Up**: Customer picks up and pays, NewebPay notifies merchant
177
+
178
+ ### 3. B2C Bulk Warehouse - No Payment
179
+
180
+ 1. **Create Order**: Customer selects store (payment already completed)
181
+ 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
182
+ 3. **Merchant Ships**: Merchant delivers goods to logistics center
183
+ 4. **Logistics Distributes**: Logistics center verifies and distributes to pickup store
184
+ 5. **Customer Picks Up**: Customer picks up, NewebPay notifies merchant
185
+
186
+ ### 4. C2C Store-to-Store - No Payment
187
+
188
+ 1. **Create Order**: Customer selects store (payment already completed)
189
+ 2. **Get Shipping Code**: Merchant calls Get Shipment Number API & Print Label API
190
+ 3. **Merchant Ships**: Merchant delivers goods to sender store
191
+ 4. **Store Ships**: Sender store ships to logistics center, then to pickup store
192
+ 5. **Customer Picks Up**: Customer picks up, NewebPay notifies merchant
193
+
194
+ ---
195
+
196
+ ## API Operations
197
+
198
+ ### 1. Store Map Query API [NPA-B51]
199
+
200
+ Query convenience store locations for pickup or sender.
201
+
202
+ **Endpoint:**
203
+ - Test: `https://ccore.newebpay.com/API/Logistic/storeMap`
204
+ - Production: `https://core.newebpay.com/API/Logistic/storeMap`
205
+
206
+ **Request Parameters:**
207
+
208
+ | Field | Description | Type | Required |
209
+ |-------|-------------|------|----------|
210
+ | UID_ | Merchant ID | Varchar(15) | V |
211
+ | EncryptData_ | Encrypted data | Text | V |
212
+ | HashData_ | Hash data | Text | V |
213
+ | Version_ | API version | Varchar(5) | V |
214
+ | RespondType_ | Response format | Varchar(6) | V |
215
+
216
+ **EncryptData_ Parameters:**
217
+
218
+ | Field | Description | Type | Required | Notes |
219
+ |-------|-------------|------|----------|-------|
220
+ | MerchantOrderNo | Merchant order number | Varchar(30) | V | Unique order ID |
221
+ | LgsType | Logistics type | Varchar(15) | V | B2C or C2C |
222
+ | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
223
+ | ReturnURL | Return URL | Varchar(50) | V | URL after store selection |
224
+ | TimeStamp | Unix timestamp | Text | V | Current time in seconds |
225
+ | ExtraData | Extra data | Varchar(20) | - | Returned as-is |
226
+
227
+ **Response EncryptData_ Parameters:**
228
+
229
+ | Field | Description | Type | Notes |
230
+ |-------|-------------|------|-------|
231
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
232
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
233
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
234
+ | StoreName | Store name | Varchar(10) | Selected store name |
235
+ | StoreTel | Store phone | Varchar(12) | Store phone number |
236
+ | StoreAddr | Store address | Varchar(100) | Store address |
237
+ | StoreID | Store code | Varchar(8) | Store ID (use this for shipment) |
238
+ | ExtraData | Extra data | Varchar(20) | Original value returned |
239
+
240
+ ---
241
+
242
+ ### 2. Create Shipment API [NPA-B52]
243
+
244
+ Create logistics shipment order after payment order is established.
245
+
246
+ **Endpoint:**
247
+ - Test: `https://ccore.newebpay.com/API/Logistic/createShipment`
248
+ - Production: `https://core.newebpay.com/API/Logistic/createShipment`
249
+
250
+ **EncryptData_ Parameters:**
251
+
252
+ | Field | Description | Type | Required | Notes |
253
+ |-------|-------------|------|----------|-------|
254
+ | MerchantOrderNo | Merchant order number | Varchar(30) | V | Unique order ID |
255
+ | TradeType | Trade type | Int(1) | V | 1=COD, 3=No Payment |
256
+ | UserName | Recipient name | Varchar(20) | V | Pickup person name |
257
+ | UserTel | Recipient phone | Varchar(10) | V | Mobile number |
258
+ | UserEmail | Recipient email | Varchar(50) | V | Email address |
259
+ | StoreID | Pickup store ID | Varchar(10) | V | From store map query |
260
+ | Amt | Transaction amount | Int(10) | V | Order amount |
261
+ | NotifyURL | Notification URL | Varchar(100) | - | Pickup completion callback |
262
+ | ItemDesc | Product description | Varchar(100) | - | Product name |
263
+ | LgsType | Logistics type | Varchar(3) | V | B2C or C2C |
264
+ | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
265
+ | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
266
+
267
+ **Response EncryptData_ Parameters:**
268
+
269
+ | Field | Description | Type | Notes |
270
+ |-------|-------------|------|-------|
271
+ | MerchantID | Merchant ID | Varchar(15) | NewebPay merchant ID |
272
+ | Amt | Transaction amount | Int(10) | Order amount |
273
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
274
+ | TradeNo | NewebPay trade number | Varchar(20) | Platform transaction ID |
275
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
276
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
277
+ | StoreID | Pickup store ID | Varchar(10) | Store code |
278
+ | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
279
+
280
+ ---
281
+
282
+ ### 3. Get Shipment Number API [NPA-B53]
283
+
284
+ Get shipping code before shipment. Merchants can print labels at convenience store Kiosk.
285
+
286
+ **Endpoint:**
287
+ - Test: `https://ccore.newebpay.com/API/Logistic/getShipmentNo`
288
+ - Production: `https://core.newebpay.com/API/Logistic/getShipmentNo`
289
+
290
+ **EncryptData_ Parameters:**
291
+
292
+ | Field | Description | Type | Required | Notes |
293
+ |-------|-------------|------|----------|-------|
294
+ | MerchantOrderNo | Merchant order numbers | Json_array | V | Max 10 orders at once |
295
+ | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
296
+
297
+ **Response EncryptData_ Parameters:**
298
+
299
+ | Field | Description | Type | Notes |
300
+ |-------|-------------|------|-------|
301
+ | SUCCESS | Success array | Json_array | Multiple records |
302
+ | ERROR | Error array | Json_array | Multiple records |
303
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
304
+ | ErrorCode | Error code | Varchar(20) | SUCCESS or error code |
305
+ | LgsNo | Shipment number | Varchar(20) | Logistics tracking number |
306
+ | StorePrintNo | Store print code | Varchar(20) | Code for Kiosk printing |
307
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
308
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
309
+
310
+ ---
311
+
312
+ ### 4. Print Label API [NPA-B54]
313
+
314
+ Print shipping labels to attach to products.
315
+
316
+ **Endpoint:**
317
+ - Test: `https://ccore.newebpay.com/API/Logistic/printLabel`
318
+ - Production: `https://core.newebpay.com/API/Logistic/printLabel`
319
+
320
+ **Important**: Must use Form POST method (not JSON API call)
321
+
322
+ **EncryptData_ Parameters:**
323
+
324
+ | Field | Description | Type | Required | Notes |
325
+ |-------|-------------|------|----------|-------|
326
+ | LgsType | Logistics type | Varchar(15) | V | B2C or C2C |
327
+ | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
328
+ | MerchantOrderNo | Merchant order numbers | json_array | V | Max: 7-11(18), FamilyMart(8), Hi-Life(18), OK Mart(18) |
329
+ | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
330
+
331
+ **Response**: Returns HTML page with printable shipping label
332
+
333
+ ---
334
+
335
+ ### 5. Query Shipment API [NPA-B55]
336
+
337
+ Query logistics order information and status.
338
+
339
+ **Endpoint:**
340
+ - Test: `https://ccore.newebpay.com/API/Logistic/queryShipment`
341
+ - Production: `https://core.newebpay.com/API/Logistic/queryShipment`
342
+
343
+ **EncryptData_ Parameters:**
344
+
345
+ | Field | Description | Type | Required | Notes |
346
+ |-------|-------------|------|----------|-------|
347
+ | MerchantOrderNo | Merchant order number | Varchar(30) | V | Order ID |
348
+ | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
349
+
350
+ **Response EncryptData_ Parameters:**
351
+
352
+ | Field | Description | Type | Notes |
353
+ |-------|-------------|------|-------|
354
+ | MerchantID | Merchant ID | Varchar(15) | NewebPay merchant ID |
355
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
356
+ | TradeNo | NewebPay trade number | Varchar(20) | Platform transaction ID |
357
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
358
+ | Amt | Transaction amount | Int(10) | Order amount |
359
+ | ItemDesc | Product description | Varchar(100) | Product name |
360
+ | NotifyURL | Notification URL | Varchar(50) | Callback URL |
361
+ | LgsNo | Shipment number | Varchar(20) | Logistics tracking number |
362
+ | StorePrintNo | Store print code | Varchar(20) | Kiosk print code |
363
+ | collectionAmt | Collection amount | Int(10) | COD amount |
364
+ | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
365
+ | Type | Order type | Int(1) | 1=Normal, 3=Return |
366
+ | ShopDate | Ship date | Date | Shipping date |
367
+ | UserName | Recipient name | Varchar(20) | Pickup person |
368
+ | UserTel | Recipient phone | Varchar(10) | Mobile number |
369
+ | UserEmail | Recipient email | Varchar(50) | Email |
370
+ | StoreID | Pickup store ID | Varchar(10) | Store code |
371
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
372
+ | StoreName | Store name | Varchar(20) | Store name |
373
+ | RetId | Status code | Varchar(10) | See status code table |
374
+ | RetString | Status description | Varchar(30) | See status description |
375
+
376
+ ---
377
+
378
+ ### 6. Modify Shipment API [NPA-B56]
379
+
380
+ Modify shipment order details (only for orders not yet shipped or expired).
381
+
382
+ **Endpoint:**
383
+ - Test: `https://ccore.newebpay.com/API/Logistic/modifyShipment`
384
+ - Production: `https://core.newebpay.com/API/Logistic/modifyShipment`
385
+
386
+ **Modifiable Conditions:**
387
+ - Not yet obtained shipping number
388
+ - Shipment expired
389
+ - Store reselection
390
+
391
+ **EncryptData_ Parameters:**
392
+
393
+ | Field | Description | Type | Required | Notes |
394
+ |-------|-------------|------|----------|-------|
395
+ | MerchantOrderNo | Merchant order number | Varchar(30) | V | Order ID |
396
+ | LgsType | Logistics type | Varchar(15) | V | B2C or C2C |
397
+ | ShipType | Logistics provider | Varchar(15) | V | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
398
+ | UserName | Recipient name | Varchar(20) | - | New recipient name |
399
+ | UserTel | Recipient phone | Varchar(10) | - | New phone number |
400
+ | UserEmail | Recipient email | Varchar(50) | - | New email |
401
+ | StoreID | Pickup store ID | Varchar(10) | + | New store ID |
402
+ | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
403
+
404
+ **Response EncryptData_ Parameters:**
405
+
406
+ | Field | Description | Type | Notes |
407
+ |-------|-------------|------|-------|
408
+ | MerchantID | Merchant ID | Varchar(15) | NewebPay merchant ID |
409
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
410
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
411
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
412
+
413
+ ---
414
+
415
+ ### 7. Track Shipment API [NPA-B57]
416
+
417
+ Track complete logistics delivery history.
418
+
419
+ **Endpoint:**
420
+ - Test: `https://ccore.newebpay.com/API/Logistic/trace`
421
+ - Production: `https://core.newebpay.com/API/Logistic/trace`
422
+
423
+ **EncryptData_ Parameters:**
424
+
425
+ | Field | Description | Type | Required | Notes |
426
+ |-------|-------------|------|----------|-------|
427
+ | MerchantOrderNo | Merchant order number | Varchar(30) | V | Order ID |
428
+ | TimeStamp | Unix timestamp | Varchar(50) | V | Current time in seconds |
429
+
430
+ **Response EncryptData_ Parameters:**
431
+
432
+ | Field | Description | Type | Notes |
433
+ |-------|-------------|------|-------|
434
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
435
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
436
+ | LgsNo | Shipment number | Varchar(20) | Tracking number |
437
+ | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
438
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
439
+ | History | History array | json_array | Tracking history |
440
+ | RetId | Status code | Varchar(10) | See status code table |
441
+ | RetString | Status description | Varchar(30) | See status description |
442
+ | EventTime | Event time | Varchar(20) | Timestamp |
443
+
444
+ ---
445
+
446
+ ### 8. Status Notification [NPA-B58]
447
+
448
+ Real-time notification when shipment status changes.
449
+
450
+ **Merchant provides NotifyURL to receive notifications**
451
+
452
+ **POST Parameters:**
453
+
454
+ | Field | Description | Type | Notes |
455
+ |-------|-------------|------|-------|
456
+ | Status | Response status | Varchar(10) | SUCCESS or error code |
457
+ | Message | Response message | Varchar(30) | Status description |
458
+ | EncryptData_ | Encrypted data | Text | - |
459
+ | HashData_ | Hash data | Text | - |
460
+ | UID_ | Merchant ID | Varchar(15) | NewebPay merchant ID |
461
+ | Version_ | API version | Varchar(5) | Fixed: 1.0 |
462
+
463
+ **EncryptData_ Parameters:**
464
+
465
+ | Field | Description | Type | Notes |
466
+ |-------|-------------|------|-------|
467
+ | LgsType | Logistics type | Varchar(15) | B2C or C2C |
468
+ | MerchantOrderNo | Merchant order number | Varchar(30) | Order ID |
469
+ | LgsNo | Shipment number | Varchar(20) | Tracking number |
470
+ | TradeType | Trade type | Int(1) | 1=COD, 3=No Payment |
471
+ | ShipType | Logistics provider | Varchar(15) | 1=7-11, 2=FamilyMart, 3=Hi-Life, 4=OK Mart |
472
+ | RetId | Status code | Varchar(10) | See status code table |
473
+ | RetString | Status description | Varchar(30) | See status description |
474
+ | EventTime | Event time | Varchar(20) | Timestamp |
475
+
476
+ ---
477
+
478
+ ## Encryption Methods
479
+
480
+ ### Hash Data Processing
481
+
482
+ NewebPay Logistics uses the same encryption method as NewebPay Payment:
483
+
484
+ 1. **AES-256-CBC Encryption**: Encrypt data using merchant's HashKey and HashIV
485
+ 2. **SHA256 Hash**: Add HashKey + AES result + HashIV, then SHA256 hash and uppercase
486
+
487
+ **Process:**
488
+ ```
489
+ EncryptData = AES-256-CBC(data, HashKey, HashIV)
490
+ HashData = SHA256(HashKey + EncryptData + HashIV).toUpperCase()
491
+ ```
492
+
493
+ ---
494
+
495
+ ## Status Codes
496
+
497
+ ### RetId Status Codes & RetString Descriptions
498
+
499
+ | RetId | RetString | Category |
500
+ |-------|-----------|----------|
501
+ | 0_1 | Order not processed | Pending |
502
+ | 0_2 | Shipment number expired, please get new number | Pending |
503
+ | 0_3 | Shipment canceled | Pending |
504
+ | 1 | Order processing | Processing |
505
+ | 2 | Store received shipment | In Transit |
506
+ | 3 | Store reselected, waiting for re-shipment | In Transit |
507
+ | 4 | Arrived at logistics center | In Transit |
508
+ | 11 | Pickup store closed, please reselect | In Transit |
509
+ | 5 | Arrived at pickup store | Ready for Pickup |
510
+ | 6 | Customer picked up | Completed |
511
+ | -1 | Returned to merchant | Completed |
512
+ | -6 | Home delivery return requested | Completed |
513
+ | -9 | Logistics inspection error | Completed |
514
+ | -2 | Returned to sender/designated return store | Return/Compensation |
515
+ | -3 | Returned to logistics center | Return/Compensation |
516
+ | -4 | Returning to logistics center (customer did not pickup) | Return/Compensation |
517
+ | -5 | Soon to be returned (customer did not pickup) | Return/Compensation |
518
+ | -7 | Error compensation approved | Return/Compensation |
519
+ | -10 | Product destroyed/discarded | Return/Compensation |
520
+ | -11 | Product destroyed/discarded | Return/Compensation |
521
+ | 10 | Soon to be returned | Return/Compensation |
522
+ | 12 | Return store closed, please reselect | Return/Compensation |
523
+ | 13 | Returning to logistics center (merchant did not pickup) | Return/Compensation |
524
+ | 14 | Please request home delivery return | Return/Compensation |
525
+ | 15 | Product destroyed/discarded | Return/Compensation |
526
+ | 16 | Please confirm bank account | Return/Compensation |
527
+
528
+ ---
529
+
530
+ ## Error Codes
531
+
532
+ ### Common Error Codes
533
+
534
+ | Code | Message | Notes |
535
+ |------|---------|-------|
536
+ | SUCCESS | Success | - |
537
+ | 1101 | Failed to create logistics order | - |
538
+ | 1102 | Merchant not found | - |
539
+ | 1103 | Duplicate merchant order number | - |
540
+ | 1104 | Logistics service not enabled | - |
541
+ | 1105 | Store information invalid or empty | - |
542
+ | 1106 | IP not allowed | - |
543
+ | 1107 | Payment order not found | - |
544
+ | 1108 | System error, cannot query logistics order | - |
545
+ | 1109 | Logistics order not found | - |
546
+ | 1110 | System error, cannot modify logistics order | - |
547
+ | 1111 | Order status cannot be modified | - |
548
+ | 1112 | Failed to modify logistics order | - |
549
+ | 1113 | System error, cannot query tracking history | - |
550
+ | 1114 | Insufficient prepaid balance | - |
551
+ | 1115 | Failed to get shipment number | - |
552
+ | 1116 | Shipment already created for this transaction | - |
553
+ | 2100 | Data format error | - |
554
+ | 2101 | Version error | - |
555
+ | 2102 | UID_ cannot be empty | - |
556
+ | 2103 | COD amount limit: 20000 NTD | - |
557
+ | 2104 | No payment amount limit: 20000 NTD | - |
558
+ | 2105 | Max 10 shipment numbers per request | - |
559
+ | 2106 | Max labels per request: 7-11(18), FamilyMart(8), Hi-Life(18), OK Mart(18) | - |
560
+ | 4101 | IP restricted | - |
561
+ | 4103 | HashData_ verification failed | - |
562
+ | 4104 | Encryption error, check Hash_Key and Hash_IV | - |
563
+
564
+ ---
565
+
566
+ ## Important Notes
567
+
568
+ ### Amount Limits
569
+ - **COD (Cash on Delivery)**: Maximum 20,000 NTD
570
+ - **No Payment**: Maximum 20,000 NTD
571
+
572
+ ### Batch Limits
573
+ - **Get Shipment Number**: Maximum 10 orders per request
574
+ - **Print Label**:
575
+ - 7-ELEVEN: Maximum 18 labels
576
+ - FamilyMart: Maximum 8 labels
577
+ - Hi-Life: Maximum 18 labels
578
+ - OK Mart: Maximum 18 labels
579
+
580
+ ### Store Code Notes
581
+ - For FamilyMart and OK Mart, the store code displayed on the map may not be the real code
582
+ - Always use the store code returned in the API response (StoreID field)
583
+
584
+ ### Timestamp
585
+ - Must use Unix timestamp (seconds since 1970-01-01 00:00:00 GMT)
586
+ - Tolerance: 120 seconds
587
+ - Incorrect timestamp will cause transaction failure
588
+
589
+ ---
590
+
591
+ ## PAYUNi API Operations
592
+
593
+ ### 1. Create 7-11 C2C Shipment
594
+
595
+ Create store-to-store logistics order.
596
+
597
+ **Endpoint:** `POST /api/logistics/create`
598
+
599
+ **Request Body:**
600
+
601
+ | Field | Type | Required | Description |
602
+ |-------|------|----------|-------------|
603
+ | MerID | String | | Merchant ID |
604
+ | Version | String | | API version (1.0) |
605
+ | EncryptInfo | String | | AES-256-GCM encrypted data |
606
+ | HashInfo | String | | SHA256 hash |
607
+
608
+ **EncryptInfo Parameters:**
609
+
610
+ | Field | Type | Required | Description |
611
+ |-------|------|----------|-------------|
612
+ | MerID | String(20) | | Merchant ID |
613
+ | MerTradeNo | String(50) | | Unique order number |
614
+ | LogisticsType | String(50) | | PAYUNi_Logistic_711 |
615
+ | GoodsType | Integer | | 1=Normal, 2=Frozen |
616
+ | GoodsAmount | Integer | | Product amount |
617
+ | GoodsName | String(50) | | Product name |
618
+ | SenderName | String(10) | | Sender name |
619
+ | SenderPhone | String(20) | | Sender phone |
620
+ | SenderStoreID | String(10) | | Sender store code (C2C only) |
621
+ | ReceiverName | String(10) | | Receiver name |
622
+ | ReceiverPhone | String(20) | | Receiver phone |
623
+ | ReceiverStoreID | String(10) | | Receiver store code |
624
+ | NotifyURL | String(500) | | Status notification URL |
625
+ | Timestamp | Integer | | Unix timestamp |
626
+
627
+ **Response (Decrypted EncryptInfo):**
628
+
629
+ | Field | Description |
630
+ |-------|-------------|
631
+ | LogisticsID | PAYUNi logistics ID |
632
+ | MerTradeNo | Merchant order number |
633
+ | CVSPaymentNo | Store payment code |
634
+ | CVSValidationNo | Store validation code |
635
+ | ExpireDate | Pickup deadline |
636
+
637
+ ---
638
+
639
+ ### 2. Create T-Cat Home Delivery
640
+
641
+ Create home delivery shipment.
642
+
643
+ **Endpoint:** `POST /api/logistics/create`
644
+
645
+ **Additional EncryptInfo Parameters:**
646
+
647
+ | Field | Type | Required | Description |
648
+ |-------|------|----------|-------------|
649
+ | LogisticsType | String(50) | | PAYUNi_Logistic_Tcat |
650
+ | GoodsType | Integer | | 1=Normal, 2=Frozen, 3=Refrigerated |
651
+ | GoodsWeight | Integer | - | Weight in grams |
652
+ | SenderZipCode | String(5) | | Sender postal code |
653
+ | SenderAddress | String(200) | | Sender address |
654
+ | ReceiverZipCode | String(5) | | Receiver postal code |
655
+ | ReceiverAddress | String(200) | | Receiver address |
656
+ | ScheduledPickupDate | String(10) | - | Pickup date (yyyy/MM/dd) |
657
+ | ScheduledDeliveryDate | String(10) | - | Delivery date (yyyy/MM/dd) |
658
+ | ScheduledDeliveryTime | String(2) | - | 01/02/03 (time slot) |
659
+
660
+ **Delivery Time Slots:**
661
+ - `01` - Before 13:00
662
+ - `02` - 14:00 - 18:00
663
+ - `03` - Not specified
664
+
665
+ **Response (Decrypted EncryptInfo):**
666
+
667
+ | Field | Description |
668
+ |-------|-------------|
669
+ | LogisticsID | PAYUNi logistics ID |
670
+ | MerTradeNo | Merchant order number |
671
+ | ShipmentNo | T-Cat tracking number |
672
+ | BookingNote | Pickup number |
673
+
674
+ ---
675
+
676
+ ### 3. Query Shipment Status
677
+
678
+ Query logistics order status.
679
+
680
+ **Endpoint:** `POST /api/logistics/query`
681
+
682
+ **EncryptInfo Parameters:**
683
+
684
+ | Field | Type | Required | Description |
685
+ |-------|------|----------|-------------|
686
+ | MerID | String | | Merchant ID |
687
+ | MerTradeNo | String | | Order number |
688
+ | Timestamp | Integer | | Unix timestamp |
689
+
690
+ **Response (Decrypted EncryptInfo):**
691
+
692
+ | Field | Description |
693
+ |-------|-------------|
694
+ | LogisticsID | PAYUNi logistics ID |
695
+ | MerTradeNo | Merchant order number |
696
+ | LogisticsType | Logistics type |
697
+ | LogisticsStatus | Status code (11/21/22/31/32) |
698
+ | LogisticsStatusMsg | Status message |
699
+ | ShipmentNo | Tracking number |
700
+ | ReceiverStoreID | Receiver store code |
701
+ | UpdateTime | Last update time |
702
+
703
+ **Logistics Status Codes:**
704
+
705
+ | Code | Description | Category |
706
+ |------|-------------|----------|
707
+ | 11 | Shipped | In Transit |
708
+ | 21 | Arrived at store / In delivery | In Transit |
709
+ | 22 | Picked up / Delivered | Completed |
710
+ | 31 | Returning | Return |
711
+ | 32 | Return completed | Return |
712
+
713
+ ---
714
+
715
+ ### 4. Status Notification Callback
716
+
717
+ Handle real-time status updates from PAYUNi.
718
+
719
+ **Callback Request (POST to NotifyURL):**
720
+
721
+ | Field | Type | Description |
722
+ |-------|------|-------------|
723
+ | MerID | String | Merchant ID |
724
+ | EncryptInfo | String | Encrypted status data |
725
+ | HashInfo | String | SHA256 hash |
726
+
727
+ **Decrypted EncryptInfo:**
728
+
729
+ | Field | Description |
730
+ |-------|-------------|
731
+ | MerID | Merchant ID |
732
+ | MerTradeNo | Merchant order number |
733
+ | LogisticsID | PAYUNi logistics ID |
734
+ | LogisticsType | Logistics type |
735
+ | LogisticsStatus | Status code |
736
+ | LogisticsStatusMsg | Status message |
737
+ | UpdateTime | Update timestamp |
738
+
739
+ **Response Required:**
740
+ - Success: `SUCCESS`
741
+ - Error: Any other response
742
+
743
+ ---
744
+
745
+ ## PAYUNi Encryption (AES-256-GCM)
746
+
747
+ ### Encryption Process
748
+
749
+ ```
750
+ 1. Create Query String from parameters
751
+ 2. AES-256-GCM encrypt (with 16-byte tag)
752
+ 3. Convert to hex: EncryptInfo = hex(encrypted + tag)
753
+ 4. Generate HashInfo: SHA256(EncryptInfo + HashKey + HashIV)
754
+ ```
755
+
756
+ ### Decryption Process
757
+
758
+ ```
759
+ 1. Convert hex to binary
760
+ 2. Split: encrypted = data[:-16], tag = data[-16:]
761
+ 3. AES-256-GCM decrypt and verify tag
762
+ 4. Parse query string to get parameters
763
+ ```
764
+
765
+ ---
766
+
767
+ ## Best Practices
768
+
769
+ 1. **Store Selection**: Always use the StoreID from the Store Map API response, not the displayed code
770
+ 2. **Error Handling**: Implement proper error handling for all API calls with retry logic
771
+ 3. **Status Tracking**: Use Status Notification webhook for real-time updates instead of polling
772
+ 4. **Encryption**: Securely store HashKey and HashIV, never expose in client-side code
773
+ 5. **Order Numbers**: Ensure MerchantOrderNo is unique across all orders
774
+ 6. **Timestamp**: Always generate fresh timestamp for each API call
775
+ 7. **Testing**: Use test environment extensively before going to production
776
+ 8. **Validation**: Validate all user input (name, phone, email) before API calls
777
+ 9. **Logging**: Log all API requests and responses for debugging and auditing
778
+ 10. **Notification URL**: Ensure NotifyURL is accessible from NewebPay servers (not localhost)
779
+
780
+ ---
781
+
782
+ ## Use Cases
783
+
784
+ ### E-commerce Platform
785
+ - Integrate store map for customers to select pickup location
786
+ - Create shipment automatically after order confirmation
787
+ - Send tracking updates to customers via email/SMS
788
+ - Handle returns and exchanges through modify shipment API
789
+
790
+ ### Marketplace
791
+ - Support multiple vendors shipping to convenience stores
792
+ - Provide unified logistics tracking interface
793
+ - Automate shipment number retrieval and label printing
794
+ - Handle COD payment collection and settlement
795
+
796
+ ### Subscription Service
797
+ - Schedule recurring shipments to same pickup store
798
+ - Automatic label generation for regular deliveries
799
+ - Batch shipment creation for multiple orders
800
+ - Track delivery success rate and optimize logistics
801
+
802
+ ---
803
+
804
+ ## Related Resources
805
+
806
+ - [EXAMPLES.md](./EXAMPLES.md) - Complete code examples (TypeScript, Python, PHP)
807
+ - [references/NEWEBPAY_LOGISTICS_REFERENCE.md](./references/NEWEBPAY_LOGISTICS_REFERENCE.md) - NewebPay Logistics API full specification
808
+ - [scripts/search.py](./scripts/search.py) - BM25 search engine for error codes and fields
809
+ - [scripts/test_logistics.py](./scripts/test_logistics.py) - Connection testing tool
810
+
811
+ ---
812
+
813
+ ## Support
814
+
815
+ ### NewebPay Technical Support
816
+ - Phone: 02-2655-8938
817
+ - Official Documentation: https://www.newebpay.com
818
+
819
+ ### API Version
820
+ Current Version: 1.0
821
+
822
+ ### Last Updated
823
+ 2026-01-29
824
+
825
+ ---
826
+
827
+ **Total Lines**: 750+