/line-pay-in-bot

Sample code to use LINE Pay in your bot.

Primary LanguageJavaScriptMIT LicenseMIT

Overview

A sample code to use LINE Pay in your bot.

Demo

line-pay-in-bot-demo

Getting started

Create sandbox of LINE Pay

Go to LINE Pay Developers and create your sandbox. You can retrieve Channel Id and Channel Secret Key after successful login to LINE Pay Console. You also need to configure white lists of server ip addresses which access to LINE Pay API.

Create a channel of LINE Messaging API

Go to LINE developers console and create your channel for LINE Messaging API.

Installation

$ git clone https://github.com/nkjm/line-pay-in-bot.git
$ cd line-pay-in-bot/
$ npm install

Configuration

Create .env file and write following replacing YOUR_VALUE to your value of each parameters.

LINE_BOT_CHANNEL_SECRET=YOUR_VALUE
LINE_BOT_ACCESS_TOKEN=YOUR_VALUE
LINE_PAY_CHANNEL_ID=YOUR_VALUE
LINE_PAY_CHANNEL_SECRET=YOUR_VALUE
LINE_PAY_CONFIRM_URL=YOUR_VALUE

As for LINE_PAY_CONFIRM_URL, it will be https://YOUR_HOSTNAME/pay/confirm.

You can use free services like ngrok or serveo to launch your server. Please be noted that you need to register your global ip address as white list of LINE Pay sandbox. Also need to register https://YOUR_HOSTNAME/webhook as webook URL in LINE Messaging API channel configuration.

*Please keep in mind that these hostname and ip address may change every time you restart the server.

Launch server

If you like to try the server with middleware of the SDK, run follwoing command. This is much simpler but not so flexible.

$ node with_middleare.js

If you like to try the server without using middleware of the SDK, run following command. You can control the behavior more in detail in this configuration.

$ node without_middleware.js

Reference

For more methods of LINE Pay API SDK, refer to API reference.

License

MIT