重試交易(悠遊卡)

交易過程發生回應資料中的Retry值是1(含)以上時 (錯誤碼可能為000125或是0462xx), 就必須呼叫重試交易API

此API為必要串接

當交易進行的過程中, 如果有些步驟已經完成, 但還有步驟未完成前就被中斷 (例如扣款過程中卡片在交易進行程序中被取走), 就會導致交易不完整, 導致錯帳或其他問題。

此時, 就必須依照下面指示步驟進行重試交易, 讓交易完成.

交易過程發生回應資料中的Retry值是1(含)以上時 (錯誤碼可能為000125或是0462xx), 就必須呼叫重試交易API, 否則會出現錯帳

重試交易前, 需要先排除原先交易失敗的因素, 例如取走的卡片需要放回讀卡機上.

重試交易需要重試三次,第三次重試(發送Retry = 3)若失敗該筆交易就視為無法完成, 不能再進行重試. 該筆交易需反應給悠遊卡公司.

Request

欄位

必填

型別

範例

說明

Method

YES

String(5)

31800

支付方式, 悠遊卡使用31800

ServiceType

YES

String

Payment

填入發生錯誤的交易的Response的Header.ServiceType中的值

MchId

YES

String

Account0001

填入發生錯誤的交易的Response的Header.MchId

TradeKey

YES

String

sha256...hash

交易密碼

CreateTime

YES

String

20180101120000

建立日期, yyyyMMddHHmmss

Data

欄位

必填

型別

範例

說明

Retry

YES

String

1

填入發生錯誤的交易的Response的Data.Retry中的值 (note: 非Data.request.Retry)

DeviceId

YES

String

01301234

填入發生錯誤的交易的Response的Data.request.DeviceID中的值

Amount

YES

String

50

填入發生錯誤的交易的Response的Data.request.Amount中的值

StoreOrderNo

YES

String

PO12345678

填入發生錯誤的交易的Response的Data.OrderId中的值

TerminalTXNNumber

YES

String

091212

填入發生錯誤的交易的Response的Data.request.TerminalTXNNumber中的值

HostSerialNumber

YES

String

091212

填入發生錯誤的交易的Response的Data.request.HostSerialNumber中的值

RefundKey

(YES)

String

sha256...hash

退款密碼, 當ServiceType為Refund/Cancel/EZCRefund時需帶入此欄位

ActionType

(YES)

String

當ServiceType為Cancel時需要帶入, 由發生錯誤的交易的Response中取得.

Response

Header

欄位

必填

型別

範例

說明

StatusCode

YES

String

0000

交易結果代碼

StatusDesc

YES

String

STATUS_SUCCESS

交易結果代碼說明

Method

YES

String

31800

支付方式, 悠遊卡使用31800

ServiceType

YES

String

Payment

服務代碼, 同Request所傳入的ServiceType

MchId

YES

String

Account0001

特店帳號

ResponseTime

YES

String

20180101120000

交易回應時間, yyyyMMddHHmmss

Data

欄位

必填

型別

範例

說明

request

YES

JSON String

request所傳入的data參數

TXNResult

YES

String

Success

交易結果

Retry

YES

String

0

下次request的Retry參數值

ErrorCode

YES

String

000000

交易結果代碼

OrderId

YES

String

PO12345678

訂單編號

NewAESKey

NO

String

內部交易使用

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\":\"milk\"}"
}

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\":\"milk\",\"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\":\"milk\",\"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"
}
}