Test Credit Card Numbers for Stripe & PayPal

Use official Stripe and PayPal sandbox card numbers for successful checkout and declined-payment tests. Keep each fixture with its provider.

Test fixture

Stripe Visa success   4242 4242 4242 4242
Stripe Visa decline   4000 0000 0000 0002
PayPal Visa capture   4012 8888 8888 1881

Sandbox card numbers by provider

Use the Visa examples below inside their own sandbox. Stripe documents 4242 4242 4242 4242 for a successful test card payment and 4000 0000 0000 0002 for a generic decline. PayPal lists 4012 8888 8888 1881 for Expanded Checkout sandbox capture. Use a future expiration date and the appropriate security code. For these Visa examples a three digit test code such as 123 is sufficient when the hosted form requests it.

Use your Stripe test keys with the Stripe test form. For PayPal, use a sandbox client ID and the sandbox endpoint. Store the provider and expected outcome next to each case so your test runner cannot accidentally reuse a Stripe scenario in the PayPal adapter.

Check the complete payment flow

Start with a successful payment and assert how the application records authorization and capture. Keep the provider transaction ID so you can match it to the sandbox dashboard. Then run a decline and verify that the cart remains available and that the user can safely choose another payment method without creating a second order.

For PayPal error cases, use the rejection triggers in its documentation. For Stripe automated API tests, prefer the documented test PaymentMethod identifiers. Hosted form tests can enter the displayed card numbers using the browser. For asynchronous flows, add a case for a delayed or repeated webhook and check that the order state changes once.

Keep fixtures safe to share

Include the scenario name and expected state in fixture files. Exclude API keys, full request logs and customer billing data. Keep card numbers as strings because form input and test fixtures work with text. The example selects a fixture for a test runner without making a network request. Use these values only in the provider sandbox and follow the provider documentation for additional payment outcomes.

Record each fixture’s provider documentation link with the test case so a teammate can check the expected behavior when checkout settings change.

JavaScript test example

const sandboxCards = {
  stripe: { captured: '4242424242424242', declined: '4000000000000002' },
  paypal: { captured: '4012888888881881' },
};
function checkoutFixture(provider, expected, sandbox) {
  if (!sandbox) throw new Error('Sandbox required');
  const cardNumber = sandboxCards[provider]?.[expected];
  if (!cardNumber) throw new Error('Unknown sandbox case');
  return { cardNumber, expected };
}
console.log(checkoutFixture('stripe', 'declined', true));

Related generators