rohit/line-pay

Line Payment Package for Laravel

3.0.0 2019-01-30 10:11 UTC

This package is not auto-updated.

Last update: 2024-11-10 03:05:27 UTC


README

Very easy and light package for Line Payment.

Installation

Composer

Add Line Pay to your composer.json file

"rohit/line-pay": "^3.0"

Run composer install to get the latest version of package

Or you can directly run the composer require command

composer require rohit/line-pay

Configuration

After the package install is completed you need to configure config/app.php and add Providers and Aliases

    'providers` => [
        .......
        .......
        Rohit\LinePay\LinePayServiceProvider::class
    ]
    'aliases' => [
        ......
        ......
        'LinePay' => Rohit\LinePay\Facades\LinePay::class
    ]

Vendor Publish

After the above steps, you need to publish vendor for this packge. It will create line-pay.php file under config folder. This folder contains the configuration for your locales.

php artisan vendor:publish --provider="Rohit\LinePay\LinePayServiceProvider"

The file line-pay.php will contain the following structure

    return [
        'channel-id' => 'Line Pay Channel Id',
        'channel-secret' => 'Line Pay Channel Secret',
        'reservation-url' => 'https://sandbox-api-pay.line.me/v1/payments/request',
        'detail-url' => 'https://sandbox-api-pay.line.me/v1/payments',
    ];

Functions

  • Process Payment

    You can process your payment with the function process Payment which accepts array as an arguments with following

    LinePay::processPayment($params);

    The array params for processPayment is described below:

    The response from the process payment will be as below

    [
        'status' => 'success' or 'failed',
        'data' => [
            'request' => 'Params you send while calling the function (You may need to save it to log for future)',
            'response' => 'Array response (You may need to save it to log for future)',
        ],
    ]
    
    The response will be empty [] or as follows:
    [
        'returnCode' => '0000' (if success) or other code,
        'returnMessage' -> 'OK',
        'info' => [
            'transactionId' => 'Transaction Id eg: 12345678',
            'paymentUrl' => [
                'web' => 'Payment url for web.' (Need to redirect to this for payment),
                'app' => 'Payment url for app',
            ],
            'paymentAccessToken' => 'Access Token for Payment'
        ],
    ]
  • Verify Payment

    After Successful payment from line, it redirects to the confirmUrl. Now we need to verify the payment from line before updating our order. Its a 3 way handshake for security. This function takes 2 arguments. TransactionId and the array of parameters.

    LinePay::verifyPayment($transactionId, $params);

    The array param for verifyPayment is described below:

    The response from the verify payment will be as below

    [
        'status' => 'success' or 'failed',
        'data' => [
            'request' => 'Params you send while calling the function (You may need to save it to log for future)',
            'response' => 'Array response (You may need to save it to log for future)',
        ],
    ]

    The response will be empty [] or as follows:

    If payment Type is NORMAL the response will be as follow:
    [
        'returnCode' => '0000' (if success) or other code,
        'returnMessage' -> 'OK',
        'info' => [
            'orderId' => 'OrderID of the payment',
            'transactionId' => 'Transaction Id',
            'payInfo' => [
                [
                    'method' => 'BALANCE',
                    'amount' => '10',
                ],
                [
                    'method' => 'DISCOUNT',
                    'amount' => '10',
                ],
            ],
        ],
    ]
    If payment Type is PREAPPROVED the response will be as follow:
    [
        'returnCode' => '0000' (if success) or other code,
        'returnMessage' -> 'OK',
        'info' => [
            'orderId' => 'OrderID of the payment',
            'transactionId' => 'Transaction Id',
            'payInfo' => [
                [
                    'method' => 'CREDIT_CARD',
                    'amount' => '10',
                    'creditCardNickName' => 'test',
                    'creditCardBrand' => 'VISA',
                ],
                'regKey' => 'Random reg Key',
            ],
        ],
    ]
  • Capture Payment

    If capture is false while processing payment by processPayment function, then the payment is completed only after the Catpute API is called. This function completes the payment that was only authorized by processPayment. This function takes 2 arguments. TransactionId and the array of parameters.

    LinePay::verifyPayment($transactionId, $params);

    The array param for verifyPayment is described below:

    The response from the verify payment will be as below

    [
        'status' => 'success' or 'failed',
        'data' => [
            'request' => 'Params you send while calling the function (You may need to save it to log for future)',
            'response' => 'Array response (You may need to save it to log for future)',
        ],
    ]
    
    The response will be empty [] or as follows:
    [
        'returnCode' => '0000' (if success) or other code,
        'returnMessage' -> 'OK',
        'info' => [
            'orderId' => 'The order id',
            'transactionId' => 'Transaction Id eg: 12345678',
            'info' => [
                [
                    'method' => 'BALANCE',
                    'amount' => 10,
                ],
                [
                    'method' => 'DISCOUNT',
                    'amount' => 10,
                ],
            ],
        ],
    ]
  • Void Payment

    Voids a previously authorized payment. A payment that has been already captured can be refunded by this API

    LinePay::voidPayment($transactionId);

    The response from the void payment will be as below

    [
        'status' => 'success' or 'failed',
        'data' => [
            'request' => [],
            'response' => 'Array response (You may need to save it to log for future)',
        ],
    ]
    
    The response will be empty [] or as follows:
    [
        'statusCode' => '0000' (if success) or other code,
        'returnMessage' => 'OK',
    ]