Git Product home page Git Product logo

line-pay's Introduction

Overview

This is unofficial SDK to use LINE Pay inside the node.js based application on top of express framework.

Getting started

Create sandbox

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.

Installation

$ npm install --save line-pay

Server/Router configuration

Here is extremely basic server configuration to start payment flow.

"use strict";

const app = require("express")();
const uuid = require("uuid/v4");
const line_pay = require("line-pay");

const pay = new line_pay({
    channelId: process.env.LINE_PAY_CHANNEL_ID,
    channelSecret: process.env.LINE_PAY_CHANNEL_SECRET,
    isSandbox: true
});

app.listen(process.env.PORT || 5000, () => {
    console.log(`server is listening to ${process.env.PORT || 5000}...`);
});

app.use("/pay", pay.middleware({
    productName: "demo product",
    amount: 1,
    currency: "JPY",
    orderId: uuid()
}), (req, res, next) => {
    // Now payment should have been completed.
    res.send("Payment has been completed.");
});

When you open browser and access to https://YOUR_HOSTNAME/pay, it starts payment flow by reserving payment and redirect you to authorization screen.

When you approve the payment, you redirect back to https://YOUR_HOSTNAME/pay/confirm and the server actually captures the payment.

You can control the flow by using individual methods like reserve() or confirm() in the SDK.

Reference

For more methods, refer to API reference. Demo & Sample code to use LINE Pay inside chatbot would be a good reference for Bot developers.

License

MIT

line-pay's People

Contributors

nkjm avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

line-pay's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.