Skip to content

Stripe API version upgrades, checked against your code.

Stripe dates its API versions, and every request runs against one: your account's default, or the version your code sets.

Moving to a newer version can remove or reshape fields your code reads. GitGo shows you which lines before you switch.

Real output

An upgrade from 2022-08-01 to 2022-11-15.

GitGo CLI output for a small TypeScript file, on sample data based on Stripe's API. The counts are not Stripe's.

gitgo diff
$ gitgo diff stripe-2022-08-01.json stripe-2022-11-15.json
BREAKING response-property-removed GET /v1/payment_intents/{intent} · $.charges $.charges in response 200 was removed
INFO     response-required-property-added GET /v1/payment_intents/{intent} · $.latest_charge new required property $.latest_charge in response 200
BREAKING response-property-became-optional GET /v1/charges/{charge} · $.refunds $.refunds in response 200 is now optional and may be absent
BREAKING response-became-nullable GET /v1/charges/{charge} · $.refunds $.refunds in response 200 can now be null
2022-08-01 -> 2022-11-15: 8 breaking, 5 risky, 7 info; 7 operations broken
Real GitGo CLI output, shortened.
src/responses.ts4 breaking · 1 info
5export async function latestCharge(id: string) {
6 const pi = await stripe.paymentIntents.retrieve(id);
7 const chargeId = pi.charges.data[0].id;
charges removed in 2022-11-15
8 const { charges, latest_charge: latest } = await stripe.paymentIntents.retrieve(id);
charges removedlatest_charge is new
9 console.log(charges.total_count, latest);
charges removed
10 const status = (await stripe.paymentIntents.retrieve(id)).status;
11 const list = await stripe.paymentIntents.list({ limit: 3 });
12 for (const item of list.data) {
13 console.log(item.charges.url);
data[].charges removed
14 }
15 return [chargeId, status];
16}
The example file, with each line GitGo flagged.
gitgo scan
$ gitgo scan --from stripe-2022-08-01.json --to stripe-2022-11-15.json ./src
responses.ts:7:20  BREAKING $.charges was removed (GET /v1/payment_intents/{intent})
responses.ts:8:11  BREAKING $.charges was removed (GET /v1/payment_intents/{intent})
responses.ts:8:20  INFO     new required property $.latest_charge (GET /v1/payment_intents/{intent})
responses.ts:9:15  BREAKING $.charges was removed (GET /v1/payment_intents/{intent})
responses.ts:13:17 BREAKING $.data[].charges was removed (GET /v1/payment_intents)
5 impacts (4 breaking, 0 risky, 1 info) in 1 file; 6 files scanned, 0 skipped, 31 API usages; spec 2022-08-01 -> 2022-11-15
Real GitGo CLI output, messages shortened.

What GitGo checks for Stripe.

  • stripe-node calls in TypeScript and JavaScript, and stripe-python calls in Python
  • The API version each Stripe client pins
  • Response fields your code reads
  • Removed operations, fields that became optional or nullable, and new enum values

What changed in Stripe API version 2022-11-15

Two changes in this version break code that reads PaymentIntents and Charges:

  • PaymentIntent responses no longer include charges. Read latest_charge instead.
  • Charge responses no longer include refunds by default, so code that reads them must expand them.

The output on this page uses sample data, so its counts are not Stripe's.

In development

The fix will arrive as a pull request.

GitGo will write a fix for each line that breaks and open a pull request, with the replay result from your CI. You review and merge, or let GitGo merge when your checks pass.

Move Stripe API to 2022-11-15Sample pull request

gitgo-hq[bot] wants to merge 1 commit into main

Stripe removed charges from PaymentIntent responses in 2022-11-15. This reads latest_charge instead and moves the pinned version.

src/responses.tsSample
@@ -3 +3 @@
3−const stripe = new Stripe('sk_test', { apiVersion: '2022-08-01' });
3+const stripe = new Stripe('sk_test', { apiVersion: '2022-11-15' });
@@ -7,3 +7,3 @@
7− const chargeId = pi.charges.data[0].id;
8− const { charges, latest_charge: latest } = await stripe.paymentIntents.retrieve(id);
9− console.log(charges.total_count, latest);
7+ const chargeId = pi.latest_charge as string;
8+ const { latest_charge: latest } = await stripe.paymentIntents.retrieve(id);
9+ console.log(latest);
@@ -13 +13 @@
13− console.log(item.charges.url);
13+ console.log(item.latest_charge);
  • gitgo/deprecationsNo breaking usages left for 2022-11-15
  • Your CITests passed

Stripe questions.

How do I upgrade the Stripe API version safely?

Download the OpenAPI descriptions for your current version and the target version, run gitgo scan --from current.json --to target.json against your code, and fix each breaking line it reports. Then change the apiVersion your Stripe client pins. A hosted service that writes those fixes as a pull request is in development.

Which Stripe SDKs does GitGo read?

stripe-node in TypeScript and JavaScript, and stripe-python. Other languages are not scanned yet.

Upgrade the API version you have been putting off.

Run the CLI against your code, or connect a repository and let GitGo watch it.