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

@fanbasis/checkout-core

v0.3.9

Published

Core payment checkout functionality for Fanbasis SDK

Readme

@fanbasis/checkout-core

Core payment checkout functionality for the Fanbasis SDK. This package provides the foundational JavaScript library for integrating Fanbasis checkout into any web application.

🚀 Quick Start

Installation

npm install @fanbasis/checkout-core

Basic Usage

import { PaymentCheckout } from '@fanbasis/checkout-core';

const checkout = PaymentCheckout.create({
  creatorId: 'your-creator-id',
  productId: 'your-product-id',
  checkoutSessionSecret: 'your-session-secret',
  environment: 'sandbox'
});

// Attach to DOM element and initialize
const container = document.getElementById('checkout-container');
checkout.attachToElement(container);
await checkout.init();

📦 Package Contents

Core Exports

  • PaymentCheckout - Main checkout class for creating and managing checkout instances
  • EventEmitter - Event system for handling checkout lifecycle events
  • Type definitions - Complete TypeScript support

Embed Exports

  • /embed - Hosted JavaScript solution for CDN integration
  • Global API - window.PaymentCheckout for browser environments
  • Attribute parsing - Automatic configuration from HTML data attributes

🎯 Key Features

  • Framework Agnostic - Works with any JavaScript framework or vanilla JS
  • TypeScript Support - Full type definitions included
  • Event System - Comprehensive event handling for checkout lifecycle
  • Theme Customization - Extensive styling and layout options
  • Multiple Integration Methods - Configuration objects, fluent builder, data attributes
  • Hosted Solution - CDN-ready embed script for quick integration
  • Production Ready - Built-in error handling, validation, and security features

📋 Configuration

Required Parameters

interface CheckoutConfig {
  creatorId: string;              // Your creator identifier
  productId: string;              // The product to sell
  checkoutSessionSecret: string;  // Session secret for security
  environment: 'sandbox' | 'production';
}

Optional Parameters

interface CheckoutConfig {
  // Additional products to offer
  bumpProductIds?: string[];
  
  // Pre-applied coupon and affiliate tracking
  couponCode?: string;
  affiliateCode?: string;
  
  // Custom API endpoint
  overrideBaseUrl?: string;
  
  // Theme customization
  theme?: CustomizationParams;
  
  // Container styling
  containerOptions?: {
    width?: string;
    height?: string;
  };
  
  // Redirect behavior
  redirectSettings?: RedirectSettings;
  
  // Submit button control
  showSubmitButton?: boolean;
}

🔧 Integration Methods

1. Configuration Object

const checkout = PaymentCheckout.create({
  creatorId: 'creator_123',
  productId: 'product_456',
  checkoutSessionSecret: 'secret_789',
  environment: 'sandbox'
});

2. Fluent Builder

const checkout = PaymentCheckout.create()
  .creatorId('creator_123')
  .productId('product_456')
  .checkoutSessionSecret('secret_789')
  .environment('sandbox')
  .theme({
    theme: 'dark',
    accent_color: '#ff6b6b'
  })
  .build();

3. Data Attributes (Embed)

<div data-checkout
     data-creator-id="creator_123"
     data-product-id="product_456"
     data-checkout-session-secret="secret_789"
     data-environment="sandbox">
</div>

📡 Event Handling

checkout.on('checkout:opened', () => {
  console.log('Checkout opened');
});

checkout.on('checkout:success', (data) => {
  console.log('Payment successful:', data.transactionId);
});

checkout.on('checkout:error', (error) => {
  console.error('Payment failed:', error.message);
});

🌐 Hosted JavaScript

For quick integration without a build process, use the hosted JavaScript:

<script src="https://cdn.embedded.fanbasis.io/embed/index.js"></script>
<script>
  PaymentCheckout.create({
    creatorId: 'creator_123',
    productId: 'product_456',
    checkoutSessionSecret: 'secret_789',
    environment: 'sandbox'
  }).attachTo(document.getElementById('checkout-container'));
</script>

📚 Documentation

🧪 Testing

# Run unit tests
npm test

# Run tests in watch mode
npm run test:watch

# Run integration tests
npm run test:e2e

# Run with coverage
npm run test:coverage

📦 Build

# Development build
npm run build

# Production build
npm run build:prod

# CDN build
npm run build:cdn

🔍 Bundle Analysis

# Analyze bundle size
npm run analyze

# Check size limits
npm run size

📄 License

This package is part of the Fanbasis Payment SDK. See the main project for license information.

🆘 Support


Size: ~50KB (gzipped)
Dependencies: eventemitter3
Browser Support: Modern browsers with ES2020+ support