Stripe retrieve checkout session ID only on server side

Does anyone know how to retrieve the checkout session ID on the server side, after the checkout has been completed in an embedded checkout?

Edit:
I wanted to know, how to retrieve the session id solely on the server side. The wording was completely wrong on my end.

Looking at the stripe docs for embedded checkout you can return the session ID in an url param after the checkout completes:

Then setup the redirect URL, which will be loaded after a successful or cancelled payment. You can see that it contains the dynamic {CHECKOUT_SESSION_ID} which is the Checkout Session ID:

On the redirect page you can get this url param and send it to your server action.

1 Like

Yes. I know. But I wanted to do it solely on the server side without the passing of params from a return URL. My question was not precise enough.

I actually found a way:
While looking at the server logs, the session id is already being generated.
You can retrieve it form the Create Checkout Session as a binding:

ex1
ex2

Maybe you could put the retrieve all checkout sessions action sorted by last created right after the Create Checkout action then get the id of the first record from there?

1 Like

No no. It does work now! I just had to select the 'id' binding from the 'Create Checkout Session'! That's how I can gather the session_id even before the checkout is completed.

1 Like

Awesome to know. Sometimes we ( I ) overthink the issue haha.

1 Like