#nshah97_docs
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/1431234521755422822
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
๐
I now want to add some client inputted data as metadata to the checkout session
Why not calling your backend and update the Checkout Session ?
That's what im trying to do, using runServerUpdate
You 'll need to get actions fro mthe checkout object, which isn't the case for you
You are collecting the metadata from your own form inputs
so you simply need to make you backend call from your frontend:
await fetch('/update-checkout-session', {
method: 'POST',
body: JSON.stringify({checkoutSessionId: '{CHECKOUT_SESSION_ID}'}),
});
and not use runServerUpdatE?
I don't see the need for it now honestly
You can do the backend call from any where in your frontend code after collecting the required inputs
I would have assumed that there'd be benefits of using runServerUpdate like loading states on the rendered payment element etc
And updating the element once backend call has resolved...
I think it's better to follow the path I mentinoed above
So just call my server endpoint outside of stripe, from wherever appropriate in my frontend ?
what is the purpose of runServerUpdate then?
yes
The purpose is to run server update when an action is received from the Checkout Session
Here is an example (update checkout object when the checkout is succeded)
const checkout = stripe.initCheckout({
clientSecret: 'CLIENT_SECRET',
});
checkout.loadActions().then(function(result) {
if (result.type === 'success') {
// Use the actions object to interact with the Checkout Session
const actions = result.actions;
actions.runServerUpdate(
() => {
return fetch('/update-checkout-session', {
method: 'POST',
body: JSON.stringify({checkoutSessionId: '{CHECKOUT_SESSION_ID}'}),
});
}
);
}
}
But according to what you are describing there is no need to sync the Checkout Session creation/actions with updating it's metada collceted outside of stripe.