Giter Club home page Giter Club logo

rest-api-sdk-nodejs's Introduction

REST API SDK for Node.js

Continuous integration status:

Build Status Coverage Status

NPM status:

NPM version Dependency 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.

Usage

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).

    paypal_sdk.configure({
      'host': 'api.sandbox.paypal.com',
      '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) {
        console.log(error);
        throw error;
      } else {
        console.log("Create Credit-Card Response");
        console.log(credit_card);
      }
    })
  • To use OpenID Connect

    // OpenID configuration
    paypal_sdk.configure({
      'openid_client_id': 'CLIENT_ID',
      'openid_client_secret': 'CLIENT_SECRET',
      'openid_redirect_uri': 'http://example.com' });
    
    // 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){
      console.log(tokeninfo);
    });
    
    // Get tokeninfo with Refresh code
    paypal_sdk.openid_connect.tokeninfo.refresh("Replace with refresh_token", function(error, tokeninfo){
      console.log(tokeninfo);
    });
    
    // Get userinfo with Access code
    paypal_sdk.openid_connect.userinfo.get("Replace with access_code", function(error, userinfo){
      console.log(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] (https://github.com/Runnable/rest-api-sdk-nodejs/tree/master/samples). 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)

Reference

[REST API Reference] (https://developer.paypal.com/webapps/developer/docs/api/)

Contribution

  • 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

rest-api-sdk-nodejs's People

Contributors

prannamalai avatar siddick avatar avidas avatar tkanta avatar lvairamani avatar ganeshx avatar bulkan avatar dasmall avatar jkingyens avatar lathavairamani avatar sahat avatar

Watchers

Luis Specian avatar James Cloos avatar

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.