#kqtipow - Checkout Session metadata

1 messages ยท Page 1 of 1 (latest)

real lance
#

Hello ๐Ÿ‘‹

#

You can do this by having your server retrieve the Checkout Session by the session_id that you get in the success URL

#

So when the user completes their payment, they will be directed to a URL like
http://localhost/test/success.php?session_id=cs_test_123
You can then retrieve the Session with a call to retrieve and then the metadata will be right on the object:

  'cs_test_123',
  []
);```
stoic plinth
#

Yes, i have retieved succesfully

#

but wondering how to access that variable metadata

real lance
#

I think it will look something like
$order_id = $session->metadata["order_id"]

#

Have you tried that or just accessing $session->metadata to see what is in there?

stoic plinth
#

Yes

real lance
#

Do you have the ID of the checkout session that that is for?

stoic plinth
#

$checkout_session = \Stripe\Checkout\Session::retrieve($session_id); I have it this way

#

Brilliant!

#

your answer helped me!

#

thanks a lot

#

$order_id = $session->metadata["order_id"]
that did the magix

real lance
#

Nice! What was your code for that before out of curiosity?

stoic plinth
#
$paymentIntent = \Stripe\PaymentIntent::retrieve($checkout_session->payment_intent); 

$metadata = $paymentIntent->metadata['order_id'];
#

Maybe i was tried to access data inside on Stripe side

real lance
stoic plinth
#

You mean I can set customer name/email at PHP snippet, when I created session ID?

#

sorry, session*

real lance
#

My link there was just about setting the metadata on the payment intent instead of just the Checkout Session

stoic plinth
#

Thanks

#

very useful

#

I will use it to finish integration, thanks a lot again ๐Ÿ™‚

real lance
#

Of course, good luck! Just let us know if you run in to anything else

stoic plinth
#

Thanks!