PHP code example of rohit / line-pay

1. Go to this page and download the library: Download rohit/line-pay library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

rohit / line-pay example snippets


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

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

    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',
    ];

    LinePay::processPayment($params);
    

    [
        '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'
        ],
    ]
    

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

    [
        '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)',
        ],
    ]
    

    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',
            ],
        ],
    ]
    

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

    [
        '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,
                ],
            ],
        ],
    ]
    

    LinePay::voidPayment($transactionId);