#olegb-webhooks

1 messages ยท Page 1 of 1 (latest)

copper coral
#

Hi there! No stupid questions ๐Ÿ™‚

#

If you need exact syntax help then I can ask a colleague who is familiar with c#

scenic lion
#

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

copper coral
#

One sec, let me ask a colleague who is familiar with c#

scenic lion
#

thank you

naive harbor
scenic lion
#

or alternatively maybe what is the call to get the customer information from the customerid

naive harbor
#

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

scenic lion
#

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

naive harbor
#

Many of our objects "reference" other objects like the Session has customer: 'cus_123' if a customer is associated with it

#

you can't do this with webhooks/events

scenic lion
#

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

naive harbor
#

correct

scenic lion
#

thanks very much, really appreciate it