question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Document Webhook Object Deserialization in Migration Guide

See original GitHub issue

In 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:closed
  • Created 5 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
mickjermsurawong-stripecommented, Mar 21, 2019

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 😃

0reactions
mickjermsurawong-stripecommented, Mar 20, 2019

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 of Webhook for the reason that event class also supports retrieving from /v1/events endpoint as well.

Read more comments on GitHub >

github_iconTop 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 >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found