#ruin_code

1 messages ¡ Page 1 of 1 (latest)

humble zealotBOT
#

👋 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.

verbal mantle
#

hi there!

wraith moon
#

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

verbal mantle
#

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

wraith moon
verbal mantle
#

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.

wraith moon
#

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

verbal mantle
#

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.

wraith moon
#

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

verbal mantle
#

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.

wraith moon
#

and what would happened when I realease to prod?

#

some webhooks would fail?

#

and then I need to hotswap endpoint

#

on prod execution?

verbal mantle
#

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
humble zealotBOT