#MidnighttFoxx
1 messages · Page 1 of 1 (latest)
What do you mean when you say frontend? Do you mean client-side using Stripe.js and your publishable key?
If that's what your asking then no, that's not possible
i have a working payment sheet that has some metadata that i passed in when i run paymentIntents.create, but there is something i want to add from a different API call after the payment succeeds
Then you'll need to update that PaymentIntent server-side
could you explain how i would go about doing that
what specific part of it are you having trouble with?
im not exactly sure how to access said paymentIntent
But what specifically do you mean by that? Do you already have the PaymentIntent ID client-side and don't know what to do with it? Do you not have the PaymentIntent ID at all?
i don't have the ID at all
Gotcha - so there's a couple of different ways you could do this, but the best way is to use webhooks. You'd listen for the payment_intent.succeeded event to be notified whenever a PaymentIntent succeeds, and from your webhook handler you can make the API request to update the PI with whatever metadata you want
so i was able to get the webhook working to check for success, but now how do i alter the metadata
https://stripe.com/docs/api/payment_intents/update#update_payment_intent-metadata <- This is what you'd use
i tried to update the metadata and got "unhandled promise rejection: stripe.paymentIntents.update is not defined"
Can you show us your code? It's likely you haven't initialized the Stripe library correctly
do you want just the few lines?
Show us the lines where you call stripe.paymentIntents.update and how you initialize the STripe library
This is your client-side code. You need to be updating the PaymentIntent from your server.
That's why it's failing - the client-side stripe library doesn't allow you to update PaymentIntents in this way
oh, so then its not possible to do what i wanted i guess
because that token is stored client side
Yeah as I said from the start - it's not possible to set metadata client-side. You need to call to your own server that makes the request to Stripe using your secret key