Application Scenarios
If the API request is successful, a URL will be returned (InvoiceHtml). Place this URL into the address bar of a browser, and the e-invoice will be displayed, which could be printed or to be saved in image or in PDF file.
API URLs:
- Stage: https://einvoice-stage.ecpay.com.tw/B2CInvoice/InvoicePrint
- Production: https://einvoice.ecpay.com.tw/B2CInvoice/InvoicePrint
HTTPS format
- Content Type :application/json
- HTTP Method :POST
Request by Merchant (Json format)
PlatformID String(10)
- This parameter is specifically designed for platform vendors collaborating with ECPay. It can only be utilized after applying for and activating the service.
- If you are a general vendor, please leave the PlatformID empty.
- When using this parameter, the MerchantID must be filled in with the specific store code bound to your PlatformID to prevent operation failures.
- Please note that only the MerchantID of a bound sub-merchant can be used to avoid operational failures. For binding operations, please contact your business representative.
MerchantID String(10)
Required
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 to verify the time interval of this connection.
Special Notes:
- If ECPay receives the API call is more 10 minutes late than the timestamp sent by merchants, this request will be failed. Reference information is as follows:http://www.epochconverter.com/。
- Merchants are suggested to frequently synchronize the time zone of server to another server of the nearest time zone.
Data String
Required
- Message payload
- This is the encrypted data in JSON format.
AES Encryption Description
Example
{
"MerchantID": "2000132",
"RqHeader": {
"Timestamp": 1525168923
},
"Data": "..."
}
Message payload of Data(Json format) : please urlencode the JSON string firstly and then do AES encryption
MerchantID String(10)
Required
InvoiceNo String(10)
Required
- The e-invoice numbers
- The data includes 2 letter track alphabets (i.e. InvoiceHeader) and 8 digits.
InvoiceDate String(20)
Required
- Date of e-invoice created
- Format: yyyy-MM-dd
PrintStyle Int
- The formatting of e-invoice (i.e. how you want the e-invoice to be printed.)
- Values including:
1: single-sided printing (default).
2: double-sided printing.
3: printing with thermal paper.
4: B2B A4 (Only invoives with Tax ID Number can be used)
5: B2B A5 (Only invoives with Tax ID Number can be used)
IsShowingDetail Int
1:Show details
2:Hide details
Special Notes:
- Invoices with TaxNumber will always show the details and will not refer to the setting of this parameter.
- If this parameter is not set, invoices “with TaxNumber” will “show” details by default, and invoices “without TaxNumber” will “not show” details by default
- When [PrintStyle] is B2B A4 or B2B A5, all details will be showed will not refer to the setting of this parameter.
Example
{
"MerchantID": "2000132",
"InvoiceNo": "UV11100016",
"InvoiceDate": "2018-10-28"
}
Response format
- Content Type :application/json
- HTTP Method :POST
Response by ECPay (Json format)
PlatformID String(10)
MerchantID String(10)
Required
Response header
Timestamp Number
Unix timestamp(GMT+8)
TransCode Int
- Response code to indicate whether the payload is successfully accepted
- Possible values:
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
- Message payload
- Responde relevant data, this is the encrypted JSON format data。
AES Encryption Description
Example
{
"MerchantID": "2000132",
"RpHeader": {
"Timestamp": 1525169058
},
"TransCode": 1,
"TransMsg": "",
"Data": "..."
}
Message payload of Data(Json format) : please do AES decryption to the Data firstly and then do urldecode.
RtnCode Int
- Return codes to indicate whether the API is successfully executed or not.
- Possible values:
1: API is successfully executed.
Others: failed.
RtnMsg String(200)
Return messages to indicate whether the API is successfully executed or not.
InvoiceHtml String(500)
The URL is valid for 1 hour from the time of calling this print API
Example
{
"RtnCode": 1,
"RtnMsg": "成功",
"InvoiceHtml": "https://aa.aa.aa"
}