Scenario
This API provides merchants to search order information and allows them to filter valid orders.
- Step 1. Merchant: Transmit the following parameters to the API URLS via Server Site POST.
- Step 2. ECPay : Return order information parameters once received and verified to be correct.
Special Note:
- If you do not receive the payment result notification after 40 minutes from the time of order generation, you can use the API to check the payment result.
- If you are calling the API too fast, you will receive an HTTP Status Code 403, so please slow down the API and wait 30 minutes before calling again.If you need to access the API at a high speed, please contact the service provider.
- For multiple order enquiries, please refer to the Downloading Merchant Balance Statement.
API URLS
- Stage: https://payment-stage.ecpay.com.tw/Cashier/QueryTradeInfo/V5
- Production: https://payment.ecpay.com.tw/Cashier/QueryTradeInfo/V5
HTTPS Transfer Protocol
- Content Type :application/x-www-form-urlencoded
- HTTP Method :POST
Request Parameters Description
MerchantID String(10)
Required
MerchantTradeNo String(20)
Required
Merchant transaction ID.
- Merchant Transaction ID transmitted to ECPay when order was created.
TimeStamp Int
Required
Verification time.
- Convert current time to UnixTimeStamp (see example) to verify the time interval of this interfacing.
- ECPay verification time interval is currently set to be under 3 minutes and interfacing will expire if time is exceeded.
- Reference:http://www.epochconverter.com/。
CheckMacValue String
Required
Checksum.
- Please refer to the Appendix Checksum mechanism.
PlatformID String(10)
Platform merchant ID (Provided by Green World).
Used by contracted platform merchants.
- For general merchants or platform merchant interfacing, please leave empty.
- For use by platform merchants, please set [MerchantID] as the parameter.
Return Parameter Details
MerchantID String(10)
MerchantTradeNo String(20)
Merchant transaction ID.
- Merchant Transaction ID transmitted to ECPay when order was created.
StoreID String(20)
Merchant store ID.
- Allows merchants to enter specific store ID.
- This parameter only allows a combination of upper and lower case alphanumeric characters.
TradeNo String(20)
ECPay transaction ID.
TradeAmt Int
Transaction amount
PaymentDate String(20)
Payment time.
- The format is yyyy/MM/dd HH:mm:ss
PaymentType String(20)
Payment method selected by merchant.
HandlingCharge Number
Total processing fee.
- Only calculated after completion – $0 before calculation.
TradeDate String(20)
Transaction time.
- The format is yyyy/MM/dd HH:mm:ss
TradeStatus String(8)
Transaction status.
Return value:
- If it is 0, the order has been created but payment has not been completed.
- If it is 1, the order has been created and payment is complete.
- If it is 10200095, it means that the order has not been created and the consumer has not completed the payment process, therefore the transaction has failed.
ItemName String(400)
Merchandise name.
CustomField1 String(50)
Merchant notes field
CustomField2 String(50)
Merchant notes field
CustomField3 String(50)
Merchant notes field
CustomField4 String(50)
Merchant notes field
CheckMacValue String
Checksum.
- The merchant must check the checksum [CheckMacValue] to verify. Please refer to the Appendix Checksum Mechanism.
YAML
The provided YAML file is used to define information such as the configuration, structure, operations, and infrastructure management of the API, making it easier for developers to understand and use the API.
openapi: 3.1.0
info:
title: ECPay Order Query API
version: 1.0.0
servers:
- url: https://payment.ecpay.com.tw
description: Production Environment
- url: https://payment-stage.ecpay.com.tw
description: Testing Environment
paths:
/Cashier/QueryTradeInfo/V5:
post:
summary: Query order information
requestBody:
content:
application/x-www-form-urlencoded:
schema:
type: object
properties:
MerchantID:
type: string
description: Merchant ID provided by ECPay
MerchantTradeNo:
type: string
description: Merchant trade number
TimeStamp:
type: integer
description: Unix timestamp of the request
CheckMacValue:
type: string
description: CheckMac value for verification
PlatformID:
type: string
description: Partner platform ID
required:
- MerchantID
- MerchantTradeNo
- TimeStamp
- CheckMacValue
responses:
'200':
description: Successful response
content:
application/json:
schema:
type: object
properties:
MerchantID:
type: string
description: Merchant ID
MerchantTradeNo:
type: string
description: Merchant trade number
StoreID:
type: string
description: Store ID under the merchant
TradeNo:
type: string
description: ECPay trade number
TradeAmt:
type: integer
description: Transaction amount
PaymentDate:
type: string
description: Payment date (yyyy/MM/dd HH:mm:ss)
PaymentType:
type: string
description: Payment type selected by the merchant
HandlingCharge:
type: number
description: Total handling charge
PaymentTypeChargeFee:
type: number
description: Payment type charge fee
TradeDate:
type: string
description: Order creation date (yyyy/MM/dd HH:mm:ss)
TradeStatus:
type: string
description: Transaction status (0: not paid, 1: paid, 10200095: not completed)
ItemName:
type: string
description: Item name
CustomField1:
type: string
description: Custom field 1
CustomField2:
type: string
description: Custom field 2
CustomField3:
type: string
description: Custom field 3
CustomField4:
type: string
description: Custom field 4
CheckMacValue:
type: string
description: CheckMac value