收據開立

應用場景

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

API介接網址

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

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)
特店編號 必填

Amount Number
收據金額 必填

  • 當 ReceiptType = 4 且 DonorType = 5 時,收據金額不可大於一萬
  • 當 ReceiptType = 4 & PaymentMethod = 3,Amount 不可大於10萬
  • 收據金額需與商品明細金額的加總相同,金額可為0

Name String(60)
收據抬頭 必填

ReceiptType Int
收據類型 必填

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

❗ 注意事項:若有公益政治收據開立需求,請聯繫綠界業務團隊申請開通權限,我們將由專人為您辦理相關程序。

DonorType Int
持有人身份 

當 ReceiptType = 2 、 4 時,此欄位必填

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

❗ 注意事項

  • 當 ReceiptType = 2 時,DonorType 不可帶入3、4、5
  • 當 ReceiptType = 1 時,系統將忽略此欄位之值

RetrievalMethod Int
索取方式 必填

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

ReceiptDate String(20)
開立收據日期 必填

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

RelateNumber String(64)
自訂編號 必填

需為唯一值不可重複使用

❗ 注意事項

  • 請勿使用特殊符號
  • 大小寫英文視為相同 (e.g. 123abc456=123ABC456)

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

  • 當 ReceiptType = 2 時,此欄位必填
  • 當 ReceiptType = 4 & Amount > 30000 & DonorType = 1、2、3、4 時,此欄位必填

❗ 注意事項

  • DonorType = 1,帶入證號
  • DonorType=2,帶入統編
  • DonorType = 3,帶入人民團體登記字號
  • DonorType= 4,帶入政黨登記字號

Email String(200)
電子郵件

當 RetrievalMethod = 2 時,此欄位必填

Phone String(15)
連絡電話

當 ReceiptType = 2 & DonorType = 2 時,此欄位必填

CellPhone String(10)
手機號碼

當 ReceiptType = 2 & DonorType = 1 時,此欄位必填

CompanyAddress String(200)
營業登記地址

DeliveryAddress String(200)
收據寄送地址

當 RetrievalMethod = 1時,此欄位必填

Note String(200)
收據備註

Items Array<Object>
商品明細

  • 當 ReceiptType = 2 時,僅可帶入一項商品
  • 當 ReceiptType = 1、2 時,此欄位必填

ItemSeq Int
明細排列序號 

請帶入1~999整數數字

ItemName String(100)
商品名稱 

ItemCount Int
商品數量 

ItemPrice Number
單價 

可帶入0

ItemAmount Number
單項商品合計金額 

ItemAmount = ItemCount * ItemPrice

PaymentMethod Int
收受款別 

當 ReceiptType = 4 & PaymentMethod = 3,Amount 不可大於10萬

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

❗ 注意事項:當 ReceiptType = 1 、 2 時,系統將忽略此欄位之值,收受款別皆為匯款

CheckInfo Object
票據資料

當 ReceiptType = 4 & PaymentMethod = 2,此欄位必填

CheckNumber String(20)
票據號碼 

Drawer String(50)
發票人 

IssueDate String(20)
發票日 

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

DonationInfo Object
捐贈資料

當 ReceiptType = 4,此欄位必填

❗ 注意事項:當 ReceiptType = 1 、 2 時,系統將忽略此欄位之值

IsBequest Int
是否遺囑捐贈 

預設為0

  • 0: 否
  • 1: 是

DonationDate String(20)
捐贈日 

當 ReceiptType = 4,此欄位必填

DepositDate String(20)
存入專戶日期 

  • 自定義日期:若自行帶入此欄位,系統將以帶入的資料為準
  • 系統自動補齊:若此欄位不帶入,系統另提供 DepositTradeNo 參數
    • 系統將透過後台定期排程進行比對
    • 待該筆訂單款項實際入帳後,系統會自動更新並補上正確的「存入專戶日期」。

❗ 注意事項

  • 若 DepositDate 與 DepositTradeNo 皆未帶入,則該筆資料將不會紀錄存入日期,亦不會觸發自動補齊機制。
  • 請自行至綠界廠商後台,或透過收據修改 API 補齊存入專戶日期資料
  • 缺少存入專戶日期資料,可能會導致無法上傳至監察院系統進行申報

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

  • 傳入時:請帶入「綠界交易編號 (TradeNo)」。系統將透過定期排程,於訂單款項實際入帳後,自動補上該筆訂單之「存入專戶日期」。

  • 不傳入時: 若欲自行指定存入日期,或該訂單非透過綠界金流收款,請將此欄位保持空白(或不傳入),切勿填寫非綠界之訂單編號。

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

  • 若 DepositTradeNo 有帶入「綠界交易編號 ( TradeNo )」,此欄位將透過定期排程,於訂單款項實際入帳後,固定帶入「永豐商業銀行
  • 如自行帶入,會以自行帶入的為主。

❗ 注意事項:當 ReceiptType = 1 、 2 時,系統將忽略此欄位之值

Data參數範例(Json格式)

				
					{
    "MerchantID": "2000132",
    "Amount": 100,
    "Name": "綠界科技",
    "ReceiptType": 1,
    "DonorType": 3,
    "RetrievalMethod": 1,
    "ReceiptDate": "2025/10/07 00:00:00",
    "RelateNumber": "20251007000000001",
	"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": ""
}
				
			

綠界回傳參數格式

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

ReceiptNo String(20)
綠界收據編號

Data參數範例

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


				
			

YAML

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

				
					openapi: 3.1.0
info:
  title: 收據開立
  version: 1.0.0
  x-source-url: https://developers.ecpay.com.tw/64254/
servers:
- url: https://einvoice-stage.ecpay.com.tw
  description: Testing Environment
- url: https://einvoice.ecpay.com.tw
  description: Production Environment
paths:
  /Receipt/Issue:
    post:
      summary: 收據開立
      requestBody:
        required: true
        content:
          application/json:
            schema:
              type: object
              required:
              - MerchantID
              - Timestamp
              - Data
              - MerchantID
              - Amount
              - Name
              - ReceiptType
              - RetrievalMethod
              - ReceiptDate
              - RelateNumber
              properties:
                MerchantID:
                  type: string
                  maxLength: 10
                  description: 特店編號
                Timestamp:
                  type: number
                  description: 傳入時間
                Data:
                  type: string
                  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: 開立收據日期
                RelateNumber:
                  type: string
                  maxLength: 64
                  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: 付款/匯款金融機構
                RtnCode:
                  type: integer
                  description: 回應代碼
                RtnMsg:
                  type: string
                  maxLength: 200
                  description: 回應訊息
                ReceiptNo:
                  type: string
                  maxLength: 20
                  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.

綠界官方網站