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

@henrylabs-interview/payments

v0.2.27

Published

A lightweight payments SDK for creating and confirming checkouts, with built-in webhook support and an embeddable checkout UI.

Readme

Henry Labs – Interview: Payment Processor

A lightweight payments SDK for creating and confirming checkouts, with built-in webhook support and an embeddable checkout UI.

This SDK simulates a real-world payment processing system, including:

  • Fraud detection
  • Transient system errors
  • Retry scenarios
  • Asynchronous authorization flows

It is designed to test robustness, error handling, and webhook integration.


Installation

bun install

Build:

bun run build

Overview

The SDK provides:

  • Checkout creation
  • Checkout confirmation
  • Webhook endpoint registration
  • Embeddable checkout UI (frontend)
  • API key validation

The system performs internal validation, fraud screening, and simulated load conditions.

Operations may:

  • Succeed immediately
  • Resolve asynchronously
  • Require retries
  • Fail due to fraud controls
  • Fail due to temporary system overload

Usage


Initialize (Backend)

import { PaymentProcessor } from '@henrylabs-interview/payments';

const processor = new PaymentProcessor({
	apiKey: ...,
});

Checkout API

Available under:

processor.checkout;

Create a Checkout

const response = await processor.checkout.create({
	amount: 1000,
	currency: 'USD',
	customerId: 'cust_123',
});

Confirm a Checkout (Backend)

const response = await processor.checkout.confirm({
	checkoutId: ...,
	type: 'raw-card',
	data: {
		number: ...,
		expMonth: XX,
		expYear: XXXX,
		cvc: XXX,
	},
});

Embedded Checkout (Frontend)

The SDK provides an optional embeddable checkout UI for collecting card details in the browser.


Initialize Embedded Checkout

import { EmbeddedCheckout } from '@henrylabs-interview/payments';

const embedded = new EmbeddedCheckout({
	checkoutId: 'chk_123',
});

Render Embedded Checkout

embedded.render('#checkout-container', (paymentToken) => {
	console.log('Received payment token:', paymentToken);

	// Send token to backend for confirmation
});

Parameters

| Parameter | Description | | -------------------- | ------------------------------------- | | containerElementId | ID of DOM element to render into | | callbackFn | Called with a generated payment token |

Behavior

  • Renders a secure card collection UI
  • Collects card number, expiry, and CVC
  • Generates a payment token
  • Returns the token via callback
  • Token should be sent to your backend for confirmation

The embedded checkout is intended for browser environments only.


Webhooks

Available under:

processor.webhooks;

Register Webhook Endpoint

processor.webhooks.createEndpoint({
	url: 'https://example.com/webhooks',
	event: 'checkout.confirm',
	secret: 'whsec_...',
});

Webhook Events

Events may be emitted for:

  • checkout.create
  • checkout.confirm
  • checkout.success
  • checkout.failure

Events are triggered for:

  • Immediate outcomes
  • Asynchronous resolutions
  • Retry scenarios

Webhook Security

If a secret is provided:

  • Deliveries are signed
  • Consumers must verify signatures
  • Handlers must be idempotent

Retries may occur if delivery fails.


Disclaimer

This SDK is intended for evaluation and sandbox purposes only.

It does not process real payments and should not be used in production.