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 🙏

© 2026 – Pkg Stats / Ryan Hefner

strapi5-plugin-for-stripe

v1.0.3

Published

Accept Stripe Payments with Strapi 5

Readme

A Strapi 5 plugin to manage Stripe products and subscriptions directly from the admin panel, and provide a simple front-end checkout integration via a ready-to-use JavaScript snippet.

📚 Table of Contents

🚀 Installation

  1. Copy the plugin into your Strapi project:
npm i strapi5-plugin-for-stripe

or

yarn add strapi5-plugin-for-stripe
  1. Restart Strapi:
yarn develop

💡 Environment Variables (.env)

To use the Strapi Stripe plugin, you need to configure some environment variables in your Strapi project .env file. These variables allow the plugin to connect to your Stripe account securely.

Required Variables

| Variable | Description | | ---------------------------------------- | ----------------------------------------------------------------------------------------- | | STRAPI_ADMIN_TEST_STRIPE_SECRET_KEY | Your Stripe Test Secret Key. Used when the plugin is in test mode. | | STRAPI_ADMIN_LIVE_STRIPE_SECRET_KEY | Your Stripe Live Secret Key. Used when the plugin is in live mode. | | STRAPI_ADMIN_STRIPE_WEBHOOK_SECRET_KEY | Your Stripe Webhook Secret. Needed if you are using Stripe webhooks to handle events. |

Example .env file

STRAPI_ADMIN_TEST_STRIPE_SECRET_KEY=sk_test_XXXXXXXXXXXXXXXXXXXXXXXX
STRAPI_ADMIN_LIVE_STRIPE_SECRET_KEY=sk_live_XXXXXXXXXXXXXXXXXXXXXXXX
STRAPI_ADMIN_STRIPE_WEBHOOK_SECRET_KEY=whsec_XXXXXXXXXXXXXXXXXXXXXXXX

🪝 Webhooks (Signature Verification)

This plugin can receive Stripe webhook events, verify the Stripe signature, and forward the authenticated event payload to your external API (your business logic stays outside the plugin).

✅ The plugin does not process Stripe events internally.
It only authenticates the event (signature check) and then forwards it.

🧱 1) Enable raw body support in Strapi

Stripe signature verification requires the raw request body.
If Strapi parses the body first, verification will fail.

Edit your Strapi project middleware config:

config/middlewares.js

{
  name: "strapi::body",
  config: {
    includeUnparsed: true,
  },
},

Then restart Strapi.

❌ Without this, Stripe verification will fail (invalid signature).

🔗 2) Stripe Webhook Endpoint URL

When you create the webhook in Stripe, Stripe needs an Endpoint URL (a public URL that Stripe can call).

In production, it should be your Strapi webhook route, for example: https://your-backend.com/api/strapi5-plugin-for-stripe/webhook

In local development, Stripe cannot call localhost directly. Use Stripe CLI instead (see below).

🔐 3) Create a Webhook endpoint in Stripe (to get the webhook secret)

  1. Open the Stripe Dashboard (Test or Live mode depending on your environment)

  2. Go to Developers → Webhooks

  3. Click Add endpoint

  4. Select the events you want to receive (minimum recommended):

    • checkout.session.completed

    Depending on your use-case (subscriptions), you may also want:

    • invoice.paid
    • customer.subscription.deleted
    • customer.subscription.created
    • customer.subscription.updated
  5. Enter your Endpoint URL

  6. Click Add endpoint

  7. Open the created endpoint → find Signing secret

  8. Click Reveal and copy the value (starting with whsec_...)

You can now paste this value to your .env file

🧪 4) Local development (no public URL)

Stripe can’t reach localhost from the internet. Use the Stripe CLI to forward events to your local Strapi server:

stripe login
stripe listen --forward-to localhost:1337/api/strapi5-plugin-for-stripe/webhook

The CLI will display a temporary signing secret: Your webhook signing secret is whsec_...

Use that value in your .env during local development: STRAPI_ADMIN_STRIPE_WEBHOOK_SECRET_KEY=whsec_FROM_STRIPE_CLI

⚠️ The Stripe CLI signing secret changes every time you restart stripe listen.

⚙️ Configuration

Go to Admin Panel → Plugins → Stripe Settings and configure:

  • Environment: test or live
  • Currency: EUR, USD, GBP or CAD
  • Webhook forward URL: Securly forward webhook events to a given URL
  • Success URL: Redirect after successful payment
  • Cancel URL: Redirect if payment is canceled

Save the settings once configured.

If you want to configure the allowed payment methods, you can do it directly in the Stripe Dashboard, by going to Settings → Payments → Payment methods.

📦 Managing Products

The plugin allows you to manage Stripe products directly from the admin UI.

Supported product types

  • ✅ One-time payments
  • 🔁 Subscriptions

Available fields

  • Name
  • Price (entered in main currency unit)
  • Payment Type
  • Interval (subscriptions only)
  • Trial period (subscriptions only / optional)

Important Stripe behavior

Stripe prices are immutable. If you change the price or subscription interval, the plugin automatically:

  • Creates a new price
  • Deactivates the old one

This is handled transparently.

🧑‍💻 Embed Payment Button Code

After creating a product in the Stripe plugin, click on the Embed Code icon next to the product.

A modal will open with a ready-to-use integration snippet and clear instructions to help you add a payment button to your website.

To integrate the payment button:

  • Copy the provided JavaScript snippet and paste it into your page.
  • Add the payment button HTML to your product listing page.
  • Configure the button using data-* attributes (price ID, customer email, metadata, etc.).
  • Customize the button label (for example: Buy Now, Pay Now) and style it using your own CSS.

The product listing page is the page where your products are displayed and where customers can start the checkout process by clicking the payment button.

📝 License

This plugin is licensed under the MIT license. See the COPYING file for details.

©2026 Maxime Hamou