LINE Pay API Reference
Infra and Tech Support
If you need technical support or have questions about internal errors, contact the Technical Support (dl_tech_support_jp@linecorp.com).
Env | URL | Description |
---|---|---|
Sandbox | https://sandbox-api-pay.line.me | Environment for integration testing you can test APIs |
Production | https://api-pay.line.me | Real Service Environment |
Overview
Partner Deposit
LINE Pay provides deposit functions to affiliated stores. With this function, the affiliated store can deposit to the LINE Pay member within the set set limit. LINE Pay members can be specified by the Reference No.
To use APIs, you have to go through the steps to register as a LINE Pay affiliated store
Reference No
It is an identifier that can identify LINE Pay members who are uniquely assigned to each member. LINE Pay members can check their reference no in the app.
Credit Amount
The credit amount is the maximum amount that can be deposited within a period and is managed by the affiliated store unit. And the credit amount is updated every settlement cycle. In order to use the function of partner deposit, the credit amount must be set in advance. If the credit amount setting period is exceeded or the credit amount setting is forcibly terminated for some reason, this function is no longer possible to use.
Each Maximum Amount Limit
There is a maximum amount limit. The LINE Pay affiliated stores can not deposit more than the amount limit even though the credit amount remains.
Partner Deposit APIs
API Authentication
This section describes the authentication for using the LINE Pay API. The "Channel ID" and "Channel SecretKey" information required for authentication can be confirmed through the merchant center site(https://pay.line.me) after the affiliated store registration is completed. The Channel Id and Secret for integration are issued for Sandbox and Production respectively.
Hmac Signature
- Algorithm : HMAC-SHA256
- HMAC-SHA256(Key, Data)
- Key : Channel Secret
- Data (Depends on HTTP Method)
- GET : Channel Secret + URI + Query String + nonce
- POST : Channel Secret + URI + Request Body + nonce
HTTP Method : GET
Signature = Base64(HMAC-SHA256(Your ChannelSecret, (Your ChannelSecret + URL Path + Query String + nonce)))
Query String : The ?
Character is not included. (example : name1=value1&name2=value2...)
HTTP Method : POST
Signature = Base64(HMAC-SHA256(Your ChannelSecret, (Your ChannelSecret + URL Path + RequestBody + nonce)))
Common Http Request Header
The following table shows the Http Header information for API authentication of LINE Pay.
Key | Data Type | Required | Description |
---|---|---|---|
Content-Type | String | Y | application/json |
X-LINE-ChannelId | String | Y | Integration Information - Channel ID |
X-LINE-Authorization-Nonce | String | Y | UUID or Request timestamp |
X-LINE-Authorization | String | Y | HMAC Base64 Signature |
X-LINE-Authorization-Nonce
Do not generate the same signature using a one-time random value nonce. You can prevent an attacker from continuing to send the same request for malicious purposes. For one-time nonce generation you can use UUID 1 or 4 or timestamp.
Nonce Generation
String nonce = UUID.randomUUID().toString();
Sample
HMAC Sample Code
import java.math.BigDecimal;
import java.util.UUID;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.codec.binary.Base64;
import org.apache.commons.codec.digest.HmacUtils;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.core.JsonProcessingException;
public final class HmacSignature {
public void exampleForGet() {
String requestUri = "/v1/partner-deposits/limit";
String ChannelSecret = "a917ab6a2367b536f8e5a6e2977e06f4";
String nonce = UUID.randomUUID().toString();
String signature = makeSignature(ChannelSecret, ChannelSecret + requestUri + nonce);
}
public void exampleForPost() {
DepositForm form = new DepositForm();
form.setOrderId("20190118002934873800");
form.setReferenceNo("11512574225");
form.setAuthCd("1274");
form.setCurrency("JPY");
form.setAmount(new BigDecimal(100));
form.setMemo("reward test");
String requestUri = "/v1/partner-deposits";
String ChannelSecret = "a917ab6a2367b536f8e5a6e2977e06f4";
String nonce = UUID.randomUUID().toString();
String signature = makeSignature(ChannelSecret, ChannelSecret + requestUri + toJson(form) + nonce);
}
private String makeSignature(final String key, final String data) {
return toBase64String(HmacUtils.getHmacSha256(key.getBytes()).doFinal(data.getBytes()));
}
private String toBase64String(byte[] bytes) {
byte[] byteArray = Base64.encodeBase64(bytes);
return new String(byteArray);
}
private String toJson(Object form) {
try {
return (new ObjectMapper()).writeValueAsString(form);
} catch (JsonProcessingException e) {
// TODO: error handling
throw new RuntimeException(e);
}
}
@Getter
@Setter
private class DepositForm {
private String referenceNo;
private BigDecimal amount;
private String currency;
private String orderId;
private String authCd;
private String memo;
}
}
Check Limit API
This is a API that provides limit information. This API allows you to view the currently set deposit and remaining balance.
API Spec
GET /v1/partner-deposits/limit
- Connection Timeout : 5sec
- Read Timeout : 10sec
Response
Response Body
field | data type | length | description |
---|---|---|---|
returnCode | String | 4 | return code |
returnMessage | String | 300 | return message or reason for failure |
info.creditAmount | Number | credit amount | |
info.remainAmount | Number | remaining amount in the credit amount setting period | |
info.eachMaxAmount | Number | amount which can deposit per once |
Return Code
Code | Description |
---|---|
1104 | The store is not one of the affiliated store. |
1105 | The affiliated store cannot use the LINE Pay. |
1106 | A header info error |
9000 | An internal error |
Sample
Request
curl -X GET \
-H "Content-Type: application/json" \
-H "X-LINE-ChannelId: {your channelId}" \
-H "X-LINE-Authorization-Nonce: e51779e1-5788-4884-9c3a-52f7bf8cb0fa" \
-H "X-LINE-Authorization: {Hmac signature}" \
https://sandbox-api-pay.line.me/v1/partner-deposits/limit
Response
{
"returnCode":"0000",
"returnMessage":"success",
"info": {
"creditAmount":1500000,
"remainAmount":74000,
"eachMaxAmount":10000
}
}
Deposit API
This is a API to deposit to balance of the LINE Pay member.
API Spec
POST /v1/partner-deposits
- Connection Timeout : 5sec
- Read Timeout : 10sec
Request Body
field | data type | length | required | description |
---|---|---|---|---|
referenceNo | String | 11 | Y | LINE Pay Member Identifier |
amount | Number | Y | deposit amount | |
currency | String | 3 | Y | currency (ISO-4217) ex) JPY, THB, TWD |
orderId | String | 100 | Y | order id which is unique generated by affiliated store |
authCd | String | 4 | N | Last 4-digits of mobile phone number registered in LINE app. |
Response Body
field | data type | length | description |
---|---|---|---|
returnCode | String | 4 | return code |
returnMessage | String | 300 | return message or reason of failure |
info.transactionId | Number | 19 | transaction id which is unique generated by LINE Pay |
info.transactionDate | String | 20 | transaction date (ISO-8601) which is the time processed by LINE Pay ex) 2019-01-18T23:19:52Z |
Return Codes
Code | Description |
---|---|
1101 | LINE Pay number (or additional verification) is wrong. |
1104 | The store is not one of the affiliated store. |
1105 | The affiliated store cannot use the LINE Pay. |
1106 | A header info error |
1108 | Failed to send balance to target user due to user status, balance limit, and so on. |
1124 | Amount info error (scale) |
1136 | Wrong phonenumber error |
1142 | Insufficient balance remains. |
1170 | Balance of the member's account has been changed. |
1172 | There is a record of transaction with the same order number. |
1178 | The currency is not supported by the store. |
1183 | The amount should be greater than the minimum amount configured in advance. |
1184 | The amount should be less than the maximum amount configured in advance. |
1198 | Processing the request |
1199 | Internal request error |
2101 | A parameter error |
2102 | JSON data format error |
9000 | An internal error |
Sample
Request
curl -X POST \
-H "Content-Type: application/json" \
-H "X-LINE-ChannelId: {your channelId}" \
-H "X-LINE-Authorization-Nonce: e51779e1-5788-4884-9c3a-52f7bf8cb0fa" \
-H "X-LINE-Authorization: {Hmac signature}" \
-d '{ "referenceNo":"11512574225", "amount": 1000, "currency":"JPY", "orderId":"Ord2018123100000001", "authCd":"1266" }' \
https://sandbox-api-pay.line.me/v1/partner-deposits
Response
{
"returnCode":"0000",
"returnMessage":"success",
"info": {
"transactionId":2019011804956338240,
"transactionDate":"2019-01-18T23:19:52Z"
}
}
Merchant balance history API
This API returns a list of transactions that have contributed to the account balance of the partner such as charges and transfers.
The transactions returned are sorted by transaction date in descending order.
* This api only provides charge/tranfer histories for Merchant Balance partners.
API Spec
GET /v1/partner-deposits
- Connection Timeout : 5sec
- Read Timeout : 10sec
Query Parameters
field | data type | length | required | description |
---|---|---|---|---|
transactionType | String | 20 | Y | transaction type condition to search (ALL / TRANSFER / CHARGE) |
orderId | String | 100 | N | order id which is unique generated by affiliated store |
startDate | Date | 10 | N | start date to search (if orderId is null, it's required): YYYY-MM-DD |
endDate | Date | 10 | N | end date to search (if orderId is null, it's required): YYYY-MM-DD |
page | Number | N | start page number of history (default is 1) | |
size | Number | N | number of results per page (default is 10) |
Response Body
field | data type | length | description |
---|---|---|---|
returnCode | String | 4 | return code |
returnMessage | String | 300 | return message or reason of failure |
info[].transactionId | Number | 19 | transaction id which is unique generated by LINE Pay |
info[].orderId | String | 100 | order id which is unique generated by affiliated store (available when transactionType is TRANSFER) |
info[].transactionDate | String | 20 | transaction date (ISO-8601) which is the time processed by LINE Pay ex) 2019-01-18T23:19:52Z |
info[].transactionType | String | 20 | transaction type: TRANSFER (transfer balance from merchant to user) CHARGE (recharge merchant balance through virtual account) |
info[].transactionAmount | Number | transfer or charge amount | |
info[].referenceNo | String | 11 | LINE Pay Member Identifier (available when transactionType is TRANSFER) |
Return Codes
Code | Description |
---|---|
1101 | LINE Pay number (or additional verification) is wrong. |
1104 | The store is not one of the affiliated store. |
1105 | The affiliated store cannot use the LINE Pay. |
1106 | A header info error |
1140 | A user enters wrong/empty arguments. |
2101 | A parameter error |
2102 | JSON data format error |
9000 | An internal error |
Sample
Request
curl -X GET \
-H "Content-Type: application/json" \
-H "X-LINE-ChannelId: {your channelId}" \
-H "X-LINE-Authorization-Nonce: e51779e1-5788-4884-9c3a-52f7bf8cb0fa" \
-H "X-LINE-Authorization: {Hmac signature}" \
https://sandbox-api-pay.line.me/v1/partner-deposits?transactionType=ALL&startDate=2020-06-01&endDate=2020-06-30
Response
{
"returnCode":"0000",
"returnMessage":"success",
"info": [{
"transactionId": 2020060911435878020,
"orderId": "1234567891249",
"transactionDate": "2020-06-09T04:30:18Z",
"transactionType": "TRANSFER",
"transactionAmount": 2,
"referenceNo": "11030001082"
}]
}
Request
curl -X GET \
-H "Content-Type: application/json" \
-H "X-LINE-ChannelId: {your channelId}" \
-H "X-LINE-Authorization-Nonce: e51779e1-5788-4884-9c3a-52f7bf8cb0fa" \
-H "X-LINE-Authorization: {Hmac signature}" \
https://sandbox-api-pay.line.me/v1/partner-deposits?transactionType=ALL&orderId=1234567891249
Response
{
"returnCode":"0000",
"returnMessage":"success",
"info": [{
"transactionId": 2020060911435878020,
"orderId": "1234567891249",
"transactionDate": "2020-06-09T04:30:18Z",
"transactionType": "TRANSFER",
"transactionAmount": 2,
"referenceNo": "11030001082"
}]
}
Appendix
LINE Pay error codes
Defining error codes that may occur in the LINE Pay.
The return messages of the error codes are in English and a hyphen(-) is sent when the message is sent without a message.
Code | Description |
---|---|
1101 | LINE Pay number (or additional verification) is wrong. |
1104 | The store is not one of the affiliated store. |
1105 | The affiliated store cannot use the LINE Pay. |
1106 | A header info error |
1108 | Failed to send balance to target user due to user status, balance limit, and so on. |
1124 | Amount info error (scale) |
1136 | Wrong phonenumber error |
1142 | Insufficient balance remains. |
1140 | A user enters wrong/empty arguments. |
1142 | Insufficient balance remains. |
1170 | Balance of the member's account has been changed. |
1172 | There is a record of transaction with the same order number. |
1178 | The currency is not supported by the store. |
1183 | The amount should be greater than the minimum amount configured in advance. |
1184 | The amount should be less than the maximum amount configured in advance. |
1198 | Processing the request |
1199 | Internal request error |
2101 | A parameter error |
2102 | JSON data format error |
9000 | An internal error |
Sandbox Test Page
LINE Pay affiliated store will be able to see the list of reference numbers assigned to test users on this page and check their LINE Pay balance.
https://sandbox-web-pay.line.me/web/sandbox/deposit/reference-numbers