#Scott-PI-webhook
1 messages · Page 1 of 1 (latest)
Hi there! Yep you would grab it via event.data.object.payment_intent from a charge.captured evenet
For some reason I can't seem to access that level of the event
I am trying to access through PaymentIntentAmountCapturableUpdated
Ah sorry, that is a different event.
The way you can figure this out yourself is to go to the event in the API ref. Ie: https://stripe.com/docs/api/events/types#event_types-payment_intent.amount_capturable_updated
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Then you see a little label for what type of object it is.
For that event... it is a Payment intent
If you click on that it will take you to that object
So then you can see you want the id property
public async Task<IActionResult> Index()
{
var json = await new StreamReader(HttpContext.Request.Body).ReadToEndAsync();
bool RC = false;
try
{
var _event = EventUtility.ConstructEvent(json, Request.Headers["Stripe-Signature"], WebHookSecret);
switch (_event.Type)
{
case Events.PaymentIntentAmountCapturableUpdated:
RC = await PICaptureUpdate("PI ID GOES HERE");
break;
}
return Ok();
}
catch(Exception ex)
{
return BadRequest();
}
}
So you would access via event.data.object.id
Does not seem to be an id thin object
Can you log out what you see for event.data.object?
I just had to pop out. I’ll reply shortly
No problem
So after the object section it has a small list, maybe I need to define the object as “PaymentIntent”?
Like Object<PaymentIntent>().Id?
Hi 👋 I'm stepping in for @bronze agate
Can you share an event ID for the webhook event type in question?
I just want to be looking at the same object so we are all on the same page
we_1Kr1GvBHoAmxvHT4kVa6pRk9
Unfortunately that's the ID for the webhook itself, not a webhook event
Event IDs start evt_
Apologies evt_3Kr3KpBHoAmxvHT40UCeOJ1r
Perfect, thanks
Okay so here is the request payload I see when I examine this event:
{
"id": "evt_3KrxxxxxxxxxxxxJ1r",
"object": "event",
"api_version": "2020-08-27",
"created": 1650560331,
"data": {
"object": {
"id": "pi_3KxxxxxxxxxxXE",
"object": "payment_intent",
.....
So we can see the event object contains the data.object which is the payment intent with the ID you are looking for.
Unfortunately that appears to be a code syntax issue. We can see the data.object.id does clearly exist. What code/framework are you using?
This is ASP .NET Core 5
Not sure if it’s the latest update but I’d imagine the web hook event isn’t new in the last week
Yeah, C# has lots of fun issues with casting that make it appear like the API isn't returning what we know it is returning.
Are you using the Stripe library for .NET?
Yes I am, I did a endpoint where I return the PI and I can see the details but for some reason I can’t just access the PI Id for the webhook
I tried casting the object as well but no luck
So even when the Event.Data.Object is cast to a PI object, you still cannot access the ID?
That’s correct
This is what we have in our Quickstart for .NET webhook listeners:
var paymentIntent = stripeEvent.Data.Object as PaymentIntent;
So after that you cannot access paymentIntent.id?
here's the page:
https://stripe.com/docs/webhooks/quickstart
Your version of casting worked fine. I was trying to in-line cast
Okay. Probably some other fun language/framework specific issue. I like to reference the quickstart as a gut check on implementations in different languages. I'm glad it was useful.
Thank you so much for that 🙂
Happy to do it 👍