#sadeghiamir_webhooks
1 messages ยท Page 1 of 1 (latest)
๐ 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/1278300233872445545
๐ 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.
- sadeghiamir_webhooks, 7 minutes ago, 20 messages
my java code is:
@PostMapping("/stripe/webhooks")
@ResponseStatus(HttpStatus.ACCEPTED)
public String handleStripeWebhook(@RequestBody String payload, @RequestHeader("Stripe-Signature") String sigHeader) throws Exception {
Event event = null;
try {
event = ApiResource.GSON.fromJson(payload, Event.class);
} catch (JsonSyntaxException e) {
// Invalid payload
ResponseEntity.status(HttpStatus.BAD_REQUEST).body(null);
return "";
}
if (stripeEndpointSecret != null && sigHeader != null) {
Subscription subscription = null;
try {
event = Webhook.constructEvent(
payload, sigHeader, stripeEndpointSecret
);
} catch (JsonSyntaxException e)
return "";
} catch (SignatureVerificationException e) {
return "";
}
// Deserialize the nested object inside the event
EventDataObjectDeserializer dataObjectDeserializer = event.getDataObjectDeserializer();
if (dataObjectDeserializer.getObject().isPresent()) {
subscription = (Subscription) dataObjectDeserializer.getObject().get();
} else {
// Deserialization failed, probably due to an API version mismatch.
// Refer to the Javadoc documentation on `EventDataObjectDeserializer` for
// instructions on how to handle this case, or return an error here.
log.error("deserialize failed for {} ", dataObjectDeserializer.getRawJson());
}
but this segment (if (dataObjectDeserializer.getObject().isPresent())) return false
Hi, let me help you with this.
Do you know if no other errors are thrown? Can you print the event object?
I got event but "dataObjectDeserializer.getObject().isPresent()" return false value
What do you use to print the object?
I run server in debugging mode and this event is value of debugging mode
Which version of the Java SDK are you using? https://github.com/stripe/stripe-java
<dependency>
<groupId>com.stripe</groupId>
<artifactId>stripe-java</artifactId>
<version>26.7.0</version>
</dependency>
Which line in your code returns this JSON?
I have breakpoint at this line:if (dataObjectDeserializer.getObject().isPresent())
I get this event from debugger thread & variables
Hmm this kind of issues normall signify a mismatch between the API version of the event/webhook and the SDK.
But that doesn't seem to be true here โ 26.7.0 is fixed to 2024-06-20 version which the example event you've shared was generated with
can you suggest me java sdk version and api version for resolving this issue?
I don't think that's the root cause here as the version of the SDK version you're using is locked to the same API version of the event (as noted above)
Checking with a colleague
Can you try and use the deserializeUnsafe method as outlined here?
As an example:
subscription = (Subscription) dataObjectDeserializer.deserializeUnsafe();
Also, can you make sure your in that your integration code is indeed using version 26.7.0 of the SDK? Recent requests from your account are using 25.x.x
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
That would result in the API version mismatch and the issues you're seeing. Maybe you need to re-sync Gradle?
dataObjectDeserializer.deserialize() hast this error:
eserialize()' has private access in 'com.stripe.model.EventDataObjectDeserializer'
It's deserializeUnsafe()
I upgraded today for resolving this issue
Well looking at API requests made today (like the above) I don't think it's actually upgraded the SDK version compiled in your code. You likely need to rebuild and/or resync the dependencies