#michael-1219_webhooks

1 messages · Page 1 of 1 (latest)

graceful lodgeBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

🔗 This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1301491926230634630

📝 Have more to share? Add more details, code, screenshots, videos, etc. below.

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

livid orchid
#

this is the log of server

#

hi there

#

and this is code sniping

slender gull
#

Hi
Have you tried to check what element is missing in the event payload ?

livid orchid
#

not sure acttually

slender gull
#

You need to debug your integration and check

#

what you can is to use stripe cli

#

and forward the event to your localhot and debug the event ingestions

livid orchid
#

got it

#

appriciate it, i am going to try

graceful lodgeBOT
livid orchid
#

In the stripe_events method of the PayController class, an exception (java.util.NoSuchElementException: No value present) is thrown when processing a Stripe webhook callback. Specifically, the error occurs at the line event.getDataObjectDeserializer().getObject().get(), indicating that an attempt was made to retrieve the value of an empty Optional object, which resulted in the exception.

Possible Causes

1.    Deserialization Failure: The Stripe event data may not be deserialized as expected, leading to event.getDataObjectDeserializer().getObject() returning an empty Optional. This could happen if some required fields are missing in the event data or if the data format does not match the expected structure.
2.    Missing Event Data: It’s possible that certain types of webhook events do not include a data.object field, while the code assumes that all events contain it. If Stripe sends an event without data.object, then getDataObjectDeserializer().getObject() would return an empty value.
3.    Incorrect Webhook Verification: If the webhook signature verification fails, it could lead to data parsing issues. Therefore, it’s important to ensure that the webhookSecret is correctly configured and that the webhook verification is successful.
4.    Data Structure Differences in Testing Environment: In a test environment, Stripe may return data with a different structure, causing the code to encounter an empty Optional when accessing certain fields.
iron gulch
#

Which version of the SDK are you using?

livid orchid
#

2024-06-20

#

i am not very sure about what cause this error, since I am not very familier with webhook

iron gulch
#

Looks like 26.0.0 according to logs which aligns with that API version

graceful lodgeBOT
livid orchid
#

yeah i though the api version might not be the causes of this error

iron gulch
#

My guess would be that signature verification is failing via constructEvent, generally happens for one of two reasons:

  • Event payload is malformed – constructEvent requires the raw event payload
  • Your signing secret is wrong
iron gulch
livid orchid
#

i actually not sure how to check stripe-jave version, but java-SDK in this project is 1.8

#

got you point

tidal mirage
#

you only get this error of getDataObjectDeserializer().getObject being empty if there's an API version mismatch. What version of stripe-java is your project using?

livid orchid
#

emmm, how to check the stripe-java version

tidal mirage
#

check your pom.xml perhaps

#

search for "stripe-java" in your project and find the file where you declare the dependency. etc

livid orchid
#

the version is 24

tidal mirage
#

can you share the exact version?

livid orchid
#

24.0.0

tidal mirage
#

the 'easiest' fix would be to update your code to use the latest version of the library (28.0.0) and also create a new webhook endpoint that uses the latest API version, and use that instead.

livid orchid
#

appreciate your help, i will try it

tidal mirage
#

another alternative is there is an "unsafe" function you can call to try and access the data anyway even if the API versions don't match dataObjectDeserializer.deserializeUnsafe()

livid orchid
tidal mirage
#

well the API version you use in API requests is determined by the version of stripe-java you're using.

#

in your case the best solution here is probably to create a webhook endpoint pinned to 2023-10-16 using that API call. Alternatively, upgrade your code + libraries + webhook to the lateset API version.

livid orchid
#

how could i choice the version you mentioned

#

i dont find that choice actually

tidal mirage