Skip to content

Conversation

julienbourdeau
Copy link
Contributor

@julienbourdeau julienbourdeau commented Mar 6, 2025

Context

The version of the Stripe can be set in your Stripe account or passed in each requests. Versions are date strings with optional tags.

Note that the API version is unrelated to the version of the gem. FYI we use 6.5.0, latests version is 13.5.0.

With Lago, each customer use their own Stripe account which my use any version by default. We don't set the version explicitly but fortunately we use very stable features and our calls work in all version.

We intend to save the payment method information when we receive the payment_intent.succeeded but for the first time, we experienced the difference between webhook versions. The charges array was removed:

Overview

Our current version is 2020-08-27. We will upgrade to 2025-04-30.basil.

The version is set in the client during Rails boot so the client will set it explicitly for all requests.

Stripe.api_version = "2025-04-30.basil"

https://docs.stripe.com/changelog/basil

Webhooks

You cannot update the api_version of an existing WebhookEndpoint. You must create a new WebhookEndpoint with the new version and delete the old one once you migrated. This is actually the best way to not have any downtime.

https://docs.stripe.com/webhooks/versioning

It means to set the version for all our customers, we'll need to recreate the endpoint for all organization. It's fine but before we upgrade the endpoint, we should move to a more recent version. We'll need to keep the fixtures virtually forever for the same reason we keep migrations.

See #3718

The Plan

Other related PRs

vincent-pochet
vincent-pochet previously approved these changes Mar 6, 2025
@julienbourdeau julienbourdeau force-pushed the feat/stripe-version branch 2 times, most recently from e603a04 to 5113764 Compare May 26, 2025 10:12
julienbourdeau added a commit that referenced this pull request May 26, 2025
## Context

This PR is part of [upgrading
Stripe](#3300) (clients + API
version).

## Description

This is extracted from #3300. 

**You cannot update the `api_version` of an existing WebhookEndpoint**.
You must create a new WebhookEndpoint with the new version and delete
the old one once you migrated. This is the best way to not have any
downtime.

https://docs.stripe.com/webhooks/versioning

It means to set the version for all our customers, we'll need to
recreate the endpoint for all organization. It's fine but I'd rather
upgrade to a more recent version before we enforce it in the webhook.

* Replace `PaymentProviders::StripeService.new.refresh_webhook` by
dedicated `RefreshWebhookService`
* Tried to make `PaymentProviders::StripeService.create_or_update` a
little clearer as secrets cannot be updated
@julienbourdeau julienbourdeau self-assigned this Jun 9, 2025
@julienbourdeau julienbourdeau marked this pull request as draft June 9, 2025 09:10
@julienbourdeau julienbourdeau changed the title feat(stripe): Introduce Stripe version feat(stripe): Upgrading Stripe version Jun 9, 2025
julienbourdeau added a commit that referenced this pull request Jun 9, 2025
## Context

See #3300

## Description

When upgrading stripe versions, your app will continue to receive older
version of the webhook for while (exactly like when running rails db
migrations) so all modifications made to webhooks processing need to be
backward compatible.

We run tests with all versions to ensure compat'.

**Make sure you hide whitespace to review!**

![CleanShot 2025-06-09 at 11 07
07@2x](https://github.com/user-attachments/assets/ff46f79c-1ddd-4f13-8e9b-d870de7b9b7d)
rsempe pushed a commit that referenced this pull request Jun 11, 2025
## Context

See #3300

## Description

When upgrading stripe versions, your app will continue to receive older
version of the webhook for while (exactly like when running rails db
migrations) so all modifications made to webhooks processing need to be
backward compatible.

We run tests with all versions to ensure compat'.

**Make sure you hide whitespace to review!**

![CleanShot 2025-06-09 at 11 07
07@2x](https://github.com/user-attachments/assets/ff46f79c-1ddd-4f13-8e9b-d870de7b9b7d)
julienbourdeau added a commit that referenced this pull request Jun 24, 2025
## Roadmap Task

👉  https://getlago.canny.io/feature-requests/p/{{FEATURE_SLUG}}

## Context

Everything you need to know:
#3300

## Description

From now on, all Stripe API calls made by lago will be made using the
API version `2025-04-30.basil`.

Lago users can continue to use Stripe in any versions they like on their
side. They can keep their stripe account configured with any version
too.

Until now, Lago would use the user's account version, which could lead
to different response shape, breaking the code. It never did yet because
we use very core and simple feature of Stripe, but it could in the
future.
diegocharles pushed a commit that referenced this pull request Jul 11, 2025
## Roadmap Task

👉  https://getlago.canny.io/feature-requests/p/{{FEATURE_SLUG}}

## Context

Everything you need to know:
#3300

## Description

From now on, all Stripe API calls made by lago will be made using the
API version `2025-04-30.basil`.

Lago users can continue to use Stripe in any versions they like on their
side. They can keep their stripe account configured with any version
too.

Until now, Lago would use the user's account version, which could lead
to different response shape, breaking the code. It never did yet because
we use very core and simple feature of Stripe, but it could in the
future.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants