#jmak

1 messages · Page 1 of 1 (latest)

bronze kayakBOT
light sleet
#

Hello! That's correct, an Event containing another object will not have any expandable properties expanded. If you want that information you need to retrieve the object from the API and specify you want those properties expanded.

wooden saddle
#

how would i obtain that checkout session event data properly?

i've obtained the session like so but the line items are null

light sleet
#

And in that request specify the properties you want expanded.

wooden saddle
#

so i'm not supposed to unmarshal raw JSON data like this?

light sleet
#

Not sure I understand... there is no data there. The Event does not contain the data you're looking for.

wooden saddle
#

you mean there is no data in event.data.Raw?

light sleet
#

I'm not sure about the Raw part (I'm not a Go developer), but there should be data in event.data if I'm understanding correctly, yes. But it's not going to be JSON if you're using our Go library, it will be a Go object.

#

Our Go library handles converting the JSON from the API into a Go object for you, it's not something you need to do yourself.

#

You would need to do that if you aren't using our library.

wooden saddle
#

is there documentation for how to properly obtain the stripe event from the webhook once the webhook event is emitted?

light sleet
#

That's interesting, our other libraries handle that for you.

wooden saddle
#

yeah so in this case I have the full Event Payload, but how do i get back to the session?

#

I see an EventData field and the Raw object that i'm taking in

light sleet
#

You get the Checkout Session's ID and use that to retrieve it from the API.

#

The Checkout Session would be session based on your code above.

wooden saddle
#

yeah i understand that but i need a session ID from the event in order to retrieve it

#

where is that session ID stored?

light sleet
#

Inside the session. Not sure how to do it in Go, but probably session.id or similar.

#

Did that work? Does session.id have a value?

wooden saddle
#

let me double check real quick one second

light sleet
#

I don't know if you need to capitalize it like session.Id or anything like that.

#

event.Data makes me think you might.

wooden saddle
#

ok it worked its inside data.raw and session.ID is valid

#

so now i need to retrieve and expand?

#

one thing i find odd about doing it that way though is that i've already obtained my session object

#

is there no way to expand the line items directly?

#

you can see in this code that i've unmarshaled the raw event data into this session variable i've created

#

so i feel like re-obtaining the full session would be not a good way to do it. is there a way i can just expand line items now that i have the session object

light sleet
#

There is no way to expand the line items in the Event, you can only expand when interacting with the API directly.

#

Re-obtaining the Checkout Session is the only way to do this.

wooden saddle
#

i think succintly put is there is a session object that i've obtained via raw data json and i'd like to have all those expanded objects. traditionally it seems like you expand in the params when making the session object, so do I have to make the params empty

light sleet
#

What you're asking for is a very common feature request, but currently there is no way to expand properties inside the object stored in an Event.

#

The only way to expand properties is to interact with or fetch those objects directly from the API.

wooden saddle
#

would this be possible?

light sleet
#

No.

#

It is simply not possible to expand properties inside an Event.

wooden saddle
#

okay... let me try it your way

#

so i have to do this? is it ok toi initialize the params to empty except for the ones i want to expand? or do i need to specify all the fields i want

light sleet
#

Not sure I understand. If you want to expand a property you need to indicate as such, but you don't need to specify anything else beyond that.

wooden saddle
#

like is there a cleaner way to write this?

light sleet
#

As far as I know that's how you would do that in Go. Don't know of a cleaner way.

wooden saddle
#

got it okay.

Also I have a separate question now that thats figured out. So upon creation of the payment session there are redirect URLs.

I've set up endpoints to listen to the payment success endpoint, but it looks like the event emission takes priority. Is that correct? If so, then does that mean i dont need a specific endpoint for handling payment suiccess

light sleet
#

The cancel_url will be used if someone goes "back", meaning they hit the back button to return to your site inside Checkout. The success_url is where they land if they complete Checkout successfully. If you're listening for checkout.session.completed Events with a Webhook Endpoint we wait up to 10 seconds for you to respond with success to that Event delivery before sending someone to your success_url so you can prepare your success page based on the outcome.

#

It sounds like you might be thinking theres something like a "failed payment URL" but there is not. If payment fails Checkout will show an error and ask them to try again, it won't redirect them.

wooden saddle
#

so we listen for events before sending them to either success url or cancel url right?

#

what do most people do on their success URL then? it seems like that's where the backend will record everything to the DB correct?

#

or should i be handling that in the checkout.session.completed

misty osprey
#

A common pattern is to do it on either checkout.session.completed or hitting the success URL, whichever comes first

#

You should definitely have this logic in checkout.session.completed because sometimes the user's connection can cut out after making the payment but before they hit your URL. So if you only listen to that and the connection cuts out, you could charge a user without knowing

wooden saddle
#

hmm okay gotcha

#

also i noticed on some payment links there is google pay at the top and apple pay

#

but sometimes it missing

#

how do i have that show up everytime

misty osprey
#

Trying to think of why that might be

#

Do you have shipping address collection and/or Stripe Tax turned on for some of these sessions? I think that can affect it but will need to double check

wooden saddle
#

nope i dont think so

#

ive also tested all of these only by generating the checkout session programmtically

misty osprey
#

Do you have the ID of a session that does not include these wallets? I can take a look at that

wooden saddle
#

most of the most recent ones dont have the google or apple pay

#

i cant remember ones that have had one in a long time

misty osprey
#

One of those IDs should do then

#

It is hard to say in general why they might be there or not be there, a few things can affect their compatability. A specific ID will help me look in to your situation better

wooden saddle
#

py_1MZgRBPXxdADnIZnnDgKbTTo

#

also is there a way to see my total platform earnings from the connect dashboard?
i can click into a connected account and see the connected fees I've taken, but I'd like to see that all at once glance

#

like ideally i want to be able to see which sellers have what fees i've collected from

misty osprey
#

The ID I am looking for is of the form cs_test_1234 or cs_live_1234 do you have one of those IDs? I can look this up via the py ID but it will take a bit

misty osprey
#

Thank you! Checking in to this ID. It actually stops at the # so here it would be cs_test_a1lqBKYyfcRWcfH1R7EQ2JY5p1yz9pkOXiiJ3AQZeB0sazCObTCnNDjvnI

wooden saddle
#

okay cool thanks for letting me know

atomic needle
#

👋 stepping in and having a look

#

Can you create a fresh Checkout Session I can visit?

atomic needle
#

Yes it is browser dependent

#

You will only see Apple Pay in Safari

#

Also you need a valid card saved in your Apple Pay Wallet

wooden saddle
#

ah ok

#

problemn solved then

#

i was on brave

#

is there a fake google pay credit card i can use?

atomic needle
#

No you have to have a live card in your wallet, however when you use your test keys we will swap it out for a test card in your Stripe Account (we won't actually charge your live card)

wooden saddle
#

ah ok

#

very helpful to know thank u