Skip to main content

Online API

The LINE Pay Online API is a web API used for processing online payments, and all communication occurs over HTTPS. You can call APIs from anywhere as long as HTTPS is supported regardless of the operating system or the service implementation language used to develop the service. Prerequisites are required when calling the API.

To enable LINE Pay online payments, you must not only integrate the LINE Pay Online API but also implement redirection pages, which act as the interface between your service and the LINE Pay server.

Endpoint

The following is the API's endpoint format.

https://{host}/{apiPath}?{queryString}
  • host is the hostname of the API server.
    • Sandbox server (for tests): sandbox-api-pay.line.me
    • Production server (for actual service): api-pay.line.me
  • apiPath is the specific path of the API being called. This includes the API version and can be found in the detailed documentation of each endpoint.
  • queryString is a set of query parameters. Each parameter is a key=value pair, separated by &.

You can find the following endpoints.

Request

API requests follow the rules below.

  • All API requests are sent over HTTPS.
  • Parameters are passed via path, query, or as a JSON-formatted request body.

Request header

API requests commonly require the following headers.

Header name (key)Data typeDescriptionRequired
Content-TypeStringSet to application/json.Required
X-LINE-AuthorizationStringCredentials generated by the HMAC SHA256 algorithmRequired
X-LINE-Authorization-NonceStringA randomly generated UUID. Version 1 or 4, or timestamp if requestedRequired
X-LINE-ChannelIdStringChannel IDRequired
X-LINE-MerchantDeviceProfileIdStringDevice profile ID. You can view device-specific statistics in reports provided by LINE Pay. The ID is typically the serial number of the merchant’s terminal and is used as needed. Include this header together with X-LINE-MerchantDeviceType.Optional
X-LINE-MerchantDeviceTypeStringDevice type. Specifies the device type as defined by the merchant for identification purposes. Specify with the X-LINE-MerchantDeviceProfileId header.Optional

For information on preparing your API credentials, see Prepare API credentials.

Request body

Depending on the endpoint, parameters can be delivered in a request body. The request body is in the form of a JSON object.

Below is an example of the request body.

{
"productName": "Brown pen",
"amount": 1000,
"currency": "TWD",
"orderId": "Ord2018123100000001"
}

Response

API responses always return an HTTP status code of 200 OK, along with the result of the request, consisting of a response header and a response body.

Response header

API responses commonly include the following headers.

Header name (key)Data typeDescriptionIncluded
Content-TypeStringapplication/jsonAlways

Response body

The response body is a JSON object that contains detailed request results and includes the following fields.

Field nameData typeDescriptionIncluded
infoObjectAPI request result data. The data is included in the response only when the API call is successful.Conditional
returnCodeStringResult codeAlways
returnMessageStringMessage corresponding to returnCodeAlways

Success response

If the API request is processed successfully, the response body sets returnCode to 0000. If result data is available, it is returned in the info field.

Below is an example of the response body of a successful API request.

{
"returnCode": "0000",
"returnMessage": "OK",
"info": {
"orderId": "MKSI_M_20180904_1000001",
"transactionId": 2018082512345678910,
"payInfo": [
{
"method": "BALANCE",
"amount": 1000
}
]
}
}

Error response

If there is an error in the API request, the server considers the error as a failure and returns a result code corresponding to the cause of the error. The response body of a failed API request delivers error information, and the info field isn't returned in such cases.

Below is an example of the response body of a failed API request.

{
 "resultCode": 1104,
"statusMessage": "Merchant not found."
}

Transaction ID

Transaction is a concept for the actions performed by the LINE Pay server during the payment process. Actions such as payment request, payment confirmation, capture, and refund are all considered transactions. Transaction ID is a 19-digit integer value used to identify these actions. LINE Pay server returns a transaction ID when an action is processed, and you can use the ID to retrieve information about that transaction or request an action for that transaction.

