查詢單筆收據

應用場景

特店可使用此API,查詢單筆收據明細資料

API介接網址

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

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)
綠界收據編號

需與 RelateNumber 擇一必填

RelateNumber String(64)
自訂編號

需與 ReceiptNo 擇一必填

Data參數範例(Json格式)

				
					{
    "MerchantID": "2000132",
    "ReceiptNo": "Sale2025100900000002",
	"RelateNumber": "A12345678979"
}
				
			

綠界回傳參數格式

  • 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)
回應訊息

MerchantID String(10)
特店編號

Amount Number
收據金額 

Name String(60)
收據抬頭 

ReceiptType Int
收據類型

  • 1:一般 
  • 2:公益 
  • 4:政治捐獻

DonorType Int
持有人身份 

  • 1:自然人
  • 2:公司/法人
  • 3:人民團體
  • 4:政黨
  • 5:匿名

RetrievalMethod Int
索取方式

  • 1:紙本
  • 2:電子
  • 3:自行處理

ReceiptDate String(20)
開立收據日期

格式為「yyyy-MM-dd HH:mm:ss」或「 yyyy/MM/dd HH:mm:ss」

RelateNumber String(64)
自訂編號

ReceiptNo String(20)
收據號碼

InvalidStatus Int
作廢狀態

  • 0:否
  • 1:是

InvalidDate String(20)
作廢日期

格式為「yyyy-MM-dd HH:mm:ss」或「 yyyy/MM/dd HH:mm:ss」

Identifier String(50)
收據持有人證號/統一編號/人民團體/政黨登記字號

Email String(200)
電子郵件

Phone String(15)
連絡電話

CellPhone String(10)
手機號碼

CompanyAddress String(200)
營業登記地址

DeliveryAddress String(200)
收據寄送地址

Note String(200)
收據備註

Items Array<Object>
商品明細

ItemSeq Int
明細排列序號 

ItemName String(100)
商品名稱 

ItemCount Int
商品數量 

ItemPrice Number
單價 

ItemAmount Number
單項商品合計金額 

PaymentMethod Int
收受款別 

  • 1: 匯款
  • 2: 票據
  • 3: 現金

CheckInfo Object
票據資料

CheckNumber String(20)
票據號碼 

Drawer String(50)
發票人 

IssueDate String(20)
發票日 

格式為「yyyy-MM-dd」或「 yyyy/MM/dd」

DonationInfo Object
捐贈資料

IsBequest Int
是否遺囑捐贈 

  • 0: 否
  • 1: 是

DonationDate String(20)
捐贈日 

DepositDate String(20)
存入專戶日期 

格式為「yyyy-MM-dd」或「 yyyy/MM/dd」

DepositTradeNo String(20)
存入專戶訂單編號

RemittingBank String(100)
付款/匯款金融機構

Data參數範例(Json格式)

				
					{
    "RtnCode": 1,
    "RtnMsg": "Success",
    "MerchantID": "2000132",
    "Amount": 100,
    "Name": "綠界科技",
    "ReceiptType": 1,
    "DonorType": 3,
    "RetrievalMethod": 1,
    "ReceiptDate": "2025/10/07 00:00:00",
    "RelateNumber": "20251007000000001",
    "ReceiptNo": "Sale2026040800000448",
    "InvalidStatus": 0,
    "InvalidDate": "",
	"Identifier": "97025978",
	"Email": "aa@aa.aa",
	"Phone": "26550557",
	"CellPhone": "",
	"CompanyAddress": "115台北市南港區成功路一段58號3樓",
	"DeliveryAddress": "115台北市南港區成功路一段58號3樓",
	"Notes": "test",
	"Items": [
		{
			"ItemSeq": 1,
			"ItemName": "item01",
			"ItemCount": 2,
			"ItemPrice": 50,
			"ItemAmount": 100
		}
	],
	 "PaymentMethod": 1,
	 "CheckInfo": {
		 "CheckNumber": "123456789",
		 "Drawer": "test",
		 "IssueDate": "2026/03/04"
	},
	 "DonationInfo": {
		 "IsBequest": 0,
		 "DonationDate": "2026/03/04",
		 "DepositDate": "2026/03/04"
	},
	 "DepositTradeNo": "",
	 "RemittingBank": ""
}
				
			

