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

opengig-stripe

v1.0.3

Published

A wrapper for Stripe payment services with support for checkout and payment intents

Downloads

30

Readme

Stripe Payment Wrapper

A TypeScript wrapper for Stripe payment services that simplifies working with Checkout Sessions and Payment Intents.

Features

  • 🛒 Easy-to-use Stripe Checkout session creation
  • 💳 Simplified Payment Intent management
  • 🔒 Type-safe interfaces
  • 💰 Support for subscriptions and one-time payments
  • 🌐 Currency customization
  • 📦 Metadata support

Installation

npm install stripe-payment-wrapper

Quick Start

import { createStripeClient } from 'stripe-payment-wrapper';

const stripe = createStripeClient('your_stripe_secret_key');

// Create a checkout session
const checkoutSession = await stripe.checkout.createPaymentSession({
  priceId: 'price_H5ggYwtDq4fbrJ',
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel'
});

// Create a payment intent
const paymentIntent = await stripe.paymentIntent.create({
  amount: 2000, // $20.00
  currency: 'usd'
});

Usage Examples

Checkout Sessions

Create a Subscription Checkout

const session = await stripe.checkout.createPaymentSession({
  priceId: 'price_H5ggYwtDq4fbrJ',
  customerId: 'cus_123456',
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel',
  mode: 'subscription',
  quantity: 1,
  metadata: {
    orderId: '6735'
  }
});

Create a One-Time Payment Checkout

const session = await stripe.checkout.createOneTimePaymentSession({
  amount: 2000, // $20.00
  currency: 'usd',
  successUrl: 'https://example.com/success',
  cancelUrl: 'https://example.com/cancel',
  metadata: {
    orderId: '6735'
  }
});

Payment Intents

Create a Payment Intent

const intent = await stripe.paymentIntent.create({
  amount: 2000, // $20.00
  currency: 'usd',
  customerId: 'cus_123456',
  metadata: {
    orderId: '6735'
  }
});

Confirm a Payment Intent

const confirmedIntent = await stripe.paymentIntent.confirm(
  'pi_123456',
  'pm_123456'
);

Retrieve a Payment Intent

const intent = await stripe.paymentIntent.retrieve('pi_123456');

Update a Payment Intent

const updatedIntent = await stripe.paymentIntent.update('pi_123456', {
  metadata: {
    status: 'processed'
  }
});

Cancel a Payment Intent

const cancelledIntent = await stripe.paymentIntent.cancel('pi_123456');

API Reference

StripeCheckout

createPaymentSession(options)

  • priceId: string - Stripe Price ID
  • customerId?: string - Optional Stripe Customer ID
  • successUrl: string - URL to redirect after successful payment
  • cancelUrl: string - URL to redirect after cancelled payment
  • mode?: 'subscription' | 'payment' (default: 'subscription')
  • quantity?: number (default: 1)
  • metadata?: Record<string, string>

createOneTimePaymentSession(options)

  • amount: number - Amount in cents
  • currency?: string (default: 'usd')
  • successUrl: string
  • cancelUrl: string
  • metadata?: Record<string, string>

StripePaymentIntent

create(options)

  • amount: number - Amount in dollars
  • currency?: string (default: 'usd')
  • customerId?: string
  • metadata?: Record<string, string>

confirm(paymentIntentId, paymentMethodId?)

  • paymentIntentId: string
  • paymentMethodId?: string

retrieve(paymentIntentId)

  • paymentIntentId: string

update(paymentIntentId, data)

  • paymentIntentId: string
  • data: any

cancel(paymentIntentId)

  • paymentIntentId: string

Error Handling

try {
  const session = await stripe.checkout.createPaymentSession({
    // options
  });
} catch (error) {
  if (error instanceof Error) {
    console.error('Error:', error.message);
  }
}

Best Practices

  1. Environment Variables: Store your Stripe secret key in environment variables
  2. Error Handling: Always implement proper error handling
  3. Webhooks: Set up webhooks to handle asynchronous events
  4. Testing: Use Stripe's test mode keys for development
  5. Currency: Always specify amounts in the smallest currency unit (cents for USD)

Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

License

MIT License - see LICENSE file for details