Document Webhook Object Deserialization in Migration Guide
See original GitHub issueIn v7 the charge object (assuming I’ve check that the event type should have a charge object) in a webook could be obtained via.
Event event = Webhook.constructEvent(payload, signature, secret);
Charge charge = (Charge) event.getData().getObject();
The getObject however is now deprecated. It would appear that the correct call is now
Charge charge = (Charge) event.getDataObjectDeserializer().getObject();
This should be documented in the migration guide as well as I don’t see a test deserializing an object from a webhook. It would be helpful if there was a test that constructed the webhook Event from signature and payload. Checked the event type and then deserialized it.
Event event = Webhook.constructEvent(payload, signature, secret);
if (event.getType().equals(STRIPE_EVENT_CHARGE_SUCCEEDED)) {
Charge charge = (Charge) event.getDataObjectDeserializer().getObject();
doSomething(charge);
}
https://github.com/stripe/stripe-java/blob/master/src/test/java/com/stripe/net/WebhookTest.java
Issue Analytics
- State:
- Created 5 years ago
- Comments:6 (6 by maintainers)
Top Results From Across the Web
event.getDataObjectDeserializer().getObject.isPresent ...
Hi there,. I've been using the EventDataObjectSerializer pattern from the Java code examples in the Stripe webhook documentation (e.g. https://stripe.com ...
Read more >Azure Event Grid client library for .NET - Microsoft Learn
Deserializing event data From here, one can access the event data by deserializing to a specific type by calling ToObjectFromJson<T>() on the ...
Read more >Webhooks - Nautobot Documentation - To the Core Docs!
data - A serialized representation of the object after the change was made. This is typically equivalent to the model's representation in Nautobot's...
Read more >Dynamic Admission Control | Kubernetes
Mutating admission webhooks are invoked first, and can modify objects sent to the API server to enforce custom defaults. After all object ......
Read more >Webhook migration guide - 8x8 Developer
The Webhook configuration API is available for SMS and for Chat Apps. This allows you to manage your webhooks and to receive the...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
hi @codylerum! 8.0.2 is released, adding the test and java doc to reflect migration guide–also updated. (8.0.1 is an accidental release with no actual change) I’m closing this issue now, but please let me know if i’m still missing something else in this major version release. Thank you again for your contribution 😃
Glad to hear that you were able to able upgrade to v8 successfully! And thank you for the feedback so far.
I made 2 PRs, cc you both, to add documentations to both source code and the migration update guide, and also a test on
Event
class itself instead ofWebhook
for the reason that event class also supports retrieving from/v1/events
endpoint as well.