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

stripe-test-cards

v0.1.0

Published

A comprehensive, typed reference of all Stripe test card numbers for use in test suites.

Readme

stripe-test-cards

A typed reference of all Stripe test card numbers for use in test suites.

Motivation

Stripe's test card numbers are scattered across their documentation. Every project that integrates Stripe ends up with the same magic strings copy-pasted into tests — 4242424242424242 here, 4000000000000002 there — with no indication of what they do or whether they're still current.

This library centralises all of them in one place, organised by use case, with full TypeScript types. Your editor autocompletes the card you need; the library documents what it does.

// Before
cardNumber: "4000000000009995" // declined? which one? why?

// After
cardNumber: cards.declined.insufficientFunds.number

Installation

npm install stripe-test-cards

Usage

import cards from 'stripe-test-cards';

Every card object has number, brand, cvc, expiry, and description. Use number to fill in your Stripe API calls or test form inputs.

Happy-path tests

await stripe.paymentIntents.create({
  amount: 2000,
  currency: 'usd',
  payment_method: cards.standard.visa.pmId,
  confirm: true,
});

Decline handling

it('shows an error on insufficient funds', async () => {
  await fillCardForm(cards.declined.insufficientFunds.number);
  await expect(page.getByText('Your card has insufficient funds')).toBeVisible();
});

it('shows an error on expired card', async () => {
  await fillCardForm(cards.declined.expiredCard.number);
  await expect(page.getByText('Your card has expired')).toBeVisible();
});

3D Secure / SCA

it('completes payment after 3DS authentication', async () => {
  await fillCardForm(cards.threeDS.requiredIe.number);
  await handle3DSModal(); // authenticate in the Stripe iframe
  await expect(page.getByText('Payment successful')).toBeVisible();
});

it('handles frictionless 3DS without user interaction', async () => {
  await fillCardForm(cards.threeDS.frictionless.number);
  await expect(page.getByText('Payment successful')).toBeVisible();
});

Radar / fraud scenarios

it('blocks a high-risk card', async () => {
  await fillCardForm(cards.radar.alwaysBlocked.number);
  await expect(page.getByText('Your card was declined')).toBeVisible();
});

Country-specific billing

// Keys are ISO 3166-1 alpha-2 country codes
await fillCardForm(cards.country.DE.number); // Germany
await fillCardForm(cards.country.GB.number); // United Kingdom
await fillCardForm(cards.country.JP.number); // Japan

Parameterised tests

cards.all is a flat object containing every card across all categories — useful for smoke-testing your payment flow against the full set.

it.each(Object.entries(cards.all))('processes card %s without throwing', async (_name, card) => {
  await expect(submitPayment(card.number)).resolves.not.toThrow();
});

Available categories

| Property | Description | |---|---| | cards.standard | Always-succeeding cards across all major networks | | cards.coBranded | Cartes Bancaires and EFTPOS Australia co-branded cards | | cards.declined | Cards that trigger specific decline codes | | cards.radar | Radar fraud-scoring scenarios | | cards.dispute | Cards that trigger disputes or chargebacks | | cards.disputeDeflection | Visa RDR, Compelling Evidence 3.0, Ethoca Alerts | | cards.threeDS | 3D Secure / SCA flows (required, frictionless, challenge, etc.) | | cards.terminal | In-person / PIN scenarios | | cards.refund | Async refund state transitions | | cards.balance | Cards where funds bypass the pending balance | | cards.country | Cards issued in specific countries (ISO 3166-1 alpha-2 keys) | | cards.all | Flat spread of all cards for parameterised tests |

TypeScript

The library exports four interfaces you can use to type your own helpers:

import type { StripeTestCard, StripeDeclineCard, Stripe3DSCard, StripeCountryCard } from 'stripe-test-cards';

function fillCardForm(card: StripeTestCard) {
  // card.number, card.cvc, card.expiry are all typed
}

function assertDeclineCode(card: StripeDeclineCard, expected: string) {
  expect(card.declineCode).toBe(expected);
}

Notes

  • All test cards work only with Stripe test mode API keys (sk_test_...).
  • CVC can be any 3-digit number (4 digits for Amex). Expiry can be any future date.
  • Where available, pmId (pm_card_*) and tokenId (tok_*) are included for API-level testing without needing to tokenise a card number.