跳轉至主體

查詢付款明細

如果合作商店需要查詢指定付款明細或退款明細,或者商家需要查詢特定的支付明細,可以使用付款明細檢索API。使用合作商店提供的訂單號碼或LINE Pay伺服器回應發送的交易ID (transaction ID)訊息,請求付款明細如下。

呼叫Online API時,取得必要credentials的方法請參考準備API credentials。本頁所述的程式碼範例使用準備API credentials程式碼範例中定義的requestOnlineAPI()函數。

const getPaymentInfo = async function ({ orderIds = [], transactionIds = [] }) {
if (orderIds.length === 0 && transactionIds.length === 0) {
throw new Error(
"At least one of order ID or transaction ID must be input."
);
} else {
const orderIdsQuery = new URLSearchParams(
orderIds.map((value) => ["orderId", value])
);
const transactionIdsQuery = new URLSearchParams(
transactionIds.map((value) => ["transactionId", value])
);

let response = await requestOnlineAPI({
method: "GET",
baseUrl: targetAPIServer,
apiPath: `/v3/payments/${requestTransactionId}/confirm`,
queryString: `${orderIdsQuery.toString()}&${transactionIdsQuery.toString()}`,
});

return response;
}
};

// ...

try {
let response = getPaymentInfo({
orerIds: ["20230601ORD45678910", "20230601ORD45678911"],
});

console.log("Response: ", response);
} catch (error) {
console.log(error);
}

可以透過新增1個或多個相同的查詢參數來設定1個以上訂單號碼交易ID (transaction ID),每次最多可以查看100條API付款明細。

處理交易ID訊息時,根據平台,可能需要將交易ID視為字串。詳細說明請參考交易ID (transaction ID)

根據查詢的付款明細,回應中包含的訊息可能會有所不同。以下是收到的回應付款明細範例。

{
"returnCode": "0000",
"returnMessage": "success",
"info": [
{
"transactionId": 2019060112345678910,
"transactionDate": "2019-06-01T09:00:00Z",
"transactionType": "PAYMENT",
"payInfo": [
{ "method": "BALANCE", "amount": 110 }
],
"productName": "test production",
"currency": "TWD",
"orderId": "20190601ORD45678910",
// ...
"packages": [
{
"id": "1",
"amount": 85,
"userFeeAmount": 0
},
{
"id": "3",
"amount": 5,
"userFeeAmount": 0
}
]
// ...
}
]
}

如果查詢了具有退款歷史記錄的付款明細,則可能包括退款訊息(info.refundList)如下所示。

{
"returnCode": "0000",
"returnMessage": "success",
"info": [
{
// ...
"refundList": [
{
"refundTransactionId": 2019060112345678911,
"transactionType": "PARTIAL_REFUND",
"refundAmount": -1,
"refundTransactionDate": "2019-06-06T09:00:00Z"
}
// ...
]
// ...
}
]
}

退款後收到的回應或透過上述付款明細識別的退款交易ID(info.refundList.refundTransactionId)來查詢付款明細,即可查看如下詳細退款明細。

{
"returnCode": "0000",
"returnMessage": "success",
"info": [
{
"transactionId": 2019060112345678912,
"transactionDate": "2019-06-01T09:48:43Z",
"transactionType": "PARTIAL_REFUND",
"payInfo": [
{
"method": "CREDIT_CARD",
"amount": 85
},
{
"method": "POINT",
"amount": 8
}
],
"productName": "Brown",
"currency": "TWD",
"orderId": "20190101123123123",
"originalTransactionId": 2019060112345678910
}
]
}