#ruin_code
1 messages ¡ Page 1 of 1 (latest)
đ Welcome to your new thread!
â˛ď¸ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).
âąď¸ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1251150813376544770
đ Have more to share? Add details, code, screenshots, videos, etc. below.
hi there!
hi
I'll share some logs, so you get more info
ahh it is too big, give me sec to lean it out
[Jun 14 14:16:23.538] INFO [rest/log.go:50] invalid webhook signature {"request_id": "867d2f51-c124-43be-ae9b-88be6a789538", "httpRequest": {"requestMethod": "POST", "requestUrl": "/api/v1/stripe/webhook", "requestSize": "6658", "status": 400, "responseSize": "121", "userAgent": "Stripe/1.0 (+https://stripe.com/docs/webhooks)", "remoteIp": "::1", "serverIp": "localhost:8003", "referer": "", "latency": "1.026625ms", "cacheLookup": false, "cacheHit": false, "cacheValidatedWithOriginServer": false, "protocol": "HTTP/1.1"}, "curl": "LEANED_OUT", "error": {"slug": "invalid_request", "message": "invalid webhook signature", "code": 400, "user_message": "Bad request input parameters", "type": {"slug": "invalid_request", "core": true}, "internal": "Received event with API version 2020-08-27, but stripe-go 76.20.0 expects API version 2023-10-16. We recommend that you create a WebhookEndpoint with this API version. Otherwise, you can disable this error by using `ConstructEventWithOptions(..., ConstructEventOptions{..., ignoreAPIVersionMismatch: true})` but be wary that objects may be incorrectly deserialized."}}
the code worked and it is in production with 72 version
the error is pretty clear:
"Received event with API version 2020-08-27, but stripe-go 76.20.0 expects API version 2023-10-16. We recommend that you create a WebhookEndpoint with this API version
so you need to create a new webhook endpoint with API version 2023-10-16, and then use that to send events to your server.
this is in local env, how can I do that?
I assumed it is automatic?
Also, I don't want to upgrade PROD and would love if multiple API versions can be active because of interoperability during deploy so we don't lose webhooks
I assumed it is automatic?
what is automatic? if you upgrade the version of a strongly typed stripe library, you also need to upgrade the webhook endpoint sending you events
if you are doing this in test mode, then you should create the new webhook endpoint in test mode.
I use this command:
stripe listen --forward-to localhost:8003/api/v1/stripe/webhook
should version be automatic
there is no way to choose version of stripe api via cli
so i assumed it is automatic
only when I "ADD" endpoint, i can choose the api
but that would not work for local development as I don't have static ip address
and would need some request forwarding solution (like ngrok) but would rather use stripe listen
there is no way to choose version of stripe api via cli
true, the only thing you could set is the--lastestflag to use the latest available version https://docs.stripe.com/cli/listen#listen-latest
and would need some request forwarding solution (like ngrok) but would rather use stripe listen
yes I would recommend using ngrok or similar, and then use that URL when creating a new webhook endpoint with the correct API version set.
and what would happened when I realease to prod?
some webhooks would fail?
and then I need to hotswap endpoint
on prod execution?
updating webhook endpoints for strongly typed library is a bit tricky. basically:
- you need two webhook endpoints, one on the old API version, one on the new version. and both endpoints are sending event to the same URL, however add a query parameter so that your code can distinguish between the two
- update your code (on the old api version) to process events sent from the old webhook endpoint and ignore events sent from the new webhook endpoint
- then update your library, and this time ignore events sent from the old webhook endpoint and process events sent from the new webhook endpoint