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

@funnelpay/billing

v0.1.0

Published

JavaScript SDK for Funnelpay billing with Primer integration

Readme

@funnelpay/billing

A modern TypeScript SDK for subscription payments with Primer Headless Checkout integration.

Features

  • Modern API: Clean, Promise-based interface with event-driven architecture
  • Dynamic Pricing: Update prices without page reload
  • Type-Safe: Complete TypeScript definitions and type safety
  • Event-Driven: Handle success, errors, and status changes with ease
  • Robust: Built-in error handling, retries, and validation
  • Lightweight: Minimal dependencies, browser-optimized
  • Headless Checkout: Full control over checkout UI with Primer Headless Checkout

Installation

Via NPM

npm install @funnelpay/billing @primer-io/checkout-web

Via CDN

<script src="https://sdk.primer.io/web/v2.57.3/Primer.min.js"></script>
<link rel="stylesheet" href="https://sdk.primer.io/web/v2.57.3/Checkout.css" />
<script src="https://unpkg.com/@funnelpay/billing@latest/dist/funnelpay-billing.min.js"></script>

Quick Start

import { Billing } from '@funnelpay/billing';

Billing.configure({ orgId: 'your-org-id' });

const checkout = await Billing.createCheckout({
  orgId: 'your-org-id',
  priceId: 'price_123',
  customer: {
    externalId: 'user_456',
    email: '[email protected]',
  },
  container: '#checkout-container',
});

checkout.on('success', (result) => {
  console.log('Payment succeeded:', result.orderId);
});

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

API Reference

configure(config)

Configure global SDK settings.

import { configure } from '@funnelpay/billing';

configure({
  orgId: 'your-org-id',
  baseUrl: 'https://billing.funnelpay.com', // optional
  region: 'default', // optional
});

createCheckout(options)

Creates a new checkout instance.

  • options.orgId (string) - Organization identifier
  • options.priceId (string, required) - Price identifier
  • options.customer (object, required) - Customer info
  • options.container (string, required) - CSS selector for container
  • Returns: Promise<CheckoutInstance>

createClientSession(params)

Create a client session manually (for advanced integrations).

  • Returns: Promise<{ clientToken: string, orderId: string, type: string }>

CheckoutInstance

Properties

  • id - Unique checkout identifier
  • state - Current state
  • orderId - Order identifier
  • isDestroyed - Whether checkout has been destroyed

Methods

  • updatePrice(priceId) - Update checkout price
  • getStatus() - Get current status
  • destroy() - Destroy instance and clean up
  • isReady() - Check if ready
  • isProcessing() - Check if processing

Events

  • 'success' - Payment completed
  • 'error' - Payment failed
  • 'status-change' - State changed
  • 'destroy' - Checkout destroyed

Development

npm install
npm run build
npm run dev       # watch mode
npm run typecheck
npm run lint
npm run test

tree

billing/ ├── package.json # @funnelpay/billing 包配置 ├── tsconfig.json # TypeScript 配置 ├── rollup.config.mjs # Rollup 构建配置(ESM/CJS/UMD/Min 四种格式) ├── eslint.config.mjs # ESLint 配置 ├── jest.config.ts # Jest 测试配置 ├── .prettierrc # Prettier 格式化配置 ├── .gitignore ├── LICENSE # MIT 协议 ├── README.md # 使用文档 ├── src/ │ ├── index.ts # 主入口,导出 Billing/configure/createCheckout 等 │ ├── enums.ts # PaymentMethod 枚举 │ ├── types.ts # 完整的 TypeScript 类型定义 │ ├── constants.ts # SDK 版本、API 端点、事件名、错误码等常量 │ ├── errors.ts # 错误类层级(FunnelpaySDKError → ValidationError/APIError/...) │ ├── event-emitter.ts # 轻量级事件发射器 │ ├── utils.ts # 工具函数(merge, retry, withTimeout 等) │ ├── validation.ts # 输入校验 │ ├── config.ts # 全局配置管理 │ ├── api-client.ts # REST API 客户端(session/payment 接口) │ ├── primer-wrapper.ts # Primer Headless Checkout 封装 │ ├── checkout-instance.ts # CheckoutInstance 生命周期管理 │ ├── loader.ts # 加载动画 UI 组件 │ └── skin/ │ └── default-skin.ts # 默认皮肤骨架(TODO 待实现) └── dist/ # 构建产物 ├── funnelpay-billing.esm.js ├── funnelpay-billing.cjs.js ├── funnelpay-billing.js (UMD) ├── funnelpay-billing.min.js (UMD 压缩) └── types/ (TypeScript 类型声明)

License

MIT © Funnelpay