Ticketing Operations / Ticket Issuance

Scenario

Scenario 1: Issuing paper, electronic, or convenience store tickets

Before issuing tickets, the merchant must first complete the product listing on the Vendor Management System.After obtaining the product number, the merchant should then connect to the ECPay payment service via API to complete the order payment and issue the ticket using the order number from the merchant system.

Scenario 2: Issuing serial number-only tickets

  • In this scenario, only a serial number is obtained after the ticket issuance is complete, and the consumer does not receive any form of ticket.
  • There’s no need to list the product first; you can directly specify the product name and denomination for ticket issuance.
  • If using ECPay payment services, please first integrate the ECPay payment API to complete the order payment, then issue the ticket using the merchant order number corresponding to the payment order.

❗ Special Note:

  • For paper tickets, issuing them through the “Ticket Issuance API” will execute the issuance immediately upon calling the API.
  • For electronic tickets, convenience store tickets and serial number-only tickets, the “Ticket Issuance API” only receives data, and the issuance process is subsequently handled through a scheduled job. The scheduled job is expected to be completed within 5 minutes.
  • The RtnCode parameter in the API response only represents the result of receiving the issuance data. Please call the “Query Ticket Issuance Results API” again to confirm whether the issuance was successful.

API URLs

  • Stage:https://ecticket-stage.ecpay.com.tw/api/Ticket/Issue
  • Production:https://ecticket.ecpay.com.tw/api/Ticket/Issue

Message format

  • Accept:text/html
  • Content Type:application/json
  • HTTP Method:POST

Request (JSON format)

PlatformID String(10)

Platform ID

  • This is used by platform merchants and will be provided by ECPay.
  • For platform merchants, please populate with [MerchantID].
  • For general merchants, please set as null.

MerchantID String(10)
Required

Merchant ID (provided by ECPay)

RqHeader Object
Required

Request header

Timestamp Number
Required

Please convert the transmission time to a timestamp (GMT+8). ECPay will use this parameter to convert the current time to Unix Timestamp and verify the time interval of this API call.

❗ Special Note

  • ECPay will verify the timestamp.If ECPay receives the request is more 10 minutes late than the timestamp, the transaction will be failed.
  • Merchants are suggested to synchronize the time of a computer on client- or server-side to another server or nearest reference time source.
  • For more details can be seen here; another online tool can be found here.

Data Object
Required

Payload of JSON that has been encrypted.

CheckMacValue String
Required

Checksum

Request Example (JSON format)

				
					{
    "PlatformID": "3002599",
    "MerchantID": "2000132",
    "RqHeader": {
        "Timestamp": 1525168923
    },
    "Data": "…",
    "CheckMacValue": "…"
}

				
			

Message payload of Data (JSON format)

❗ Special Note: Please urlencode the JSON string firstly and then do AES encryption.

MerchantID String(10)
Required

Merchant ID (provided by ECPay)

MerchantTradeNo String(25)

Transaction ID (provided by the merchant).

❗ Special Note

  • If the order includes a pick-up voucher, this field is required; if all the items in the order are gift vouchers, please do not fill in this field.
  • Merchant Transaction IDs are unique and can not be reused.
  • The value of this parameter is a combination of upper and lower case alphanumeric characters.

FreeTradeNo String(20)

Gift Vouchers Transaction ID.

❗ Special Note

  • If all the items in the order are gift vouchers, this field is required; if the order includes a pick-up voucher, please do not fill in this field.
  • Gift Vouchers Transaction IDs are unique and can not be reused.
  • The value of this parameter is a combination of upper and lower case alphanumeric characters.

IssueType String(1)
Required

Ticket issuing type.

  • 1: Convenience store ticket
  • 2: Paper ticket
  • 3: Electronic ticket

PrintType String(1) 

Printing method

  • 1: Print by ECPay
  • 2: Print by merchant

❗ Special Note

  • When IssueType=2 (paper ticket), this field is required.

IsImmediate String(1)

Is it available for immediate use

  • 1: Immediate.It can be used immediately after issuance without setting an effective date [StartDate].
  • 2: Non-immediate.The electronic ticket start date [StartDate] needs to be set, and the earliest start date can be set one day after the issue date. This is commonly used in pre-sale ticket scenarios.

❗ Special Note

  • When [IssueType]=3 (electronic ticket), this field is required.
  • As convenience store tickets and paper tickets can only be issued immediately, when [IssueType]=1 (convenience store ticket) or 2 (paper ticket), this field does not need to be filled in, and the system is fixed to immediate issuance.

RefundNotifyURL String(200)

URL for receiving refund notifications.

When a pickup voucher order is refunded, the ECTicket Server will actively notify the platform merchant or store of the refund-related information via Server POST method.

❗ Special Note

  • This URL domain needs to apply for firewall access with ECPay in advance.
  • If you need to receive refund notifications for pickup vouchers, please fill in this parameter to receive the notifications.

StoreID String(20)

The branch that issued this ticket. When this parameter is provided, the system will validate if the branch exists and is in an active state.

❗ Special Note
  • Please create the branch information in the 【ECPay Vendor’s Management System】 first and then provide us with the branch number. ※How to create branch data? Please refer to the Ticket Issuance Management Platform Operation Manual. 
  • Limited to English letters and numbers only, and full-width characters are not allowed.
  • The length is restricted to 2 to 20 characters.
  • When the field is empty, it indicates that this record is issued by the main branch.

