Socket
Socket
Sign inDemoInstall

serverless-stripe

Package Overview
Dependencies
519
Maintainers
1
Versions
12
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    serverless-stripe

Serverless plugin for managing Stripe webhooks.


Version published
Maintainers
1
Created

Readme

Source

Serverless Stripe Plugin

This plugin is designed for the Serverless Framework. It automates the creation of Stripe webhooks and binds them to serverless functions. It also provides some basic functionality for creating products and prices to them (the focus is is to help create subscriptions that utilize those).

Steps for using this plugin:

  1. Install and configure the serverless-domain-manager plugin.

  2. Generate a Stripe API key. You'll need permissions for managing webhooks, products, customer portal and prices. Also make sure you have aws rights to put and read aws ssm parameters

  3. Modify your serverless configuration as shown below:

      custom: {
        stripe: [
          {
            accountId: 'Default',
            apiKey: 'my-stripe-api-key',
            webhooks: [
              {
                functionName: 'webhookHandler',
                events: [
                  'invoice.payment_succeeded',
                ],
                webhookSecretEnvVariableName: 'stripeWebhookSecret',
              },
            ],
            products: [
              {
                name: 'Subscription',
                internal: {
                  id: 'subscription',
                  description: 'Subscription product',
                },
                prices: [
                  {
                    id: 'price_sweden',
                    price: 9900,
                    currency: 'sek',
                    interval: 'year',
                    countryCode: 'SE',
                  },
                ],
              },
            ],
            billingPortals: [
              {
                configuration: {...}, //Stripe.BillingPortal.ConfigurationCreateParams
                internalId: 'portal2',
                envVariableName: 'customerSupportPortalId',
              },
            ],
          }
        ],
        domain: {
          // Please note these are serverless-domain-manager configurations but they're also used in this plugin
          domainName: "mydomain.com",
          basePath: "my-api",
        },
      },
    
  4. Develop the webhookHandler function. The Stripe webhook endpoint secret will be available as process.env.stripeWebhookSecret (or under whatever name you've configured in webhookSecretEnvVariableName).

  5. If you add any products, the generated Stripe product id will be accessible through environment variables, using the internal id (e.g., process.env["subscription"] in this example). The same applies to product prices (e.g., process.env["price_sweden"] for this case).

  6. Deploy your Serverless application.

You can refer to the source code provided if you're interested in the underlying implementation of this plugin.

Keywords

FAQs

Last updated on 06 Feb 2024

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc