#Jaxon-paymentintent
1 messages · Page 1 of 1 (latest)
Hi!
I want to create a webhook that get's called whenever a user's payment_intent succeess is called.
The event is calledpayment_intent.succeeded
Is there a way to make the user buy a product instead of a dynamic amount.
I'm not sure to understand. Can you clarify your question?
I want to allow the user to make a payment. But I want the product Id in the payment_intent.succeeded
Got it! The products and prices objects don't work with PaymentIntent. That's only for Checkout Sessions and Billing.
But you could add the product ID in the metadata of the PaymentIntent.
How would I go about doing that in Node?
When you create (or update) the PaymentIntent, add a metadata parameter. This can contain anything you want: https://stripe.com/docs/api/payment_intents/create?lang=node#create_payment_intent-metadata
For example when creating the PaymentIntent in Node:
For example in Node:
const paymentIntent = await stripe.paymentIntents.create({
amount: 2000,
currency: 'eur',
payment_method_types: ['card'],
metadata: {
foo: "bar",
price: "price_xxx"
}
});
So something like this will work fine?
const paymentIntent = await stripe.paymentIntents.create({
amount: parseInt(req.body.amount),
currency: 'aud',
customer: customerId,
metadata: {
'uid': req.body.uid,
'product_id': req.body.product_id
}
});
Yes it should. But just to clarify: the metadata will have no effect on the actual price of the PaymentIntent. But when listening to the payment_intent.succeeded event, you will be able to retrieve all information stored in the metadata field.