#imzikkado
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- imzikkado-customer-metadata, 7 hours ago, 9 messages
- imzikkado, 13 hours ago, 29 messages
First where do you want to set the metadta? The PaymentIntent or the Customer?
I didn't find information on how to include the PaymentIntent in checkout.create, I even tried with ChatGPT, but it doesn't return functional codes (it must be because of the old api), I tried using the metadata in the customer, but it returns an empty {}
stripeRouter.post('/', async (req, res) => {
if (!req.isAuthenticated())
res.redirect('/auth')
const customer = await stripe.customers.create({
metadata: {
userId: req.session.passport.user.id
}
})
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: "brl",
product_data: {
name: "RPSide - 1 Month",
},
unit_amount: 3000,
},
quantity: 1
},
],
payment_intent_data: {
setup_future_usage: 'off_session'
},
customer: customer.id,
mode: "payment",
success_url: "http://localhost:8080/painel",
cancel_url: "http://localhost:8080/planos"
});
res.json({ id: session.id });
});
What do you mean by returns empty
Anything in Stripe API is an object, and they have their own metadata
the metadata
ie. Customer can has its own metadata, same the PaymentIntent, and CheckoutSession
If you set metadata to the Customer, then it should have the metadata
You can check by looking at your request log https://dashboard.stripe.com/test/logs
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
I will perfom some test
Do you have any example code on how to include the paymentIntent in the checkout? I really have a problem with the payment system integration logic.
What do you mean by include?
I don't need to pass the PaymentIntent in checkout.session,create?
stripe.paymentIntents.create
example
const customer = await stripe.customers.create({
metadata: {
itemType: req.body.itemType,
userId: req.session.passport.user.id
}
})
const session = await stripe.checkout.sessions.create({
payment_method_types: ['card'],
line_items: [
{
price_data: {
currency: "brl",
product_data: {
name: "RPSide - 1 Month",
},
unit_amount: 3000,
},
quantity: 1
},
],
payment_intent_data: {
setup_future_usage: 'off_session'
},
customer: customer.id,
mode: "payment",
success_url: "http://localhost:8080/painel",
cancel_url: "http://localhost:8080/planos"
});
customer: customer.id = stripe.customers.create
No, Checkout Session will generate a PaymentIntent under the hood
? = stripe.paymentIntents.create
Please follow this guide for step by step introduction
It's to create a standalone PaymentIntent. It's a different flow, to be used with Payment Element (not Checkout)
in a subscription system it would be useful then as there will not be items.