SDK for PayPal REST APIs

npm install paypal-rest-sdk
70 downloads in the last day
435 downloads in the last week
1 740 downloads in the last month

REST API SDK for Node.js NPM version Build Status

Repository for PayPal's Node SDK (node.js version >=0.6.x) and Node samples for REST API. Refer Node.js Sample Reference App for a sample web app implementing the REST APIs.


To write an app using the SDK

  • Register for a developer account and get your client_id and secret at PayPal Developer Portal.
  • Add dependency 'paypal-rest-sdk' in your package.json file.
  • Require 'paypal-rest-sdk' in your file

    var paypal_sdk = require('paypal-rest-sdk');
  • Create config options, with required parameters (host, port, client_id, secret).

      'host': '',
      'port': '',
      'client_id': 'EBWKjlELKMYqRNQ6sYvFo64FtaRLRR5BdHEESmha49TM',
      'client_secret': 'EO422dn3gQLgDbuwqTjzrFgFtaRLRR5BdHEESmha49TM'
  • Invoke the rest api (eg: store a credit card) with required parameters (eg: data, config_options, callback).

    var card_data = {
      "type": "visa",
      "number": "4417119669820331",
      "expire_month": "11",
      "expire_year": "2018",
      "cvv2": "123",
      "first_name": "Joe",
      "last_name": "Shopper"
    paypal_sdk.credit_card.create(card_data, function(error, credit_card){
      if (error) {
        throw error;
      } else {
        console.log("Create Credit-Card Response");
  • To use OpenID Connect

    // OpenID configuration
      'openid_client_id': 'CLIENT_ID',
      'openid_client_secret': 'CLIENT_SECRET',
      'openid_redirect_uri': '' });
    // Authorize url
    paypal_sdk.openid_connect.authorize_url({'scope': 'openid profile'});
    // Get tokeninfo with Authorize code
    paypal_sdk.openid_connect.tokeninfo.create("Replace with authorize code", function(error, tokeninfo){
    // Get tokeninfo with Refresh code
    paypal_sdk.openid_connect.tokeninfo.refresh("Replace with refresh_token", function(error, tokeninfo){
    // Get userinfo with Access code
    paypal_sdk.openid_connect.userinfo.get("Replace with access_code", function(error, userinfo){
    // Logout url
    paypal_sdk.openid_connect.logout_url("Replace with tokeninfo.id_token");
  • To create Future Payments, check out this sample for executing future payments for a customer who has granted consent on a mobile device.

  • For Invoicing, check out the samples to see how you can use the node sdk to create, send and manage invoices.

Running Samples

Instructions for running samples are located in the [sample directory] ( Try these samples in a live sandbox environment:

Running Tests

To run the test suite first invoke the following command within the repo

If mocha is not installed

npm install -g mocha

and then to install the development dependencies:

npm install

then run the tests:

mocha -t 15000 #(timeout is specified in milliseconds eg: 15000ms)


[REST API Reference] (


  • If you would like to contribute, please fork the repo and send in a pull request.
  • Please ensure you run grunt before sending in the pull request.

Bitdeli Badge

npm loves you