#olegb-webhooks
1 messages ยท Page 1 of 1 (latest)
Hi there! No stupid questions ๐
I'm not very familiar with c# but it should just be the top-level property of the Checkout Session object that is returned to you: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer_email
If you need exact syntax help then I can ask a colleague who is familiar with c#
Thanks, maybe I'm confused, but when I capture that event, i have the stripeEvent object that was json parsed from incoming Inputstream.. all is good... when i open the stripeEvent object i see it all there but just don't know how to reference it.. for example, i can get the event type (stripeEvent.Type) but I need to get to customer email, which is buried deeper.. hope im explaining it right
One sec, let me ask a colleague who is familiar with c#
thank you
๐ I always recommend starting with https://stripe.com/docs/webhooks/quickstart
or alternatively maybe what is the call to get the customer information from the customerid
That example shows the whole deserialization and makes it fairly easy once you see it, but I never remember it otherwise
It looks like this ```stripeEvent = EventUtility.ConstructEvent(json,
signatureHeader, endpointSecret);
if (stripeEvent.Type == Events.PaymentIntentSucceeded)
{
var paymentIntent = stripeEvent.Data.Object as PaymentIntent;
Console.WriteLine("A successful payment for {0} was made.", paymentIntent.Amount);
// Then define and call a method to handle the successful payment intent.
// handlePaymentIntentSucceeded(paymentIntent);
}```
So basically you "cast" event.Data.Object into the right object based on Type
so you likely want ```stripeEvent = EventUtility.ConstructEvent(json,
signatureHeader, endpointSecret);
if (stripeEvent.Type == Events.CheckoutSessionCompleted)
{
var session = stripeEvent.Data.Object as Session;
var email = Session.CustomerEmail;
}```
assuming you have all the right imports and all that
ahh.. ok, so you cast it as session and then go from there.. thank you !! - in general what is the best way to get all of the customer info, is there an easy call that exists?
thanks @naive harbor that worked !! thank you - can you point me to a customer call (above) and i think i'm on my way
Many of our objects "reference" other objects like the Session has customer: 'cus_123' if a customer is associated with it
What you can do is "expand" the entire object as documented on https://stripe.com/docs/expand
So you could parse the event, get the id cs_test_123 and then call https://stripe.com/docs/api/checkout/sessions/retrieve and expand the customer to get both at once
you can't do this with webhooks/events
thank you, let me research this... although i may not be able to do this directly i should be able to do this from within webhooks controller, right? thanks again
correct
https://stripe.com/docs/expand#multiple-properties is exactly the example you want. I was copy-pasting from it to tweak it and realized it's literally what you're trying to do :p
thanks very much, really appreciate it