Coder Social home page Coder Social logo

meteor-paypal's Introduction

Paypal for Meteor

Meteor Package for easy Paypal payment processing.

Usage

mrt add paypal

Setup

If you haven't already, sign up for a developer account at: https://developer.paypal.com/

Create a sandbox application and copy your REST API CREDENTIALS.

Create a file server/paypal_config.js including:

  Meteor.Paypal.config = {
    'host': 'api.sandbox.paypal.com',
    'port': '',
    'client_id': 'Your Paypal Client Id',
    'client_secret': 'Your Paypal Client Secret'
  }

Basic

Format is Meteor.Paypal.*transaction_type*({ {/*card data*/}, {/*transaction data*/}, function(err, res){...})

  Meteor.Paypal.authorize({
      name: 'Buster Bluth',
      number: '4111111111111111',
      type: 'visa',
      cvv2: '123',
      expire_year: '2015',
      expire_month: '01'
    },
    {
      total: '100.10',
      currency: 'USD'
    },
    function(error, results){
      if(error)
        //Deal with Error
      else
        //results contains:
        //  saved (true or false)
        //  if false: "error" contains the reasons for failure
        //  if true: "payment" contains the transaction information
    });

For information on the payment object returned see Paypal's Payment Option Documentation

Transaction types are: Meteor.Paypal.authorize and Meteor.Paypal.purchase for the difference, see Paypal's Documentation

Extras

Include {{> paypalCreditCardForm }} in a template. In the template's javascript file, include:

  Template.paypalCreditCardForm.events({
    'submit #paypal-payment-form': function(evt, tmp){
      evt.preventDefault();
      
      var card_data = Template.paypalCreditCardForm.card_data();
      
      //Probably a good idea to disable the submit button here to prevent multiple submissions.
      
      Meteor.Paypal.purchase(card_data, {total: '100.50', currency: 'USD'}, function(err, results){
        if (err) console.error(err);
        else console.log(results);
      });
    }
  });

Acknowledgements

Special Thanks to Phillip Jacobs (@phillyqueso) for his help with Fibers and Futures without which, this project would've failed.

meteor-paypal's People

Contributors

alexanderottenhoff avatar dolgarev avatar lalomartins avatar

Watchers

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