#livelove_best-practices
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
đ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1395844745875554387
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
Hello
You can just call your backend after confirmPayment resolves, yeah?
https://docs.stripe.com/payments/accept-a-payment?platform=web&ui=elements#web-submit-payment
The other option would be to listen to a webhook event
Okay but how can i validate on my backend if the data send is after the actuall transaction
Stripe will notify you when the payment succeeds
Ye but then im limited with the data typed in inputs
It's step 5 in the guide I shared above
Sorry, can you share more details?
Like what information are you trying to submit to your backend?
Okay so i was thinking about showing some additional inputs in the same element as the payment elements are shown. Like eg user wants to buy a custom dining menu and he will configure that menu and then pay for it and i would Like to have with that payment data some data which i could use to save that dining menu in my database
Gotcha. There are two options I can think of right now.
First option is,
Once the user is done configuring a dining menu, you save that in your Database before you create a PaymentIntent. Then when you create a PaymentIntent, you associate that PaymentIntent to the menu in your database. When the PaymentIntent is confirmed, you can call your server with the relevant PaymentIntent ID to mark that "order" as paid.
Second option is,
This option relies on Webhooks. Once the user is done configuring and you call your server to create a PaymentIntent - you send the menu details to the server. Then you store the menu details in PaymentIntent metadata. When that PaymentIntent is confirmed and payment succeeds, you look at the payment_intent.succeeded event's payload to figure out what PaymentIntent was confirmed and what was the associated menu in it's metadata . Then you can store the menu from the metadata in your own Database
Option 1 is more static where the menu can exist in your database without the user paying for it.
Option 2 is more dynamic where the menu will only exist in your database if the payment is successful.
Okay ye does look like solid solutions, thx for the help i will go for second option