#MidnighttFoxx

1 messages · Page 1 of 1 (latest)

spring badgeBOT
blissful cosmos
#

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

remote plinth
#

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

blissful cosmos
#

Then you'll need to update that PaymentIntent server-side

remote plinth
#

could you explain how i would go about doing that

blissful cosmos
#

what specific part of it are you having trouble with?

remote plinth
#

im not exactly sure how to access said paymentIntent

blissful cosmos
#

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?

remote plinth
#

i don't have the ID at all

blissful cosmos
#

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

remote plinth
#

so i was able to get the webhook working to check for success, but now how do i alter the metadata

blissful cosmos
remote plinth
#

i tried to update the metadata and got "unhandled promise rejection: stripe.paymentIntents.update is not defined"

blissful cosmos
#

Can you show us your code? It's likely you haven't initialized the Stripe library correctly

remote plinth
#

do you want just the few lines?

blissful cosmos
#

Show us the lines where you call stripe.paymentIntents.update and how you initialize the STripe library

remote plinth
blissful cosmos
#

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

remote plinth
#

oh, so then its not possible to do what i wanted i guess

#

because that token is stored client side

blissful cosmos
#

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

remote plinth
#

ok. thank you for your help anyways

#

Happy Holidays!