Skip to main content

Offline API v4

The LINE Pay Offline API is a web API for offline payments processed through a merchant's terminal and all communication occurs over HTTPS. APIs can be called from any environment that supports HTTPS, regardless of the operating system or programming language. Make sure to meet the prerequisites before calling the API.

Endpoint

The following is the API's endpoint format.

https://{host}/{apiPath}?{queryString}
  • host is the hostname of the API server.
    • Sandbox server (for testing): 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 can be 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. Specify the device type as defined by the merchant for identification purposes. Use together with the X-LINE-MerchantDeviceProfileId header.Optional

For information on preparing your API credentials, see Prequisites.

Request body

For specific endpoints, 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 include an HTTP status code 200 OK and delivers the result of the request, which consists 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": "CREDIT_CARD",
"amount": 900
}
]
}
}

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
0000The request is successful.
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.
1133This is an invalid My Code (oneTimeKey).
1141There is a problem with the account status. In case of EPI transaction, the merchant may not have enabled the EPI payment method.
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.
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.
1183Payment amount must exceed the minimum amount set.
1184Payment amount must not exceed the maximum amount set.
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.
1999(On retry) The request information differs from the previous request.
2020Failed to reserve the limit for the payment amount during the pre-authorization stage of the Electronic Payment Institution (EPI) payment process.
2021Exceeded restricted user (Punished ID user, PID user) payment limit during an EPI payment.
2022Exceeded the user's payment limit during an EPI payment.
2023Exceeded an individual user's per-transaction, daily, or monthly limit allowed at a specific merchant.
2024Exceeded the merchant's per-transaction, daily, or monthly limit for receiving payments.
2042Failed to refund for an EPI payment, due to the merchant's insufficient refund reserve.
2101Parameter error occurred.
2102JSON data format error occurred.
2103Unauthorized parameter has been entered.
2104This is an invalid request. Please check the result message.
9000Internal error occurred.