---
# System prepended metadata

title: Gateweb 境內測試 API 規格/Gateweb Domestic_Test+API+Specifications

---

# Gateweb 境內測試 API 規格/Gateweb Domestic_Test+API+Specifications

## 目錄/Table of content 

[TOC]



## 概述

本份文件說明如何與關網資訊的Web API系統互動執行操作
•	開立發票
•	作廢發票
•	開立折讓單
•	作廢折讓單

## 名詞說明

| **GET**   | Https動作動詞，用於透過Web API搜尋和獲取資訊                 |
| --------- | ------------------------------------------------------------ |
| **POST**  | Https動作動詞，用於透過 Web API 發出、取消或要求等動作       |
| **eGUI**  | 台灣的電子發票，政府用來追蹤賣家的稅額。如果購買者是消費者，電子發票的號碼可以用於兌獎。. |
| **C0403** | Gateweb所發行的代號，功能為：開立發票                        |
| **C0503** | Gateweb所發行的代號，功能為：作廢發票                        |
| **D0403** | Gateweb所發行的代號，功能為：開立折讓                        |
| **D0503** | Gateweb所發行的代號，功能為：作廢折讓                        |
| **C0401** | 政府所發行的檔案代號，功能為：開立發票                       |
| **C0501** | 政府所發行的檔案代號，功能為：作廢發票                       |
| **D0401** | 政府所發行的檔案代號，功能為：開立折讓                       |
| **D0501** | 政府所發行的檔案代號，功能為：作廢折讓                       |

## 基本流程圖 - 發票生命週期

