#Village-Checkout-Success
1 messages · Page 1 of 1 (latest)
And is the ID time limited? Is it invalid once the checkout session has expired to the customer?
Hiya! You can grab the Session ID from the request in the Dashboard where you create the Checkout Session. This will be in your logs at https://dashboard.stripe.com/test/logs and will look like POST /v1/checkout/sessions
If its not clear, in testing my custom success page, i just want to hard code in a ID while im working on it so i dont have to trigger a real checkout transaction every time i want to reload the page.
To what you said, gab from where i created a checkout session, is this time limited? Can i still use a checkout session from over a day ago? Or does it have to be a non expired session?
If the session was completed then no it is not time limited and you can then retrieve that Checkout Session at any point in the future
Is that the {CHECKOUT_SESSION_ID}?
No, that is a request ID. Scroll down to the Response Body
Im guessing here, cause i dont know what the key value is. Is that the ID that starts with cs_test_alskdfj... or something else?
Yes that is it.
Maybe im misunderstanding, it looks to me like this is only showing me the session object i created and sent over to checkout to create the session for the customer. I don't see it containing the results of the checkout process, did they successfully make payment, etc.
Im looking through sessions from yesterdays testing, i guess id have to create a new checkout to know 100%
If you aren't seeing any data about the payment/customer then you likely didn't actually complete the session. If it hasn't been 24 hours you can grab the URL from the request you were just looking at and go complete the Session now
Sessions expire in 24 hours
I just went through a test successful checkout.
cs_test_a18VHdXXS4Qt4JfJOH9B2apHKyhjzuYb4w8rj1JBsIIoFwJu4wyBG8uLjw
I dont see anything informative in there, only what i already know, what i sent over to create the session. I assumed this was a way to know the outcome of a checkout for rendering a success landing page for the customer.
Maybe I'm misunderstanding what you are looking for.
But really you use the Checkout Session to then retrieve the other relevant objects.
Like was payment successful? Was a customer and subscription created, or is their payment frozen pending review and they need to be told to wait, etc.
Like it would be stupid for me to say, "Congrads on signing up, now go log in" when their payment wasnt approved yet and they cant log in.
Sure, but like I just said, you can see the outcome just from the Session itself. If you want the specifics of the Subscription to display then you would retrieve the Subscription based on it being a part of the Session retrieval response
Okay, i see the session object already has payment_status=paid, i missed it earlier.
The general flow is to parse the Session ID from the URL and send it to your server. Then you retrieve that session on your server to note the details. You can use expansion to, for example, get the Subscription details all in one retrieval request.
Then you pass what you want back to your client to be displayed.
Yes, my progress so far is sending to checkout, having https://www.$baseDomain/page?id={CHECKOUT_SESSION_ID}, then on the page im getting \Stripe\Checkout\Session::retrieve($sessId);
Im just learning/figuring out what and how to use what's returned in that $session to render the success page. I didn't see at first the payment_status being returned. Thank you for pointing that out to me.
Where can i see the different possible values for that? To code in different responses.
See the link above which has the enums
Just the three, paid unpaid no_payment_required? So if stripe is holding a payment for review, does that just kick back as unpaid? Or do they even get sent to the success_url in that case? Is this behavior documented somewhere?
There isn't a situation where after putting in payment details, stripe might not approve or decline, but send it to some kind of review? I had that happen to me once on a site using stripe, i assumed it was stripe doing it.
No. If it is a card payment then it will either synchronously succeed or fail.
If it fails, the Checkout Session will not be completed.
Like i put in my CC info and hit submit, it said thanks for payment but its under review check back later to see if approved.
No that is not a thing.
Okay, must have been something built into the site itself, just made me think it was coming from stripe. My misunderstanding.
So is it a safe assumption, if they end up on the success_url and payment_status=paid then we golden?
Now what about non-instant payments? Link some of the international banking stuff. How does that flow?
Yep so asnych payment methods are a little more complicated, and are one of the reasons why Webhooks are much more effective than using the Session ID from the Success URL.
With Asynch payment methods then the Checkout Session will show paid, but the PaymentIntent will go into processing
Would they still end up on success_url, do i need to worry about those cases in building this page?
Yes they still end up on Success URL
You just need to then figure out a way to know that the payment turns out to be successful later on.
We recommend Webhooks
The other way would be to poll the API every so often to check on the status of the PaymentIntent.
Yes, im relying on endpoint webhooks for creating accounts, granting access on my end. If that is what you are talking about.
Ah okay, in that case why are you leaning on the Success URL from the Checkout Session at all?
Why not just use Webhooks for that
Im just building the success_url now, the cosmetics fluff. My backend is already functioning, i just want to make sure what im rendering to the customer on the landing page matches reality.
I suppose this will result in a slightly delayed success page.... so yeah okay I see.
Yeah fair
I forgot about the latency with Webhooks and that it doesn't really make sense for rendering your success page
But yeah, for asynch paymentmethod order fulfillment all you need to do is listen for the checkout.session.async_payment_succeeded webhook
The way im using stripe, they signup, i hold their info in a session on my backend, i listen for endpoint webhooks, when i get invoice.paid i create an account on my end for them and give them access until subscription end time. So i just need something on success page saying "Congrads, you signed up, now you can login with your user/pass, blah blah" but ofcourse it would be stupid to blanket say that without knowing it really happened backend.
Gotcha.
Yesterday it was suggested to use checkout custom success page, im doing that, im getting the {checkout_session_id} and loading the session from that.
What brought me to you now is figuring out what to rely on in that session to know i can tell them, your user/pass works now.
So from what i gather my answer is payment_status=paid. Is that all i have to look out for? I can just build my page around if that is paid or not? Nothing else i need to consider?
Yes that will let you know that the customer successfully completed a Checkout Session and either completed a card payment or started an asynch payment successfully.
Is there any situation where they would be sent to the success_url and payment_status wouldn't be paid?
Am i doing a bunch of leg work for no reason if its always paid to even be on that page?
Okay, my modes are always subscription
so in my case, no
Okay, thank you, i believe that covers it all. Im done.
Are you offering trials?
@worn fractal okay I just checked because I wanted to make sure, and we return unpaid for payment_status for asynch payment methods while the payment is processing. Then we will return paid once it finishes processing.
No im not offering trails, i only create customer accounts on my end after i get a successful invoice.paid hook
For asynch payments that return unpaid is there anything else returned in that $session that would tell me its unpaid because its a pending bank draft (for example), or am i blinding trusting if they on the page and == unpaid then must mean its asynch payment?
No nothing would inherently tell you, but when you retrieve the Checkout Session you can expand the subscription.latest_invoice.payment_intent and check the status
If it is processing then you know it is async
If you aren't familiar with expanding responses, this is what I'm talking about: https://stripe.com/docs/api/expanding_objects
Thanks.
Im not doing it right, im not getting the expanded info.
I tried both
$session = \Stripe\Checkout\Session::retrieve($sessId, ['expand'=>'payment_intent']);
$session = \Stripe\Checkout\Session::retrieve($sessId, ['expand'=>'latest_invoice.payment_intent']);
You need subscription.latest_invoice.payment_intent like I stated above
the output is session object...
Can you log out $session->subscription->latest_invoice->payment_intent?
This is the ID im using cs_test_a18VHdXXS4Qt4JfJOH9B2apHKyhjzuYb4w8rj1JBsIIoFwJu4wyBG8uLjw
lol I just did this in node a few mins ago
👋 you're using the legacy PHP approach
basically your expand is completely ignored @worn fractal, it's easy to see if you just dump the whole object, you'd see the invoice/subscription isn't expanded at all
Yes, i see that, thats how i know it isn't working, cause i am dumping the $session
If you stick to the legacy way (you shouldn't) you want $session = \Stripe\Checkout\Session::retrieve([ 'id', $sessId, 'expand'=>'latest_invoice.payment_intent'] ]);
but really the newer way with the client is way easier and would have worked from the start
which docs are you following exactly?
And based on that, this is how i did checkout session, is this not the "correct" way anymore?
This doesn't work, i tired both 'id', $sessId, ... and 'id'=>$sessId, ...
'id' $sessId,
'expand'=>['latest_invoice.payment_intent']
]);```
come on
sorry my keyboard is not fun today
'id' => $sessId,
'expand'=>['latest_invoice.payment_intent']
]);```
It needed the subsbcription added to it, this worked
$session = \Stripe\Checkout\Session::retrieve(['id' => $sessId, 'expand' => ['subscription.latest_invoice.payment_intent']]);
But you are saying that is frowned upon now, i need to read what you linked before...
not really frowned upon, but the new way is a lot cleaner
if you used it, your original attempt at expanding would have "just worked"
you wouldn't need the "trick" of making the id part of the params like you have to right now
Okay, im on track for now, thanks for the info. You can close this thread.