#Dupelet-webhook
1 messages ยท Page 1 of 1 (latest)
WB!
@ResponseStatus(value = HttpStatus.OK)
public ResponseStatus stripeTransactionSuccess(@RequestBody Event event) {
logger.info("API version: " + event.toString());```
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
here's a good place to start https://stripe.com/docs/webhooks
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?
@RequestBody Event event
I don't think it does what you think it does
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
let me know if you need any more help
@dim fjord let's chat here
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
Catching up here, can you share a specific event type or a evt_xxx ID?
So you're using Checkout, and you want details of the line items from the session/payment?
Yes. Or basically any way for my webhook to figure out what item just got paid for
You'd be better off listening for checkout.session.completed events, and expanding the line_items field from within your webhook
Ah ok. Wrong event type then
Oh good. I missed that page
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
Thanks. I should be able to take it from there