mrgalaxy:stripe

v2.2.0Published 10 years ago

This package has not had recent updates. Please investigate it's current state before committing to using it in your project.

A Meteor package containing Stripe scripts:

Install

Using Meteor's Package System:

$ meteor add mrgalaxy:stripe

Usage

Client

In order for Stripe.js to be loaded directly on iOS and Android a new rule needs to be created in your mobile-config.js located in the root of your project. Create the new file if it doesn't already exist and insert the line below.

1App.accessRule('https://*.stripe.com/*');

In order to allow the Stripe variable to be accessible it must be loaded in the Meteor.startup. This will ensure that calls are deferred until after your Meteor app has started.

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

The same goes for Stripe Checkout, too:

1Meteor.startup(function() {
2    var handler = StripeCheckout.configure({
3		key: 'YOUR_PUBLISHABLE_KEY',
4		token: function(token) {}
5	});
6});

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:

1ccNum = $('#ccnum').val();
2cvc = $('#cvc').val();
3expMo = $('#exp-month').val();
4expYr = $('#exp-year').val();
5
6Stripe.card.createToken({
7	number: ccNum,
8	cvc: cvc,
9	exp_month: expMo,
10	exp_year: expYr,
11}, function(status, response) {
12	stripeToken = response.id;
13	Meteor.call('chargeCard', stripeToken);
14});

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

Server

1Meteor.methods({
2  'chargeCard': function(stripeToken) {
3    var Stripe = StripeAPI('SECRET_KEY');
4
5    Stripe.charges.create({
6      amount: 1000,
7      currency: 'usd',
8      source: stripeToken
9    }, function(err, charge) {
10      console.log(err, charge);
11    });
12  }
13});

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