#Jaxon-paymentintent

1 messages · Page 1 of 1 (latest)

silver oak
#

Hi!

I want to create a webhook that get's called whenever a user's payment_intent succeess is called.
The event is called payment_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?

crystal patrol
#

I want to allow the user to make a payment. But I want the product Id in the payment_intent.succeeded

silver oak
#

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.

crystal patrol
#

How would I go about doing that in Node?

silver oak
#

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"
  }
});
crystal patrol
#

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
        }
      });
silver oak
#

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.