Git Product home page Git Product logo

stripe-meteor's Introduction

A Meteor package containing Stripe scripts:

Install

Using Meteor's Package System:

$ meteor add mrgalaxy:stripe

Usage

Client

Stripe.js is now loaded directly from stripe.com and this happens after all other Meteor scripts are loaded. As such, the Stripe variable is not immediately available for use so instead, calls need to be deferred until after your Meteor app has started, like so:

Meteor.startup(function() {
    Stripe.setPublishableKey('YOUR_PUBLISHABLE_KEY');
});

The same goes for Stripe Checkout, too:

Meteor.startup(function() {
    var handler = StripeCheckout.configure({
		key: 'YOUR_PUBLISHABLE_KEY',
		token: function(token) {}
	});
});

In order to remain PCI compliant under the new DSS 3.0 rules, never send credit card details to the server. Use client-side credit card details to create a secure token, per this example:

ccNum = $('#ccnum').val();
cvc = $('#cvc').val();
expMo = $('#exp-month').val();
expYr = $('#exp-year').val();

Stripe.card.createToken({
	number: ccNum,
	cvc: cvc,
	exp_month: expMo,
	exp_year: expYr,
}, function(status, response) {
	stripeToken = response.id;
	Meteor.call('chargeCard', stripeToken);
});

See the Stripe docs (https://stripe.com/docs/stripe.js, https://stripe.com/docs/checkout) for all the API specifics.

Server

Meteor.methods({
  'chargeCard': function(stripeToken) {
    var Stripe = StripeAPI('SECRET_KEY');

    Stripe.charges.create({
      amount: 1000,
      currency: 'usd',
      source: stripeToken
    }, function(err, charge) {
      console.log(err, charge);
    });
  }
});

For a complete reference, please see the original: https://github.com/stripe/stripe-node

stripe-meteor's People

Contributors

tyler-johnson avatar lirbank avatar adambrodzinski avatar dandv avatar dangilkerson avatar mjhea0 avatar tejas-manohar avatar

Watchers

James Cloos avatar Praveen Koka 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.