A Meteor package containing Stripe scripts:
NOTE: This does not contain checkout.js. If you require this script use this instead.
Using Meteor's Package System:
$ meteor add kayla:stripe
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');
});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, for all the API specifics.
Meteor.methods({
'chargeCard': function(stripeToken) {
var Stripe = StripeAPI('SECRET_KEY');
Stripe.charges.create({
amount: 1000, // in ¢
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