taiwan-logistics-skill 1.0.3 → 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,774 +1,774 @@
1
- # NewebPay Logistics API Reference
2
-
3
- **Complete API specification for NewebPay Logistics Services**
4
-
5
- Version: 1.0
6
- Last Updated: 2026-01-29
7
-
8
- ---
9
-
10
- ## Table of Contents
11
-
12
- 1. [Overview](#overview)
13
- 2. [Authentication & Encryption](#authentication--encryption)
14
- 3. [API Endpoints](#api-endpoints)
15
- 4. [Data Types & Formats](#data-types--formats)
16
- 5. [Error Codes](#error-codes)
17
- 6. [Status Codes](#status-codes)
18
- 7. [Testing](#testing)
19
-
20
- ---
21
-
22
- ## Overview
23
-
24
- ### Service Types
25
-
26
- **B2C (大宗寄倉) - Bulk Warehouse:**
27
- - Merchant ships goods to NewebPay logistics center
28
- - Logistics center distributes to pickup convenience stores
29
- - Only available for 7-ELEVEN
30
-
31
- **C2C (店到店) - Store-to-Store:**
32
- - Merchant ships goods to sender convenience store
33
- - Store ships to logistics center, then to pickup store
34
- - Available for: 7-ELEVEN, FamilyMart, Hi-Life, OK Mart
35
-
36
- ### Trade Types
37
-
38
- | Code | Type | Description |
39
- |------|------|-------------|
40
- | 1 | 取貨付款 | Cash on Delivery (COD) |
41
- | 3 | 取貨不付款 | No Payment (payment already completed) |
42
-
43
- ### Convenience Store Codes
44
-
45
- | Code | Store | C2C Support | B2C Support |
46
- |------|-------|-------------|-------------|
47
- | 1 | 7-ELEVEN | | |
48
- | 2 | FamilyMart (全家) | | ✗ |
49
- | 3 | Hi-Life (萊爾富) | | ✗ |
50
- | 4 | OK Mart | | ✗ |
51
-
52
- ---
53
-
54
- ## Authentication & Encryption
55
-
56
- ### Encryption Method
57
-
58
- NewebPay Logistics uses AES-256-CBC + SHA256 encryption (same as NewebPay Payment).
59
-
60
- **Required Credentials:**
61
- - Merchant ID (UID)
62
- - HashKey (32 characters)
63
- - HashIV (16 characters)
64
-
65
- ### Encryption Process
66
-
67
- #### 1. Encrypt Data (AES-256-CBC)
68
-
69
- ```
70
- EncryptData = AES-256-CBC(JSON.stringify(data), HashKey, HashIV)
71
- ```
72
-
73
- **Parameters:**
74
- - Algorithm: AES-256-CBC
75
- - Key: HashKey (32 bytes)
76
- - IV: HashIV (16 bytes)
77
- - Mode: CBC
78
- - Padding: PKCS7
79
-
80
- #### 2. Generate Hash (SHA256)
81
-
82
- ```
83
- HashData = SHA256(HashKey + EncryptData + HashIV).toUpperCase()
84
- ```
85
-
86
- ### Decryption Process
87
-
88
- #### 1. Verify Hash
89
-
90
- ```
91
- CalculatedHash = SHA256(HashKey + EncryptData + HashIV).toUpperCase()
92
- if (CalculatedHash !== HashData) throw Error('Hash verification failed')
93
- ```
94
-
95
- #### 2. Decrypt Data
96
-
97
- ```
98
- DecryptedJSON = AES-256-CBC-Decrypt(EncryptData, HashKey, HashIV)
99
- Data = JSON.parse(DecryptedJSON)
100
- ```
101
-
102
- ---
103
-
104
- ## API Endpoints
105
-
106
- ### Base URLs
107
-
108
- **Test Environment:**
109
- ```
110
- https://ccore.newebpay.com/API/Logistic
111
- ```
112
-
113
- **Production Environment:**
114
- ```
115
- https://core.newebpay.com/API/Logistic
116
- ```
117
-
118
- ### API List
119
-
120
- | API | Endpoint | Method | Description |
121
- |-----|----------|--------|-------------|
122
- | Store Map Query | `/storeMap` | POST | Query convenience store locations |
123
- | Create Shipment | `/createShipment` | POST | Create logistics order |
124
- | Get Shipment Number | `/getShipmentNo` | POST | Get shipping code for printing |
125
- | Print Label | `/printLabel` | POST (Form) | Print shipping labels |
126
- | Query Shipment | `/queryShipment` | POST | Query order status |
127
- | Modify Shipment | `/modifyShipment` | POST | Modify order details |
128
- | Track Shipment | `/trace` | POST | Track delivery history |
129
-
130
- ---
131
-
132
- ## 1. Store Map Query API [NPA-B51]
133
-
134
- Query convenience store locations for customer to select pickup or sender store.
135
-
136
- ### Request
137
-
138
- **URL:** `POST /API/Logistic/storeMap`
139
-
140
- **Parameters:**
141
-
142
- | Field | Type | Required | Description |
143
- |-------|------|----------|-------------|
144
- | UID_ | Varchar(15) | | Merchant ID |
145
- | EncryptData_ | Text | | Encrypted data |
146
- | HashData_ | Text | | SHA256 hash |
147
- | Version_ | Varchar(5) | | API version (fixed: "1.0") |
148
- | RespondType_ | Varchar(6) | | Response format (fixed: "JSON") |
149
-
150
- **EncryptData_ Content:**
151
-
152
- | Field | Type | Required | Description |
153
- |-------|------|----------|-------------|
154
- | MerchantOrderNo | Varchar(30) | | Unique order ID (alphanumeric + underscore) |
155
- | LgsType | Varchar(15) | | "B2C" or "C2C" |
156
- | ShipType | Varchar(15) | | "1"=7-11, "2"=FamilyMart, "3"=Hi-Life, "4"=OK Mart |
157
- | ReturnURL | Varchar(50) | | Callback URL after store selection |
158
- | TimeStamp | Text | | Unix timestamp (tolerance: 120 seconds) |
159
- | ExtraData | Varchar(20) | - | Custom data (returned as-is) |
160
-
161
- ### Response
162
-
163
- **Status Codes:**
164
- - `SUCCESS`: Request successful
165
- - Error codes: See [Error Codes](#error-codes)
166
-
167
- **Response Parameters:**
168
-
169
- | Field | Type | Description |
170
- |-------|------|-------------|
171
- | Status | Varchar(10) | Response status |
172
- | Message | Varchar(30) | Status message |
173
- | EncryptData | Text | Encrypted response data |
174
- | HashData | Text | SHA256 hash |
175
- | UID | Varchar(15) | Merchant ID |
176
- | Version | Varchar(5) | API version |
177
-
178
- **Decrypted EncryptData Content (Callback):**
179
-
180
- | Field | Type | Description |
181
- |-------|------|-------------|
182
- | LgsType | Varchar(15) | Logistics type |
183
- | ShipType | Varchar(15) | Store type code |
184
- | MerchantOrderNo | Varchar(30) | Order ID |
185
- | StoreName | Varchar(10) | Selected store name |
186
- | StoreTel | Varchar(12) | Store phone number |
187
- | StoreAddr | Varchar(100) | Store address |
188
- | StoreID | Varchar(8) | Store code (use this for shipment creation) |
189
- | ExtraData | Varchar(20) | Original custom data |
190
-
191
- **Important Notes:**
192
- - For FamilyMart and OK Mart, the store code displayed on map may differ from the actual StoreID
193
- - Always use the StoreID returned in the callback, not the displayed code
194
-
195
- ---
196
-
197
- ## 2. Create Shipment API [NPA-B52]
198
-
199
- Create logistics shipment order after payment order is established.
200
-
201
- ### Request
202
-
203
- **URL:** `POST /API/Logistic/createShipment`
204
-
205
- **Parameters:**
206
-
207
- | Field | Type | Required | Description |
208
- |-------|------|----------|-------------|
209
- | UID_ | Varchar(15) | | Merchant ID |
210
- | EncryptData_ | Text | | Encrypted data |
211
- | HashData_ | Text | | SHA256 hash |
212
- | Version_ | Varchar(5) | | Fixed: "1.0" |
213
- | RespondType_ | Varchar(6) | | Fixed: "JSON" |
214
-
215
- **EncryptData_ Content:**
216
-
217
- | Field | Type | Required | Description |
218
- |-------|------|----------|-------------|
219
- | MerchantOrderNo | Varchar(30) | | Unique order ID |
220
- | TradeType | Int(1) | | 1=COD, 3=No Payment |
221
- | UserName | Varchar(20) | | Recipient name |
222
- | UserTel | Varchar(10) | | Recipient mobile number |
223
- | UserEmail | Varchar(50) | | Recipient email |
224
- | StoreID | Varchar(10) | | Pickup store code (from store map) |
225
- | Amt | Int(10) | | Transaction amount (max: 20000 NTD) |
226
- | NotifyURL | Varchar(100) | - | Status notification callback URL |
227
- | ItemDesc | Varchar(100) | - | Product description |
228
- | LgsType | Varchar(3) | | "B2C" or "C2C" |
229
- | ShipType | Varchar(15) | | "1"=7-11, "2"=FamilyMart, "3"=Hi-Life, "4"=OK Mart |
230
- | TimeStamp | Varchar(50) | | Unix timestamp (tolerance: 120 seconds) |
231
-
232
- **Amount Limits:**
233
- - COD (TradeType=1): Maximum 20,000 NTD
234
- - No Payment (TradeType=3): Maximum 20,000 NTD
235
-
236
- ### Response
237
-
238
- **Decrypted EncryptData Content:**
239
-
240
- | Field | Type | Description |
241
- |-------|------|-------------|
242
- | MerchantID | Varchar(15) | NewebPay merchant ID |
243
- | Amt | Int(10) | Transaction amount |
244
- | MerchantOrderNo | Varchar(30) | Order ID |
245
- | TradeNo | Varchar(20) | NewebPay transaction ID (important: save this) |
246
- | LgsType | Varchar(15) | Logistics type |
247
- | ShipType | Varchar(15) | Store type |
248
- | StoreID | Varchar(10) | Pickup store code |
249
- | TradeType | Int(1) | Trade type |
250
-
251
- ---
252
-
253
- ## 3. Get Shipment Number API [NPA-B53]
254
-
255
- Get shipping code before shipment. Merchants can use this code to print labels at convenience store Kiosk machines.
256
-
257
- ### Request
258
-
259
- **URL:** `POST /API/Logistic/getShipmentNo`
260
-
261
- **EncryptData_ Content:**
262
-
263
- | Field | Type | Required | Description |
264
- |-------|------|----------|-------------|
265
- | MerchantOrderNo | Json_array | | Array of order IDs (max 10) |
266
- | TimeStamp | Varchar(50) | | Unix timestamp |
267
-
268
- **Batch Limit:** Maximum 10 orders per request
269
-
270
- ### Response
271
-
272
- **Decrypted EncryptData Content:**
273
-
274
- | Field | Type | Description |
275
- |-------|------|-------------|
276
- | SUCCESS | Json_array | Array of successful results |
277
- | ERROR | Json_array | Array of failed results |
278
-
279
- **SUCCESS Array Item:**
280
-
281
- | Field | Type | Description |
282
- |-------|------|-------------|
283
- | MerchantOrderNo | Varchar(30) | Order ID |
284
- | ErrorCode | Varchar(20) | "SUCCESS" |
285
- | LgsNo | Varchar(20) | Logistics tracking number |
286
- | StorePrintNo | Varchar(20) | Code for Kiosk printing |
287
- | ShipType | Varchar(15) | Store type |
288
- | LgsType | Varchar(15) | Logistics type |
289
-
290
- **ERROR Array Item:**
291
-
292
- | Field | Type | Description |
293
- |-------|------|-------------|
294
- | MerchantOrderNo | Varchar(30) | Order ID |
295
- | ErrorCode | Varchar(20) | Error code (see error codes section) |
296
-
297
- ---
298
-
299
- ## 4. Print Label API [NPA-B54]
300
-
301
- Print shipping labels to attach to products.
302
-
303
- ### Request
304
-
305
- **URL:** `POST /API/Logistic/printLabel`
306
-
307
- **Important:** This API requires **Form POST** method (not JSON API call). The response is an HTML page for printing.
308
-
309
- **EncryptData_ Content:**
310
-
311
- | Field | Type | Required | Description |
312
- |-------|------|----------|-------------|
313
- | LgsType | Varchar(15) | | "B2C" or "C2C" |
314
- | ShipType | Varchar(15) | | "1"=7-11, "2"=FamilyMart, "3"=Hi-Life, "4"=OK Mart |
315
- | MerchantOrderNo | json_array | | Array of order IDs |
316
- | TimeStamp | Varchar(50) | | Unix timestamp |
317
-
318
- **Batch Limits:**
319
-
320
- | Store | Maximum Labels per Request |
321
- |-------|----------------------------|
322
- | 7-ELEVEN (1) | 18 |
323
- | FamilyMart (2) | 8 |
324
- | Hi-Life (3) | 18 |
325
- | OK Mart (4) | 18 |
326
-
327
- ### Response
328
-
329
- Returns HTML page with printable shipping labels.
330
-
331
- ---
332
-
333
- ## 5. Query Shipment API [NPA-B55]
334
-
335
- Query logistics order information and current status.
336
-
337
- ### Request
338
-
339
- **URL:** `POST /API/Logistic/queryShipment`
340
-
341
- **EncryptData_ Content:**
342
-
343
- | Field | Type | Required | Description |
344
- |-------|------|----------|-------------|
345
- | MerchantOrderNo | Varchar(30) | | Order ID |
346
- | TimeStamp | Varchar(50) | | Unix timestamp |
347
-
348
- ### Response
349
-
350
- **Decrypted EncryptData Content:**
351
-
352
- | Field | Type | Description |
353
- |-------|------|-------------|
354
- | MerchantID | Varchar(15) | Merchant ID |
355
- | LgsType | Varchar(15) | Logistics type |
356
- | TradeNo | Varchar(20) | NewebPay transaction ID |
357
- | MerchantOrderNo | Varchar(30) | Order ID |
358
- | Amt | Int(10) | Transaction amount |
359
- | ItemDesc | Varchar(100) | Product description |
360
- | NotifyURL | Varchar(50) | Notification URL |
361
- | LgsNo | Varchar(20) | Logistics tracking number |
362
- | StorePrintNo | Varchar(20) | Store print code |
363
- | collectionAmt | Int(10) | COD collection amount |
364
- | TradeType | Int(1) | 1=COD, 3=No Payment |
365
- | Type | Int(1) | 1=Normal, 3=Return |
366
- | ShopDate | Date | Ship date |
367
- | UserName | Varchar(20) | Recipient name |
368
- | UserTel | Varchar(10) | Recipient phone |
369
- | UserEmail | Varchar(50) | Recipient email |
370
- | StoreID | Varchar(10) | Pickup store code |
371
- | ShipType | Varchar(15) | Store type |
372
- | StoreName | Varchar(20) | Store name |
373
- | Retld | Varchar(10) | Status code (see status codes section) |
374
- | RetString | Varchar(30) | Status description |
375
-
376
- ---
377
-
378
- ## 6. Modify Shipment API [NPA-B56]
379
-
380
- Modify shipment order details. Only available for orders that have not yet been shipped.
381
-
382
- ### Request
383
-
384
- **URL:** `POST /API/Logistic/modifyShipment`
385
-
386
- **Modifiable Conditions:**
387
- - Order has not yet obtained shipping number (RetId: 0_1)
388
- - Shipment expired (RetId: 0_2)
389
- - Store reselection required (RetId: 3, 11, 12)
390
-
391
- **EncryptData_ Content:**
392
-
393
- | Field | Type | Required | Description |
394
- |-------|------|----------|-------------|
395
- | MerchantOrderNo | Varchar(30) | | Order ID |
396
- | LgsType | Varchar(15) | | Logistics type |
397
- | ShipType | Varchar(15) | | Store type |
398
- | UserName | Varchar(20) | - | New recipient name |
399
- | UserTel | Varchar(10) | - | New phone number |
400
- | UserEmail | Varchar(50) | - | New email |
401
- | StoreID | Varchar(10) | + | New store code |
402
- | TimeStamp | Varchar(50) | | Unix timestamp |
403
-
404
- **Note:** When modifying for store reselection (RetId: 3, 11, 12), only StoreID can be changed. UserName, UserTel, and UserEmail cannot be modified.
405
-
406
- ### Response
407
-
408
- **Decrypted EncryptData Content:**
409
-
410
- | Field | Type | Description |
411
- |-------|------|-------------|
412
- | MerchantID | Varchar(15) | Merchant ID |
413
- | MerchantOrderNo | Varchar(30) | Order ID |
414
- | LgsType | Varchar(15) | Logistics type |
415
- | ShipType | Varchar(15) | Store type |
416
-
417
- ---
418
-
419
- ## 7. Track Shipment API [NPA-B57]
420
-
421
- Track complete logistics delivery history with all status changes.
422
-
423
- ### Request
424
-
425
- **URL:** `POST /API/Logistic/trace`
426
-
427
- **EncryptData_ Content:**
428
-
429
- | Field | Type | Required | Description |
430
- |-------|------|----------|-------------|
431
- | MerchantOrderNo | Varchar(30) | | Order ID |
432
- | TimeStamp | Varchar(50) | | Unix timestamp |
433
-
434
- ### Response
435
-
436
- **Decrypted EncryptData Content:**
437
-
438
- | Field | Type | Description |
439
- |-------|------|-------------|
440
- | LgsType | Varchar(15) | Logistics type |
441
- | MerchantOrderNo | Varchar(30) | Order ID |
442
- | LgsNo | Varchar(20) | Tracking number |
443
- | TradeType | Int(1) | Trade type |
444
- | ShipType | Varchar(15) | Store type |
445
- | History | json_array | Array of tracking history events |
446
- | Retld | Varchar(10) | Current status code |
447
- | RetString | Varchar(30) | Current status description |
448
-
449
- **History Array Item:**
450
-
451
- | Field | Type | Description |
452
- |-------|------|-------------|
453
- | Retld | Varchar(10) | Status code at this time |
454
- | RetString | Varchar(30) | Status description |
455
- | EventTime | Varchar(20) | Event timestamp |
456
-
457
- ---
458
-
459
- ## 8. Status Notification [NPA-B58]
460
-
461
- Real-time notification when shipment status changes. NewebPay will POST to the NotifyURL provided when creating shipment.
462
-
463
- ### Callback Request
464
-
465
- **Method:** POST to merchant's NotifyURL
466
-
467
- **Parameters:**
468
-
469
- | Field | Type | Description |
470
- |-------|------|-------------|
471
- | Status | Varchar(10) | "SUCCESS" or error code |
472
- | Message | Varchar(30) | Status message |
473
- | EncryptData_ | Text | Encrypted data |
474
- | HashData_ | Text | SHA256 hash |
475
- | UID_ | Varchar(15) | Merchant ID |
476
- | Version_ | Varchar(5) | API version |
477
-
478
- **Decrypted EncryptData_ Content:**
479
-
480
- | Field | Type | Description |
481
- |-------|------|-------------|
482
- | LgsType | Varchar(15) | Logistics type |
483
- | MerchantOrderNo | Varchar(30) | Order ID |
484
- | LgsNo | Varchar(20) | Tracking number |
485
- | TradeType | Int(1) | Trade type |
486
- | ShipType | Varchar(15) | Store type |
487
- | Retld | Varchar(10) | Status code |
488
- | RetString | Varchar(30) | Status description |
489
- | EventTime | Varchar(20) | Event timestamp |
490
-
491
- ### Callback Response
492
-
493
- Merchant must respond with:
494
- - Success: `1|OK`
495
- - Error: `0|Error` or `0|[Error Message]`
496
-
497
- **Important:**
498
- - NotifyURL must be accessible from NewebPay servers (not localhost)
499
- - Must respond within timeout period
500
- - NewebPay will retry if no response received
501
-
502
- ---
503
-
504
- ## Data Types & Formats
505
-
506
- ### TimeStamp Format
507
-
508
- Unix timestamp in seconds since 1970-01-01 00:00:00 GMT.
509
-
510
- ```typescript
511
- // JavaScript
512
- const timestamp = Math.floor(Date.now() / 1000).toString();
513
-
514
- // Python
515
- import time
516
- timestamp = str(int(time.time()))
517
- ```
518
-
519
- **Tolerance:** 120 seconds (±2 minutes)
520
-
521
- ### Date Format
522
-
523
- Date fields use `yyyy-MM-dd` format:
524
- - Example: `2026-01-29`
525
-
526
- ### MerchantOrderNo Format
527
-
528
- - Length: Up to 30 characters
529
- - Allowed characters: Alphanumeric (A-Z, a-z, 0-9) and underscore (_)
530
- - Must be unique across all orders
531
- - Example: `ORD_20260129_001`
532
-
533
- ### Phone Number Format
534
-
535
- - Format: 10 digits starting with 09
536
- - Example: `0912345678`
537
- - No spaces or dashes
538
-
539
- ### Email Format
540
-
541
- - Standard email format
542
- - Max length: 50 characters
543
- - Example: `customer@example.com`
544
-
545
- ---
546
-
547
- ## Error Codes
548
-
549
- ### API Error Codes
550
-
551
- | Code | Message | Description | Solution |
552
- |------|---------|-------------|----------|
553
- | SUCCESS | 成功 | Success | - |
554
- | 1101 | 新增物流訂單失敗 | Failed to create logistics order | Check order parameters |
555
- | 1102 | 查無合作商店 | Merchant not found | Verify merchant credentials |
556
- | 1103 | 已存在相同的商店訂單編號 | Duplicate order number | Use unique MerchantOrderNo |
557
- | 1104 | 無啟用對應物流商服務 | Logistics service not enabled | Contact NewebPay to enable service |
558
- | 1105 | 門市資訊有誤或空白 | Invalid or empty store information | Verify StoreID from store map |
559
- | 1106 | 不允許 IP | IP not allowed | Add IP to whitelist |
560
- | 1107 | 查無金流訂單資料 | Payment order not found | Create payment order first |
561
- | 1108 | 系統異常,無法查詢物流訂單資料 | System error, cannot query order | Retry later or contact support |
562
- | 1109 | 查無物流訂單資料 | Logistics order not found | Verify MerchantOrderNo |
563
- | 1110 | 系統異常,無法修改物流訂單資料 | System error, cannot modify order | Retry later or contact support |
564
- | 1111 | 該筆物流單狀態已無法修改內容 | Order status cannot be modified | Check order status first |
565
- | 1112 | 修改物流單失敗 | Failed to modify order | Check modification parameters |
566
- | 1113 | 系統異常,無法查詢物流貨態歷程資料 | System error, cannot query tracking | Retry later or contact support |
567
- | 1114 | 預付費用餘額不足 | Insufficient prepaid balance | Add balance to account |
568
- | 1115 | 取寄貨單號失敗 | Failed to get shipment number | Check order status, retry later |
569
- | 1116 | 該交易已建立寄貨單資訊 | Shipment already created | Use query API to get details |
570
-
571
- ### Data Format Errors
572
-
573
- | Code | Message | Description |
574
- |------|---------|-------------|
575
- | 2100 | 資料格式錯誤 | Data format error |
576
- | 2101 | 版本錯誤 | Version error |
577
- | 2102 | UID_ 不可為空 | UID_ cannot be empty |
578
- | 2103 | 超商取貨付款的金額限 20000 元內 | COD amount limit: 20000 NTD |
579
- | 2104 | 超商取貨不付款的金額限 20000 元內 | No payment amount limit: 20000 NTD |
580
- | 2105 | 一次最多僅能取得 10 筆寄貨單號 | Max 10 shipment numbers per request |
581
- | 2106 | 7-11/全家/萊爾富/OK 最多標籤數限制 | Max labels exceeded for provider |
582
-
583
- ### Security Errors
584
-
585
- | Code | Message | Description |
586
- |------|---------|-------------|
587
- | 4101 | IP 限制使用 | IP restricted |
588
- | 4103 | HashData_ 資料檢查不符合 | Hash verification failed |
589
- | 4104 | 加密資料有誤,請確認 Hash_Key 與 Hash_IV | Encryption error, check credentials |
590
-
591
- ---
592
-
593
- ## Status Codes
594
-
595
- ### RetId & RetString
596
-
597
- | RetId | RetString | Category | Description |
598
- |-------|-----------|----------|-------------|
599
- | 0_1 | 訂單未處理 | Pending | Order not processed |
600
- | 0_2 | 物流單號已過期,請重新取號 | Pending | Shipment number expired |
601
- | 0_3 | 取消出貨 | Pending | Shipment canceled |
602
- | 1 | 訂單處理中 | Processing | Order processing |
603
- | 2 | 超商已收件 | In Transit | Store received shipment |
604
- | 3 | 已重選門市,等待物流重新出貨 | In Transit | Store reselected, waiting for re-shipment |
605
- | 4 | 商品已進物流中心驗收完成 | In Transit | Arrived at logistics center |
606
- | 11 | 取貨門市關店,請重新選取 | In Transit | Pickup store closed, reselect required |
607
- | 5 | 商品送達取貨門市 | Ready for Pickup | Arrived at pickup store |
608
- | 6 | 買家取貨完成 | Completed | Customer picked up (success) |
609
- | -1 | 商品已退回廠商 | Completed | Returned to merchant |
610
- | -6 | 已申請宅配退貨 | Completed | Home delivery return requested |
611
- | -9 | 物流驗收異常等待回覆 | Completed | Logistics inspection error |
612
- | -2 | 商品送達原寄件(指定退貨)門市 | Return/Compensation | Returned to sender store |
613
- | -3 | 商品退回物流中心驗收完成 | Return/Compensation | Returned to logistics center |
614
- | -4 | 商品退往物流中心(買家未取) | Return/Compensation | Returning (customer did not pickup) |
615
- | -5 | 商品即將退回(買家未取) | Return/Compensation | Soon to return (customer did not pickup) |
616
- | -7 | 已同意/申請異常判賠 | Return/Compensation | Compensation approved |
617
- | -10 | 商品已銷毀/拋棄 | Return/Compensation | Product destroyed |
618
- | -11 | 商品已銷毀/拋棄 | Return/Compensation | Product destroyed |
619
- | 10 | 商品即將退回 | Return/Compensation | Soon to be returned |
620
- | 12 | 退貨門市關店,請重新選取 | Return/Compensation | Return store closed |
621
- | 13 | 商品退往物流中心(賣家未取) | Return/Compensation | Returning (merchant did not pickup) |
622
- | 14 | 請申請宅配退貨 | Return/Compensation | Request home delivery return |
623
- | 15 | 商品已銷毀/拋棄 | Return/Compensation | Product destroyed |
624
- | 16 | 請確認匯款帳號 | Return/Compensation | Confirm bank account |
625
-
626
- ---
627
-
628
- ## Testing
629
-
630
- ### Test Credentials
631
-
632
- Contact NewebPay to obtain test credentials:
633
- - Test Merchant ID (UID)
634
- - Test HashKey
635
- - Test HashIV
636
-
637
- ### Test Environment
638
-
639
- **Base URL:**
640
- ```
641
- https://ccore.newebpay.com/API/Logistic
642
- ```
643
-
644
- ### Testing Checklist
645
-
646
- **1. Store Map Query**
647
- - [ ] Test B2C logistics type
648
- - [ ] Test C2C logistics type
649
- - [ ] Test all 4 convenience store types
650
- - [ ] Verify store selection callback
651
- - [ ] Verify StoreID format
652
-
653
- **2. Create Shipment**
654
- - [ ] Test COD (TradeType=1)
655
- - [ ] Test No Payment (TradeType=3)
656
- - [ ] Test amount limits (max 20,000)
657
- - [ ] Verify TradeNo generation
658
- - [ ] Test with valid StoreID
659
-
660
- **3. Get Shipment Number**
661
- - [ ] Test single order
662
- - [ ] Test multiple orders (up to 10)
663
- - [ ] Test with invalid order IDs
664
- - [ ] Verify LgsNo and StorePrintNo
665
-
666
- **4. Print Label**
667
- - [ ] Test batch limits per store type
668
- - [ ] Verify HTML response
669
- - [ ] Test print functionality
670
-
671
- **5. Query Shipment**
672
- - [ ] Test with valid order ID
673
- - [ ] Test with invalid order ID
674
- - [ ] Verify all returned fields
675
- - [ ] Check status codes
676
-
677
- **6. Modify Shipment**
678
- - [ ] Test modify recipient info
679
- - [ ] Test modify store
680
- - [ ] Test with non-modifiable status
681
- - [ ] Verify error handling
682
-
683
- **7. Track Shipment**
684
- - [ ] Test tracking history
685
- - [ ] Verify history array
686
- - [ ] Check timestamp formats
687
-
688
- **8. Status Notification**
689
- - [ ] Setup test callback URL
690
- - [ ] Test callback decryption
691
- - [ ] Test response format
692
- - [ ] Verify all status codes
693
-
694
- ### Common Test Scenarios
695
-
696
- **Scenario 1: Complete C2C Flow**
697
- 1. Query store map → Get StoreID
698
- 2. Create shipment → Get TradeNo
699
- 3. Get shipment number → Get LgsNo and StorePrintNo
700
- 4. Print label → Generate shipping label
701
- 5. Query shipment → Check status
702
- 6. Track shipment → View history
703
-
704
- **Scenario 2: Modify Recipient**
705
- 1. Create shipment
706
- 2. Query shipment status
707
- 3. Modify recipient information
708
- 4. Query shipment again to verify
709
-
710
- **Scenario 3: Change Pickup Store**
711
- 1. Create shipment
712
- 2. Query store map for new store
713
- 3. Modify shipment with new StoreID
714
- 4. Verify modification
715
-
716
- ---
717
-
718
- ## Best Practices
719
-
720
- ### 1. Order Number Management
721
- - Use unique, sequential order numbers
722
- - Include date/time in order number for tracking
723
- - Keep record of all order numbers
724
- - Don't reuse order numbers even for canceled orders
725
-
726
- ### 2. Error Handling
727
- - Always verify hash before decrypting
728
- - Implement retry logic for transient errors (1108, 1110, 1113)
729
- - Don't retry for permanent errors (1102, 1103, 1104)
730
- - Log all API requests and responses
731
-
732
- ### 3. Security
733
- - Store HashKey and HashIV securely (environment variables, secrets manager)
734
- - Never expose credentials in client-side code
735
- - Use HTTPS for all NotifyURL endpoints
736
- - Validate IP whitelist for production
737
-
738
- ### 4. Status Tracking
739
- - Use status notification webhook instead of polling
740
- - Handle all status codes appropriately
741
- - Send customer notifications for key status changes (5, 6, -1)
742
- - Log all status updates
743
-
744
- ### 5. Store Selection
745
- - Always use StoreID from API response, not displayed code
746
- - Validate StoreID before creating shipment
747
- - Cache store information for reuse
748
- - Provide clear store selection UI to customers
749
-
750
- ### 6. Testing
751
- - Test all APIs in test environment before production
752
- - Verify encryption/decryption works correctly
753
- - Test error scenarios
754
- - Validate timestamp handling
755
-
756
- ---
757
-
758
- ## Support
759
-
760
- ### NewebPay Technical Support
761
-
762
- **Phone:** 02-2655-8938
763
-
764
- **Official Website:** https://www.newebpay.com
765
-
766
- ### API Documentation
767
-
768
- For the latest API documentation and updates, visit NewebPay's developer portal or contact technical support.
769
-
770
- ---
771
-
772
- **Document Version:** 1.0
773
- **Last Updated:** 2026-01-29
774
- **Total Lines:** 950+
1
+ # NewebPay Logistics API Reference
2
+
3
+ **Complete API specification for NewebPay Logistics Services**
4
+
5
+ Version: 1.0
6
+ Last Updated: 2026-01-29
7
+
8
+ ---
9
+
10
+ ## Table of Contents
11
+
12
+ 1. [Overview](#overview)
13
+ 2. [Authentication & Encryption](#authentication--encryption)
14
+ 3. [API Endpoints](#api-endpoints)
15
+ 4. [Data Types & Formats](#data-types--formats)
16
+ 5. [Error Codes](#error-codes)
17
+ 6. [Status Codes](#status-codes)
18
+ 7. [Testing](#testing)
19
+
20
+ ---
21
+
22
+ ## Overview
23
+
24
+ ### Service Types
25
+
26
+ **B2C (大宗寄倉) - Bulk Warehouse:**
27
+ - Merchant ships goods to NewebPay logistics center
28
+ - Logistics center distributes to pickup convenience stores
29
+ - Only available for 7-ELEVEN
30
+
31
+ **C2C (店到店) - Store-to-Store:**
32
+ - Merchant ships goods to sender convenience store
33
+ - Store ships to logistics center, then to pickup store
34
+ - Available for: 7-ELEVEN, FamilyMart, Hi-Life, OK Mart
35
+
36
+ ### Trade Types
37
+
38
+ | Code | Type | Description |
39
+ |------|------|-------------|
40
+ | 1 | 取貨付款 | Cash on Delivery (COD) |
41
+ | 3 | 取貨不付款 | No Payment (payment already completed) |
42
+
43
+ ### Convenience Store Codes
44
+
45
+ | Code | Store | C2C Support | B2C Support |
46
+ |------|-------|-------------|-------------|
47
+ | 1 | 7-ELEVEN | | |
48
+ | 2 | FamilyMart (全家) | | ✗ |
49
+ | 3 | Hi-Life (萊爾富) | | ✗ |
50
+ | 4 | OK Mart | | ✗ |
51
+
52
+ ---
53
+
54
+ ## Authentication & Encryption
55
+
56
+ ### Encryption Method
57
+
58
+ NewebPay Logistics uses AES-256-CBC + SHA256 encryption (same as NewebPay Payment).
59
+
60
+ **Required Credentials:**
61
+ - Merchant ID (UID)
62
+ - HashKey (32 characters)
63
+ - HashIV (16 characters)
64
+
65
+ ### Encryption Process
66
+
67
+ #### 1. Encrypt Data (AES-256-CBC)
68
+
69
+ ```
70
+ EncryptData = AES-256-CBC(JSON.stringify(data), HashKey, HashIV)
71
+ ```
72
+
73
+ **Parameters:**
74
+ - Algorithm: AES-256-CBC
75
+ - Key: HashKey (32 bytes)
76
+ - IV: HashIV (16 bytes)
77
+ - Mode: CBC
78
+ - Padding: PKCS7
79
+
80
+ #### 2. Generate Hash (SHA256)
81
+
82
+ ```
83
+ HashData = SHA256(HashKey + EncryptData + HashIV).toUpperCase()
84
+ ```
85
+
86
+ ### Decryption Process
87
+
88
+ #### 1. Verify Hash
89
+
90
+ ```
91
+ CalculatedHash = SHA256(HashKey + EncryptData + HashIV).toUpperCase()
92
+ if (CalculatedHash !== HashData) throw Error('Hash verification failed')
93
+ ```
94
+
95
+ #### 2. Decrypt Data
96
+
97
+ ```
98
+ DecryptedJSON = AES-256-CBC-Decrypt(EncryptData, HashKey, HashIV)
99
+ Data = JSON.parse(DecryptedJSON)
100
+ ```
101
+
102
+ ---
103
+
104
+ ## API Endpoints
105
+
106
+ ### Base URLs
107
+
108
+ **Test Environment:**
109
+ ```
110
+ https://ccore.newebpay.com/API/Logistic
111
+ ```
112
+
113
+ **Production Environment:**
114
+ ```
115
+ https://core.newebpay.com/API/Logistic
116
+ ```
117
+
118
+ ### API List
119
+
120
+ | API | Endpoint | Method | Description |
121
+ |-----|----------|--------|-------------|
122
+ | Store Map Query | `/storeMap` | POST | Query convenience store locations |
123
+ | Create Shipment | `/createShipment` | POST | Create logistics order |
124
+ | Get Shipment Number | `/getShipmentNo` | POST | Get shipping code for printing |
125
+ | Print Label | `/printLabel` | POST (Form) | Print shipping labels |
126
+ | Query Shipment | `/queryShipment` | POST | Query order status |
127
+ | Modify Shipment | `/modifyShipment` | POST | Modify order details |
128
+ | Track Shipment | `/trace` | POST | Track delivery history |
129
+
130
+ ---
131
+
132
+ ## 1. Store Map Query API [NPA-B51]
133
+
134
+ Query convenience store locations for customer to select pickup or sender store.
135
+
136
+ ### Request
137
+
138
+ **URL:** `POST /API/Logistic/storeMap`
139
+
140
+ **Parameters:**
141
+
142
+ | Field | Type | Required | Description |
143
+ |-------|------|----------|-------------|
144
+ | UID_ | Varchar(15) | | Merchant ID |
145
+ | EncryptData_ | Text | | Encrypted data |
146
+ | HashData_ | Text | | SHA256 hash |
147
+ | Version_ | Varchar(5) | | API version (fixed: "1.0") |
148
+ | RespondType_ | Varchar(6) | | Response format (fixed: "JSON") |
149
+
150
+ **EncryptData_ Content:**
151
+
152
+ | Field | Type | Required | Description |
153
+ |-------|------|----------|-------------|
154
+ | MerchantOrderNo | Varchar(30) | | Unique order ID (alphanumeric + underscore) |
155
+ | LgsType | Varchar(15) | | "B2C" or "C2C" |
156
+ | ShipType | Varchar(15) | | "1"=7-11, "2"=FamilyMart, "3"=Hi-Life, "4"=OK Mart |
157
+ | ReturnURL | Varchar(50) | | Callback URL after store selection |
158
+ | TimeStamp | Text | | Unix timestamp (tolerance: 120 seconds) |
159
+ | ExtraData | Varchar(20) | - | Custom data (returned as-is) |
160
+
161
+ ### Response
162
+
163
+ **Status Codes:**
164
+ - `SUCCESS`: Request successful
165
+ - Error codes: See [Error Codes](#error-codes)
166
+
167
+ **Response Parameters:**
168
+
169
+ | Field | Type | Description |
170
+ |-------|------|-------------|
171
+ | Status | Varchar(10) | Response status |
172
+ | Message | Varchar(30) | Status message |
173
+ | EncryptData | Text | Encrypted response data |
174
+ | HashData | Text | SHA256 hash |
175
+ | UID | Varchar(15) | Merchant ID |
176
+ | Version | Varchar(5) | API version |
177
+
178
+ **Decrypted EncryptData Content (Callback):**
179
+
180
+ | Field | Type | Description |
181
+ |-------|------|-------------|
182
+ | LgsType | Varchar(15) | Logistics type |
183
+ | ShipType | Varchar(15) | Store type code |
184
+ | MerchantOrderNo | Varchar(30) | Order ID |
185
+ | StoreName | Varchar(10) | Selected store name |
186
+ | StoreTel | Varchar(12) | Store phone number |
187
+ | StoreAddr | Varchar(100) | Store address |
188
+ | StoreID | Varchar(8) | Store code (use this for shipment creation) |
189
+ | ExtraData | Varchar(20) | Original custom data |
190
+
191
+ **Important Notes:**
192
+ - For FamilyMart and OK Mart, the store code displayed on map may differ from the actual StoreID
193
+ - Always use the StoreID returned in the callback, not the displayed code
194
+
195
+ ---
196
+
197
+ ## 2. Create Shipment API [NPA-B52]
198
+
199
+ Create logistics shipment order after payment order is established.
200
+
201
+ ### Request
202
+
203
+ **URL:** `POST /API/Logistic/createShipment`
204
+
205
+ **Parameters:**
206
+
207
+ | Field | Type | Required | Description |
208
+ |-------|------|----------|-------------|
209
+ | UID_ | Varchar(15) | | Merchant ID |
210
+ | EncryptData_ | Text | | Encrypted data |
211
+ | HashData_ | Text | | SHA256 hash |
212
+ | Version_ | Varchar(5) | | Fixed: "1.0" |
213
+ | RespondType_ | Varchar(6) | | Fixed: "JSON" |
214
+
215
+ **EncryptData_ Content:**
216
+
217
+ | Field | Type | Required | Description |
218
+ |-------|------|----------|-------------|
219
+ | MerchantOrderNo | Varchar(30) | | Unique order ID |
220
+ | TradeType | Int(1) | | 1=COD, 3=No Payment |
221
+ | UserName | Varchar(20) | | Recipient name |
222
+ | UserTel | Varchar(10) | | Recipient mobile number |
223
+ | UserEmail | Varchar(50) | | Recipient email |
224
+ | StoreID | Varchar(10) | | Pickup store code (from store map) |
225
+ | Amt | Int(10) | | Transaction amount (max: 20000 NTD) |
226
+ | NotifyURL | Varchar(100) | - | Status notification callback URL |
227
+ | ItemDesc | Varchar(100) | - | Product description |
228
+ | LgsType | Varchar(3) | | "B2C" or "C2C" |
229
+ | ShipType | Varchar(15) | | "1"=7-11, "2"=FamilyMart, "3"=Hi-Life, "4"=OK Mart |
230
+ | TimeStamp | Varchar(50) | | Unix timestamp (tolerance: 120 seconds) |
231
+
232
+ **Amount Limits:**
233
+ - COD (TradeType=1): Maximum 20,000 NTD
234
+ - No Payment (TradeType=3): Maximum 20,000 NTD
235
+
236
+ ### Response
237
+
238
+ **Decrypted EncryptData Content:**
239
+
240
+ | Field | Type | Description |
241
+ |-------|------|-------------|
242
+ | MerchantID | Varchar(15) | NewebPay merchant ID |
243
+ | Amt | Int(10) | Transaction amount |
244
+ | MerchantOrderNo | Varchar(30) | Order ID |
245
+ | TradeNo | Varchar(20) | NewebPay transaction ID (important: save this) |
246
+ | LgsType | Varchar(15) | Logistics type |
247
+ | ShipType | Varchar(15) | Store type |
248
+ | StoreID | Varchar(10) | Pickup store code |
249
+ | TradeType | Int(1) | Trade type |
250
+
251
+ ---
252
+
253
+ ## 3. Get Shipment Number API [NPA-B53]
254
+
255
+ Get shipping code before shipment. Merchants can use this code to print labels at convenience store Kiosk machines.
256
+
257
+ ### Request
258
+
259
+ **URL:** `POST /API/Logistic/getShipmentNo`
260
+
261
+ **EncryptData_ Content:**
262
+
263
+ | Field | Type | Required | Description |
264
+ |-------|------|----------|-------------|
265
+ | MerchantOrderNo | Json_array | | Array of order IDs (max 10) |
266
+ | TimeStamp | Varchar(50) | | Unix timestamp |
267
+
268
+ **Batch Limit:** Maximum 10 orders per request
269
+
270
+ ### Response
271
+
272
+ **Decrypted EncryptData Content:**
273
+
274
+ | Field | Type | Description |
275
+ |-------|------|-------------|
276
+ | SUCCESS | Json_array | Array of successful results |
277
+ | ERROR | Json_array | Array of failed results |
278
+
279
+ **SUCCESS Array Item:**
280
+
281
+ | Field | Type | Description |
282
+ |-------|------|-------------|
283
+ | MerchantOrderNo | Varchar(30) | Order ID |
284
+ | ErrorCode | Varchar(20) | "SUCCESS" |
285
+ | LgsNo | Varchar(20) | Logistics tracking number |
286
+ | StorePrintNo | Varchar(20) | Code for Kiosk printing |
287
+ | ShipType | Varchar(15) | Store type |
288
+ | LgsType | Varchar(15) | Logistics type |
289
+
290
+ **ERROR Array Item:**
291
+
292
+ | Field | Type | Description |
293
+ |-------|------|-------------|
294
+ | MerchantOrderNo | Varchar(30) | Order ID |
295
+ | ErrorCode | Varchar(20) | Error code (see error codes section) |
296
+
297
+ ---
298
+
299
+ ## 4. Print Label API [NPA-B54]
300
+
301
+ Print shipping labels to attach to products.
302
+
303
+ ### Request
304
+
305
+ **URL:** `POST /API/Logistic/printLabel`
306
+
307
+ **Important:** This API requires **Form POST** method (not JSON API call). The response is an HTML page for printing.
308
+
309
+ **EncryptData_ Content:**
310
+
311
+ | Field | Type | Required | Description |
312
+ |-------|------|----------|-------------|
313
+ | LgsType | Varchar(15) | | "B2C" or "C2C" |
314
+ | ShipType | Varchar(15) | | "1"=7-11, "2"=FamilyMart, "3"=Hi-Life, "4"=OK Mart |
315
+ | MerchantOrderNo | json_array | | Array of order IDs |
316
+ | TimeStamp | Varchar(50) | | Unix timestamp |
317
+
318
+ **Batch Limits:**
319
+
320
+ | Store | Maximum Labels per Request |
321
+ |-------|----------------------------|
322
+ | 7-ELEVEN (1) | 18 |
323
+ | FamilyMart (2) | 8 |
324
+ | Hi-Life (3) | 18 |
325
+ | OK Mart (4) | 18 |
326
+
327
+ ### Response
328
+
329
+ Returns HTML page with printable shipping labels.
330
+
331
+ ---
332
+
333
+ ## 5. Query Shipment API [NPA-B55]
334
+
335
+ Query logistics order information and current status.
336
+
337
+ ### Request
338
+
339
+ **URL:** `POST /API/Logistic/queryShipment`
340
+
341
+ **EncryptData_ Content:**
342
+
343
+ | Field | Type | Required | Description |
344
+ |-------|------|----------|-------------|
345
+ | MerchantOrderNo | Varchar(30) | | Order ID |
346
+ | TimeStamp | Varchar(50) | | Unix timestamp |
347
+
348
+ ### Response
349
+
350
+ **Decrypted EncryptData Content:**
351
+
352
+ | Field | Type | Description |
353
+ |-------|------|-------------|
354
+ | MerchantID | Varchar(15) | Merchant ID |
355
+ | LgsType | Varchar(15) | Logistics type |
356
+ | TradeNo | Varchar(20) | NewebPay transaction ID |
357
+ | MerchantOrderNo | Varchar(30) | Order ID |
358
+ | Amt | Int(10) | Transaction amount |
359
+ | ItemDesc | Varchar(100) | Product description |
360
+ | NotifyURL | Varchar(50) | Notification URL |
361
+ | LgsNo | Varchar(20) | Logistics tracking number |
362
+ | StorePrintNo | Varchar(20) | Store print code |
363
+ | collectionAmt | Int(10) | COD collection amount |
364
+ | TradeType | Int(1) | 1=COD, 3=No Payment |
365
+ | Type | Int(1) | 1=Normal, 3=Return |
366
+ | ShopDate | Date | Ship date |
367
+ | UserName | Varchar(20) | Recipient name |
368
+ | UserTel | Varchar(10) | Recipient phone |
369
+ | UserEmail | Varchar(50) | Recipient email |
370
+ | StoreID | Varchar(10) | Pickup store code |
371
+ | ShipType | Varchar(15) | Store type |
372
+ | StoreName | Varchar(20) | Store name |
373
+ | Retld | Varchar(10) | Status code (see status codes section) |
374
+ | RetString | Varchar(30) | Status description |
375
+
376
+ ---
377
+
378
+ ## 6. Modify Shipment API [NPA-B56]
379
+
380
+ Modify shipment order details. Only available for orders that have not yet been shipped.
381
+
382
+ ### Request
383
+
384
+ **URL:** `POST /API/Logistic/modifyShipment`
385
+
386
+ **Modifiable Conditions:**
387
+ - Order has not yet obtained shipping number (RetId: 0_1)
388
+ - Shipment expired (RetId: 0_2)
389
+ - Store reselection required (RetId: 3, 11, 12)
390
+
391
+ **EncryptData_ Content:**
392
+
393
+ | Field | Type | Required | Description |
394
+ |-------|------|----------|-------------|
395
+ | MerchantOrderNo | Varchar(30) | | Order ID |
396
+ | LgsType | Varchar(15) | | Logistics type |
397
+ | ShipType | Varchar(15) | | Store type |
398
+ | UserName | Varchar(20) | - | New recipient name |
399
+ | UserTel | Varchar(10) | - | New phone number |
400
+ | UserEmail | Varchar(50) | - | New email |
401
+ | StoreID | Varchar(10) | + | New store code |
402
+ | TimeStamp | Varchar(50) | | Unix timestamp |
403
+
404
+ **Note:** When modifying for store reselection (RetId: 3, 11, 12), only StoreID can be changed. UserName, UserTel, and UserEmail cannot be modified.
405
+
406
+ ### Response
407
+
408
+ **Decrypted EncryptData Content:**
409
+
410
+ | Field | Type | Description |
411
+ |-------|------|-------------|
412
+ | MerchantID | Varchar(15) | Merchant ID |
413
+ | MerchantOrderNo | Varchar(30) | Order ID |
414
+ | LgsType | Varchar(15) | Logistics type |
415
+ | ShipType | Varchar(15) | Store type |
416
+
417
+ ---
418
+
419
+ ## 7. Track Shipment API [NPA-B57]
420
+
421
+ Track complete logistics delivery history with all status changes.
422
+
423
+ ### Request
424
+
425
+ **URL:** `POST /API/Logistic/trace`
426
+
427
+ **EncryptData_ Content:**
428
+
429
+ | Field | Type | Required | Description |
430
+ |-------|------|----------|-------------|
431
+ | MerchantOrderNo | Varchar(30) | | Order ID |
432
+ | TimeStamp | Varchar(50) | | Unix timestamp |
433
+
434
+ ### Response
435
+
436
+ **Decrypted EncryptData Content:**
437
+
438
+ | Field | Type | Description |
439
+ |-------|------|-------------|
440
+ | LgsType | Varchar(15) | Logistics type |
441
+ | MerchantOrderNo | Varchar(30) | Order ID |
442
+ | LgsNo | Varchar(20) | Tracking number |
443
+ | TradeType | Int(1) | Trade type |
444
+ | ShipType | Varchar(15) | Store type |
445
+ | History | json_array | Array of tracking history events |
446
+ | Retld | Varchar(10) | Current status code |
447
+ | RetString | Varchar(30) | Current status description |
448
+
449
+ **History Array Item:**
450
+
451
+ | Field | Type | Description |
452
+ |-------|------|-------------|
453
+ | Retld | Varchar(10) | Status code at this time |
454
+ | RetString | Varchar(30) | Status description |
455
+ | EventTime | Varchar(20) | Event timestamp |
456
+
457
+ ---
458
+
459
+ ## 8. Status Notification [NPA-B58]
460
+
461
+ Real-time notification when shipment status changes. NewebPay will POST to the NotifyURL provided when creating shipment.
462
+
463
+ ### Callback Request
464
+
465
+ **Method:** POST to merchant's NotifyURL
466
+
467
+ **Parameters:**
468
+
469
+ | Field | Type | Description |
470
+ |-------|------|-------------|
471
+ | Status | Varchar(10) | "SUCCESS" or error code |
472
+ | Message | Varchar(30) | Status message |
473
+ | EncryptData_ | Text | Encrypted data |
474
+ | HashData_ | Text | SHA256 hash |
475
+ | UID_ | Varchar(15) | Merchant ID |
476
+ | Version_ | Varchar(5) | API version |
477
+
478
+ **Decrypted EncryptData_ Content:**
479
+
480
+ | Field | Type | Description |
481
+ |-------|------|-------------|
482
+ | LgsType | Varchar(15) | Logistics type |
483
+ | MerchantOrderNo | Varchar(30) | Order ID |
484
+ | LgsNo | Varchar(20) | Tracking number |
485
+ | TradeType | Int(1) | Trade type |
486
+ | ShipType | Varchar(15) | Store type |
487
+ | Retld | Varchar(10) | Status code |
488
+ | RetString | Varchar(30) | Status description |
489
+ | EventTime | Varchar(20) | Event timestamp |
490
+
491
+ ### Callback Response
492
+
493
+ Merchant must respond with:
494
+ - Success: `1|OK`
495
+ - Error: `0|Error` or `0|[Error Message]`
496
+
497
+ **Important:**
498
+ - NotifyURL must be accessible from NewebPay servers (not localhost)
499
+ - Must respond within timeout period
500
+ - NewebPay will retry if no response received
501
+
502
+ ---
503
+
504
+ ## Data Types & Formats
505
+
506
+ ### TimeStamp Format
507
+
508
+ Unix timestamp in seconds since 1970-01-01 00:00:00 GMT.
509
+
510
+ ```typescript
511
+ // JavaScript
512
+ const timestamp = Math.floor(Date.now() / 1000).toString();
513
+
514
+ // Python
515
+ import time
516
+ timestamp = str(int(time.time()))
517
+ ```
518
+
519
+ **Tolerance:** 120 seconds (±2 minutes)
520
+
521
+ ### Date Format
522
+
523
+ Date fields use `yyyy-MM-dd` format:
524
+ - Example: `2026-01-29`
525
+
526
+ ### MerchantOrderNo Format
527
+
528
+ - Length: Up to 30 characters
529
+ - Allowed characters: Alphanumeric (A-Z, a-z, 0-9) and underscore (_)
530
+ - Must be unique across all orders
531
+ - Example: `ORD_20260129_001`
532
+
533
+ ### Phone Number Format
534
+
535
+ - Format: 10 digits starting with 09
536
+ - Example: `0912345678`
537
+ - No spaces or dashes
538
+
539
+ ### Email Format
540
+
541
+ - Standard email format
542
+ - Max length: 50 characters
543
+ - Example: `customer@example.com`
544
+
545
+ ---
546
+
547
+ ## Error Codes
548
+
549
+ ### API Error Codes
550
+
551
+ | Code | Message | Description | Solution |
552
+ |------|---------|-------------|----------|
553
+ | SUCCESS | 成功 | Success | - |
554
+ | 1101 | 新增物流訂單失敗 | Failed to create logistics order | Check order parameters |
555
+ | 1102 | 查無合作商店 | Merchant not found | Verify merchant credentials |
556
+ | 1103 | 已存在相同的商店訂單編號 | Duplicate order number | Use unique MerchantOrderNo |
557
+ | 1104 | 無啟用對應物流商服務 | Logistics service not enabled | Contact NewebPay to enable service |
558
+ | 1105 | 門市資訊有誤或空白 | Invalid or empty store information | Verify StoreID from store map |
559
+ | 1106 | 不允許 IP | IP not allowed | Add IP to whitelist |
560
+ | 1107 | 查無金流訂單資料 | Payment order not found | Create payment order first |
561
+ | 1108 | 系統異常,無法查詢物流訂單資料 | System error, cannot query order | Retry later or contact support |
562
+ | 1109 | 查無物流訂單資料 | Logistics order not found | Verify MerchantOrderNo |
563
+ | 1110 | 系統異常,無法修改物流訂單資料 | System error, cannot modify order | Retry later or contact support |
564
+ | 1111 | 該筆物流單狀態已無法修改內容 | Order status cannot be modified | Check order status first |
565
+ | 1112 | 修改物流單失敗 | Failed to modify order | Check modification parameters |
566
+ | 1113 | 系統異常,無法查詢物流貨態歷程資料 | System error, cannot query tracking | Retry later or contact support |
567
+ | 1114 | 預付費用餘額不足 | Insufficient prepaid balance | Add balance to account |
568
+ | 1115 | 取寄貨單號失敗 | Failed to get shipment number | Check order status, retry later |
569
+ | 1116 | 該交易已建立寄貨單資訊 | Shipment already created | Use query API to get details |
570
+
571
+ ### Data Format Errors
572
+
573
+ | Code | Message | Description |
574
+ |------|---------|-------------|
575
+ | 2100 | 資料格式錯誤 | Data format error |
576
+ | 2101 | 版本錯誤 | Version error |
577
+ | 2102 | UID_ 不可為空 | UID_ cannot be empty |
578
+ | 2103 | 超商取貨付款的金額限 20000 元內 | COD amount limit: 20000 NTD |
579
+ | 2104 | 超商取貨不付款的金額限 20000 元內 | No payment amount limit: 20000 NTD |
580
+ | 2105 | 一次最多僅能取得 10 筆寄貨單號 | Max 10 shipment numbers per request |
581
+ | 2106 | 7-11/全家/萊爾富/OK 最多標籤數限制 | Max labels exceeded for provider |
582
+
583
+ ### Security Errors
584
+
585
+ | Code | Message | Description |
586
+ |------|---------|-------------|
587
+ | 4101 | IP 限制使用 | IP restricted |
588
+ | 4103 | HashData_ 資料檢查不符合 | Hash verification failed |
589
+ | 4104 | 加密資料有誤,請確認 Hash_Key 與 Hash_IV | Encryption error, check credentials |
590
+
591
+ ---
592
+
593
+ ## Status Codes
594
+
595
+ ### RetId & RetString
596
+
597
+ | RetId | RetString | Category | Description |
598
+ |-------|-----------|----------|-------------|
599
+ | 0_1 | 訂單未處理 | Pending | Order not processed |
600
+ | 0_2 | 物流單號已過期,請重新取號 | Pending | Shipment number expired |
601
+ | 0_3 | 取消出貨 | Pending | Shipment canceled |
602
+ | 1 | 訂單處理中 | Processing | Order processing |
603
+ | 2 | 超商已收件 | In Transit | Store received shipment |
604
+ | 3 | 已重選門市,等待物流重新出貨 | In Transit | Store reselected, waiting for re-shipment |
605
+ | 4 | 商品已進物流中心驗收完成 | In Transit | Arrived at logistics center |
606
+ | 11 | 取貨門市關店,請重新選取 | In Transit | Pickup store closed, reselect required |
607
+ | 5 | 商品送達取貨門市 | Ready for Pickup | Arrived at pickup store |
608
+ | 6 | 買家取貨完成 | Completed | Customer picked up (success) |
609
+ | -1 | 商品已退回廠商 | Completed | Returned to merchant |
610
+ | -6 | 已申請宅配退貨 | Completed | Home delivery return requested |
611
+ | -9 | 物流驗收異常等待回覆 | Completed | Logistics inspection error |
612
+ | -2 | 商品送達原寄件(指定退貨)門市 | Return/Compensation | Returned to sender store |
613
+ | -3 | 商品退回物流中心驗收完成 | Return/Compensation | Returned to logistics center |
614
+ | -4 | 商品退往物流中心(買家未取) | Return/Compensation | Returning (customer did not pickup) |
615
+ | -5 | 商品即將退回(買家未取) | Return/Compensation | Soon to return (customer did not pickup) |
616
+ | -7 | 已同意/申請異常判賠 | Return/Compensation | Compensation approved |
617
+ | -10 | 商品已銷毀/拋棄 | Return/Compensation | Product destroyed |
618
+ | -11 | 商品已銷毀/拋棄 | Return/Compensation | Product destroyed |
619
+ | 10 | 商品即將退回 | Return/Compensation | Soon to be returned |
620
+ | 12 | 退貨門市關店,請重新選取 | Return/Compensation | Return store closed |
621
+ | 13 | 商品退往物流中心(賣家未取) | Return/Compensation | Returning (merchant did not pickup) |
622
+ | 14 | 請申請宅配退貨 | Return/Compensation | Request home delivery return |
623
+ | 15 | 商品已銷毀/拋棄 | Return/Compensation | Product destroyed |
624
+ | 16 | 請確認匯款帳號 | Return/Compensation | Confirm bank account |
625
+
626
+ ---
627
+
628
+ ## Testing
629
+
630
+ ### Test Credentials
631
+
632
+ Contact NewebPay to obtain test credentials:
633
+ - Test Merchant ID (UID)
634
+ - Test HashKey
635
+ - Test HashIV
636
+
637
+ ### Test Environment
638
+
639
+ **Base URL:**
640
+ ```
641
+ https://ccore.newebpay.com/API/Logistic
642
+ ```
643
+
644
+ ### Testing Checklist
645
+
646
+ **1. Store Map Query**
647
+ - [ ] Test B2C logistics type
648
+ - [ ] Test C2C logistics type
649
+ - [ ] Test all 4 convenience store types
650
+ - [ ] Verify store selection callback
651
+ - [ ] Verify StoreID format
652
+
653
+ **2. Create Shipment**
654
+ - [ ] Test COD (TradeType=1)
655
+ - [ ] Test No Payment (TradeType=3)
656
+ - [ ] Test amount limits (max 20,000)
657
+ - [ ] Verify TradeNo generation
658
+ - [ ] Test with valid StoreID
659
+
660
+ **3. Get Shipment Number**
661
+ - [ ] Test single order
662
+ - [ ] Test multiple orders (up to 10)
663
+ - [ ] Test with invalid order IDs
664
+ - [ ] Verify LgsNo and StorePrintNo
665
+
666
+ **4. Print Label**
667
+ - [ ] Test batch limits per store type
668
+ - [ ] Verify HTML response
669
+ - [ ] Test print functionality
670
+
671
+ **5. Query Shipment**
672
+ - [ ] Test with valid order ID
673
+ - [ ] Test with invalid order ID
674
+ - [ ] Verify all returned fields
675
+ - [ ] Check status codes
676
+
677
+ **6. Modify Shipment**
678
+ - [ ] Test modify recipient info
679
+ - [ ] Test modify store
680
+ - [ ] Test with non-modifiable status
681
+ - [ ] Verify error handling
682
+
683
+ **7. Track Shipment**
684
+ - [ ] Test tracking history
685
+ - [ ] Verify history array
686
+ - [ ] Check timestamp formats
687
+
688
+ **8. Status Notification**
689
+ - [ ] Setup test callback URL
690
+ - [ ] Test callback decryption
691
+ - [ ] Test response format
692
+ - [ ] Verify all status codes
693
+
694
+ ### Common Test Scenarios
695
+
696
+ **Scenario 1: Complete C2C Flow**
697
+ 1. Query store map → Get StoreID
698
+ 2. Create shipment → Get TradeNo
699
+ 3. Get shipment number → Get LgsNo and StorePrintNo
700
+ 4. Print label → Generate shipping label
701
+ 5. Query shipment → Check status
702
+ 6. Track shipment → View history
703
+
704
+ **Scenario 2: Modify Recipient**
705
+ 1. Create shipment
706
+ 2. Query shipment status
707
+ 3. Modify recipient information
708
+ 4. Query shipment again to verify
709
+
710
+ **Scenario 3: Change Pickup Store**
711
+ 1. Create shipment
712
+ 2. Query store map for new store
713
+ 3. Modify shipment with new StoreID
714
+ 4. Verify modification
715
+
716
+ ---
717
+
718
+ ## Best Practices
719
+
720
+ ### 1. Order Number Management
721
+ - Use unique, sequential order numbers
722
+ - Include date/time in order number for tracking
723
+ - Keep record of all order numbers
724
+ - Don't reuse order numbers even for canceled orders
725
+
726
+ ### 2. Error Handling
727
+ - Always verify hash before decrypting
728
+ - Implement retry logic for transient errors (1108, 1110, 1113)
729
+ - Don't retry for permanent errors (1102, 1103, 1104)
730
+ - Log all API requests and responses
731
+
732
+ ### 3. Security
733
+ - Store HashKey and HashIV securely (environment variables, secrets manager)
734
+ - Never expose credentials in client-side code
735
+ - Use HTTPS for all NotifyURL endpoints
736
+ - Validate IP whitelist for production
737
+
738
+ ### 4. Status Tracking
739
+ - Use status notification webhook instead of polling
740
+ - Handle all status codes appropriately
741
+ - Send customer notifications for key status changes (5, 6, -1)
742
+ - Log all status updates
743
+
744
+ ### 5. Store Selection
745
+ - Always use StoreID from API response, not displayed code
746
+ - Validate StoreID before creating shipment
747
+ - Cache store information for reuse
748
+ - Provide clear store selection UI to customers
749
+
750
+ ### 6. Testing
751
+ - Test all APIs in test environment before production
752
+ - Verify encryption/decryption works correctly
753
+ - Test error scenarios
754
+ - Validate timestamp handling
755
+
756
+ ---
757
+
758
+ ## Support
759
+
760
+ ### NewebPay Technical Support
761
+
762
+ **Phone:** 02-2655-8938
763
+
764
+ **Official Website:** https://www.newebpay.com
765
+
766
+ ### API Documentation
767
+
768
+ For the latest API documentation and updates, visit NewebPay's developer portal or contact technical support.
769
+
770
+ ---
771
+
772
+ **Document Version:** 1.0
773
+ **Last Updated:** 2026-01-29
774
+ **Total Lines:** 950+