New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

stripe-event-types

Package Overview
Dependencies
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

stripe-event-types

TypeScript typings for Stripe webhook events

  • 3.1.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
16K
decreased by-0.71%
Maintainers
1
Weekly downloads
 
Created
Source

Stripe Event Types

npm Build

This provides TypeScript typings for Stripe webhook events to strongly type the type and data.object fields. These types are automatically generated by scraping Stripe's documentation for types of events.

Why is this needed? The typings included in the stripe library are lacking in this respect. The type for type is a string instead of a string literal and the type for data.object is {} which requires casting each usage of it. This can lead to mistakes in your implementation that could easily be caught with stronger types.

Typed Webhook Event

Installation

Install the package with:

npm install stripe-event-types
# or
yarn add stripe-event-types

Version compatability

Note If you are using stripe version 13.11 or greater, you don't need the stripe-event-types library because the typings have been added to the stripe library.

stripe-event-types versionstripe version
313.5 - 13.10
211
110

Usage

Webhook event

When constructing the webhook event, cast it to Stripe.DiscriminatedEvent to strongly type the type and data.object fields:

+/// <reference types="stripe-event-types" />

const event = stripe.webhooks.constructEvent(
  request.body,
  request.headers['stripe-signature'],
  'whsec_test'
-);
+) as Stripe.DiscriminatedEvent;

Event type

The Stripe.DiscriminatedEvent.Type type is a string literal of all event types:

/// <reference types="stripe-event-types" />

const type: Stripe.DiscriminatedEvent.Type = "charge.succeeded";

Keywords

FAQs

Package last updated on 28 Oct 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc