@atorify/easy-paypal

1.0.2 • Public • Published

@atorify/easy-paypal

Makes PayPal automation easy.

Install

$ npm install @atorify/easy-paypal

Usage

const easyPaypal = require("@atorify/easy-paypal");
const express = require("express");
const app = express();

// setting up the config/client
easyPaypal.Paypal.SandboxClient("client token", "secret token"); // you can use Client() instead of SandboxClient() for live production.
easyPaypal.Paypal.Config("product name", /*price here (integer/double)*/ 10, /*redirect to any link when finished purchasing*/ "http://127.0.0.1/success");

app.get("/buy", async (req, res) => {
    res.redirect(await easyPaypal.Paypal.Start()); // automatically creates an order and redirects to the paypal purchase page.
});

app.get("/success", async (req, res) => {
    if(await easyPaypal.Paypal.Verify(req.query.token)) { // the Verify function will return true if the purchase token is valid and actually paid.
        res.send("Purchase finished!");
    } else {
        res.send("Purchase failed.");
    }
});

app.listen(80);

Package Sidebar

Install

npm i @atorify/easy-paypal

Weekly Downloads

1

Version

1.0.2

License

MIT

Unpacked Size

4.95 kB

Total Files

6

Last publish

Collaborators

  • atorify