Skip to content

Commit

Permalink
updated stripe_webhook_handler with related object fetching and impro…
Browse files Browse the repository at this point in the history
…ved output
  • Loading branch information
jar-stripe committed Sep 28, 2024
1 parent d83368c commit cb0551d
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion examples/snippets/stripe_webhook_handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,11 @@ app.post(
// Fetch the event data to understand the failure
const event = await client.v2.core.events.retrieve(thinEvent.id);
if (event.type == 'v1.billing.meter.error_report_triggered') {
const meter = await event.fetchRelatedObject();
const meter = await client.billing.meters.retrieve(
event.related_object.id
);
const meterId = meter.id;
console.log(`Success! ${meterId}`);
// Record the failures and alert your team
// Add your logic here
}
Expand Down

0 comments on commit cb0551d

Please sign in to comment.