YAML

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

				
					openapi: 3.1.0
info:
  title: 查詢單筆收據
  version: 1.0.0
  x-source-url: https://developers.ecpay.com.tw/64544/
servers:
- url: https://einvoice-stage.ecpay.com.tw
  description: Testing Environment
- url: https://einvoice.ecpay.com.tw
  description: Production Environment
paths:
  /Receipt/GetReceipt:
    post:
      summary: 查詢單筆收據
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - MerchantID
              - Timestamp
              - Data
              - MerchantID
              properties:
                MerchantID:
                  type: string
                  maxLength: 10
                  description: 特店編號
                Timestamp:
                  type: number
                  description: 傳入時間
                Data:
                  type: string
                  description: 加密資料
                ReceiptNo:
                  type: string
                  maxLength: 20
                  description: 收據號碼
                RelateNumber:
                  type: string
                  maxLength: 64
                  description: 自訂編號
                RtnCode:
                  type: integer
                  description: 回應代碼
                RtnMsg:
                  type: string
                  maxLength: 200
                  description: 回應訊息
                Amount:
                  type: number
                  description: 收據金額
                Name:
                  type: string
                  maxLength: 60
                  description: 收據抬頭
                ReceiptType:
                  type: integer
                  description: 收據類型
                DonorType:
                  type: integer
                  description: 持有人身份
                RetrievalMethod:
                  type: integer
                  description: 索取方式
                ReceiptDate:
                  type: string
                  maxLength: 20
                  description: 開立收據日期
                InvalidStatus:
                  type: integer
                  description: 作廢狀態
                InvalidDate:
                  type: string
                  maxLength: 20
                  description: 作廢日期
                Identifier:
                  type: string
                  maxLength: 50
                  description: 收據持有人證號/統一編號/人民團體/政黨登記字號
                Email:
                  type: string
                  maxLength: 200
                  description: 電子郵件
                Phone:
                  type: string
                  maxLength: 15
                  description: 連絡電話
                CellPhone:
                  type: string
                  maxLength: 10
                  description: 手機號碼
                CompanyAddress:
                  type: string
                  maxLength: 200
                  description: 營業登記地址
                DeliveryAddress:
                  type: string
                  maxLength: 200
                  description: 收據寄送地址
                Note:
                  type: string
                  maxLength: 200
                  description: 收據備註
                ItemSeq:
                  type: integer
                  description: 明細排列序號
                ItemName:
                  type: string
                  maxLength: 100
                  description: 商品名稱
                ItemCount:
                  type: integer
                  description: 商品數量
                ItemPrice:
                  type: number
                  description: 單價
                ItemAmount:
                  type: number
                  description: 單項商品合計金額
                PaymentMethod:
                  type: integer
                  description: 收受款別
                CheckInfo:
                  type: object
                  description: 票據資料
                CheckNumber:
                  type: string
                  maxLength: 20
                  description: 票據號碼
                Drawer:
                  type: string
                  maxLength: 50
                  description: 發票人
                IssueDate:
                  type: string
                  maxLength: 20
                  description: 發票日
                DonationInfo:
                  type: object
                  description: 捐贈資料
                IsBequest:
                  type: integer
                  description: 是否遺囑捐贈
                DonationDate:
                  type: string
                  maxLength: 20
                  description: 捐贈日
                DepositDate:
                  type: string
                  maxLength: 20
                  description: 存入專戶日期
                DepositTradeNo:
                  type: string
                  maxLength: 20
                  description: 存入專戶訂單編號
                RemittingBank:
                  type: string
                  maxLength: 100
                  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.

綠界官方網站