A sample code to use LINE Pay in your bot.
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.
Go to LINE developers console and create your channel for LINE Messaging API.
$ git clone https://github.com/nkjm/line-pay-in-bot.git
$ cd line-pay-in-bot/
$ npm install
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.
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
For more methods of LINE Pay API SDK, refer to API reference.