Skip to main content

Implement without redirection URL

In the basic payment method, when the customer completes LINE Pay authentication, the page the customer sees is redirected to the redirection URL the merchant entered when calling the payment request API. For the merchant, receiving the redirection URL request means that the customer completed LINE Pay authentication and can request payment confirmation.

However, you can configure LINE Pay to not make any calls to the merchant server after LINE Pay authentication without providing redirection URL information when requesting payment. In this case, the customers aren't redirected to a payment confirmation page after LINE Pay authentication, and the merchant server needs to check the payment status with the LINE Pay server to determine if the payment confirmation request is possible. The payment workflow, when implemented without a redirection URL, is as follows.

To implement payment without providing a redirection URL, set the value of the field (options.redirectUrls.confirmUrlType) that determines how to call the redirection URL when calling the payment request API, to "NONE". If you do so, the LINE Pay server doesn't send any HTTP requests to the merchant even if the customer completes LINE Pay authentication. The following is an example of requesting payment without providing a redirection URL.

For information on obtaining the credentials needed to call the Online API, see Prepare API credentials. The code example described on this page uses the requestOnlineAPI() function defined in the Prepare API credentials code example.

try {
// Payment request without redirection URL
let response = await requestOnlineAPI({
method: "POST",
baseUrl: targetAPIServer,
apiPath: "/v3/payments/request",
data: {
amount: 1000,
currency: "TWD",
// ...
redirectUrls: {
// ...
confirmUrlType: "NONE",
},
},
});

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

To complete a payment without providing redirection URL information, the merchant server must request payment confirmation to the LINE Pay server. To determine if you can request payment confirmation without providing a redirection URL, call the API to check payment request status at certain intervals (every one second recommended). This requires the transaction ID (info.transactionId) you received as response to the payment request. The following is the code to check the payment request status.

let intervalId = null;

const getPayRequestStatus = async function (requestTransactionId) {
try {
if (!requestTransactionId) throw new Error("Transaction ID is required!");
let response = await requestOnlineAPI({
method: "GET",
baseUrl: targetAPIServer,
apiPath: `/v3/payments/requests/${requestTransactionId}/check`,
});

switch (response.returnCode) {
case "0000":
console.log("In progress");
break;
case "0110":
console.log("Finished");
// Do something
case "0121":
console.log("Cancelled");
// Do something

// ...

default:
clearInterval(intervalId);
}
} catch (error) {
console.log(error);
}
};

intervalId = setInterval(getPayRequestStatus("2023042201206549310"), 1000);

Depending on the service implementation language, you may need to process the transaction ID as a string when handling transaction ID information. For more information, see the Transaction ID.

If you check the payment request status, the following response will be delivered.

{
"returnCode": "0000",
"returnMessage": "success"
}

Based on the result code (returnCode), you can determine the payment request status. You need to determine the following three statuses.

  • 0000: The customer has not yet completed LINE Pay authentication.
  • 0110: The customer has completed LINE Pay authentication, and you can proceed with payment confirmation.
  • 0121: The customer canceled the payment, or the LINE Pay authentication waiting time expired.