Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@deepkit-community/stripe

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@deepkit-community/stripe

Interacting with the Stripe API or consuming Stripe webhooks in your Deepkit applications is now easy as pie 🥧

  • 0.0.1-alpha
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
Created
Source

@deepkit-community/stripe

Interacting with the Stripe API or consuming Stripe webhooks in your Deepkit applications is now easy as pie 🥧

version downloads license

Features

  • 💉 Injectable Stripe client for interacting with the Stripe API in Controllers and Providers

  • 🎉 Optionally exposes an API endpoint from your Deepkit application at to be used for webhook event processing from Stripe. Defaults to /stripe/webhook/ but can be easily configured

  • 🔒 Automatically validates that the event payload was actually sent from Stripe using the configured webhook signing secret

  • 🕵️ Discovers providers from your application decorated with StripeWebhookHandler and routes incoming events to them

  • 🧭 Route events to logical services easily simply by providing the Stripe webhook event type

Getting Started

Install

NPM
  • Install the package along with the stripe peer dependency npm install --save @deepkit-community/stripe stripe
YARN
  • Install the package using yarn with the stripe peer dependency yarn add @deepkit-community/stripe stripe

Import

Import and add stripeModule to the imports section of the consuming module. Your Stripe API key is required, and you can optionally include a webhook configuration if you plan on consuming Stripe webhook events inside your app.

import { stripeModule } from '@deepkit-community/stripe';

Application.create({
  imports: [
    stripeModule.configure({
      apiKey: 'test',
      webhookConfig: {
        secret: STRIPE_SECRET,
      },
    }),
    ApiConsoleModule,
  ],
});

Configuration

Configuration can be provided inline as seen in the example above or using ENV variables with a prefix of stripe.

Injectable Providers

The module exposes an injectable Stripe instance that is pre-configured with your API Key based on module configuration. To inject it, use the 'Stripe' injection token:

@injectable()
class MyService {
  constructor(@inject('Stripe') private readonly stripe: Stripe) {}
}

Consuming Webhooks

Included API Endpoint

This module will automatically add a new API endpoint to your Deepkit application for processing webhooks. By default, the route for this endpoint will be stripe/webhook but you can modify this to use a different prefix using the controllerRoutePrefix and controllerRoute configuration when importing the module.

Decorate Methods For Processing Webhook Events

Exposing provider/service methods to be used for processing Stripe events is easy! Simply use the provided decorator and indicate the event type that the handler should receive.

Review the Stripe documentation for more information about the types of events available.

@injectable()
class PaymentCreatedService {
  @StripeWebhookHandler('payment_intent.created')
  handlePaymentIntentCreated(evt: StripeEvent) {
    // execute your custom business logic
  }
}

Configure Webhooks in the Stripe Dashboard

Follow the instructions from the Stripe Documentation for remaining integration steps such as testing your integration with the CLI before you go live and properly configuring the endpoint from the Stripe dashboard so that the correct events are sent to your Deepkit app.

License

MIT License

FAQs

Package last updated on 24 Aug 2021

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