#batangatroy-save-and-reuse

1 messages · Page 1 of 1 (latest)

muted scaffold
unkempt tangle
#

got it

muted scaffold
#

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

unkempt tangle
#

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.

muted scaffold
#

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

unkempt tangle
#

again, when I look at the logs in the account - the logs indicate the response contains the setup_intent object

muted scaffold
#

then i think you just want:
$intent = $session -> setup_intent

#

right?

unkempt tangle
#

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

muted scaffold
#

mm it should, you're include the expand parameter 🤔

unkempt tangle
#

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

muted scaffold
#

yes, thats the setup intent object -- which piece do you need from it?

unkempt tangle
#

payment_method

muted scaffold
#

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

unkempt tangle
#

ok, I don't understand the difference - I see. Ok. events are webhooks

muted scaffold
#

if youre doing this in a webhook handler, you would just retrieve the setup intent like the example shows

unkempt tangle
#

yes, this is synchronous - first draft -

muted scaffold
#

if youre already retrieving the session via the api, you can use expand

#

if you're handling a webhook event, you need to retrieve

unkempt tangle
#

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.

muted scaffold
#

like req_1234

unkempt tangle
#

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

muted scaffold
#

aha! excellent, so you have what you need now?

unkempt tangle
#

yes, thank you.

muted scaffold
#

awesome, have a good day 🙂