#daan-webhook-go
1 messages ยท Page 1 of 1 (latest)
Hi, taking a look here
Ok, getting this error: Received event with API version 2020-08-27, but stripe-go 74.12.0 expects API version 2022-11-15.
But i only see an option for setting a version when using Add an endpoint and not in Test in local environments
I'm unsure if the above two are related to each other. You're trying to confirm how you'd pass a specific API version on testing webhook with stripe CLI right?
I'm trying to test this on my end, please give me a few moments.
That's okay ๐
Can you try this?
stripe trigger checkout.session.completed --api-version 2019-09-09
you can chance the event to whatever you'd like to listen to
Do I need to do this for every event type?
yes
and i probably need to change it to 2020-08-27 right? Because is just upgraded my sdk to the newest version
Yeap!
Ok, ran the commands. I'll need a minute to test.
I'm still getting the same error unfortunately
Ah, you're on stripe-go 74.12.0
Yes
I ran: ./stripe trigger payment_intent.succeeded --api-version 2022-11-15
Maybe change my secret key?
I'm getting help as I do not know much about go
๐
daan-webhook-go
stripe-go is pinned to a specific API version because it's a statically typed library. Basically we have typed classes for every API resources/parameters.
So if you get the Event with version A but your library expects version B, the deserialization could crash. Imagine a property that is a boolean now but was a string before
So what you need to do as a developer is make sure that you receive Events formatted with the same API version as your library.
Yeah, but how do i change the version?
The way you do this is that you configure your webhook endpoint to be pinned to the right/correct API version, usually you do this with code by creating the WebhookEndpoint and setting the api_version parameter: https://stripe.com/docs/api/webhook_endpoints/object#webhook_endpoint_object-api_version
The "problem" you have is that you use the CLI and it defaults to whatever is the version in your account which is a bit annoying
What I usually do is I use a separate test account that I put on the latest API version that way it's easier
otherwise you can use ngrok or similar https://ngrok.com/ to forward real Events to your local server (what the CLI does)
Isn't there a way to change the API version of my account? otherwise I have to redo a lot of configuration.
With the CLI what you can do is https://stripe.com/docs/cli/listen#listen-latest
I'm still in the testing stage so it's not going to break stuff
I mean you can change the default API version but that will affect prodcuction
but yeah if you're just testing on that account and nothing else that's totally easier
I'm not in production with this account
go to https://dashboard.stripe.com/developers and at the bottom you can upgrade to the latest API version
Ahh alright, thanks for the help!
that's what my UI says, see the upgrade in the top right? that's what you need to click
It say's upgrade is not available in test mode
yeah you have to look at the Live mode one