Repository navigation
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.
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.
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.
| Topic | Description |
|---|---|
| API | Client configuration and endpoint methods |
| Errors | Error codes and diagnostic metadata |
| Schemas | Public Guardian schemas and inferred types |
Deno:
deno add jsr:@tundraconnect/stripeBun:
bunx jsr add @tundraconnect/stripeNode.js:
npx jsr add @tundraconnect/stripeimport { 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);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.
MIT. Part of Tundra Connect, typed vendor API clients for Deno, Bun, Node.js and Cloudflare Workers.
- Algolia
- AzureBlob
- CloudflareDNS
- CloudflareEmail
- CloudflareSaaS
- CloudflareTurnstile
- CoinGecko
- Discord
- DodoPayments
- GCS
- GoogleAnalytics
- GoogleCertificateManager
- GoogleWebRisk
- Kalshi
- ntfy
- OpenExchange
- OpenWeatherMap
- PayPal
- Polymarket
- Razorpay
- Resend
- S3
- SendGrid
- Sentry
- Slack
- Stripe
- Telegram
- Twilio
- UpstashRedis
- URLhaus