#Scott-PI-webhook

1 messages · Page 1 of 1 (latest)

bronze agate
#

Hi there! Yep you would grab it via event.data.object.payment_intent from a charge.captured evenet

sharp prawn
#

For some reason I can't seem to access that level of the event

#

I am trying to access through PaymentIntentAmountCapturableUpdated

bronze agate
#

Ah sorry, that is a different event.

#

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

sharp prawn
#
        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();
            }
        }
bronze agate
#

So you would access via event.data.object.id

sharp prawn
#

Does not seem to be an id thin object

bronze agate
#

Can you log out what you see for event.data.object?

sharp prawn
#

I just had to pop out. I’ll reply shortly

bronze agate
#

No problem

sharp prawn
#

So after the object section it has a small list, maybe I need to define the object as “PaymentIntent”?

#

Like Object<PaymentIntent>().Id?

empty salmon
#

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

sharp prawn
#

we_1Kr1GvBHoAmxvHT4kVa6pRk9

empty salmon
#

Unfortunately that's the ID for the webhook itself, not a webhook event

#

Event IDs start evt_

sharp prawn
#

Apologies evt_3Kr3KpBHoAmxvHT40UCeOJ1r

empty salmon
#

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.

sharp prawn
empty salmon
#

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?

sharp prawn
#

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

empty salmon
#

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?

sharp prawn
#

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

empty salmon
#

So even when the Event.Data.Object is cast to a PI object, you still cannot access the ID?

sharp prawn
#

That’s correct

empty salmon
#

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?

sharp prawn
#

Your version of casting worked fine. I was trying to in-line cast

empty salmon
#

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.

sharp prawn
#

Thank you so much for that 🙂

empty salmon
#

Happy to do it 👍