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

simple-js-payment-system

v1.1.5

Published

Simple payment modal system with Stripe integration

Readme

Payment System

A lightweight, customizable payment modal system with Stripe integration that supports both direct invocation and visit-count based triggers.

Payment System Demo

Features

  • 🎨 Customizable modal design and text
  • 💳 Stripe payment integration
  • 🔄 Visit count based triggers
  • 📱 Device-specific payment tracking
  • 📊 Analytics integration (Google Analytics & Plausible)

Quick Start

<!-- Include Stripe.js -->
<script src="https://js.stripe.com/v3/"></script>
<!-- Include Payment System -->
<script src="https://unpkg.com/[email protected]/payment.js"></script>

<script>
new PaymentSystem()
    .minVisitCount(5)
    .discardVisitCount(1)
    .stripeConfig({
        test: {
            publishableKey: 'your_test_key',
            priceId: 'your_test_price_id'
        },
        live: {
            publishableKey: 'your_live_key',
            priceId: 'your_live_price_id'
        }
    })
    .isLive(true)
    .run();
</script>

Usage Examples

Direct Button Trigger

Create a button that shows the payment modal when clicked:

<button onclick="_PaymentSystem.showModalIfNotPaid()">
    Unlock Premium
</button>

Visit Count Based Trigger

Show the modal after specific number of visits:

new PaymentSystem()
    .minVisitCount(5)        // Show after 5 visits
    .discardVisitCount(1)    // Add 1 visit when user clicks "Later"
    .stripeConfig({
        // ...your stripe config
    })
    .run();

Customization

Modal Text

new PaymentSystem()
    .modalTitle('❤️ Support Our Work')
    .modalDescription('Your custom description')
    .modalSubDescription('One-time payment • Instant access')
    .modalActionText('Donate $2.99')
    .modalDiscardText('Maybe Later')
    .run();

Visit Count Configuration

  • minVisitCount: Number of visits before showing modal
  • discardVisitCount: Number of visits to add when user clicks "Later"
// Show modal after 10 visits
// Add 2 visits when dismissed
new PaymentSystem()
    .minVisitCount(10)
    .discardVisitCount(2)
    .run();

Environment

// Automatically switch between test/live based on hostname
new PaymentSystem()
    .isLive(window.location.hostname !== '127.0.0.1')
    .run();

Payment Status Check

You can check if the user has already paid using the hasPaid method:

const payment = new PaymentSystem()
    .stripeConfig({
        // ...your config
    })
    .run();

// Check payment status
if (payment.hasPaid()) {
    console.log('User has paid');
} else {
    console.log('User has not paid');
}

// Example with conditional modal
function checkAndShowModal() {
    if (!payment.hasPaid()) {
        payment.showModal();
    }
}

Analytics

The system automatically tracks events if Google Analytics (gtag) or Plausible is present:

  • custom_pay_{pageName}: When user clicks payment button
  • custom_modal_close_{pageName}: When modal is closed
  • custom_modal_show_{pageName}: When showModalIfNotPaid is called

Device Tracking

Payment status is tracked per device using browser fingerprinting to prevent sharing of access between devices.