應用場景
特店可使用此API,發送收據開立或作廢的通知。
API介接網址
- 測試環境:https://einvoice-stage.ecpay.com.tw/Receipt/Notify
- 正式環境:https://einvoice.ecpay.com.tw/Receipt/Notify
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無法正常運作。
特店傳入參數範例(Json格式)
{
"MerchantID": "2000132",
"RqHeader": {
"Timestamp": 1525168923
},
"Data": "加密資料"
}
Data參數說明(Json格式) : 請先將Json字串進行urlencode後再進行AES加密
MerchantID String(10)
特店編號 必填
ReceiptNo String(20)
綠界收據編號 必填
Notified String(1)
發送對象 必填
- C:收據持有人
- M:廠商
- A:全部
NotifyTag Int
發送內容類型 必填
- 1:開立
- 2:作廢
NotifyMail String(200)
發送電子郵件
- 可帶入多筆電子郵件,請使用半形 ; 分隔
- 當 Notified = C 或 A 時,此欄位必填
Data參數範例(Json格式)
{
"MerchantID": "2000132",
"ReceiptNo": "Sale2025100900000002",
"NotifyMail": "aa@aa.aa;bb@bb.bb",
"NotifyTag": 1,
"Notified": "C"
}
綠界回傳參數格式
- Content Type :application/json
- HTTP Method :POST
- Crypto-Mode :AES-CBC \ AES-GCM (預設為 AES-CBC)
綠界回傳參數範例
{
"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/64624/
servers:
- url: https://einvoice-stage.ecpay.com.tw
description: Testing Environment
- url: https://einvoice.ecpay.com.tw
description: Production Environment
paths:
/Receipt/Notify:
post:
summary: 收據通知
requestBody:
required: true
content:
application/json:
schema:
type: object
required:
- MerchantID
- Timestamp
- Data
- MerchantID
- ReceiptNo
- Notified
- NotifyTag
properties:
MerchantID:
type: string
maxLength: 10
description: 特店編號
Timestamp:
type: number
description: 傳入時間
Data:
type: string
description: 加密資料
ReceiptNo:
type: string
maxLength: 20
description: 綠界收據編號
Notified:
type: string
maxLength: 1
description: 發送對象
NotifyTag:
type: integer
description: 發送內容類型
NotifyMail:
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