#batangatroy-save-and-reuse
1 messages · Page 1 of 1 (latest)
got it
And, in step 4, there is an info box that says ...If you’re requesting this information synchronously from the Stripe API (as opposed to handling webhooks), you can combine the previous step with this step by expanding the SetupIntent object in the request to the /v1/checkout/session endpoint. Doing this prevents you from having to make two network requests to access the newly created PaymentMethod ID.
I'm making a PHP request that looks like this ... $session = \Stripe\Checkout\Session::retrieve($session_id, ['expand' => ['setup_intent']]);... where $session_id is the attached to the end of the URL that stripe calls
but the response is not expanding the "setup_intent" - object - it is just replying with the id
just copying in here for reference form main
sure. thanks. sorry about htat
the code looks like ``` $stripe_secret = config('app.stripe_secret');
\Stripe\Stripe::setApiKey($stripe_secret);
$session_id = $request->session_id;
$session = \Stripe\Checkout\Session::retrieve($session_id, ['expand' => ['setup_intent']]);
// $intent = \Stripe\SetupIntent::retrieve($session['setup_intent']);```
the last line is commented out because I'm trying to replace it with the expand array in the call above it.
nah my fault for being slow to make the thread :p
ah gotcha
thanks i got very confused because the link took me to the wrong page in the docs (cooke on my side, not your fault)
i get it now
so that second to last line is correct
again, when I look at the logs in the account - the logs indicate the response contains the setup_intent object
But when I look at the "Events" section for the same call - it shows just the setup_intent id
yes but $session does not contain the object in the return
is only contains the id
mm it should, you're include the expand parameter 🤔
that's the snippet from "Logs" on the account - so it looks right
but that's the snippet from the "Events" for the same call
and that's what I'm seeing in $session
yes, thats the setup intent object -- which piece do you need from it?
payment_method
yes, events dont include any expansion, you need to request the object
thats why the callout says "if you're requesting synchronously..."
there is no way to expand with webhook events
ok, I don't understand the difference - I see. Ok. events are webhooks
if youre doing this in a webhook handler, you would just retrieve the setup intent like the example shows
yes, this is synchronous - first draft -
if youre already retrieving the session via the api, you can use expand
if you're handling a webhook event, you need to retrieve
I understand. it's just that I'm not getting the expanded object from the call above. there must be something between my code and the endpoint response that is mucking it up; I'll look closer since you've confirmed the code appears to be correct.
can you share the request id of your retrieve call?
https://stripe.com/docs/api/request_ids
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
like req_1234
actually - I just did something that I should have done before - I looked at the response of the fetch in my browser and the response from your endpoint is as expected (includes expanded setup_intent object) - so Laravel must be doing something after its been received.
so you can close or archive this thread. thanks for sticking with me
aha! excellent, so you have what you need now?
yes, thank you.
awesome, have a good day 🙂