Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
6ea2e2d
Bump version to 19.1.0
jar-stripe Oct 3, 2025
45f7983
Merge upstream and update generated code for v2039 and
stripe-openapi[bot] Oct 3, 2025
abcdb46
Update generated code for v2040 and
stripe-openapi[bot] Oct 6, 2025
b234624
Update generated code for v2041 and
stripe-openapi[bot] Oct 6, 2025
00f0442
Improve event notification example (#2454)
xavdid-stripe Oct 6, 2025
9c6637d
Merge upstream and update generated code for v2041 and
stripe-openapi[bot] Oct 6, 2025
0e959d4
Update generated code for v2042 and
stripe-openapi[bot] Oct 6, 2025
98f898f
Update generated code for v2043 and
stripe-openapi[bot] Oct 7, 2025
e1a23a7
Update generated code for v2045 and
stripe-openapi[bot] Oct 7, 2025
bab7a69
Update generated code for v2046 and
stripe-openapi[bot] Oct 7, 2025
bfbdcd2
Update generated code for v2048 and
stripe-openapi[bot] Oct 8, 2025
217aaee
Update generated code for v2049 and
stripe-openapi[bot] Oct 9, 2025
7cab54d
Update generated code for v2051 and
stripe-openapi[bot] Oct 9, 2025
2c57d93
Update generated code for v2052 and
stripe-openapi[bot] Oct 9, 2025
00e8705
Update generated code for v2053 and
stripe-openapi[bot] Oct 9, 2025
683f308
Update generated code for v2054 and
stripe-openapi[bot] Oct 9, 2025
864a911
Update generated code for v2055 and
stripe-openapi[bot] Oct 10, 2025
da28b33
Update generated code for v2056 and
stripe-openapi[bot] Oct 10, 2025
6f66f23
Update generated code for v2057 and
stripe-openapi[bot] Oct 10, 2025
f735995
Update generated code for v2062 and
stripe-openapi[bot] Oct 13, 2025
3906dc1
Update generated code for v2065 and
stripe-openapi[bot] Oct 13, 2025
a15782c
Update generated code for v2066 and
stripe-openapi[bot] Oct 13, 2025
0efe4f5
Update generated code for v2067 and
stripe-openapi[bot] Oct 14, 2025
1da3c7a
Update generated code for v2073 and
stripe-openapi[bot] Oct 15, 2025
afc3df8
Update generated code for v2074 and
stripe-openapi[bot] Oct 15, 2025
9645a65
Update generated code for v2076 and
stripe-openapi[bot] Oct 16, 2025
78c6541
Update generated code for v2077 and
stripe-openapi[bot] Oct 16, 2025
e98c164
Update generated code for v2082 and
stripe-openapi[bot] Oct 17, 2025
7a17742
Update generated code for v2083 and
stripe-openapi[bot] Oct 17, 2025
0594a04
Update generated code for v2085 and
stripe-openapi[bot] Oct 17, 2025
6511d4e
Update generated code for v2086 and
stripe-openapi[bot] Oct 17, 2025
9e79a14
Update generated code for v2088 and
stripe-openapi[bot] Oct 18, 2025
6c8e40f
Update generated code for v2089 and
stripe-openapi[bot] Oct 20, 2025
46ec154
Update generated code for v2091 and
stripe-openapi[bot] Oct 20, 2025
102d1be
Update generated code for v2092 and
stripe-openapi[bot] Oct 21, 2025
84dd27c
Update generated code for v2094 and
stripe-openapi[bot] Oct 22, 2025
15a9651
Update generated code for v2095 and
stripe-openapi[bot] Oct 22, 2025
6cc4a13
Update generated code for v2096 and
stripe-openapi[bot] Oct 22, 2025
0ecc3d8
Update generated code for v2097 and
stripe-openapi[bot] Oct 22, 2025
10916c1
Update generated code for v2098 and
stripe-openapi[bot] Oct 22, 2025
bdee6af
Update generated code for v2099 and
stripe-openapi[bot] Oct 22, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion API_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2025-09-30.preview
577fcb57736b925392ea563c0284df9002c75ac9
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,14 @@
## 19.2.0-beta.1 - 2025-10-03
* Contains bug fixes and improvements from [v19.1.0](https://github.com/stripe/stripe-node/blob/master/CHANGELOG.md#1910---2025-10-03).

## 19.1.0 - 2025-10-03
* [#2453](https://github.com/stripe/stripe-node/pull/2453) add missing fetchEvent type for UnknownEventNotification

- Add missing `fetchEvent()` declaration to the `Stripe.Events.UnknownEventNotification` interface
- Tweak `Stripe.Events.fetchRelatedObject` so that it's always defined and returns `null` if there's no `related_object`. This fixes the situation where the `UnknownEventNotification` says that `fetchRelatedObject()` is defined, but calling it throws an error.
* [#2447](https://github.com/stripe/stripe-node/pull/2447) Update param in deprecation docs link
* [#2444](https://github.com/stripe/stripe-node/pull/2444) Update CHANGELOG.md to point to right API version

## 19.1.0-beta.1 - 2025-09-30
This release changes the pinned API version to `2025-09-30.preview`. It is built on top of SDK version 19.0.0 which contains breaking changes. Please review the [changelog for 19.0.0](https://github.com/stripe/stripe-go/blob/master/CHANGELOG.md#1900---2025-09-30) if upgrading from older SDK versions.

Expand Down
2 changes: 1 addition & 1 deletion OPENAPI_VERSION
Original file line number Diff line number Diff line change
@@ -1 +1 @@
v2028
v2099
56 changes: 0 additions & 56 deletions examples/snippets/event_notification_webhook_handler.js

This file was deleted.

95 changes: 95 additions & 0 deletions examples/snippets/event_notification_webhook_handler.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/**
* event_notification_webhook_handler.ts - receive and process event notifications like the
* v1.billing.meter.error_report_triggered event.
* In this example, we:
* - create a Stripe client object called client
* - use client.parseEventNotification to parse the received event notification webhook body
* - call client.v2.core.events.retrieve to retrieve the full event object
* - if it is a v1.billing.meter.error_report_triggered event type, call
* event.fetchRelatedObject to retrieve the Billing Meter object associated
* with the event.
* - if it is a v1.billing.meter.no_meter_found event type, just log the event
* - if it is an unknown event type, cast to Stripe.Events.UnknownEventNotification
* and log that we received an unknown event type.
*/

import {Stripe} from 'stripe';
import express from 'express';

const app = express();

const apiKey = process.env.STRIPE_API_KEY ?? '';
const webhookSecret = process.env.WEBHOOK_SECRET ?? '';

const client = new Stripe(apiKey);

app.post(
'/webhook',
express.raw({type: 'application/json'}),
async (req, res) => {
const sig = req.headers['stripe-signature'] ?? '';

try {
const eventNotification = client.parseEventNotification(
req.body,
sig,
webhookSecret
);

// TS will narrow event based on the `type` property
if (eventNotification.type == 'v1.billing.meter.error_report_triggered') {
// this this block, eventNotification is correctly
// a Stripe.Events.V1BillingMeterErrorReportTriggeredEventNotification

// there's basic info about the related object in the notification
console.log(
`Meter w/ id ${eventNotification.related_object.id} had a problem`
);

// or you can fetch the full object from the API for more details
const meter = await eventNotification.fetchRelatedObject();
console.log(`Meter ${meter.display_name} (${meter.id}) had a problem`);

// And you can always fetch the full event:
const event = await eventNotification.fetchEvent();
console.log(`More info: ${event.data.developer_message_summary}`);
} else if (eventNotification.type === 'v1.billing.meter.no_meter_found') {
// in this block, eventNotification is correctly
// a Stripe.Events.V1BillingMeterNoMeterFoundEventNotification

// that interface doesn't define `fetchRelatedObject()` because the event
// has no related object. so this line would correctly give a type error:
// eventNotification.fetchRelatedObject();

// but fetching the event always works:
const event = await eventNotification.fetchEvent();
console.log(
`Err: No meter found: ${event.data.developer_message_summary}`
);
// Events that were introduced after this SDK version release are
// represented as `UnknownEventNotification`s.
// They're valid, the SDK just doesn't have corresponding classes for them.
// In that case, you ignore the type mismatch and cast to UnknownEventNotification
// @ts-expect-error
} else if (eventNotification.type === 'some.new.event') {
const unknownEvent = eventNotification as Stripe.Events.UnknownEventNotification;

// you can still fetch the related object, if one exists
// but its type is `unknown`
const obj = await unknownEvent.fetchRelatedObject();

// and you can still fetch the event:
const event = await unknownEvent.fetchEvent();
// @ts-expect-error
console.log(`Got new event: ${event.data}`);
}

res.sendStatus(200);
} catch (err) {
console.log(`Webhook Error: ${(err as any).stack}`);
res.status(400).send(`Webhook Error: ${(err as any).message}`);
}
}
);

app.listen(4242, () => console.log('Running on port 4242'));
Loading
Loading