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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@codesled/stripe-payments

v1.0.2

Published

Simple Stripe checkout integration module from CodeSled

Downloads

16

Readme

@codesled/stripe-payments

Simple, composable Stripe checkout integration for Node.js applications. Create Stripe Checkout sessions and verify webhooks with minimal setup — no boilerplate, no complexity.

Framework-agnostic and dev-first. Designed to make payments frictionless to implement.

🚀 Part of the CodeSled developer toolkit — reusable modules that help you build apps faster.


Features

  • Create Stripe Checkout sessions with one function
  • Supports both one-time and subscription payments
  • Minimal setup with secure defaults
  • Verify Stripe webhook signatures
  • Compatible with Express, Next.js, or any Node backend
  • Plug-and-play — no need to read Stripe docs
  • Now supports manual Stripe key initialization with initStripe()

Installation

npm install @codesled/stripe-payments

You must have a Stripe account and access to secret keys.


Environment Setup

Create a .env file (or set env variables) with the following:

STRIPE_SECRET_KEY=sk_test_...
STRIPE_WEBHOOK_SECRET=whsec_...

These values are found in your Stripe Dashboard.


Initialization

You must call initStripe() once before using createCheckoutSession() or verifyWebhookSignature().

Option 1 — Using .env (recommended):

require("dotenv").config();
const { initStripe } = require("@codesled/stripe-payments");

initStripe(); // uses STRIPE_SECRET_KEY from .env

Option 2 — Manual Stripe key:

const { initStripe } = require("@codesled/stripe-payments");

initStripe("sk_test_yourSecretKeyHere");

Usage Example

Creating a Checkout Session

const {
  initStripe,
  createCheckoutSession,
} = require('@codesled/stripe-payments');

initStripe(); // or pass the key manually

const sessionUrl = await createCheckoutSession({
  priceId: 'price_123',
  successUrl: 'https://yourapp.com/success',
  cancelUrl: 'https://yourapp.com/cancel',
  customerEmail: '[email protected]',
  mode: 'payment' // "payment" for one-time or "subscription" for recurring
});

console.log('Redirect to:', sessionUrl);

Verifying Webhook Events

Use in a raw body parser route (e.g. in Express or Next.js API route):

const {
  initStripe,
  verifyWebhookSignature,
} = require('@codesled/stripe-payments');

initStripe(); // or initStripe("sk_test_...")

const event = verifyWebhookSignature(req.rawBody, req.headers['stripe-signature']);

// Handle event type
if (event.type === 'checkout.session.completed') {
  const session = event.data.object;
  console.log('Checkout complete:', session.id);
}

Functions

| Function | Purpose | |----------------------------|------------------------------------------------| | initStripe() | Initializes Stripe with your secret key | | createCheckoutSession() | Generate a hosted Stripe Checkout session URL | | verifyWebhookSignature() | Validate incoming webhook using Stripe secret |


Notes

  • Supports both subscription mode and one-time mode via the mode option.
  • Requires raw body middleware for webhook validation (e.g., express.raw({ type: 'application/json' })).
  • initStripe() must be called before any other function.

Local Testing

Use Stripe CLI or Dashboard to trigger test webhooks:

stripe listen --forward-to localhost:3000/webhook

Why Use This Package?

Stripe is powerful, but overkill for simple needs. This package abstracts away Stripe’s verbose API and lets you:

  • 🚫 Avoid boilerplate
  • 🧐 Skip reading docs
  • 🧹 Reuse across all CodeSled apps

Focus on shipping — we handle the payment logic.


License

MIT — Free to use, share, and build on.


About CodeSled

CodeSled is a modular developer toolkit — reusable code blocks for core app functionality (auth, payments, CMS, and more). Build faster. Ship smarter.

Follow @codesled for updates.