#nshah97_docs

1 messages ยท Page 1 of 1 (latest)

strange lionBOT
#

๐Ÿ‘‹ 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.

nova cipher
#

๐Ÿ‘‹

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 ?

cold hatch
#

That's what im trying to do, using runServerUpdate

nova cipher
#

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}'}),
});
cold hatch
#

and not use runServerUpdatE?

nova cipher
#

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

cold hatch
#

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...

nova cipher
#

I think it's better to follow the path I mentinoed above

cold hatch
#

So just call my server endpoint outside of stripe, from wherever appropriate in my frontend ?

#

what is the purpose of runServerUpdate then?

nova cipher
#

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.

cold hatch
#

Okay sure

#

that makes sense

#

thanks a lot