Git Product home page Git Product logo

paypal-node-api's Introduction

Paypal Node API

A wrapper around paypal's REST API, featuring events, promise support and auto auth.

Only supports subscriptions for now, others will be added per request.

THIS IS NOT AN OFFICIAL API

npm

Installation

NPM:

npm i kik-paypal-api

Usage

Requests
  1. The Basics
  2. Orders
  3. Subscriptions
  4. Plans
  5. Webhooks

Getting Started

You can use the API by creating an instance of PaypalClient.

const PaypalClient = require("paypal-node-api");

paypal = new PaypalClient({
    env: "sandbox",
    clientId: "id",
    secret: "secret",
    config: {}
});

env: one of either "sandbox" or "live"

clientId: your app's client id

secret: your app's secret

config: a config object

Sharing a paypal instance:
const PaypalClient = require("paypal-node-api");

const clientId = "yourApp'sId";
const secret = "yourApp'sSecret";

const paypal = new PaypalClient("sandbox", clientId, secret);

//event handlers go here
paypal.on("auth", () => {
    console.log("Paypal token refreshed");
});

module.exports = paypal;

The Basics

The Extras Object

All required parameters are supplied directly to the functions, non required parameters can be supplied via the extras parameter, this object is merged into the request's payload

The Error Object

Requests

Orders

Create
await paypal.orders.create(intent, purchaseUnits);

intent: either "CAPTURE" or "AUTHORIZE"

purchaseUnits: an array of purchase_unit_request objects

Update
await paypal.orders.update(orderId, patchRequest);

orderId: the target order's id

patchRequest: an array of patch objects

Details
await paypal.orders.details(orderId);

orderId: the target order's id

Authorize
await paypal.orders.authorize(planId);

orderId: the target order's id

Capture
await paypal.orders.capture(orderId);

orderId: the target order's id

Subscriptions

Create
await paypal.subscriptions.create(planId, extras);

planId: the plan associated with this subscription

Details
await paypal.subscriptions.details(subscriptionId);

subscriptionId: the subscription id to retrieve

returns the subscription object

Webhooks

Verify
await paypal.webhooks.verify(authAlgo, certUrl, transmissionId, transmissionSig, transmissionTime, webhookId, webhookEvent)

returns true if verified, false if not

License

GNU AGPLv3

paypal-node-api's People

Contributors

yassienw avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

paypal-node-api's Issues

Add typings

It would be nice to add typings so we can use your project with TypeScript ๐Ÿ˜ƒ

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.