npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

serverless-stripe

v0.1.1

Published

Serverless plugin for managing Stripe webhooks.

Downloads

27

Readme

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.