Skip to content
github-actions[bot] edited this page Oct 4, 2026 · 2 revisions

Stripe

Typed Stripe REST API client for Deno, Bun, Node.js and Cloudflare Workers. Create and retrieve PaymentIntents and create Customers, with idempotency keys and webhook signature verification. A lightweight alternative to the official stripe SDK for the endpoints it covers.

JSR JSR Score

Overview

Stripe provides validated createPaymentIntent(), retrievePaymentIntent(), and createCustomer() calls, form-encoding requests the way Stripe's API requires (application/x-www-form-urlencoded with bracket notation for nested objects/arrays) and validating JSON responses. It uses RESTler for transport (HTTP Basic auth, built in) and Guardian for runtime request/response validation.

Testing your code

Your tests don't need to fake HTTP. Have your code take a Stripe instance and pass in a stand-in that returns the shapes from @tundraconnect/stripe/schemas or throws a real StripeError:

import { StripeError } from '@tundraconnect/stripe/errors';

const outage = new StripeError('SERVICE_UNAVAILABLE', { status: 503 });
console.log(outage.code);

To exercise the client itself against a fake transport, subclass it and reassign the protected _fetch.

Documentation

Topic Description
API Client configuration and endpoint methods
Errors Error codes and diagnostic metadata
Schemas Public Guardian schemas and inferred types

Upstream

Installation

Deno:

deno add jsr:@tundraconnect/stripe

Bun:

bunx jsr add @tundraconnect/stripe

Node.js:

npx jsr add @tundraconnect/stripe

Quick Start

import { Stripe } from '@tundraconnect/stripe';

const client = new Stripe({
  auth: { type: 'BASIC', username: 'sk_test_...', password: '' },
});

const intent = await client.createPaymentIntent({
  amount: 1999,
  currency: 'usd',
  automatic_payment_methods: { enabled: true },
});
console.log(intent.id, intent.client_secret);

const customer = await client.createCustomer({
  email: 'jenny@example.com',
  name: 'Jenny Rosen',
});
console.log(customer.id);

Webhooks

import { Stripe } from '@tundraconnect/stripe';

const client = new Stripe({
  auth: { type: 'BASIC', username: 'sk_test_...', password: '' },
});

export async function onWebhook(req: Request): Promise<void> {
  const raw = await req.text(); // text(), never json()
  const event = await client.verifyWebhook({
    payload: raw,
    headers: req.headers,
    secret: 'whsec_...',
  });
  // `event` is now trustworthy.
}

See API → Webhooks.

License

MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.

Clone this wiki locally