#Dupelet-webhook

1 messages ยท Page 1 of 1 (latest)

heady oriole
#

๐Ÿ‘‹ happy to help on this other topic as well ๐Ÿ™‚

dim fjord
#

WB!

heady oriole
#

let me take a look

#

could you share your code snippet please?

dim fjord
#
    @ResponseStatus(value = HttpStatus.OK)
    public ResponseStatus stripeTransactionSuccess(@RequestBody Event event)  {
        logger.info("API version: " + event.toString());```
heady oriole
#

you need to construct the Event from the json body

#

in order to do that, it really depends on the framework and language you're using

dim fjord
#

Yeah, I'm on Java Spring Boot.
(@RequestBody Event event)
This is the line that's supposed to be taking the body and creating the Event

#

The next line event.toString() is printing out the Event object I just created, so I think it's going right so far

#

What does a normal event.toString() output look like?

heady oriole
#

@RequestBody Event event
I don't think it does what you think it does

dim fjord
#
        Event event = ApiResource.GSON.fromJson(payload, Event.class);

Ok, this gave me a more complete event object. I'm puzzled how the constructor managed to create half an event without choking, but oh well

heady oriole
#

let me know if you need any more help

small sorrel
#

@dim fjord let's chat here

dim fjord
#

Again on webhooks. How do I determine what item the customer paid for from the Event? Too many fields, I'm suffering from information overload

small sorrel
#

Catching up here, can you share a specific event type or a evt_xxx ID?

dim fjord
#

Event type would be payment_intent.succeeded

#

evt_3LIW37JZh6D0wx5Z01VMSxUv

small sorrel
#

So you're using Checkout, and you want details of the line items from the session/payment?

dim fjord
#

Yes. Or basically any way for my webhook to figure out what item just got paid for

small sorrel
#

You'd be better off listening for checkout.session.completed events, and expanding the line_items field from within your webhook

dim fjord
#

Ah ok. Wrong event type then

small sorrel
dim fjord
#

Oh good. I missed that page

small sorrel
#

The event payload won't contain the line_items field, so you'll need to make an additional request to retrieve the Checkout Session and expand that field

dim fjord
#

Thanks. I should be able to take it from there