stripe icon indicating copy to clipboard operation
stripe copied to clipboard

Changes in the webhook event object in newer API versions

Open vu3rdd opened this issue 5 years ago • 3 comments

It looks like the request property of the Event object that one gets from a webhook has changed in the newer versions of the API, resulting in an error:

Error in $.request: parsing Text failed, expected String, but encountered Object

The eventRequest has a type Maybe Text, however, one gets an object from Stripe:

...
    "livemode": false,
    "pending_webhooks": 2,
    "request": {
        "id": "req_XYZ",
        "idempotency_key": null
    },
    "type": "charge.succeeded"
...

This change happened in version 2017-05-25.

Are there any plans to support newer versions?

vu3rdd avatar Oct 23 '19 11:10 vu3rdd

Perhaps worth noting is that newly created Stripe accounts seem to use the newest Stripe API at the time of their creation and there is no option to downgrade.

exarkun avatar Oct 23 '19 12:10 exarkun

AFAIK the Events API (webhooks specifically) follow the latest stripe version, but other APIs (customers, etc.) use the version that is hard-coded in the HTTP header. So it's possible to use your own JSON decoding method just for stripe webhooks (that corresponds with the API version on your account), and this library for everything else.

dmjio avatar Oct 23 '19 13:10 dmjio

For what it's worth, it turns out you can request specific API versions for webhook payloads. You can do this either in the dashboard UI when creating webhooks or when using the API to create webhooks. If you use the dashboard, you are limited to choosing API versions at least as new as the default for your account and if that restricts your options to only one API version, the UI for choosing a version doesn't even appear. If you use the API, as far as I can tell, you can ask for any version you want.

exarkun avatar Nov 02 '22 13:11 exarkun