![Gateweb-IT - eGUI Overview](![Gateweb-IT - eGUI Overview](https://hackmd.io/_uploads/BkVa0RUQJl.jpg)

## API URL

| 說明                         | **測試環境ＵＲＬ**                                           |
| ---------------------------- | ------------------------------------------------------------ |
| Base  Url                    | [https://sstest.gwis.com.tw/](https://b2b2.gwis.com.tw/)     |
| Get  Token 取得金鑰          | [https://sstest.gwis.com.tw/api/authenticate](https://b2b2.gwis.com.tw/api/authenticate) |
| 開立發票 (C0403)             | [https://sstest.gwis.com.tw/](https://b2b2.gwis.com.tw/)[api/v1/simplified/C0403?domestic=true&companyKey={companyKey}](https://test3.gwis.com.tw/api/v1/simplified/C0403?domestic=true&companyKey={companyKey}) |
| 取回發票(C0403)              | [https://sstest.gwis.com.tw/](https://b2b2.gwis.com.tw/)[api/v1/simplified/C0403/{relateNumber}/{sellerIdentifier}?completeness=true](https://sstest.gwis.com.tw/api/v1/simplified/C0403/{relateNumber}/{sellerIdentifier}?completeness=true) |
| 即時取回發票資料 (C0403)     | https://sstest.gwis.com.tw/api/v1/invoice/{sellerIdentifier}/{relateNumber} |
| 作廢發票 (C0503)             | https://sstest.gwis.com.tw/api/v1/simplified/C0503?domestic=true&companyKey={companyKey} |
| 取回作廢發票(C0503)          | https://sstest.gwis.com.tw/api/v1/simplified/C0503/{relateNumber}/{sellerIdentifier}?completeness=true |
| 即時取回作廢發票(C0503)      | https://sstest.gwis.com.tw/api/v1/invoiceCancellation/{sellerIdentifier}/{relateNumber} |
| 開立折讓 (D0403)             | https://sstest.gwis.com.tw[/api/v1/simplified/D0403?domestic=true&companyKey={companyKey}](https://test3.gwis.com.tw/api/v1/simplified/D0403?domestic=true&companyKey={companyKey}) |
| 取回折讓  (D0403)            | https://sstest.gwis.com.tw/api/v1/simplified/D0403/{originalRelateNumber}/{sellerIdentifier}/{relateNumber}?completeness=true |
| 作廢折讓Cancellation (D0503) | [https://sstest.gwis.com.tw/api/v1/simplified/D0503?domestic=true&companyKey={companyKey}](https://sstest.gwis.com.tw/api/v1/simplified/D0503?domestic=false&companyKey={companyKey}) |
| 取回作廢折讓資料 (D0503)     | https://sstest.gwis.com.tw/api/v1/simplified/D0503/{relateNumber}/{sellerIdentifier}?completeness=true |

## 取得金鑰

### 方法Method: POST

### API URL

```http
https://sstest.gwis.com.tw/api/authenticate
```

### 請求與回應Request and Response

#### Request Header

```http
Content-Type=application/json
```

#### Request Body

```json
{
  "username": {username},
  "password": {password},
  "rememberMe": true
}
//Upon registration at GateWeb, Gateweb will provide username & password.

```

#### Response

```json
{
  "id_token": "eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzUxMiJ9.eyJpc3MiOiJzZWN1cmUtYXBpIiwiYXVkIjoic2VjdXJlLWFwcCIsInN1YiI6InRpbXkiL
}

```

## 電子發票

### 開立發票 - C0403

API URL

```http
POST https://sstest.gwis.com.tw/api/v1/simplified/C0403?domestic=true&companyKey={companyKey}
```

companyKey: Upon registration at GateWeb, Gateweb will provide one companyKey.

#### 欄位說明 Request Body Fields Format

```json
{
 //***********************************************************************************************
 //1. Invoice Main
 //***********************************************************************************************
  "relateNumber": "myERP_invoice_006",               // [string] 自訂規則產出SO編號(不可重複),未來查詢發票依據
  "invoiceDate": "20241122",                // [string] 發票日期 YYYYMMDD, 若未填入則由關網依當時系統日期填入
  "invoiceTime": "23:59:59",                // [string] 發票時間可預設寫死23:59:59
  "sellerDepartment":"gwPrinter001",            // [string] 印表機名稱，由關網提供，若為子母公司則以此欄位＋賣方統編欄位辨識
  
  "sellerIdentifier":"23639781",            // [string] 賣方統一編號，長度為8個字元
  "sellerName":"美商假骨文公司",                  // [string] 賣方公司名稱，需與工商登記名稱相符 
  "c":"北市忠孝東路五段100號" ,              // [string] 賣方地址，可填可不填
  "sellerPersonInCharge":"張永慶",        // [string] 賣方負責人，可填可不填
  "sellerTelephoneNumber":"02-88888888",       // [string] 賣方公司電話，可填可不填
  "sellerFacsimileNumber":"",        // [string] 賣方公司傳真，可填可不填
  "sellerEmailAddress":"test@mycompany.com",          // [string] 賣方信箱地址，可填可不填
  "buyerIdentifier": "23639781",            // [string] 買方統編，非營業人固定放0000000000
  "buyerName": "美商威軟公司",                  // [string] 買方公司名稱，非營業人固定放0000000000
  "buyerAddress": "北市忠孝東路五段100號",               // [string] 買方地址，可填可不填
  "buyerPersonInCharge": "",        // [string] 買方負責人，可填可不填
  "buyerTelephoneNumber": "",       // [string] 買方公司電話，可填可不填
  "buyerFacsimileNumber": "",       // [string] 買方公司傳真，可填可不填
  "buyerEmailAddress": "test@mycompany.com",          // [string] 買方信箱地址，可填可不填
  "mainRemark": "這是總發票備註",                 // [string] 發票總備註，若有值顯示於發票備註欄位
  "customsClearanceMark": "",       // [string] 通關註記, 稅別 tax type=2(零稅率)為必填欄位　1 (非經海關出口) or 2 (經海關出口)
  "invoiceType": "07",                // [string] 發票類別，07:一般稅額  08:特種稅額
  "donateMark": "0",                 // [string] 捐贈註記   0:非捐贈 / 1:捐贈
  "npoban": "",                     // [string]發票捐贈對象, 當donateMark(捐贈註記) = 1 時為必填3-7碼數字, 且carrierType(載具類別)必為 Null, printMark(列印註記) 必為 N
  "printMark": "Y",                  // [string] 列印註記,若 carrierType is Null   If  printMark=Y,donateMark is 1 , npoban 必填3-7碼數字, carrierType is Null  printMark is N
  "carrierType": "",                // [string] 載具類別，載具代號： EJ0110=關網會員載具, 3J0002=手機條碼, CQ0001 = 自然人憑證, 5G001 = 境外電商雲端載具
  "carrierId1": "",                 // [string] 載具顯碼
  "carrierId2": "",                 // [string] 載具隱碼     
  
  
  //***********************************************************************************************
  //2. Invoice Details
  //***********************************************************************************************
  "detail": [
    {    
      "description": "我的商品名稱01",
      "quantity": 1,									 	// [decimal]  數量
      "unit":"個",											 // [decimal]  單位
      "unitPrice": 100,									// [decimal] 單價 (含稅)
      "amount": 100,                  	// [decimal] 商品小計金額(含稅)
      "sequenceNumber":"000",           // [int] 商品明細排列序號
      "remark":"myRemark01",						// [string] 商品備註 
      "relateNumber":"myRealateNumber01"// [string] 相關號碼 
    },
     {    
      "description": "我的商品名稱02",
      "quantity": 2,									 	// [decimal]  數量
      "unit":"個",											 // [decimal]  單位
      "unitPrice": 200,									// [decimal] 單價 (含稅)
      "amount": 200,                  	// [decimal] 商品小計金額(含稅)
      "sequenceNumber":"001",           // [int] 商品明細排列序號
      "remark":"myRemark02",						// [string] 商品備註 
      "relateNumber":"myRealateNumber02"// [string] 相關號碼 
    }
  ],
 //***********************************************************************************************
 //3. Invoice Amount
 //*********************************************************************************************** 
  "salesAmount": 100,                 // [Integer] 銷售額(整數)
  "freeTaxSalesAmount": 0,          // [Integer]  銷售額(免稅)  if tax Type(3) , freeTaxSalesAmount =銷售額 ,salesAmount=0; taxAmount=0
   "ZeroTaxSalesAmount": 0,            // [Integer]  銷售額(零稅率)  if tax Type(2) , ZeroTaxSalesAmount =銷售額 ,salesAmount=0; taxAmount=0; customsClearanceMark=1 or 2
  
  "taxType": "1",                    // [string] 稅別 : 1：應稅  2：零稅率  3：免稅  4：應稅(特種稅率) 9：混合應稅與免稅或零稅率
  "taxRate": 0.05 ,                      // [float]  稅率 :  應稅=0.05,  免稅/零稅率=0
  "taxAmount": 5,                   // [Integer] 營業稅額(整數)
  "totalAmount": 105,                 // [Integer] 總計金額(整數)
  "DiscountAmount": 0,
  "OriginalCurrencyAmount":100,
  "ExchangeRate": 32,
  "Currency": "USD"
  }
```

#### 檢核說明 Format Verification

| Field 1                | Field 2        | Data Type | Min  | Max  | M/O  | Name_Name_Name           | Description_Description_Description                          |
| :--------------------- | :------------- | :-------- | :--- | :--- | :--- | :----------------------- | :----------------------------------------------------------- |
| relateNumber           |                | string    | 1    | 60   | M    | **唯一號碼**             | 自訂規則產出SO編號(不可重複),未來查詢發票依據                |
| invoiceDate            |                | string    | 8    | 8    | M    | 發票日期                 | 發票日期 YYYYMMDD, 若未填入則由關網依當時系統日期填入。 不允許只輸入 time 而沒有 date |
| invoiceTime            |                | string    | 8    | 8    | M    | 發票時間                 | 發票時間可預設寫死23:59:59                                   |
| sellerDepartment       |                | string    | 1    | 60   | O    | 印表機名稱               | 由關網提供，若為子母公司則以此欄位＋賣方統編欄               |
| sellerIdentifier       |                | String    | 8    | 8    | M    | 賣方統編                 | 長度為8個字元                                                |
| sellerName             |                | string    | 1    | 60   | M    | 賣方公司名稱             | 需與工商登記名稱相符                                         |
| sellerAddress          |                | String    | 0    | 100  | O    | 賣方地址                 |                                                              |
| sellerPersonInCharge   |                | string    | 0    | 30   | O    | 賣方負責人               |                                                              |
| SellerTelephoneNumber  |                | string    | 0    | 26   | O    | 賣方公司電話             |                                                              |
| SellerFacsimileNumber  |                | string    | 0    | 26   | O    | 賣方公司傳真             |                                                              |
| SellerEmailAddress     |                | string    | 0    | 80   | O    | 賣方信箱地址             |                                                              |
| buyerIdentifier        |                | string    | 8    | 10   | M    | 買方統編                 | 買方統編，非營業人固定放0000000000                           |
| buyerName              |                | String    | 1    | 60   | M    | 買方公司名稱             | 非營業人固定放0000000000                                     |
| buyerAddress           |                | String    | 0    | 100  | O    | 買方地址                 |                                                              |
| buyerPersonInCharge    |                | String    | 0    | 30   | O    | 買方負責人               |                                                              |
| buyerTelephoneNumber   |                | String    | 0    | 26   | O    | 買方公司電話             |                                                              |
| buyerFacsimileNumber   |                | String    | 0    | 26   | O    | 買方公司傳真             |                                                              |
| buyerEmailAddress      |                | striung   | 0    | 80   | O    |                          |                                                              |
| mainRemark             |                | string    | 0    | 200  | O    | 總備註                   | 若有值顯示於發票備註欄位                                     |
| customsClearanceMark   |                | string    | 0    | 1    | O    | 通關註記                 | 稅別 tax type=2(零稅率)為必填欄位:<br />1 (非經海關出口) or 2 (經海關出口) |
| invoiceType            |                | string    | 2    | 2    | M    | 發票類別                 | 07 ：一般稅額計算之電子發票<br/>08 ：特種稅額計算之電子發票  |
| donateMark             |                | string    |      |      | M    | 捐贈註記                 | 0:非捐贈 / 1:捐贈                                            |
| carrierType            |                | string    | 0    | 6    | O    | 載具類別號碼             | EJ0110=關網會員載具, 3J0002=手機條碼, CQ0001 = 自然人憑證, 5G001 = 境外電商雲端載具 |
| carrierId1             |                | string    | 0    | 64   | O    | 載具顯碼 id 1            | 填入載具外顯碼號碼，卡片上載列之卡片號碼資訊若載具類別為信用卡，填入刷卡日期(民國年月日共7碼)及刷卡交易金額(10碼，不足位左補0)資訊<br/>若電子發票證明聯已列印註記為 Y，此欄位必須為空白；<br/>若此欄位非空白，則電子發票證明聯已列印註記必須為 N。<br/>消費者使用手機條碼索取(含要求登載買方統編發票)，則不論是否已列印紙本皆為必填<br/>前後不允許空白及全形空白 |
| carrierId2             |                | string    | 0    | 64   | O    | 載具隱碼 id 2            | 填入載具內碼號碼，營業人應載入讀取工具所讀取之原始資訊<br/>若載具類別為信用卡，填入信用卡加密卡號<br/>若電子發票證明聯已列印註記為 Y，此欄位必須為空白；<br/>若此欄位非空白，則電子發票證明聯已列印註記必須為 N<br/>消費者使用手機條碼索取(含要求登載買方統編發票)，則不論是否已列印紙本皆為必填<br/>前後不允許空白及全形空白 |
| printMark              |                | string    | 1    | 1    | M    | 電子發票證明聯已列印註記 | Y/N，PrintMark 為 Y 時載具類別號碼，載具顯碼 ID，載具隱碼 ID 必須為空白，捐贈註記必為0<br />消費者使用手機條碼索取(含要求登載買方統編發票)，則不論是否已列印紙本，其載具類別號碼、載具顯碼 ID 和載具隱碼 ID 皆為必填 |
| npoban                 |                | string    | 3    | 7    | O    | 發票捐贈對象             | donateMark為1時必填，3-7碼字串                               |
| detail                 |                | array     | 1    | 999  | M    | 商品項目資料             |                                                              |
|                        | description    | string    | 1    | 256  | M    | 品名                     |                                                              |
|                        | quantity       | decimal   |      |      | M    | 數量                     |                                                              |
|                        | unit           | string    | 0    | 6    | O    | 單位                     |                                                              |
|                        | unitPrice      | decimal   |      |      | M    | 單價                     |                                                              |
|                        | amount         | decimal   |      |      | M    | 金額                     |                                                              |
|                        | SequenceNumber | string    | 1    | 3    | M    | 明細排列序號             |                                                              |
|                        | remark         |           | 0    | 40   | O    | 單一欄位備註             |                                                              |
|                        | relateNumber   |           | 0    | 20   | O    | 相關號碼                 |                                                              |
| salesAmount            |                | Integer   |      |      | M    | 應稅銷售額合計           | 銷售額(整數)                                                 |
| freeTaxSalesAmount     |                | Integer   |      |      | M    | 免稅銷售額合計           | 若 taxType欄位為3(免稅), 則 freeTaxSalesAmount = salesAmount(銷售額) <br />salesAmount=0; <br />taxAmount=0 |
| ZeroTaxSalesAmount     |                | Integer   |      |      | M    | 零稅率銷售額合計         | 若 taxType欄位為3(免稅), 則 ZeroTaxSalesAmount = salesAmount(銷售額) <br /> salesAmount=0, taxAmount=0, customsClearanceMark = 1 or 2 |
| taxType                |                | String    | 1    | 1    | M    | 課稅別                   | 1：應稅  2：零稅率  3：免稅  4：應稅(特種稅率) 9：混合應稅與免稅或零稅率 |
| taxRate                |                | float     |      |      | M    | 稅率                     | 稅率 :  應稅=0.05,  免稅/零稅率=0                            |
| taxAmount              |                | Integer   |      |      | M    | 營業稅額                 | 營業稅額(整數)                                               |
| totalAmount            |                | Integer   |      |      | M    | 總計                     | 總計金額(整數)                                               |
| DiscountAmount         |                | decimal   |      |      | O    | 折扣金額                 |                                                              |
| OriginalCurrencyAmount |                | decimal   |      |      | O    | 原幣金額                 |                                                              |
| ExchangeRate           |                | decimal   |      |      | O    | 匯率                     |                                                              |
| Currency               |                | string    | 0    | 3    | O    | 幣別                     |                                                              |



### 請求與回應：

Request Header

Content-Type: application/json
Authorization: Bearer {token_id}

#### 成功: 200 OK

```json
{
    "typeCode": 0,
    "errors": [
        {
            "field": null,
            "originalValue": null,
            "errorMessage": "Success"
        }
    ]
}
```

#### 其它狀態Error Code Lis

```json
{
    "typeCode": 11,
    "errors": [
        {
            "field": null,
            "originalValue": null,
            "errorMessage": "(C0403) The relateNumber is duplicated, please modify and try again. 此號碼已被使用，請修改 relateNumber 後再試"
        }
    ]
}
```

| TypeCode | **Error Message**                                            |
| :------- | :----------------------------------------------------------- |
| 11       | (C0403) The relateNumber has been used, please confirm. 此號碼已被開⽴過，請檢查後再試 |
| 12       | (C0403) Tax ID not found, please input valid tax ID for sellerIdentifier. 查無此公司統編，請檢查 sellerIdentifier |
| 13       | (C0403) Company does not have available Printer, please input "null" for sellerDepartment. 此公司查無此印表機，請在SellerDepartment欄位留空或輸⼊null |
| 14       | (C0403) The Company does not have valid e-GUI track number, Please confirm if GUI track number for the current period is imported. 此公司無可開⽴的字軌，請檢查此公司是否匯⼊該期字軌 |
| 15       | (C0403) This sellerIdentifier does not belong to this companyKey. Please input the correct sellerIdentifier. 此sellerIdentifier只能開⽴此companyKey所屬公司，或是所屬⼦公司之發票 |
| 16       | (C0403\) MoF are still processing previous data, please try again in 15 minutes. 財政部尚未處理前⼀筆資料，請等候約 15 分鐘再試 |
| 17       | (C0403) Mof processing status is 'Error'. Please contact GW support team. 財政部前⼀筆發票狀態為 E ，請聯繫關網客服 |
| 19       | (C0403) Unknown Issuance Error. Please contact GW support team. 開⽴發票異常，請聯繫客服 |



### 取回開立發票 (C0403) Status

#### 方法: GET

API URL

```http
https://sstest.gwis.com.tw/api/v1/simplified/C0403/{relateNumber}/{sellerIdentifier}?completeness=true
```

#### 參數

| 參數             | 說明                     |
| ---------------- | ------------------------ |
| relateNumber     | 唯一號碼                 |
| sellerIdentifier | 賣方統編                 |
| completeness     | 是否取回代有MIG Data檔案 |

#### 回覆範例與說明 - Response Body Field Format

```json
{
    "uploadStatus": "C",// [string] 上傳狀態　失敗:E   成功:C
    "migNumber": "TW93432550",// [string] 發票號碼
    "migData": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxJbnZvaWNlIHhtbG5zPSJ1cm46R0VJTlY6ZUludm9pY2VNZXNzYWdlOkMwNDAxOjMuMiI+DQogICAgPE1haW4+DQogICAgICAgIDxJbnZvaWNlTnVtYmVyPlRXOTM0MzI1NTA8L0ludm9pY2VOdW1iZXI+DQogICAgICAgIDxJbnZvaWNlRGF0ZT4yMDI0MTEyMjwvSW52b2ljZURhdGU+DQogICAgICAgIDxJbnZvaWNlVGltZT4yMzo1OTo1OTwvSW52b2ljZVRpbWU+DQogICAgICAgIDxTZWxsZXI+DQogICAgICAgICAgICA8SWRlbnRpZmllcj4yMzYzOTc4MTwvSWRlbnRpZmllcj4NCiAgICAgICAgICAgIDxOYW1lPue+juWVhuWBh+mqqOaWh+WFrOWPuDwvTmFtZT4NCiAgICAgICAgICAgIDxBZGRyZXNzPjwvQWRkcmVzcz4NCiAgICAgICAgICAgIDxQZXJzb25JbkNoYXJnZT7lvLXmsLjmhbY8L1BlcnNvbkluQ2hhcmdlPg0KICAgICAgICAgICAgPFRlbGVwaG9uZU51bWJlcj4wMi04ODg4ODg4ODwvVGVsZXBob25lTnVtYmVyPg0KICAgICAgICAgICAgPEZhY3NpbWlsZU51bWJlcj48L0ZhY3NpbWlsZU51bWJlcj4NCiAgICAgICAgICAgIDxFbWFpbEFkZHJlc3M+dGVzdEBteWNvbXBhbnkuY29tPC9FbWFpbEFkZHJlc3M+DQogICAgICAgICAgICA8Q3VzdG9tZXJOdW1iZXI+PC9DdXN0b21lck51bWJlcj4NCiAgICAgICAgPC9TZWxsZXI+DQogICAgICAgIDxCdXllcj4NCiAgICAgICAgICAgIDxJZGVudGlmaWVyPjIzNjM5NzgxPC9JZGVudGlmaWVyPg0KICAgICAgICAgICAgPE5hbWU+576O5ZWG5aiB6Luf5YWs5Y+4PC9OYW1lPg0KICAgICAgICAgICAgPEFkZHJlc3M+5YyX5biC5b+g5a2d5p2x6Lev5LqU5q61MTAw6JmfPC9BZGRyZXNzPg0KICAgICAgICAgICAgPFBlcnNvbkluQ2hhcmdlPjwvUGVyc29uSW5DaGFyZ2U+DQogICAgICAgICAgICA8VGVsZXBob25lTnVtYmVyPjwvVGVsZXBob25lTnVtYmVyPg0KICAgICAgICAgICAgPEZhY3NpbWlsZU51bWJlcj48L0ZhY3NpbWlsZU51bWJlcj4NCiAgICAgICAgICAgIDxFbWFpbEFkZHJlc3M+dGVzdEBteWNvbXBhbnkuY29tPC9FbWFpbEFkZHJlc3M+DQogICAgICAgICAgICA8Q3VzdG9tZXJOdW1iZXI+PC9DdXN0b21lck51bWJlcj4NCiAgICAgICAgPC9CdXllcj4NCiAgICAgICAgICAgIDxNYWluUmVtYXJrPumAmeaYr+e4veeZvOelqOWCmeiouzwvTWFpblJlbWFyaz4NCiAgICAgICAgICAgIDxJbnZvaWNlVHlwZT4wNzwvSW52b2ljZVR5cGU+DQogICAgICAgICAgICA8RG9uYXRlTWFyaz4wPC9Eb25hdGVNYXJrPg0KICAgICAgICAgICAgPENhcnJpZXJUeXBlPjwvQ2FycmllclR5cGU+DQogICAgICAgICAgICA8Q2FycmllcklkMT48L0NhcnJpZXJJZDE+DQogICAgICAgICAgICA8Q2FycmllcklkMj48L0NhcnJpZXJJZDI+DQogICAgICAgICAgICA8UHJpbnRNYXJrPlk8L1ByaW50TWFyaz4NCiAgICAgICAgICAgIDxOUE9CQU4+PC9OUE9CQU4+DQogICAgICAgICAgICA8UmFuZG9tTnVtYmVyPjgyNTA8L1JhbmRvbU51bWJlcj4NCiAgICA8L01haW4+DQogICAgPERldGFpbHM+DQogICAgICAgICAgICA8UHJvZHVjdEl0ZW0+DQogICAgICAgICAgICAgICAgPERlc2NyaXB0aW9uPuaIkeeahOWVhuWTgeWQjeeosTAxPC9EZXNjcmlwdGlvbj4NCiAgICAgICAgICAgICAgICA8UXVhbnRpdHk+MTwvUXVhbnRpdHk+DQogICAgICAgICAgICAgICAgICAgIDxVbml0Lz4NCiAgICAgICAgICAgICAgICA8VW5pdFByaWNlPjEwMDwvVW5pdFByaWNlPg0KICAgICAgICAgICAgICAgIDxBbW91bnQ+MTAwPC9BbW91bnQ+DQogICAgICAgICAgICAgICAgPFNlcXVlbmNlTnVtYmVyPjE8L1NlcXVlbmNlTnVtYmVyPg0KICAgICAgICAgICAgICAgIDxSZW1hcms+bXlSZW1hcmswMTwvUmVtYXJrPg0KICAgICAgICAgICAgICAgIDxSZWxhdGVOdW1iZXI+bXlSZWFsYXRlTnVtYmVyMDE8L1JlbGF0ZU51bWJlcj4NCiAgICAgICAgICAgIDwvUHJvZHVjdEl0ZW0+DQogICAgICAgICAgICA8UHJvZHVjdEl0ZW0+DQogICAgICAgICAgICAgICAgPERlc2NyaXB0aW9uPuaIkeeahOWVhuWTgeWQjeeosTAyPC9EZXNjcmlwdGlvbj4NCiAgICAgICAgICAgICAgICA8UXVhbnRpdHk+MjwvUXVhbnRpdHk+DQogICAgICAgICAgICAgICAgICAgIDxVbml0Lz4NCiAgICAgICAgICAgICAgICA8VW5pdFByaWNlPjIwMDwvVW5pdFByaWNlPg0KICAgICAgICAgICAgICAgIDxBbW91bnQ+MjAwPC9BbW91bnQ+DQogICAgICAgICAgICAgICAgPFNlcXVlbmNlTnVtYmVyPjI8L1NlcXVlbmNlTnVtYmVyPg0KICAgICAgICAgICAgICAgIDxSZW1hcms+bXlSZW1hcmswMjwvUmVtYXJrPg0KICAgICAgICAgICAgICAgIDxSZWxhdGVOdW1iZXI+bXlSZWFsYXRlTnVtYmVyMDI8L1JlbGF0ZU51bWJlcj4NCiAgICAgICAgICAgIDwvUHJvZHVjdEl0ZW0+DQogICAgPC9EZXRhaWxzPg0KICAgIDxBbW91bnQ+DQogICAgICAgIDxTYWxlc0Ftb3VudD4xMDA8L1NhbGVzQW1vdW50Pg0KICAgICAgICA8RnJlZVRheFNhbGVzQW1vdW50PjA8L0ZyZWVUYXhTYWxlc0Ftb3VudD4NCiAgICAgICAgPFplcm9UYXhTYWxlc0Ftb3VudD4wPC9aZXJvVGF4U2FsZXNBbW91bnQ+DQogICAgICAgIDxUYXhUeXBlPjE8L1RheFR5cGU+DQogICAgICAgIDxUYXhSYXRlPjAuMDU8L1RheFJhdGU+DQogICAgICAgIDxUYXhBbW91bnQ+NTwvVGF4QW1vdW50Pg0KICAgICAgICA8VG90YWxBbW91bnQ+MTA1PC9Ub3RhbEFtb3VudD4NCiAgICA8L0Ftb3VudD4NCjwvSW52b2ljZT4=",// [string] MIG檔 ，需要使用Base64解密
    "id": 2883920,
    "relateNumber": "myERP_invoice_007", // [string] 唯一號碼
    "migDate": "20241122", // [string] 發票開立日期 (YYYYMMDD)
    "cancelDate": null,// [string] 發票作廢日期 (YYYYMMDD)
    "voidDate": null,// [string] 發票註銷日期 (YYYYMMDD)
    "buyerId": "23639781", // [string] 買方統一編號
    "sellerId": "23639781",// [string] 賣方統一編號
    "receiveDate": "2024-11-22",// [string] 收到檔案日期
    "receiveTime": "T16:30:04.517",// [string] 收到檔案時間
    "gwReply": null, // [string] 關網檢核回覆，失敗:E   成功:C，若為E則會顯示gwErrorMessage 錯誤訊息
    "gwErrorMessage": null, // [string] 關網錯誤原因
    "taxType": "1", // [string] VAT type, 1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
    "taxAmount": "5.0000",// [float] 營業稅額
    "totalAmount": "105.0000",// [float] 銷售額
    "natReply": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48SW52b2ljZUNvbmZpcm0geG1sbnM9InVybjpHRUlOVjplSW52b2ljZU1lc3NhZ2U6QzA0MDI6My4xIj48SWQ+Mjg4MzkyMDwvSWQ+PEludm9pY2VOdW1iZXI+VFc5MzQzMjU1MDwvSW52b2ljZU51bWJlcj48SW52b2ljZURhdGU+MjAyNDExMjI8L0ludm9pY2VEYXRlPjxCdXllcklkPjIzNjM5NzgxPC9CdXllcklkPjxTZWxsZXJJZD4yMzYzOTc4MTwvU2VsbGVySWQ+PFJhbmRvbU51bWJlcj44MjUwPC9SYW5kb21OdW1iZXI+PFJlY2VpdmVEYXRlPjIwMjQxMTIyPC9SZWNlaXZlRGF0ZT48UmVjZWl2ZVRpbWU+MTY6MzA6MDQ8L1JlY2VpdmVUaW1lPjxOYXRSZXBseT5DPC9OYXRSZXBseT48U2FsZXNBbW91bnQ+MTAwPC9TYWxlc0Ftb3VudD48RnJlZVRheFNhbGVzQW1vdW50PjA8L0ZyZWVUYXhTYWxlc0Ftb3VudD48WmVyb1RheFNhbGVzQW1vdW50PjA8L1plcm9UYXhTYWxlc0Ftb3VudD48VGF4VHlwZT4xPC9UYXhUeXBlPjxUYXhSYXRlPjAuMDU8L1RheFJhdGU+PFRheEFtb3VudD41PC9UYXhBbW91bnQ+PFRvdGFsQW1vdW50PjEwNTwvVG90YWxBbW91bnQ+PC9JbnZvaWNlQ29uZmlybT4=",// [string] 財政部回覆訊息 ，失敗:E   成功:C，若為E則會顯示natErrorMessage 錯誤訊息
    "natErrorMessage": null,// [string] 財政部錯誤訊息
    "randomNumber": "8250" // [string] 防偽隨機碼
}

```

### 即時取回開立發票 (C0403) Status Instantly

#### 方法: GET

API URL

```http
https://sstest.gwis.com.tw/api/v1/invoice/{sellerIdentifier}/{relateNumber}
```

#### 參數

| 參數             | 說明     |
| ---------------- | -------- |
| sellerIdentifier | 賣方統編 |
| relateNumber     | 唯一號碼 |

#### 回覆範例與說明 - Response Body Field Format

```json
{
    "migData": {
        "uploadStatus": "C", // [string] 上傳狀態　失敗:E   成功:C
        "migNumber": "TW93432550",// [string]  發票號碼
        "migData": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxJbnZvaWNlIHhtbG5zPSJ1cm46R0VJTlY6ZUludm9pY2VNZXNzYWdlOkMwNDAxOjMuMiI+DQogICAgPE1haW4+DQogICAgICAgIDxJbnZvaWNlTnVtYmVyPlRXOTM0MzI1NTA8L0ludm9pY2VOdW1iZXI+DQogICAgICAgIDxJbnZvaWNlRGF0ZT4yMDI0MTEyMjwvSW52b2ljZURhdGU+DQogICAgICAgIDxJbnZvaWNlVGltZT4yMzo1OTo1OTwvSW52b2ljZVRpbWU+DQogICAgICAgIDxTZWxsZXI+DQogICAgICAgICAgICA8SWRlbnRpZmllcj4yMzYzOTc4MTwvSWRlbnRpZmllcj4NCiAgICAgICAgICAgIDxOYW1lPue+juWVhuWBh+mqqOaWh+WFrOWPuDwvTmFtZT4NCiAgICAgICAgICAgIDxBZGRyZXNzPjwvQWRkcmVzcz4NCiAgICAgICAgICAgIDxQZXJzb25JbkNoYXJnZT7lvLXmsLjmhbY8L1BlcnNvbkluQ2hhcmdlPg0KICAgICAgICAgICAgPFRlbGVwaG9uZU51bWJlcj4wMi04ODg4ODg4ODwvVGVsZXBob25lTnVtYmVyPg0KICAgICAgICAgICAgPEZhY3NpbWlsZU51bWJlcj48L0ZhY3NpbWlsZU51bWJlcj4NCiAgICAgICAgICAgIDxFbWFpbEFkZHJlc3M+dGVzdEBteWNvbXBhbnkuY29tPC9FbWFpbEFkZHJlc3M+DQogICAgICAgICAgICA8Q3VzdG9tZXJOdW1iZXI+PC9DdXN0b21lck51bWJlcj4NCiAgICAgICAgPC9TZWxsZXI+DQogICAgICAgIDxCdXllcj4NCiAgICAgICAgICAgIDxJZGVudGlmaWVyPjIzNjM5NzgxPC9JZGVudGlmaWVyPg0KICAgICAgICAgICAgPE5hbWU+576O5ZWG5aiB6Luf5YWs5Y+4PC9OYW1lPg0KICAgICAgICAgICAgPEFkZHJlc3M+5YyX5biC5b+g5a2d5p2x6Lev5LqU5q61MTAw6JmfPC9BZGRyZXNzPg0KICAgICAgICAgICAgPFBlcnNvbkluQ2hhcmdlPjwvUGVyc29uSW5DaGFyZ2U+DQogICAgICAgICAgICA8VGVsZXBob25lTnVtYmVyPjwvVGVsZXBob25lTnVtYmVyPg0KICAgICAgICAgICAgPEZhY3NpbWlsZU51bWJlcj48L0ZhY3NpbWlsZU51bWJlcj4NCiAgICAgICAgICAgIDxFbWFpbEFkZHJlc3M+dGVzdEBteWNvbXBhbnkuY29tPC9FbWFpbEFkZHJlc3M+DQogICAgICAgICAgICA8Q3VzdG9tZXJOdW1iZXI+PC9DdXN0b21lck51bWJlcj4NCiAgICAgICAgPC9CdXllcj4NCiAgICAgICAgICAgIDxNYWluUmVtYXJrPumAmeaYr+e4veeZvOelqOWCmeiouzwvTWFpblJlbWFyaz4NCiAgICAgICAgICAgIDxJbnZvaWNlVHlwZT4wNzwvSW52b2ljZVR5cGU+DQogICAgICAgICAgICA8RG9uYXRlTWFyaz4wPC9Eb25hdGVNYXJrPg0KICAgICAgICAgICAgPENhcnJpZXJUeXBlPjwvQ2FycmllclR5cGU+DQogICAgICAgICAgICA8Q2FycmllcklkMT48L0NhcnJpZXJJZDE+DQogICAgICAgICAgICA8Q2FycmllcklkMj48L0NhcnJpZXJJZDI+DQogICAgICAgICAgICA8UHJpbnRNYXJrPlk8L1ByaW50TWFyaz4NCiAgICAgICAgICAgIDxOUE9CQU4+PC9OUE9CQU4+DQogICAgICAgICAgICA8UmFuZG9tTnVtYmVyPjgyNTA8L1JhbmRvbU51bWJlcj4NCiAgICA8L01haW4+DQogICAgPERldGFpbHM+DQogICAgICAgICAgICA8UHJvZHVjdEl0ZW0+DQogICAgICAgICAgICAgICAgPERlc2NyaXB0aW9uPuaIkeeahOWVhuWTgeWQjeeosTAxPC9EZXNjcmlwdGlvbj4NCiAgICAgICAgICAgICAgICA8UXVhbnRpdHk+MTwvUXVhbnRpdHk+DQogICAgICAgICAgICAgICAgICAgIDxVbml0Lz4NCiAgICAgICAgICAgICAgICA8VW5pdFByaWNlPjEwMDwvVW5pdFByaWNlPg0KICAgICAgICAgICAgICAgIDxBbW91bnQ+MTAwPC9BbW91bnQ+DQogICAgICAgICAgICAgICAgPFNlcXVlbmNlTnVtYmVyPjE8L1NlcXVlbmNlTnVtYmVyPg0KICAgICAgICAgICAgICAgIDxSZW1hcms+bXlSZW1hcmswMTwvUmVtYXJrPg0KICAgICAgICAgICAgICAgIDxSZWxhdGVOdW1iZXI+bXlSZWFsYXRlTnVtYmVyMDE8L1JlbGF0ZU51bWJlcj4NCiAgICAgICAgICAgIDwvUHJvZHVjdEl0ZW0+DQogICAgICAgICAgICA8UHJvZHVjdEl0ZW0+DQogICAgICAgICAgICAgICAgPERlc2NyaXB0aW9uPuaIkeeahOWVhuWTgeWQjeeosTAyPC9EZXNjcmlwdGlvbj4NCiAgICAgICAgICAgICAgICA8UXVhbnRpdHk+MjwvUXVhbnRpdHk+DQogICAgICAgICAgICAgICAgICAgIDxVbml0Lz4NCiAgICAgICAgICAgICAgICA8VW5pdFByaWNlPjIwMDwvVW5pdFByaWNlPg0KICAgICAgICAgICAgICAgIDxBbW91bnQ+MjAwPC9BbW91bnQ+DQogICAgICAgICAgICAgICAgPFNlcXVlbmNlTnVtYmVyPjI8L1NlcXVlbmNlTnVtYmVyPg0KICAgICAgICAgICAgICAgIDxSZW1hcms+bXlSZW1hcmswMjwvUmVtYXJrPg0KICAgICAgICAgICAgICAgIDxSZWxhdGVOdW1iZXI+bXlSZWFsYXRlTnVtYmVyMDI8L1JlbGF0ZU51bWJlcj4NCiAgICAgICAgICAgIDwvUHJvZHVjdEl0ZW0+DQogICAgPC9EZXRhaWxzPg0KICAgIDxBbW91bnQ+DQogICAgICAgIDxTYWxlc0Ftb3VudD4xMDA8L1NhbGVzQW1vdW50Pg0KICAgICAgICA8RnJlZVRheFNhbGVzQW1vdW50PjA8L0ZyZWVUYXhTYWxlc0Ftb3VudD4NCiAgICAgICAgPFplcm9UYXhTYWxlc0Ftb3VudD4wPC9aZXJvVGF4U2FsZXNBbW91bnQ+DQogICAgICAgIDxUYXhUeXBlPjE8L1RheFR5cGU+DQogICAgICAgIDxUYXhSYXRlPjAuMDU8L1RheFJhdGU+DQogICAgICAgIDxUYXhBbW91bnQ+NTwvVGF4QW1vdW50Pg0KICAgICAgICA8VG90YWxBbW91bnQ+MTA1PC9Ub3RhbEFtb3VudD4NCiAgICA8L0Ftb3VudD4NCjwvSW52b2ljZT4=",// [string]  MIG檔 ，需要使用Base64解密
        "id": 40719569,
        "relateNumber": "myERP_invoice_007",// [string]  唯一號碼
        "migDate": "20241122", // [string]  發票開立日期 (YYYYMMDD)
        "cancelDate": null, // [string] 發票作廢日期(YYYYMMDD)
        "voidDate": null,// [string]  發票註銷日期 (YYYYMMDD)
        "buyerId": "23639781",// [string] 買方統一編號
        "sellerId": "23639781", // [string] 賣方統一編號
        "receiveDate": "2024-11-22", // [string] 收到檔案日期
        "receiveTime": "T16:30:04.478", // [string] 收到檔案時間
        "gwReply": null, // [string] 關網檢核回覆，失敗:E   成功:C，若為E則會顯示gwErrorMessage 錯誤訊息
        "gwErrorMessage": null,// [string] 關網錯誤原因
        "taxType": "1",// [string] VAT type, 1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
        "taxAmount": "5.0000",// [float] 營業稅額
        "totalAmount": "105.0000",// [float] 總銷售額
        "natReply": null, // [string] 財政部回覆訊息 ，失敗:E   成功:C，若為E則會顯示natErrorMessage 錯誤訊息
        "natErrorMessage": null, // [string] 財政部錯誤訊息
        "randomNumber": "8250"// [string] 防偽隨機碼
    }
}
```



### 下載C0403發票 PDF

#### 方法: GET

#### URL:

```http
https://sstest.gwis.com.tw/api/v1/simplified/pdf/invoice/api/{relateNumber}/{sellerIdentifier}
```



#### 參數:

| 參數             | 說明     |
| ---------------- | -------- |
| sellerIdentifier | 賣方統編 |
| relateNumber     | 唯一號碼 |

#### Response

 Base64 format PDF. 



### 下載折讓單 PDF

#### 方法: GET

#### URL:

```http
https://sstest.gwis.com.tw/api/v1/simplified/pdf/allowance/api/{originalRelateNumber}/{sellerIdentifier}/{relateNumber}
```



#### 參數:

| 參數             | 說明     |
| ---------------- | -------- |
| sellerIdentifier | 賣方統編 |
| relateNumber     | 唯一號碼 |

#### Response

 Base64 format PDF. 



### 作廢發票 -C0503

#### 方法: POST

#### API URL

```http
https://sstest.gwis.com.tw/api/v1/simplified/C0503?domestic=true&companyKey={companyKey}
//companyKey: Upon registration at GateWeb, Gateweb will provide one companyKey.
```

#### Request Body Fields Format 說明

```json
{
		"sellerId": "",                 //  [string] 賣方統一編號
    "relateNumber": "",            //  [string] 唯一號碼
    "cancelReason": "",            //  [string] 作廢原因
    "cancelDate": "",              //  [string] 作廢日期( YYYYMMDD)
	  "cancelTime": "",              //  [string] 作廢時間 (HH:mm:ss)
    
  
  
  
}

```

#### 200 OK回覆成功

```json
{
    "typeCode": 0,
    "errors": [
        {
            "field": null,
            "originalValue": null,
            "errorMessage": "Success"
        }
    ]
}
```

#### 其它回覆typeCode

| TypeCode | **Error Message**                                            |
| :------- | :----------------------------------------------------------- |
| 21       | (C0503) This relateNumber has not been issued, please check and try again. 此號碼沒被開⽴過，請檢查後再試 |
| 22       | (C0503) This relateNumber had already been cancelled or voided, unable to cancel. 此號碼⽬前已被作廢或註銷，無法作廢 |
| 23       | (C0503) This relateNumber currently has records of allowance (D0403), please cancel Allowance records then try again. 此號碼⽬前仍有折讓單，請將折讓單作廢後再試 |
| 24       | (C0503) Tax ID not found, please check sellerId. 查無此公司統編，請檢查 sellerId |
| 25       | (C0503) This sellerIdentifier does not belong to this companyKey. Please input the correct sellerIdentifier. 只能作廢此公司，或是所屬⼦公司之發票，請檢查 companyKey、sellerId |
| 26       | (C0503) CancleDate not within the current period of this relateNumber, unable to do cancellation. Cancellation can only be done within the same period of the issue date of the original e-GUI 只能作廢當期發票，請檢查 cancelDate |
| 29       | (C0503) Unknown Cancellation Error. Please contact GW support team. 作廢發票異常，請聯繫客服 |

### 取回作廢發票 (C0503) Status

#### 方法: GET

#### URL

```http
https://sstest.gwis.com.tw/api/v1/simplified/C0503/{relateNumber}/{sellerIdentifier}?completeness=true
```

#### 參數說明

| 參數             | 說明                     |
| ---------------- | ------------------------ |
| relateNumber     | 唯一號碼                 |
| sellerIdentifier | 賣方統一編號             |
| completeness     | 是否取回代有MIG Data檔案 |



#### 回覆範例與說明 - Response Body Field Format

```json
{
    "uploadStatus": "C", // [string] 上傳狀態　失敗:E   成功:C
    "migNumber": "TW93432550", // [string] 發票號碼
    "migData": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxDYW5jZWxJbnZvaWNlIHhtbG5zPSJ1cm46R0VJTlY6ZUludm9pY2VNZXNzYWdlOkMwNTAxOjMuMiI+DQogICAgPENhbmNlbEludm9pY2VOdW1iZXI+VFc5MzQzMjU1MDwvQ2FuY2VsSW52b2ljZU51bWJlcj4NCiAgICA8SW52b2ljZURhdGU+MjAyNDExMjI8L0ludm9pY2VEYXRlPg0KICAgIDxCdXllcklkPjIzNjM5NzgxPC9CdXllcklkPg0KICAgIDxTZWxsZXJJZD4yMzYzOTc4MTwvU2VsbGVySWQ+DQogICAgPENhbmNlbERhdGU+MjAyNDExMjI8L0NhbmNlbERhdGU+DQogICAgPENhbmNlbFRpbWU+MjM6NTk6NTk8L0NhbmNlbFRpbWU+DQogICAgPENhbmNlbFJlYXNvbj5jYW5jZWwmYW1wOzwvQ2FuY2VsUmVhc29uPg0KPC9DYW5jZWxJbnZvaWNlPg==",// [string] MIG檔 ，需要使用Base64解密
    "id": 2884177,
    "relateNumber": "myERP_invoice_007",// [string] 唯一號碼
    "migDate": "20241122", // [string] 發票開立日期 (YYYYMMDD)
    "cancelDate": "20241122", // [string] 發票作廢日期 (YYYYMMDD)
    "voidDate": null,// [string] 發票註銷日期 (YYYYMMDD)
    "buyerId": "23639781", // [string] 買方統一編號
    "sellerId": "23639781", // [string] 賣方統一編號
    "receiveDate": "2024-11-22",// [string] 收到檔案日期
    "receiveTime": "T17:48:02.683",// [string] 收到檔案時間
    "gwReply": null,// [string] 關網檢核回覆，失敗:E   成功:C，若為E則會顯示gwErrorMessage 錯誤訊息
    "gwErrorMessage": null, // [string] 關網錯誤原因
    "taxType": null,// [string] VAT type, 1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
    "taxAmount": null,// [float] 營業稅
    "totalAmount": null,// [float] 總銷售額
    "natReply": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48Q2FuY2VsSW52b2ljZUNvbmZpcm0geG1sbnM9InVybjpHRUlOVjplSW52b2ljZU1lc3NhZ2U6QzA1MDI6My4xIj48SWQ+Mjg4NDE3NzwvSWQ+PENhbmNlbEludm9pY2VOdW1iZXI+VFc5MzQzMjU1MDwvQ2FuY2VsSW52b2ljZU51bWJlcj48SW52b2ljZURhdGU+MjAyNDExMjI8L0ludm9pY2VEYXRlPjxCdXllcklkPjIzNjM5NzgxPC9CdXllcklkPjxTZWxsZXJJZD4yMzYzOTc4MTwvU2VsbGVySWQ+PENhbmNlbERhdGU+MjAyNDExMjI8L0NhbmNlbERhdGU+PFJlY2VpdmVEYXRlPjIwMjQxMTIyPC9SZWNlaXZlRGF0ZT48UmVjZWl2ZVRpbWU+MTc6NDg6MDI8L1JlY2VpdmVUaW1lPjxOYXRSZXBseT5DPC9OYXRSZXBseT48L0NhbmNlbEludm9pY2VDb25maXJtPg==",// [string] 財政部回覆訊息 ，失敗:E   成功:C，若為E則會顯示natErrorMessage 錯誤訊息
    "natErrorMessage": null,// [string] 財政部錯誤訊息
    "randomNumber": null// [string] 防偽隨機碼
}
```

### 即時取回作廢資料 (C0503) Status Instantly

#### 方法: GET

#### URL

```http
https://sstest.gwis.com.tw/api/v1/invoiceCancellation/{sellerIdentifier}/{relateNumber}
```



#### 參數

| 參數                 | 說明         |
| -------------------- | ------------ |
| **relateNumber**     | 唯一號碼     |
| **sellerIdentifier** | 賣方統一編號 |

#### 回傳JSON說明 - 200 OK

```json
{
    "migData": {
        "uploadStatus": "C",// [string] 上傳狀態　失敗:E   成功:C
        "migNumber": "TW93432550",// [string] 發票號碼
        "migData": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxDYW5jZWxJbnZvaWNlIHhtbG5zPSJ1cm46R0VJTlY6ZUludm9pY2VNZXNzYWdlOkMwNTAxOjMuMiI+DQogICAgPENhbmNlbEludm9pY2VOdW1iZXI+VFc5MzQzMjU1MDwvQ2FuY2VsSW52b2ljZU51bWJlcj4NCiAgICA8SW52b2ljZURhdGU+MjAyNDExMjI8L0ludm9pY2VEYXRlPg0KICAgIDxCdXllcklkPjIzNjM5NzgxPC9CdXllcklkPg0KICAgIDxTZWxsZXJJZD4yMzYzOTc4MTwvU2VsbGVySWQ+DQogICAgPENhbmNlbERhdGU+MjAyNDExMjI8L0NhbmNlbERhdGU+DQogICAgPENhbmNlbFRpbWU+MjM6NTk6NTk8L0NhbmNlbFRpbWU+DQogICAgPENhbmNlbFJlYXNvbj5jYW5jZWwmYW1wOzwvQ2FuY2VsUmVhc29uPg0KPC9DYW5jZWxJbnZvaWNlPg==",// [string] MIG檔 ，需要使用Base64解密
        "id": 40719569,
        "relateNumber": "myERP_invoice_007", // [string] 唯一號碼
        "migDate": "20241122",// [string] 發票開立日期 (YYYYMMDD)
        "cancelDate": "20241122",// [string] 發票作廢日期 (YYYYMMDD)
        "voidDate": null, // [string] 發票註銷日期 (YYYYMMDD)
        "buyerId": "23639781", // [string] 買方統一編號
        "sellerId": "23639781", // [string] 賣方統一編號
        "receiveDate": "2024-11-22",// [string] 收到檔案日期
        "receiveTime": "T16:30:04.478", // [string] 收到檔案時間
        "gwReply": null,// [string] 關網檢核回覆，失敗:E   成功:C，若為E則會顯示gwErrorMessage 錯誤訊息
        "gwErrorMessage": null,// [string] 關網錯誤原因
        "taxType": "1", // [string]  1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
        "taxAmount": "5.0000",  // [float] 營業稅額
        "totalAmount": "105.0000", // [float] 總銷售額
        "natReply": null, // [string] 財政部回覆訊息 ，失敗:E   成功:C，若為E則會顯示natErrorMessage 錯誤訊息
        "natErrorMessage": null,// [string] 財政部錯誤訊息
        "randomNumber": "8250" // [string] 防偽隨機碼
    }
}
```

### 開立折讓單 - D0403

#### Method: POST

#### URL

```http
https://sstest.gwis.com.tw/api/v1/simplified/D0403?domestic=true&companyKey={companyKey}
//companyKey: Upon registration at GateWeb, Gateweb will provide one companyKey.

```

#### Request Body Fields Format

```json
{
  "detail": [
    {
      "amount": 21, // [float] 折讓金額(四捨五入/不含稅)
      "description": "商品退貨",// [string] 折讓名稱
      "quantity": 1,  // [int] 數量
    "unit": "",                // [string] 單位
      "sequenceNumber": "001",  // [string] 明細排列序號
      "tax": 1,// [number]  折讓稅額
      "taxType": "1", // [string]  1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
      "unitPrice": 200// [float] 單價
    }
  ],
  "originalRelateNumber": "myERP_invoice_007",  // [string] 原始發票號碼/發票唯一號碼
  "relateNumber": "TestDomesticB2C20220815_2_1D1", // [string] 折讓單產生的唯一號碼(長度16字元，若超過則會系統產生序列替換)
  "allowanceDate": "20241125",		       // [string] 折讓日期
  "sellerId": "23639781"
}
```

| **TypeCode** | **Error Message**                                            |
| :----------- | :----------------------------------------------------------- |
| 41           | (D0403) The relateNumber has not been issued, please check then try again. 此號碼沒被開⽴過，請檢查後再試 |
| 42           | (D0403) This Allowance Number has been allowanced, please check and try again. 此號碼已重複折讓，請檢查後再試 |
| 43           | (D0403) This relateNumber had been cancelled or voided, please check and try again. 此號碼⽬前已被作廢或註銷，請檢查後再試 |
| 44           | (D0403) Allowance amount exceeds Invoice totalAmount, please check amount. 折讓⾦額超過發票總額，請檢查 amount Copy of ErrorCode 5 |
| 45           | (D0403) Allowance amount exceeds Invoice discountable amount, or Allowance tax exceeds Invoice discountable tax, please check amount and tax. 折讓⾦額超過可折餘額，或折讓稅額超過可折稅額，請檢查 amount、tax |
| 46           | (D0403) Tax ID not found, please check sellerId. 查無此公司統編，請檢查 sellerId |
| 47           | (D0403) Only the current Company can issue Allowance, or by its affiliate branches. Please check companyKey and sellerId. 只能折讓此公司，或是所屬⼦公司之發票，請檢查 companyKey、sellerId |
| 49           | (D0403) Unknown Allowance Error. please contact GW support. 折讓發票異常，請聯繫客服 |

### 取回折讓資料 (D0403) Status

#### Method GET

#### URL

```http
https://sstest.gwis.com.tw/api/v1/simplified/D0403/{originalRelateNumber}/{sellerIdentifier}/{relateNumber}?completeness=true
```

#### Parameters

| Parameters               | Desc                                               |
| ------------------------ | -------------------------------------------------- |
| **originalRelateNumber** | 原始發票號碼/發票唯一號碼                          |
| **sellerIdentifier**     | 賣方統一編號                                       |
| **relateNumber**         | 折讓單唯一號碼                                     |
| **completeness**         | whether  to receive response with inserted migData |

#### Response Body Field Format

```json
{
    "uploadStatus": "C",// [string] 上傳狀態　失敗:E   成功:C
    "migNumber": "b61086a3c5a3962c",// [string] 折讓單產生的唯一號碼(長度16字元，若超過則會系統產生序列替換) 
    "migData": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxBbGxvd2FuY2UgeG1sbnM9InVybjpHRUlOVjplSW52b2ljZU1lc3NhZ2U6RDA0MDE6My4yIj4NCiAgICA8TWFpbj4NCiAgICAgICAgPEFsbG93YW5jZU51bWJlcj5iNjEwODZhM2M1YTM5NjJjPC9BbGxvd2FuY2VOdW1iZXI+DQogICAgICAgIDxBbGxvd2FuY2VEYXRlPjIwMjQxMTI1PC9BbGxvd2FuY2VEYXRlPg0KICAgICAgICA8U2VsbGVyPg0KICAgICAgICAgICAgPElkZW50aWZpZXI+MjM2Mzk3ODE8L0lkZW50aWZpZXI+DQogICAgICAgICAgICA8TmFtZT7nvo7llYblgYfpqqjmloflhazlj7g8L05hbWU+DQogICAgICAgIDwvU2VsbGVyPg0KICAgICAgICA8QnV5ZXI+DQogICAgICAgICAgICA8SWRlbnRpZmllcj4yMzYzOTc4MTwvSWRlbnRpZmllcj4NCiAgICAgICAgICAgIDxOYW1lPue+juWVhuWogei7n+WFrOWPuDwvTmFtZT4NCiAgICAgICAgPC9CdXllcj4NCiAgICAgICAgPEFsbG93YW5jZVR5cGU+MjwvQWxsb3dhbmNlVHlwZT4NCiAgICA8L01haW4+DQogICAgPERldGFpbHM+DQogICAgICAgIDxQcm9kdWN0SXRlbT4NCiAgICAgICAgICAgIDxPcmlnaW5hbEludm9pY2VEYXRlPjIwMjQxMTIyPC9PcmlnaW5hbEludm9pY2VEYXRlPg0KICAgICAgICAgICAgPE9yaWdpbmFsSW52b2ljZU51bWJlcj5UVzkzNDMyNTUxPC9PcmlnaW5hbEludm9pY2VOdW1iZXI+DQogICAgICAgICAgICA8T3JpZ2luYWxTZXF1ZW5jZU51bWJlcj4xPC9PcmlnaW5hbFNlcXVlbmNlTnVtYmVyPg0KICAgICAgICAgICAgPE9yaWdpbmFsRGVzY3JpcHRpb24+5ZWG5ZOB6YCA6LKoPC9PcmlnaW5hbERlc2NyaXB0aW9uPg0KICAgICAgICAgICAgPFF1YW50aXR5PjE8L1F1YW50aXR5Pg0KICAgICAgICAgICAgPFVuaXRQcmljZT4yMDA8L1VuaXRQcmljZT4NCiAgICAgICAgICAgIDxBbW91bnQ+MjE8L0Ftb3VudD4NCiAgICAgICAgICAgIDxUYXg+MTwvVGF4Pg0KICAgICAgICAgICAgPEFsbG93YW5jZVNlcXVlbmNlTnVtYmVyPjE8L0FsbG93YW5jZVNlcXVlbmNlTnVtYmVyPg0KICAgICAgICAgICAgPFRheFR5cGU+MTwvVGF4VHlwZT4NCiAgICAgICAgPC9Qcm9kdWN0SXRlbT4NCiAgICA8L0RldGFpbHM+DQogICAgPEFtb3VudD4NCiAgICAgICAgPFRheEFtb3VudD4xPC9UYXhBbW91bnQ+DQogICAgICAgIDxUb3RhbEFtb3VudD4yMTwvVG90YWxBbW91bnQ+DQogICAgPC9BbW91bnQ+DQo8L0FsbG93YW5jZT4=",// [string] MIG檔 ，需要使用Base64解密
    "id": 2884216,
    "relateNumber": "TestDomesticB2C20220815_2_1D1",// [string]折讓單唯一號碼
    "migDate": "20241125",// [string] 折讓開立日期 (YYYYMMDD)
    "cancelDate": null,// [string] 折讓單作廢日期 (YYYYMMDD)
    "voidDate": null,// [string] 發票註銷日期 (YYYYMMDD)
    "buyerId": "23639781",// [string] 買方統一編號
    "sellerId": "23639781",// [string] 賣方統一編號
    "receiveDate": "2024-11-25", // [string] 收到檔案日期
    "receiveTime": "T10:48:09.173",// [string] 收到檔案時間
    "gwReply": null,// [string] 關網檢核回覆，失敗:E   成功:C，若為E則會顯示gwErrorMessage 錯誤訊息
    "gwErrorMessage": null,// [string] 關網錯誤原因
    "taxType": "1",// [string] VAT type, 1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
    "taxAmount": "1.0000",// [float] 營業稅額
    "totalAmount": "21.0000",// [float] 總銷售額
    "natReply": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48QWxsb3dhbmNlQ29uZmlybSB4bWxucz0idXJuOkdFSU5WOmVJbnZvaWNlTWVzc2FnZTpEMDQwMjozLjEiPjxJZD4yODg0MjE2PC9JZD48QWxsb3dhbmNlTnVtYmVyPmI2MTA4NmEzYzVhMzk2MmM8L0FsbG93YW5jZU51bWJlcj48QWxsb3dhbmNlRGF0ZT4yMDI0MTEyNTwvQWxsb3dhbmNlRGF0ZT48QnV5ZXJJZD4yMzYzOTc4MTwvQnV5ZXJJZD48U2VsbGVySWQ+MjM2Mzk3ODE8L1NlbGxlcklkPjxSZWNlaXZlRGF0ZT4yMDI0MTEyNTwvUmVjZWl2ZURhdGU+PFJlY2VpdmVUaW1lPjEwOjQ4OjA5PC9SZWNlaXZlVGltZT48TmF0UmVwbHk+QzwvTmF0UmVwbHk+PFRheEFtb3VudD4xPC9UYXhBbW91bnQ+PFRvdGFsQW1vdW50PjIxPC9Ub3RhbEFtb3VudD48L0FsbG93YW5jZUNvbmZpcm0+",// [string] 財政部回覆訊息 ，失敗:E   成功:C，若為E則會顯示natErrorMessage 錯誤訊息
    "natErrorMessage": null,// [string] 財政部錯誤訊息
    "randomNumber": null// [string] 防偽隨機碼
}
```

### 作廢折讓單 - D0503

#### Method:POST

#### URL:

```http
https://sstest.gwis.com.tw/api/v1/simplified/D0503?domestic=true&companyKey={companyKey}
//companyKey: Upon registration at GateWeb, Gateweb will provide one companyKey.

```

#### Request Body Field Form

```json
{
    "cancelDate": "20241125",// [string] 折讓單作廢日期 (YYYYMMDD)
     "cancelTime": "23:59:59",
    "cancelReason": "折讓作廢D0503測試",
    "originalRelateNumber": "myERP_invoice_007", // [string]原始發票唯一號碼    
    "relateNumber": "TestDomesticB2C20220815_2_1D1",// [string]折讓單唯一號碼
    "sellerId": "23639781"
}

```

#### Response Example - Success

```json
{
    "typeCode": 0,
    "errors": [
        {
            "field": null,
            "originalValue": null,
            "errorMessage": "Success"
        }
    ]
}
```

#### Response Example - Failed

```json
{
    "typeCode": 52,
    "errors": [
        {
            "field": null,
            "originalValue": null,
            "errorMessage": "(D0503) The related Allowance of relateNumber cannot be found. Please check if the Allowance was successfully issued, or it coudld be cancelled. 此號碼的原始折讓不存在，請檢查折讓是否開立成功，也許已被作廢折讓"
        }
    ]
}
//typeCode & errorMessage Please refer to the error code list
```



#### TypeCode & ErrorMessage for POST D0503

| TypeCode | Error Message                                                |
| :------- | :----------------------------------------------------------- |
| 51       | (D0503) This relateNumber had not been issued, please check then try again. 此號碼尚未被開⽴過，請檢查後再試 |
| 52       | (D0503) This relateNumber had not been allowanced, please check then try again. 此號碼沒被折讓過，請檢查後再試 |
| 53       | (D0503) The taxId is not found, please check sellerId. 查無此公司統編，請檢查 sellerId |
| 54       | (D0503) This sellerIdentifier does not belong to this companyKey. Please input the correct sellerIdentifier. 只能作廢折讓此公司，或是所屬⼦公司之發票，請檢查 companyKey、 sellerId |
| 59       | (D0503) Unknown Allowance Cancellation Error. Please contact GW support team. 作廢折讓發票異常，請聯繫關網客服 |

### 取回作廢折讓單 (D0503) Status

#### Method: GET

#### URL

```http
{{03api-url}}/api/v1/simplified/D0503/{{originalRelateNumber}}/{{sellerIdentifier}}?completeness=true
```

#### Parameters

| Parameters               | Desc                     |
| ------------------------ | ------------------------ |
| **originalRelateNumber** | 原始開立唯一號碼         |
| **sellerIdentifier**     | 賣方統一編號             |
| **completeness**         | 是否取回代有MIG Data檔案 |

#### Response Body Field Format - 200 OK

```json
[
    {
        "uploadStatus": "C",// [string] 上傳狀態　失敗:E   成功:C
        "migNumber": "b61086a3c5a3962c",// [string] 折讓單產生的唯一號碼(長度16字元，若超過則會系統產生序列替換) 
        "migData": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjxDYW5jZWxBbGxvd2FuY2UgeG1sbnM9InVybjpHRUlOVjplSW52b2ljZU1lc3NhZ2U6RDA1MDE6My4yIj4NCiAgICA8Q2FuY2VsQWxsb3dhbmNlTnVtYmVyPmI2MTA4NmEzYzVhMzk2MmM8L0NhbmNlbEFsbG93YW5jZU51bWJlcj4NCiAgICA8QWxsb3dhbmNlRGF0ZT4yMDI0MTEyNTwvQWxsb3dhbmNlRGF0ZT4NCiAgICA8QnV5ZXJJZD4yMzYzOTc4MTwvQnV5ZXJJZD4NCiAgICA8U2VsbGVySWQ+MjM2Mzk3ODE8L1NlbGxlcklkPg0KICAgIDxDYW5jZWxEYXRlPjIwMjQxMTI1PC9DYW5jZWxEYXRlPg0KICAgIDxDYW5jZWxUaW1lPjIzOjU5OjU5PC9DYW5jZWxUaW1lPg0KICAgIDxDYW5jZWxSZWFzb24+5oqY6K6T5L2c5buiRDA1MDPmuKzoqaY8L0NhbmNlbFJlYXNvbj4NCjwvQ2FuY2VsQWxsb3dhbmNlPg==",// [string] MIG檔 ，需要使用Base64解密
        "id": 2884220,
        "relateNumber": "TestDomesticB2C20220815_2_1D1",// [string]折讓單唯一號碼
        "migDate": null,// [string] 折讓開立日期 (YYYYMMDD)
        "cancelDate": null, // [string] 折讓單作廢日期 (YYYYMMDD)
        "voidDate": null,// [string] 發票註銷日期 (YYYYMMDD)
        "buyerId": "23639781", // [string] 買方統一編號
        "sellerId": "23639781",// [string] 賣方統一編號
        "receiveDate": "2024-11-25",// [string] 收到檔案日期
        "receiveTime": "T11:26:58.082",// [string] 收到檔案時間
        "gwReply": null, // [string] 關網檢核回覆，失敗:E   成功:C，若為E則會顯示gwErrorMessage 錯誤訊息
    "gwErrorMessage": "",       // [string] 關網錯誤原因

        "gwErrorMessage": null,// [string] 關網錯誤原因
        "taxType": null, // [string] VAT type, 1=taxable應稅,2=zero tax rate零稅率, 3=tax-exempt免稅,4=special tax特種稅,9=compound duties混合稅
        "taxAmount": null, // [float] 營業稅額
        "totalAmount": null,// [float] 總銷售額
        "natReply": "PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0iVVRGLTgiPz48Q2FuY2VsQWxsb3dhbmNlQ29uZmlybSB4bWxucz0idXJuOkdFSU5WOmVJbnZvaWNlTWVzc2FnZTpEMDUwMjozLjEiPjxJZD4yODg0MjIwPC9JZD48Q2FuY2VsQWxsb3dhbmNlTnVtYmVyPmI2MTA4NmEzYzVhMzk2MmM8L0NhbmNlbEFsbG93YW5jZU51bWJlcj48QWxsb3dhbmNlRGF0ZT4yMDI0MTEyNTwvQWxsb3dhbmNlRGF0ZT48QnV5ZXJJZD4yMzYzOTc4MTwvQnV5ZXJJZD48U2VsbGVySWQ+MjM2Mzk3ODE8L1NlbGxlcklkPjxDYW5jZWxEYXRlPjIwMjQxMTI1PC9DYW5jZWxEYXRlPjxSZWNlaXZlRGF0ZT4yMDI0MTEyNTwvUmVjZWl2ZURhdGU+PFJlY2VpdmVUaW1lPjExOjI2OjU4PC9SZWNlaXZlVGltZT48TmF0UmVwbHk+QzwvTmF0UmVwbHk+PC9DYW5jZWxBbGxvd2FuY2VDb25maXJtPg==",// [string] 財政部回覆訊息 ，失敗:E   成功:C，若為E則會顯示natErrorMessage 錯誤訊息
        "natErrorMessage": null,// [string] 財政部錯誤訊息
        "randomNumber": null // [string] 防偽隨機碼
    }
]
```

#### Response Example - Failed

```json
{
    "typeCode": 9,
    "errors": [
        {
            "field": null,
            "originalValue": null,
            "errorMessage": "MigDeduplication  : Get D0501 OriginalRelateNumber(myERP_invoice_00) is not found."
        }
    ]
}
//typeCode & errorMessage Please refer to the error code list
```

#### TypeCode & ErrorMessage for GET D0503

| **Error Code** | **Description** |
| :------------- | :-------------- |
| 9              | Not found       |
| 91             | Data Uploading  |



