I'm new with Node.js I want to collect user data like name, phone number, Gmail, city ...etc using nodejs & stripe. So that I can know the user from stripe dashboard with all their information.
app.post("/charge", (req, res) => {
try {
stripe.customers
.create({
name: req.body.name,
email: req.body.email,
source: req.body.stripeToken
})
.then(() => res.render("succ.html"))
.catch(err => console.log(err));
} catch (err) {
res.send(err);
}
});
when I use this code I just take the name and Gmail from user...IDK what elements can I use to take phone number and city ...etc.
scripts.js
const stripeTokenHandler = token => {
const hiddenInput = document.createElement('input');
hiddenInput.setAttribute('type', 'hidden');
hiddenInput.setAttribute('name', 'stripeToken');
hiddenInput.setAttribute('value', token.id);
form.appendChild(hiddenInput);
form.submit();
}
you can save the phone number and address in customer object's shipping property. See https://stripe.com/docs/api/customers/object#customer_object-shipping
You might also want to check out Stripe Checkout. The Checkout page provides built-in input elements to collect customer info, including phone number and billing/shipping address. See https://stripe.com/docs/payments/checkout/phone-numbers