Profer
Profer

Reputation: 633

How to create token for stripe with nodejs

I can use load-stripe to generate a token on the front-end reactjs.

Now I need to do same thing on the backend nodejs. The user will pass accountNumber cvv and other information to the backend then how can I create a token using it?

Any help would be much appreciated Thank you!!!

Upvotes: 0

Views: 1733

Answers (2)

Vinesh Goyal
Vinesh Goyal

Reputation: 637

NPM package stripe-node

var stripe = require("stripe")("sk_test_4eC39HqLyjWDarjtT1zdp7dc");

stripe.tokens.create({
  card: {
    "number": '4242424242424242',
    "exp_month": 12,
    "exp_year": 2019,
    "cvc": '123'
  }
}, function(err, token) {
  // asynchronously called
});

For more info: Stripe Documentation

Upvotes: 1

OlegDovger
OlegDovger

Reputation: 122

I would not recommend using load-stripe npm module

3 years have passed since last changes were made.

There is a good example of using stripe API on backend side without any dependencies at all.

https://github.com/olegdovger/pizza-delivery-api

Upvotes: 1

Related Questions