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

@squaredr/paykit-js

v1.0.0

Published

Vanilla JavaScript/TypeScript frontend SDK for @squaredr/paykit

Readme

@squaredr/paykit-js

Vanilla JavaScript/TypeScript frontend SDK for @squaredr/paykit. Works in any framework or no framework at all.

Install

npm install @squaredr/paykit-js

Quick Start

import { PayKitClient } from '@squaredr/paykit-js';

const client = new PayKitClient({
  provider: 'stripe',
  publicKey: 'pk_test_...',
});

// Load the provider script (Stripe.js / Razorpay checkout.js)
await client.loadProvider();

// Mount a secure card input
await client.mountCardInput('#card-element');

// On form submit — confirm payment
const result = await client.confirmPayment('pi_secret_xxx', {
  returnUrl: 'https://example.com/payment/complete',
});

if (result.error) {
  console.error(result.error.message);
} else {
  console.log('Payment succeeded:', result.chargeId);
}

Headless Mode

If you don't need a mounted card input (e.g. Razorpay modal, saved payment methods):

const client = new PayKitClient({
  provider: 'razorpay',
  publicKey: 'rzp_test_...',
});

await client.loadProvider();

// Razorpay opens its own modal
const result = await client.confirmPayment('order_xxx');

API

new PayKitClient(config)

| Option | Type | Description | |--------|------|-------------| | provider | 'stripe' \| 'razorpay' | Payment provider | | publicKey | string | Provider publishable/public key | | locale? | string | Locale code (e.g. 'en') | | appearance? | AppearanceConfig | Theme configuration |

Methods

| Method | Description | |--------|-------------| | loadProvider() | Load the provider's CDN script | | isReady | Whether the provider script has loaded | | mountCardInput(target, options?) | Mount secure card input into a DOM element or selector | | tokenize() | Tokenize payment info from mounted input | | confirmPayment(clientSecret, options?) | Confirm payment, handling 3DS/modals/redirects | | updateAppearance(appearance) | Update theme at runtime | | on(event, listener) | Register an event listener | | off(event, listener) | Remove an event listener | | destroy() | Clean up all resources |

Events

client.on('ready', () => { /* input mounted */ });
client.on('change', (e) => { /* input value changed */ });
client.on('error', (e) => { /* validation error */ });
client.on('focus', () => { /* input focused */ });
client.on('blur', () => { /* input blurred */ });
client.on('loading_start', () => { /* payment processing */ });
client.on('loading_end', () => { /* processing complete */ });

TokenizeResult

interface TokenizeResult {
  token: string;
  paymentMethodType: PaymentMethodType;
  last4?: string;
  brand?: string;
}

PaymentConfirmResult

interface PaymentConfirmResult {
  status: ChargeStatus;
  chargeId?: string;
  redirectUrl?: string;
  error?: { code: string; message: string; isRetryable: boolean };
}

Theming

Pass an appearance config to style the card input:

const client = new PayKitClient({
  provider: 'stripe',
  publicKey: 'pk_test_...',
  appearance: {
    theme: 'night',
    variables: {
      colorPrimary: '#5469d4',
      colorBackground: '#1a1a2e',
      colorText: '#ffffff',
      colorDanger: '#df1b41',
      borderRadius: '8px',
      fontFamily: 'Inter, sans-serif',
    },
  },
});

Theme variables map to CSS custom properties (--paykit-color-primary, etc.) and can be used in your own styles.

3DS Redirect Handling

After a 3DS redirect, call handleRedirectReturn() on the return URL page:

import { handleRedirectReturn } from '@squaredr/paykit-js';

const result = handleRedirectReturn();
if (result) {
  // Payment returned from 3DS
  console.log(result.status); // 'succeeded' | 'failed' | 'pending'
  console.log(result.paymentIntentId);
}

Script Loading

Provider scripts are lazily loaded from CDN on first use and cached for the page lifetime. The SDK loads:

  • Stripe: https://js.stripe.com/v3/
  • Razorpay: https://checkout.razorpay.com/v1/checkout.js

You can also use the low-level loadScript() utility directly:

import { loadScript } from '@squaredr/paykit-js';

await loadScript('https://js.stripe.com/v3/', { timeout: 10000 });

Tree-Shakable Provider Imports

To keep bundle size minimal, import only the provider you use:

import '@squaredr/paykit-js/providers/stripe';
// or
import '@squaredr/paykit-js/providers/razorpay';

Supported Providers

| Provider | Card Input | 3DS | Modal | Redirect | |----------|-----------|-----|-------|----------| | Stripe | Iframe (Elements) | Yes | No | Yes | | Razorpay | Modal (Checkout) | Yes (internal) | Yes | No |

License

MIT