The transaction ID should be processed as a 64-bit long integer. If there are problems with processing the ID as a 64-bit long integer, convert the ID to string. For example, another system that cannot process a 64-bit long integer may process the ID as an integer data type and recognize the ID as 2023010112345678800 even if the LINE Pay server sends 2023010112345678910.

Below is an example of JavaScript code to avoid the said issue. The following is an example of processing values greater than the maximum safe integer (2^53 - 1) in JavaScript as strings after handling LINE Pay API responses as plain text and before parsing them into JSON objects. The code below converts any sequence of 16 or more consecutive digits in the response value into a string.

function handleBigInteger(text) {
const largeNumberRegex = /:\s*(\d{16,})\b/g;
const processedText = text.replace(largeNumberRegex, ': "$1"');

const data = JSON.parse(processedText);

return data;
}

async function requestLINEPayAPI({
method = "GET",
baseUrl = "https://sandbox-api-pay.line.me",
apiPath,
queryString = "",
data = {},
}) {
// ...

const response = await fetch(
`${baseUrl}${apiPath}${queryString !== "" ? "&" + queryString : ""}`,
{
// ...
}
);

const processedResponse = handleBigInteger(await response.text());

return processedResponse;
}

Result code

The result of the API call consists of the result code (returnCode) and the result message (returnMessage) as shown below. See the following table.

If a result code isn't accompanied by a specific message, a hyphen symbol (-) is delivered as a message.

Result codeDescription
0000Returned when the request is successful. If this is the result of a payment request status check, the code indicates that The customer has not yet completed LINE Pay authentication.
0110The customer has completed LINE Pay authentication, and you can proceed with payment confirmation.
0121The customer canceled the payment, or the LINE Pay authentication waiting time expired.
0122Payment failed.
0123Payment completed.
1101The customer isn't a LINE Pay user.
1102The customer is currently unable to make transactions with LINE Pay.
1104The merchant isn't registered on the merchant center. Check if the correct credentials are entered.
1105LINE Pay is currently unavailable for the merchant.
1106There is an error in the request header information.
1110The credit card cannot be used.
1124There is an error in the amount information.
1141There is a problem with the account status.
1142The balance is insufficient.
1145Payment is in progress.
1150There are no transaction details.
1152There is a duplicate transaction.
1153The payment request amount and the capture amount differ.
1154The selected payment method for pre-approved payment isn't available.
1155This is an invalid transaction ID.
1159There is no payment request information.
1163Refund isn't available (refund period has expired).
1164Exceeded the refundable amount.
1165The transaction has already been refunded.
1169LINE Pay requires payment method selection and password authentication.
1170The balance in the member's account has changed.
1172Transaction details with the same order ID already exist.
1177Exceeded the maximum number of transactions that can be retrieved. (100)
1178The currency isn't supported by the merchant.
1179Cannot be processed at the moment.
1180Payment time expired.
1183Payment amount must exceed the minimum amount set.
1184Payment amount must not exceed the maximum amount set.
1190There is no pre-approved payment key.
1193Pre-approved payment key has expired.
1194Pre-approved payment isn't available for this merchant.
1198API request is duplicated.
1199Internal error occurred during the request.
1280Temporary error occurred during credit card payment.
1281Error occurred during credit card payment.
1282Error occurred during credit card authorization.
1283Payment was denied due to suspected fraudulent use.
1284Credit card payment is temporarily suspended.
1285Credit card payment information is missing.
1286Credit card payment information is incorrect.
1287Credit card expiration date has passed.
1288Insufficient balance in the credit card account
1289Exceeded the credit card limit.
1290Exceeded the per-transaction limit for credit card payments.
1291This card is reported stolen.
1292Card usage is suspended.
1293CVN input error occurred.
1294This card is on the blacklist.
1295The credit card number is incorrect.
1296This amount cannot be processed.
1298Card use was declined.
190XTemporary error occurred. Please try again later.
2101Parameter error occurred.
2102JSON data format error occurred.
9000Internal error occurred.