PHPackages                             victorzhn/line-pay-sdk - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. victorzhn/line-pay-sdk

ActiveLibrary[API Development](/categories/api)

victorzhn/line-pay-sdk
======================

LINE Pay SDK for PHP 7.0+ and guzzle7.3

4.0.1(5y ago)11.1kMITPHPPHP &gt;=7.0

Since Jun 19Pushed 5y agoCompare

[ Source](https://github.com/victorzhn/line-pay-sdk-php)[ Packagist](https://packagist.org/packages/victorzhn/line-pay-sdk)[ Docs](https://github.com/victorzhn/line-pay-sdk-php)[ RSS](/packages/victorzhn-line-pay-sdk/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (2)Dependencies (1)Versions (20)Used By (0)

 [ ![](https://camo.githubusercontent.com/f52fab8893ea6283685672f65d682339c2429078c426f2569382da0f110e8530/68747470733a2f2f7363646e2e6c696e652d617070732e636f6d2f6c696e657061792f706f7274616c2f6173736574732f696d672f706f7274616c2f6a702f6c6f676f2e737667) ](https://pay.line.me/)

LINE Pay SDK *for* PHP
======================

[](#line-pay-sdk-for-php)

LINE Pay SDK for PHP

[![Latest Stable Version](https://camo.githubusercontent.com/3fcfe0b5e20bc831df72ecd87394b62e4d16915743f9948145cb4a636f492e8b/68747470733a2f2f706f7365722e707567782e6f72672f766963746f727a686e2f6c696e652d7061792d73646b2f762f737461626c653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/victorzhn/line-pay-sdk)[![License](https://camo.githubusercontent.com/2168927d4caf978e4b4126b200c5548da93d3ef288af93f835ef114131f7abbe/68747470733a2f2f706f7365722e707567782e6f72672f766963746f727a686e2f6c696e652d7061792d73646b2f6c6963656e73653f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/victorzhn/line-pay-sdk)

English | [繁體中文](https://github.com/victorzhn/line-pay-sdk-php/blob/v3/README-zh_TW.md)

SDK VersionOnline API VersionOffline API Versionv3 (Current)[v3](https://pay.line.me/tw/developers/apis/onlineApis?locale=en_US)[v2](https://pay.line.me/tw/developers/apis/documentOffline?locale=en_US)[v2](https://github.com/victorzhn/line-pay-sdk-php/tree/v2)[v2](https://pay.line.me/documents/online_v2_en.html)[v2](https://pay.line.me/tw/developers/apis/documentOffline?locale=en_US)OUTLINE
-------

[](#outline)

- [Demonstration](#demonstration)
- [Requirements](#requirements)
    - [Authentication](#authentication)
- [Installation](#installation)
- [Usage](#usage)
    - [Client](#client)
        - [Device Information](#device-information)
    - [Response](#response)
        - [Retrieving Data](#retrieving-data)
            - [Retrieving as Object](#retrieving-as-object)
            - [Retrieving as Array](#retrieving-as-array)
        - [Methods](#methods)
            - [isSuccessful()](#issuccessful)
            - [getPaymentUrl()](#getpaymenturl)
            - [getPayInfo()](#getpayinfo)
            - [toArray()](#toarray)
            - [toObject()](#toobject)
            - [getStats()](#getstats)
    - [Online APIs](#online-apis)
        - [Payment Details API](#payment-details-api)
        - [Request API](#request-api)
        - [Confirm API](#confirm-api)
        - [Refund API](#refund-api)
        - [Check Payment Status API](#check-payment-status-api)
        - [Capture API](#capture-api)
        - [Void API](#void-api)
        - [Pay Preapproved API](#pay-preapproved-api)
        - [Check RegKey API](#check-regkey-api)
        - [Expire RegKey API](#expire-regkey-api)
    - [Offline APIs](#offline-apis)
        - [Payment](#payment)
        - [Payment Status Check](#payment-status-check)
        - [Void](#void)
        - [Capture](#capture)
        - [Refund](#refund)
        - [Authorization Details](#authorization-details)
    - [Exceptions](#exceptions)
        - [ConnectException](#connectException)
- [Resources](#resources)
- [References](#references)

---

DEMONSTRATION
-------------

[](#demonstration)

[Sample Codes Site for LINE Pay (Request, Confirm, Refund)](https://github.com/victorzhn/line-pay-sdk-php/tree/v3/sample)

```
// Create LINE Pay client
$linePay = new \victorzhn\linePay\Client([
    'channelId' => 'Your merchant X-LINE-ChannelId',
    'channelSecret' => 'Your merchant X-LINE-ChannelSecret',
    'isSandbox' => true,
]);

// Online Request API
$response = $linePay->request([
    'amount' => 250,
    'currency' => 'TWD',
    'orderId' => 'Your order ID',
    'packages' => [
        [
            'id' => 'Your package ID',
            'amount' => 250,
            'name' => 'Your package name',
            'products' => [
                [
                    'name' => 'Your product name',
                    'quantity' => 1,
                    'price' => 250,
                    'imageUrl' => 'https://yourname.com/assets/img/product.png',
                ],
            ],
        ],
    ],
    'redirectUrls' => [
        'confirmUrl' => 'https://yourname.com/line-pay/confirm',
        'cancelUrl' => 'https://yourname.com/line-pay/cancel',
    ],
]);

// Check Request API result (returnCode "0000" check method)
if (!$response->isSuccessful()) {
    throw new Exception("ErrorCode {$response['returnCode']}: {$response['returnMessage']}");
}

// Redirect to LINE Pay payment URL
header('Location: '. $response->getPaymentUrl() );
```

> [LINE Pay API Tool for testing and loging APIs](https://github.com/victorzhn/line-pay-sdk-php/tree/v3/tool)

---

REQUIREMENTS
------------

[](#requirements)

This library requires the following:

- PHP 5.4.0+|7.0+
- guzzlehttp/guzzle 5.3.1+|6.0+
- [LINE Pay merchant authentication](#authentication)

### Authentication

[](#authentication)

Each LINE Pay merchant Requires authentication information for LINE Pay integration, as shown below:

- channel ID
- channel Secret

To get an LINE Pay Authentication:

1. Merchant's verification information can be viewed at [LINE Pay Merchant Center](http://pay.line.me) after evaluation process is complete.
2. Login into [LINE Pay Merchant Center](http://pay.line.me), then **get the ChannelId/ChannelSecret** (Payment Integration Management &gt; Manage Link Key).
3. In [LINE Pay Merchant Center](http://pay.line.me), **set IP white list** for your servers (Payment Integration Management &gt; Manage Payment Server IP) *(v3 is not required)*.

> You can immediately create a sandbox merchant account for test through [LINE Pay Sandbox Creation](https://pay.line.me/tw/developers/techsupport/sandbox/creation?locale=en_US).

---

INSTALLATION
------------

[](#installation)

Run Composer in your project:

```
composer require victorzhn/line-pay-sdk ~3.0.0

```

Then you could use SDK class after Composer is loaded on your PHP project:

```
require __DIR__ . '/vendor/autoload.php';

use victorzhn\linePay\Client;
```

---

USAGE
-----

[](#usage)

Before using any API methods, first you need to create a Client with configuration, then use the client to access LINE Pay API methods.

### Client

[](#client)

Create a LINE Pay Client with [API Authentication](#authentication):

```
$linePay = new \victorzhn\linePay\Client([
    'channelId' => 'Your merchant X-LINE-ChannelId',
    'channelSecret' => 'Your merchant X-LINE-ChannelSecret',
    'isSandbox' => true,
]);
```

#### Device Information

[](#device-information)

You could set device information for Client (Optional):

```
$linePay = new \victorzhn\linePay\Client([
    'channelId' => 'Your merchant X-LINE-ChannelId',
    'channelSecret' => 'Your merchant X-LINE-ChannelSecret',
    'isSandbox' => true,
    'merchantDeviceType' => 'Device type string',
    'merchantDeviceProfileId' => 'Device profile ID string',
]);
```

### Response

[](#response)

Each API methods will return `victorzhn\linePay\Response` object, which can retrieve data referred to LINE Pay JSON response data structure.

#### Retrieving Data

[](#retrieving-data)

Response object provides response body data accessing by object attributes or array keys:

##### Retrieving as Object

[](#retrieving-as-object)

```
// Get LINE Pay results code from response
$returnCode = $response->returnCode;
// Get LINE Pay info.payInfo[] from response
$payinfo = $response->info->payinfo;
```

##### Retrieving as Array

[](#retrieving-as-array)

```
// Get LINE Pay results code from response
$returnCode = $response['returnCode'];
// Get LINE Pay info.payInfo[] from response
$payinfo = $response['info']['payinfo'];
```

#### Methods

[](#methods)

Response object has some helpful methods to use:

##### isSuccessful()

[](#issuccessful)

LINE Pay API result successful status (Check that returnCode is "0000")

*Example:*

```
if (!$response->isSuccessful()) {

    throw new Exception("Code {$response['returnCode']}: {$response['returnMessage']}");
}
```

##### getPaymentUrl()

[](#getpaymenturl)

Get LINE Pay API response body's info.paymentUrl (Default type is "web")

##### getPayInfo()

[](#getpayinfo)

Get LINE Pay API response body's info.payInfo\[\] or info.\[$param1\].payInfo\[\] as array

##### toArray()

[](#toarray)

Get LINE Pay response body as array

##### toObject()

[](#toobject)

Get LINE Pay response body as object

##### getStats()

[](#getstats)

Get `\GuzzleHttp\TransferStats` object

### Online APIs

[](#online-apis)

For Web integration. Merchant will requests a payment and generates payment URL(QR code) to customer to scan by LINE App.

> Flow: [`Request`](#request-api) -&gt; [`Confirm`](#confirm-api) -&gt; [`Details`](#payment-details-api) -&gt; [`Refund`](#refund-api)

[![PC flow](https://camo.githubusercontent.com/aa62eeb42ada6544d4861d9f7198f75876ba090c8d8485809f98f59162a0aaf5/68747470733a2f2f7061792e6c696e652e6d652f646f63756d656e74732f696d616765732f70635f7061796d656e745f726573657276655f636f6d706c6574652d36636634303061362e706e67)](https://camo.githubusercontent.com/aa62eeb42ada6544d4861d9f7198f75876ba090c8d8485809f98f59162a0aaf5/68747470733a2f2f7061792e6c696e652e6d652f646f63756d656e74732f696d616765732f70635f7061796d656e745f726573657276655f636f6d706c6574652d36636634303061362e706e67)[![Mobile flow](https://camo.githubusercontent.com/9bb95fae9be8ad1546f06da9ce21660b4c6bbe1e4c6615bbd19d313a925c7bdf/68747470733a2f2f7061792e6c696e652e6d652f646f63756d656e74732f696d616765732f6d6f62696c655f7061796d656e745f726573657276655f636f6d706c6574652d61376437306538382e706e67)](https://camo.githubusercontent.com/9bb95fae9be8ad1546f06da9ce21660b4c6bbe1e4c6615bbd19d313a925c7bdf/68747470733a2f2f7061792e6c696e652e6d652f646f63756d656e74732f696d616765732f6d6f62696c655f7061796d656e745f726573657276655f636f6d706c6574652d61376437306538382e706e67)

#### Payment Details API

[](#payment-details-api)

Gets the details of payments made with LINE Pay. This API only gets the payments that have been captured.

```
public Response details(array $queryParams=null)
```

*Example:*

```
$response = $linePay->details([
    "transactionId" => [$transactionId],
]);
```

#### Request API

[](#request-api)

Prior to processing payments with LINE Pay, the Merchant is evaluated if it is a normal Merchant store then the information is requested for payment. When a payment is successfully requested, the Merchant gets a "transactionId" that is a key value used until the payment is completed or refunded.

```
public Response request(array $bodyParams=null)
```

*Example:*

```
$response = $linePay->request([
    'amount' => 250,
    'currency' => 'TWD',
    'orderId' => 'Your order ID',
    'packages' => [
        [
            'id' => 'Your package ID',
            'amount' => 250,
            'name' => 'Your package name',
            'products' => [
                [
                    'name' => 'Your product name',
                    'quantity' => 1,
                    'price' => 250,
                    'imageUrl' => 'https://yourname.com/assets/img/product.png',
                ],
            ],
        ],
    ],
    'redirectUrls' => [
        'confirmUrl' => 'https://yourname.com/line-pay/confirm',
        'cancelUrl' => 'https://yourname.com/line-pay/cancel',
    ],
]);
```

> The `$bodyParams` specification can be referred to [Request API v3 Request Body](https://pay.line.me/documents/online_v3_en.html#request-api)

#### Confirm API

[](#confirm-api)

This API is used for a Merchant to complete its payment. The Merchant must call Confirm Payment API to actually complete the payment. However, when "capture" parameter is "false" on payment reservation, the payment status becomes AUTHORIZATION, and the payment is completed only after "Capture API" is called.

```
public Response confirm(integer $transactionId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->confirm($transactionId, [
    "amount" => 250,
    "currency" => 'TWD',
]);
```

#### Refund API

[](#refund-api)

Requests refund of payments made with LINE Pay. To refund a payment, the LINE Pay user's payment transactionId must be forwarded. A partial refund is also possible depending on the refund amount.

```
public Response refund(integer $transactionId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->refund($transactionId);
```

*For Partial refund:*

```
$response = $linePay->refund($transactionId, [
    'refundAmount' => 200,
]);
```

#### Check Payment Status API

[](#check-payment-status-api)

An API to check payment request status of LINE Pay. The merchant should regularly check user payment confirm status **without using the ConfirmURL** and decide if it is possible to complete the payment.

```
public Response check(integer $transactionId)
```

*Example:*

```
$response = $linePay->check($transactionId);
```

#### Capture API

[](#capture-api)

If "capture" is "false" when the Merchant calls the “Request API” , the payment is completed only after the Capture API is called.

```
public Response authorizationsCapture(integer $transactionId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->authorizationsCapture($transactionId, [
    "amount" => 250,
    "currency" => 'TWD',
]);
```

#### Void API

[](#void-api)

Voids a previously authorized payment. A payment that has been already captured can be refunded by using the “Refund API”.

```
public Response authorizationsVoid(integer $transactionId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->authorizationsVoid($transactionId);
```

#### Pay Preapproved API

[](#pay-preapproved-api)

When the payment type of the Request API was set as PREAPPROVED, a regKey is returned with the payment result. Pay Preapproved API uses this regKey to directly complete a payment without using the LINE app.

```
public Response preapproved(integer $regKey, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->preapproved([
    'productName' => 'Your product name',
    'amount' => 250,
    'currency' => 'TWD',
    'orderId' => 'Your order ID',
]);
```

#### Check RegKey API

[](#check-regkey-api)

Checks if regKey is available before using the preapproved payment API.

```
public Response preapprovedCheck(integer $regKey, array $queryParams=null)
```

*Example:*

```
$response = $linePay->preapprovedCheck($regKey);
```

#### Expire RegKey API

[](#expire-regkey-api)

Expires the regKey information registered for preapproved payment. Once the API is called, the regKey is no longer used for preapproved payments.

```
public Response preapprovedExpire(integer $regKey, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->preapprovedExpire($regKey);
```

### Offline APIs

[](#offline-apis)

For POS integration. Customer presents their barcode or QR code to merchants to scan at the POS machine.

> Flow: [`OneTimeKeysPay`](#payment) -&gt; [`OrdersCheck`](#payment-status-check) -&gt; [`OrdersRefund`](#refund)

#### Payment

[](#payment)

This API is to process payment by reading MyCode provided from LINE Pay App with Merchant's device.

```
public Response oneTimeKeysPay(array $bodyParams=null)
```

*Example:*

```
$response = $linePay->oneTimeKeysPay([
    'productName' => 'Your product name',
    'amount' => 250,
    'currency' => 'TWD',
    'productImageUrl' => 'https://yourname.com/assets/img/product.png',
    'orderId' => 'Your order ID',
    "oneTimeKey"=> 'LINE Pay MyCode',
]);
```

#### Payment Status Check

[](#payment-status-check)

It's the API used when the final payment status can't be checked due to read timeout.

- The status needs to be checked by calling it at regular intervals and 3~5 seconds are recommended for the interval time.
- Payment valid time is maximum 20 minutes and it's calculated from the Payment API Response time. Therefore, a merchant should check the payment status for maximum 20 minutes. In case 20 minutes are exceeded, that transaction will be the payment that couldn't be completed due to exceeded valid time.

```
public Response ordersCheck(string $orderId, array $$queryParams=null)
```

*Example:*

```
$response = $linePay->ordersCheck($orderId);
```

#### Void

[](#void)

This API is to void the authorization.

```
public Response ordersVoid(string $orderId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->ordersVoid($orderId);
```

#### Capture

[](#capture)

This API is to capture the authorized transaction.

```
public Response ordersCapture(string $orderId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->ordersCapture($orderId);
```

#### Refund

[](#refund)

This API is to refund after the payment completion (Captured data).

```
public Response ordersRefund(string $orderId, array $bodyParams=null)
```

*Example:*

```
$response = $linePay->ordersRefund($orderId);
```

#### Authorization Details

[](#authorization-details)

This API is to search the authorization details. Only authorized or cancelled (Void or Expire) data can be searched and the data after capturing can be searched by The Payment Details API.

```
public Response authorizations(array $queryParams=null)
```

*Example for searching transactionId:*

```
$response = $linePay->authorizations([
    "transactionId" => [$transactionId],
]);
```

*Example for searching orderId:*

```
$response = $linePay->authorizations([
    "orderId" => $orderId,
]);
```

---

EXCEPTIONS
----------

[](#exceptions)

Client throws exceptions for errors that occur during a API transaction.

### ConnectException

[](#connectexception)

A `victorzhn\linePay\exception\ConnectException` exception is thrown in the event of a networking error (Timeout).

```
try {

    $response = $linePay->confirm($transactionId, $bodyParams);

} catch (\victorzhn\linePay\exception\ConnectException $e) {

    // Process of confirm API timeout handling
}
```

---

RESOURCES
---------

[](#resources)

**[LINE Pay Online API v3 Guide (EN)](https://pay.line.me/tw/developers/apis/onlineApis?locale=en_US)**

**[LINE Pay Offline API v2 Guide (EN)](https://pay.line.me/tw/developers/apis/documentOffline?locale=en_US)**

[LINE Pay Sandbox creation](https://pay.line.me/tw/developers/techsupport/sandbox/creation?locale=en_US)

[LINE Pay OneTimeKeys Simulation](https://sandbox-web-pay.line.me/web/sandbox/payment/otk)

[LINE Pay OneTimeKeys Simulation (For TW Merchant)](https://sandbox-web-pay.line.me/web/sandbox/payment/oneTimeKey?countryCode=TW&paymentMethod=card&preset=1)

[LINE Pay Online API v2 Documents PDF version (Multi-language)](https://pay.line.me/tw/developers/documentation/download/tech?locale=en_US)

---

REFERENCES
----------

[](#references)

[LINE Pay Developers - APIs](https://pay.line.me/tw/developers/apis/apis?locale=en_US)

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity63

Established project with proven stability

 Bus Factor1

Top contributor holds 98.6% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~41 days

Recently: every ~76 days

Total

19

Last Release

1827d ago

Major Versions

1.0.1 → 2.0.02019-06-27

2.0.0 → 3.0.02019-07-10

v2.x-dev → 3.0.12019-07-12

3.5.1 → 4.0.02021-06-25

PHP version history (2 changes)1.0.0PHP &gt;=5.4

4.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f510e561c79978cc6e079a71ddfada3482d811f992c80d8fdd49768e62a10fd5?d=identicon)[VictorZhn](/maintainers/VictorZhn)

---

Top Contributors

[![yidas](https://avatars.githubusercontent.com/u/12604195?v=4)](https://github.com/yidas "yidas (73 commits)")[![MilesChou](https://avatars.githubusercontent.com/u/1258752?v=4)](https://github.com/MilesChou "MilesChou (1 commits)")

---

Tags

phpapisdkline payLINE SDK

### Embed Badge

![Health badge](/badges/victorzhn-line-pay-sdk/health.svg)

```
[![Health](https://phpackages.com/badges/victorzhn-line-pay-sdk/health.svg)](https://phpackages.com/packages/victorzhn-line-pay-sdk)
```

###  Alternatives

[openai-php/laravel

OpenAI PHP for Laravel is a supercharged PHP API client that allows you to interact with the Open AI API

3.7k8.8M83](/packages/openai-php-laravel)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[resend/resend-php

Resend PHP library.

596.2M35](/packages/resend-resend-php)[yidas/line-pay-sdk

LINE Pay SDK for PHP

8529.6k](/packages/yidas-line-pay-sdk)[checkout/checkout-sdk-php

Checkout.com SDK for PHP

563.5M10](/packages/checkout-checkout-sdk-php)[mozex/anthropic-laravel

Laravel integration for the Anthropic API: facade, config publishing, install command, testing fakes, messages, streaming, tool use, thinking, and batches.

72287.1k1](/packages/mozex-anthropic-laravel)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