Operator String(10)
Required  

The personnel who executed the issuance of this ticket, this field is only used for historical records.

❗ Special Note

  • The value of this parameter is a combination of upper and lower case alphanumeric characters,and do not use full-width fonts.

CustomerName String(20)

Customer’s name.

❗ Special Note

  • When [IssueType]=3 (electronic ticket), this field is required.
  • When [IssueType]=2 (paper ticket), if paper tickets need to be sent to the customer, this field must be filled in.
  • Please only fill in pure Chinese or pure English, do not mix Chinese and English.
  • When the field contains data, at least two characters must be entered.

CustomerPhone String(10)

Customer’s phone.

❗ Special Note

  • When [IssueType]=3 (electronic ticket), this field is required.
  • Only numeric characters are allowed, and it must start with ’09’.
  • Only domestic mobile phone numbers are accepted.

CustomerEmail String(80)

Customer’s Email address.

❗ Special Note

  • When [IssueType]=1 (convenience store ticket) or [IssueType]=3 (electronic ticket), this field is required.

CustomerAddress String(100)

Customer’s address.

❗ Special Note

  • When [IssueType]=2 (paper ticket), if the merchant needs to send the paper ticket to the consumer, this field must be filled in.

TicketInfo Array[Object]

Ticket Information

ItemNo String(8)
Required

Product Number

❗ Special Note

  • The value of this parameter is a combination of upper and lower case alphanumeric characters.
  • The product number in the order cannot be reused.

TicketAmount Int
Required

The number of tickets issued.

❗ Special Note

  • When [IssueType]=1 (convenience store ticket), the total number of tickets issued per order is limited to a maximum of 8.
  • When [IssueType]=2 (paper ticket) or [IssueType]=3 (electronic ticket), the total number of tickets issued per order is limited to a maximum of 100.

StartDate String(8)

The effective date of the ticket.

Refers to the date from which the ticket can be used.

  • Format: yyyymmdd

❗ Special Note

  • When [IsImmediate]=1 (immediate), this field is fixed as the date of ticket issuance.
  • When [IsImmediate]=2 (non-immediate), this field is required and must be greater than the date of ticket issuance.

ExpireDate String(8)

Expiration date of gift voucher.

  • format: yyyymmdd

❗ Special Note

  • This field is required and must be filled in only when the product is a gift voucher.
  • The date cannot be less than or equal to the ticket start date (StartDate).

Data Example (JSON format)

				
					{
    "MerchantID": "2000132",
    "MerchantTradeNo": "CBX20220302153064851",
    "FreeTradeNo": "",
    "IssueType": "3",
    "PrintType": "",
    "IsImmediate": "1",
    "RefundNotifyURL": "http://ecticket.ecpay.com.tw/RefundNotify",
    "Operator": "AngelaChan",
    "CustomerName": "Wei Shan",
    "CustomerPhone": "0912345678",
    "CustomerEmail": "Wai@ecpay.com.tw",
    "CustomerAddress": "",
    "TicketInfo":[
        {
            "ItemNo":"BR103218",
            "TicketAmount":3,
            "StartDate":"",
            "ExpireDate":""
        },
        {
            "ItemNo":"CK851236",
            "TicketAmount":5,
            "StartDate":"",
            "ExpireDate":""
        }
    ]
}

				
			

Response (JSON format)

PlatformID String(10)

Platform ID

MerchantID String(10)

Merchant ID

RpHeader Object

Response header

Timestamp Number

Unix timestamp

TransCode Int

Response codes to indicate whether the payload is successfully accepted.

  • 1: Payload (i.e. MerchantID, RqHeader, and Data) is successfully accepted by ECPay.
  • Others: failed.

TransMsg String(200)
 

Response message to indicate whether the payload is successfully accepted.

Data String

Payload of JSON that has been encrypted.

CheckMacValue String

Checksum

Response Example (JSON format)

				
					{
    "PlatformID": "3002599",
    "MerchantID": "2000132",
    "RpHeader": {
        "Timestamp": 1525169058
    },
    "TransCode": 1,
    "TransMsg": "",
    "Data": "…",
    "CheckMacValue": "…"  
}

				
			

Message payload of Data (JSON format)

RtnCode Int

Response codes to indicate whether the API is successfully executed or not.

  • 1: API is successfully executed.
  • Others: failed.
  • For more details please see error codes.

❗ Special Note

  • This response code only represents the result of data reception. The ticket issuance process will be scheduled later, and the actual ticket issuance result can be confirmed by calling the [Query Ticket Issuance Results API].

RtnMsg String(200)

Response messages.

MerchantTradeNo String(25)

Transaction ID (provided by the merchant).

FreeTradeNo String(20)

Gift voucher order number

TicketTradeNo String(16)

Transaction ID (provided by ECPay ticket management system).

TicketData Array[Object]

Ticket Information

ItemNo String(8)

Product Number

TicketAmount Int

The number of tickets issued.

TicketData Example (JSON format)

				
					{
    "RtnCode": 1,
    "RtnMsg": "success",
    "MerchantTradeNo":"CBX20220302153064851",
    "FreeTradeNo": "",
    "TicketTradeNo":"2022030215301234",
    "TicketData":[
        {
            "ItemNo":"BR103218",
            "TicketAmount":3
        },
        {
            "ItemNo":"CK851236",
            "TicketAmount":5
        }  
    ]
}

				
			

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

Green World