Home > Uncategorized > Charge a Credit card using #Stripe and #Node

Charge a Credit card using #Stripe and #Node

stripe

Stripe makes it super-easy to charge a credit card, here is an example from the command line:

var stripe = require(‘stripe’)(‘sk_test_…..’);

stripe.tokens.create({
card: {
number: ‘4242424242424242’,
exp_month: 12,
exp_year: 2020,
cvc: ‘123’
}
}, function(err, token) {
if (err != null)
{
console.log(“err:” + err);
}
else
{
console.log(“tokenid:” + token.id);
stripe.charges.create({
amount: 2000,
currency: “usd”,
source: token.id,
description: “Charge for 4242424242424242”
}, function(err, charge) {
if (err != null)
{
console.log(“err:” + err);
}
else {
console.log(“charge:” + charge.id);
}
});
}
});

 

Categories: Uncategorized
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: