결제 내역 조회하기
가맹점이 특정 결제 내역를 확인해야 한다면 결제 내역 조회 API를 이용할 수 있습니다. 가맹점에서 발급한 주문 번호나 LINE Pay 서버가 응답으로 전달한 트랙잭션 ID 정보를 이용해 다음과 같이 결제 내역을 요청하세요.
const getPaymentInfo = async function ({ orderId = "", transactionId = "" }) {
let queryString = "";
if (orderId === "" && transactionId === "") {
throw new Error(
"At least one of order ID or transaction ID must be input."
);
} else if (orderId !== "") {
queryString = `orderId=${orderId}`;
} else {
queryString = `transactionId=${transactionId}`;
}
let response = await requestOfflineAPI({
method: "GET",
baseUrl: targetAPIServer,
apiPath: `/v2/payments?${queryString}`,
queryString: queryString,
});
return response;
};
// ...
try {
let response = getPaymentInfo({ orderId: "test_order_1" });
console.log("Response: ", response);
} catch (error) {
console.log(error);
}
트랜잭션 ID 정보를 다룰 때 플랫폼에 따라 트랜잭션 ID를 문자열로 처리해야 할 수도 있습니다. 자세한 설명은 트랜잭션 ID를 참고하세요.
조회한 결제 내역에 따라 응답에 포함되는 정보가 달라질 수 있습니다. 다음은 응답으로 받은 결제 내역 예입니다.
{
"returnCode": "0000",
"returnMessage": "success",
"info": [
{
"transactionId": 2019049910005495123,
"transactionDate": "2019-04-05T11:52:20Z",
"transactionType": "PAYMENT",
"productName": "Test product",
"currency": "TWD",
"payInfo": [
{
"method": "BALANCE",
"amount": 100
}
]
}
]
}
환불한 이력이 있는 결제 내역을 조회했다면 다음과 같이 환불 정보(info.refundList
)가 포함됩니다.
{
"returnCode": "0000",
"returnMessage": "success",
"info": [
{
"transactionId": 2019049910005496810,
"transactionDate": "2019-04-08T06:31:19Z",
"transactionType": "PAYMENT",
"productName": "test product",
"currency": "TWD",
"payInfo": [
{
"method": "BALANCE",
"amount": 100
}
],
"refundList": [
{
"refundTransactionId": 2019049910005497012,
"transactionType": "PARTIAL_REFUND",
"refundAmount": 50,
"refundTransactionDate": "2019-04-08T06:33:17Z"
}
],
"orderId": "20190408001"
}
]
}