Skip to content
This repository has been archived by the owner on Sep 24, 2020. It is now read-only.

Creating Charges #109

Open
ask-joe opened this issue Oct 26, 2016 · 1 comment
Open

Creating Charges #109

ask-joe opened this issue Oct 26, 2016 · 1 comment

Comments

@ask-joe
Copy link

ask-joe commented Oct 26, 2016

Hi sorry, I'm very New to this How do I create/ add a charges on the form?

Stripe shows a way how to do it, but i don't.



// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
var stripe = require("stripe")("sk_test_A8rby2nqvlUtn6Ze1EEKeTLR");

// Get the credit card details submitted by the form
var token = request.body.stripeToken; // Using Express

// Create a charge: this will charge the user's card
var charge = stripe.charges.create({
  amount: 1000, // Amount in cents
  currency: "eur",
  source: token,
  description: "Example charge"
}, function(err, charge) {
  if (err && err.type === 'StripeCardError') {
    // The card has been declined
  }
});
@tucoinfo
Copy link

One thing is for sure, you should not do this "on the form" (client side), only on your back-end. Stripe auto-generates snippets for you in common programming languages in their docs section. I would go with that.

Any snippet using the secret key (sk_) is only for back-end use. That's why you also have a publishable (public) key (pk_) that only serves in getting a token for a card. So it cannot compromise your account in any way.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants