Skip to content

stormbkk87/meteor-paypal

This branch is 11 commits behind danibrear/meteor-paypal:master.

Folders and files

NameName
Last commit message
Last commit date

Latest commit

78fd318 · Nov 10, 2013

History

30 Commits
Aug 31, 2013
Aug 31, 2013
Aug 31, 2013
Nov 10, 2013
Sep 1, 2013
Sep 1, 2013
Sep 1, 2013
Sep 1, 2013
Sep 1, 2013
Aug 31, 2013

Repository files navigation

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.

About

Paypal integration through Meteor

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages

  • JavaScript 100.0%