-
-
Notifications
You must be signed in to change notification settings - Fork 120
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Charge objects from stripe events don't deserialize due to missing "refunds" field (on api version 2022-11-15) #347
Comments
Hello! Thanks for reporting this. We recently moved from using the regular openapi spec to the sdk version, which is intended for library codegen usage, and for which the openapi differs slightly. I believe the docs are generated from the regular spec, which is why the fields is listed as optional on their docs. To verify consider these commands:
So, what is the solution? I'm not sure in this case to be honest. I think the library is wrong, but does that mean we want to abandon the sdk definition entirely? Or only use it to infer the |
Part of my problem may be that the I will try to test this with a production webhook to see if pinning the version changes the webhook payload. |
I confirmed that when I set up a "real" webhook using So this must be something that changed between api version This is likely to bite other users in the future, because Stripe's documented way of testing webhooks doesn't permit you to set an arbitrary API version; you can only use your account default or the latest. (Some stripe CLI commands do support it, but not |
Since my problem is due to an api version mismatch (compounded by a limitation in stripe-cli), should this be closed? I hope that this library will pick up the newer Stripe API version(s) at some point, but this bug ( |
Hi! I would like to leave this open for now. I think if you are encountering this, then others might and we should address it properly. Thanks for taking the time to explore (and post) workarounds. |
I suppose I'll bump this as I'm using 2020-08-27 and am seeing the JSON deserialization error when I query/retrieve a specific charge by its ID. Perhaps I'm reading this thread wrong, but should 2020-08-27 work in this case? |
@seanpianka are you explicitly setting the API version when setting up the webhook? This is what I'm doing, for example:
edit: sorry, failed to read the message correctly. If you're using e.g. The issue I described here is caused by an API mismatch when using webhooks, so perhaps we should move this new problem discussion to another issue. |
I am going to close this. Thanks for taking the time to publicize your findings. |
Describe the bug
I am testing webhook events, and find that
charge.succeeded
events don't deserialize into theCharge
struct.For example, here's a
missing field
charge.succeeded
event sent by the stripe trigger cli. If I try to deserialize the data object, I get an errorrefunds
``. But the stripe documentation for thecharge
object says that the "refunds" field is not included by default, so I'm worried that this may be a bug?To Reproduce
I encountered this while trying to get events decoding (#344) working. I have a modified version of the
Event
struct which seems to be almost working, and I am generating test events with the stripe cli, usingstripe trigger checkout.session.completed
.That's a lot of tedious setup, so maybe it would be easier to just reproduce with this test (I've extracted the "charge" field from the event shown above):
Expected behavior
If the
refunds
field is optional, then a serializedcharge
sent by stripe should deserialize successfully.Code snippets
No response
OS
Linux
Rust version
1.66.1
Library version
async-stripe v0.18.2
API version
2022-11-15
Additional context
No response
The text was updated successfully, but these errors were encountered: