Client
I'm using Stripe Checkout custom integration - https://stripe.com/docs/checkout#integration-custom - in a following way:
var handler = StripeCheckout.configure({
key: 'YOUR_KEY_HERE',
image: 'images/logo-48px.png',
token: function(token, args) {
$.post("http://localhost:3000/charge", {token: token}, function(res) {
console.log("response from charge: " + res);
})
}
})
Using custom contrary to simple - How can I modify Stripe Checkout to instead send an AJAX request? - because simple does not allow me to make an AJAX call.
Server
https://stripe.com/docs/tutorials/charges
You've got the token for your user's credit card details, now what? Now you charge them money.
app.post('/charge', function(req, res) {
console.log(JSON.stringify(req.body, null, 2));
var stripeToken = req.body.token;
var charge = stripe.charges.create({
amount: 0005, // amount in cents, again
currency: "usd",
card: stripeToken,
description: "payinguser@example.com"
}, function(err, charge) {
if (err && err.type === 'StripeCardError') {
console.log(JSON.stringify(err, null, 2));
}
res.send("completed payment!")
});
});
Here is the error:
Is seems to me like I have last4, exp_month, exp_year but for some reason I don't have number. Any suggestions / hints / ideas?
Googling for "The card object must have a value for 'number'"
- 12 results, not much help.