重試交易(悠遊卡)
交易過程發生回應資料中的Retry值是1(含)以上時 (錯誤碼可能為000125或是0462xx), 就必須呼叫重試交易API
當交易進行的過程中, 如果有些步驟已經完成, 但還有步驟未完成前就被中斷 (例如扣款過程中卡片在交易進行程序中被取走), 就會導致交易不完整, 導致錯帳或其他問題。
此時, 就必須依照下面指示步驟進行重試交易, 讓交易完成.
交易過程發生回應資料中的Retry值是1(含)以上時 (錯誤碼可能為000125或是0462xx), 就必須呼叫重試交易API, 否則會出現錯帳
重試交易前, 需要先排除原先交易失敗的因素, 例如取走的卡片需要放回讀卡機上.
重試交易需要重試三次,第三次重試(發送Retry = 3)若失敗該筆交易就視為無法完成, 不能再進行重試. 該筆交易需反應給悠遊卡公司.
Request
填入發生錯誤的交易的Response的Header.ServiceType中的值
填入發生錯誤的交易的Response的Header.MchId
Data
填入發生錯誤的交易的Response的Data.Retry中的值 (note: 非Data.request.Retry)
填入發生錯誤的交易的Response的Data.request.DeviceID中的值
填入發生錯誤的交易的Response的Data.request.Amount中的值
填入發生錯誤的交易的Response的Data.OrderId中的值
填入發生錯誤的交易的Response的Data.request.TerminalTXNNumber中的值
填入發生錯誤的交易的Response的Data.request.HostSerialNumber中的值
退款密碼, 當ServiceType為Refund/Cancel/EZCRefund時需帶入此欄位
當ServiceType為Cancel時需要帶入, 由發生錯誤的交易的Response中取得.
Response
服務代碼, 同Request所傳入的ServiceType
Data
Data中的欄位會依據交易結果與類型而有不同, 請參照各交易(如Payment/Refund)的回應參數表
API Example
發生重試錯誤的交易(扣款交易)
Request
{
"Header": {
"Method": "31800",
"ServiceType": "Payment",
"MchId": "Acoount0001",
"TradeKey": "9af15b336e6a..........65606529a0",
"CreateTime": "20180920152226"
},
"Data": "{\"DeviceId\":\"01304108\",\"Retry\":\"0\",\"Amount\":\"1\",\"StoreOrderNo\":\"PO123456\",\"Body\":\"9af15b336e6a..........65606529a0\"}"
}
Response
{
"Header": {
"StatusCode": "0000",
"StatusDesc": "STATUS_SUCCESS",
"Method": "31800",
"ServiceType": "Payment",
"MchId": "Account0001",
"ResponseTime": "20180920152235"
},
"Data": {
"request": {
"Amount": "1",
"Retry": "0",
"BatchNumber": "18092000",
"SameCard": "0",
"ServiceType": "Payment",
"TerminalID": "08300000",
"DeviceID": "01301234",
"TerminalTXNNumber": "152226",
"HostSerialNumber": "152226",
"Time": "152226",
"Date": "20180920",
"AESKey": "ae83eef21d....f18a2644"
},
"TXNResult": "Fail",
"Retry": "1",
"ErrorCode": "000125",
"OrderId": "PO123456",
"NewAESKey": ""
}
}
第一次重試交易(失敗)
Request
{
"Header": {
"Method": "31800",
"ServiceType": "Payment",
"MchId": "Account0001",
"TradeKey": "9af15b336e6a96199......606529a0",
"CreateTime": "20180920152531"
},
"Data": "{\"DeviceId\":\"01304108\",\"Retry\":\"1\",\"Amount\":\"1\",\"StoreOrderNo\":\"PO123456\",\"RefundKey\":\"9af15b336e6a..........65606529a0\",\"ActionType\":\"\",\"TerminalTXNNumber\":\"152226\",\"HostSerialNumber\":\"152226\"}"
}
Response
{
"Header": {
"StatusCode": "0000",
"StatusDesc": "STATUS_SUCCESS",
"Method": "31800",
"ServiceType": "Payment",
"MchId": "Acoount0001",
"ResponseTime": "20180920152538"
},
"Data": {
"request": {
"Amount": "1",
"Retry": "1",
"BatchNumber": "18092000",
"SameCard": "1",
"ServiceType": "Payment",
"TerminalID": "08300000",
"DeviceID": "01301234",
"TerminalTXNNumber": "152226",
"HostSerialNumber": "152226",
"Time": "152531",
"Date": "20180920",
"AESKey": "ae83eef21d482......18a2644"
},
"TXNResult": "Fail",
"Retry": "2",
"ErrorCode": "000125",
"OrderId": "PO123456",
"NewAESKey": ""
}
}
第二次重試交易(成功)
Request
{
"Header": {
"Method": "31800",
"ServiceType": "Payment",
"MchId": "Account0001",
"TradeKey": "9af15b336e6a96199......5606529a0",
"CreateTime": "20180920152636"
},
"Data": "{\"DeviceId\":\"01301234\",\"Retry\":\"2\",\"Amount\":\"1\",\"StoreOrderNo\":\"PO123456\",\"RefundKey\":\"9af15b336e6a..........65606529a0\",\"ActionType\":\"\",\"TerminalTXNNumber\":\"152226\",\"HostSerialNumber\":\"152226\"}"
}
Response
{
"Header": {
"StatusCode": "0000",
"StatusDesc": "STATUS_SUCCESS",
"Method": "31800",
"ServiceType": "Payment",
"MchId": "Account0001",
"ResponseTime": "20180920152640"
},
"Data": {
"EZCardID": "949104293",
"EZCardType": "00",
"PersonalProfile": "00",
"CardNumberForPrint": "949104293",
"Amount": "1",
"Balance": "1917",
"BeforeTXNBalance": "1918",
"TerminalTXNNumber": "152226",
"HostSerialNumber": "152226",
"Time": "152226",
"Date": "20180920",
"ExpiryDate": "20191230",
"CPUPurseVersion": "00",
"BankCode": "00",
"AreaCode": "01",
"AutoTopUpAmount": "0",
"request": {
"Amount": "1",
"Retry": "2",
"BatchNumber": "18092000",
"SameCard": "1",
"ServiceType": "Payment",
"TerminalID": "08300000",
"DeviceID": "01301234",
"TerminalTXNNumber": "152226",
"HostSerialNumber": "152226",
"Time": "152637",
"Date": "20180920",
"AESKey": "ae83eef....bf18a2644"
},
"TXNResult": "Success",
"Retry": "0",
"ErrorCode": "000000",
"OrderId": "PO123456",
"DongleDeviceID": "0C100DE0A57E",
"RRNumber": "18092015222676",
"TXNType": "Payment",
"NewAESKey": "b9007bf485....9523d9783",
"DeviceNumber": "0830000001301234"
}
}