收據作廢

應用場景

特店可使用此API開立一般、公益與政治收據。

API介接網址

  • 測試環境:https://einvoice-stage.ecpay.com.tw/Receipt/Invalid
  • 正式環境:https://einvoice.ecpay.com.tw/Receipt/Invalid

HTTPS傳輸協定

  • Content Type :application/json
  • HTTP Method :POST
  • Crypto-Mode :AES-CBC \ AES-GCM (預設為 AES-CBC)

特店傳入參數(Json格式)

MerchantID String(10)
特店編號 必填

測試環境合作特店編號 & 正式環境金鑰取得請參考連結

RqHeader Object
傳入資料 必填

Timestamp Number
傳入時間 必填

請將傳輸時間轉換為時間戳(GMT+8),綠界會利用此參數將當下的時間轉為Unix TimeStamp來驗證此次介接的時間區間。

❗ 注意事項

  • 驗證時間區間暫訂為 10 分鐘內有效,若超過此驗證時間則此次訂單將無法建立,參考資料:http://www.epochconverter.com/
  • 合作特店須進行主機「時間校正」,避免主機產生時差,導致API無法正常運作。

Data String
加密資料 必填

此為加密過JSON格式的資料,此串接規格提供兩種加密模式,加密方法請參考以下連結說明:

特店傳入參數範例(Json格式)

				
					{
    "MerchantID": "2000132",
    "RqHeader": {
        "Timestamp": 1525168923
    },
    "Data": "加密資料"
}

				
			

Data參數說明(Json格式) : 請先將Json字串進行urlencode後再進行AES加密

MerchantID String(10)
特店編號 必填

ReceiptNo String(20)
綠界收據編號 必填

Reason String(200)
作廢原因 必填

Data參數範例(Json格式)

				
					{
    "MerchantID": "2000132",
    "ReceiptNo": "123456789123456789",
    "Reason": "作廢"
}
				
			

綠界回傳參數格式

  • Content Type :application/json
  • HTTP Method :POST
  • Crypto-Mode :AES-CBC \ AES-GCM (預設為 AES-CBC)

綠界回傳參數(Json格式)

MerchantID String(10)
特店編號 

RpHeader Object
回傳資料 

Timestamp Number
回傳時間

Unix timestamp(GMT+8)

TransCode Int
回傳代碼 

1 代表 API 傳輸資料(MerchantID, RqHeader, Data)接收成功,實際的 API 執行結果狀態請參考 RtnCode

TransMsg String(200)
回傳訊息 

Data String
加密資料 

回傳相關資料,此為加密過JSON格式的資料。

此串接規格提供兩種加密模式,加密方法請參考以下連結說明:

綠界回傳參數範例

				
					{
    "MerchantID": "2000132",
    "RpHeader": {
        "Timestamp": 1525169058
    },
    "TransCode": 1,
    "TransMsg": "",
    "Data": "..."
}

				
			

Data參數說明(Json格式) : 請先將Data進行AES解密後再做urldecode

RtnCode Int
回應代碼

1 代表 API 執行成功,其餘代碼均為失敗。

RtnMsg String(200)
回應訊息

Data參數範例

				
					{
  "RtnCode": 1,
  "RtnMsg": "Success"
}


				
			

YAML

提供的 YAML 文件用於定義 API 的配置、結構、操作和基礎設施管理等資訊,方便開發人員理解和使用 API。

				
					openapi: 3.1.0
info:
  title: 收據作廢
  version: 1.0.0
  x-source-url: https://developers.ecpay.com.tw/64513/
servers:
- url: https://einvoice-stage.ecpay.com.tw
  description: Testing Environment
- url: https://einvoice.ecpay.com.tw
  description: Production Environment
paths:
  /Receipt/Invalid:
    post:
      summary: 收據作廢
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - MerchantID
              - Timestamp
              - Data
              - MerchantID
              - ReceiptNo
              - Reason
              properties:
                MerchantID:
                  type: string
                  maxLength: 10
                  description: 特店編號
                Timestamp:
                  type: number
                  description: 傳入時間
                Data:
                  type: string
                  description: 加密資料
                ReceiptNo:
                  type: string
                  maxLength: 20
                  description: 綠界收據編號
                Reason:
                  type: string
                  maxLength: 200
                  description: 作廢原因
                RtnCode:
                  type: integer
                  description: 回應代碼
                RtnMsg:
                  type: string
                  maxLength: 200
                  description: 回應訊息
      responses:
        '200':
          description: Successful response
          content:
            application/json:
              schema:
                type: object
                properties:
                  MerchantID:
                    type: string
                    maxLength: 10
                    description: 特店編號
                  Timestamp:
                    type: number
                    description: 回傳時間
                  TransCode:
                    type: integer
                    description: 回傳代碼
                  TransMsg:
                    type: string
                    maxLength: 200
                    description: 回傳訊息
                  Data:
                    type: string
                    description: 加密資料
        '400':
          description: Invalid request
        '500':
          description: Server error

				
			

Copyright © Green World FinTech Service Co., Ltd. All rights reserved.

綠界官方網站