Testing
Before taking your integration live, use the following information to test it thoroughly.
When using Stripe.js and Elements, you should ensure that:
- The
cardElement is passed correctly tocreateTokenin yoursubmithandler - In the response handler for
createToken, card errors are handled and displayed properly - Only valid tokens are passed to your server as part of payment form submission
In your server-side code, you should ensure that:
- All requests are being made successfully. You may find it useful to view your account's events and logs as you test your integration
- All API errors are handled properly
- Relevant webhooks are handled correctly
When you're ready to take your integration live, make sure that you replace your test publishable and secret API keys with live ones. Live payments cannot be processed if your integration is still using your test API keys. You can find your API key information in your account settings.
Test card numbers and tokens
Genuine card information cannot be used in test mode. Instead, use any of the following test card numbers, a valid expiration date in the future, and any random CVC number, to create a successful payment. Each test card's billing country is set to U.S. If you need to create test card payments using cards for other billing countries, use our international test cards.
We recommend using our test tokens when testing your integration and creating charges, instead of passing card information directly to the API. Using tokens in place of card numbers helps ensure your production integration is developed in a PCI compliant manner and is not going to handle card information directly. Each token is human-readable and represents card information that has been tokenized with our client-side libraries (e.g., Stripe Elements, Stripe.js).
| Number | Brand |
|---|---|
| 4242424242424242 | Visa |
| 4000056655665556 | Visa (debit) |
| 5555555555554444 | Mastercard |
| 2223003122003222 | Mastercard (2-series) |
| 5200828282828210 | Mastercard (debit) |
| 5105105105105100 | Mastercard (prepaid) |
| 378282246310005 | American Express |
| 371449635398431 | American Express |
| 6011111111111117 | Discover |
| 6011000990139424 | Discover |
| 30569309025904 | Diners Club |
| 38520000023237 | Diners Club |
| 3566002020360505 | JCB |
| 6200000000000005 | UnionPay |
| Token | Brand |
|---|---|
| tok_visa | Visa |
| tok_visa_debit | Visa (debit) |
| tok_mastercard | Mastercard |
| tok_mastercard_debit | Mastercard (debit) |
| tok_mastercard_prepaid | Mastercard (prepaid) |
| tok_amex | American Express |
| tok_discover | Discover |
| tok_diners | Diners Club |
| tok_jcb | JCB |
| tok_unionpay | UnionPay |
International test card numbers and tokens
You can use any of the following test cards to simulate a successful payment for different billing countries. For countries that have separate domestic and international pricing (e.g., Australia), the fee calculated for test card payments is at the international rate.
| Number | Token | Country | Brand |
|---|---|---|---|
| 4000000760000002 | tok_br | Brazil (BR) | Visa |
| 4000001240000000 | tok_ca | Canada (CA) | Visa |
| 4012888888881881 | n/a | Canada (CA) | Visa |
| 4000004840000008 | tok_mx | Mexico (MX) | Visa |
| Number | Token | Country | Brand |
|---|---|---|---|
| 4000000400000008 | tok_at | Austria (AT) | Visa |
| 4000000560000004 | tok_be | Belgium (BE) | Visa |
| 4000002080000001 | tok_dk | Denmark (DK) | Visa |
| 4000002460000001 | tok_fi | Finland (FI) | Visa |
| 4000002500000003 | tok_fr | France (FR) | Visa |
| 4000002760000016 | tok_de | Germany (DE) | Visa |
| 4000003720000005 | tok_ie | Ireland (IE) | Visa |
| 4000003800000008 | tok_it | Italy (IT) | Visa |
| 4000004420000006 | tok_lu | Luxembourg (LU) | Visa |
| 4000005280000002 | tok_nl | Netherlands (NL) | Visa |
| 4000005780000007 | tok_no | Norway (NO) | Visa |
| 4000006200000007 | tok_pt | Portugal (PT) | Visa |
| 4000006430000009 | tok_ru | Russian Federation (RU) | Visa |
| 4000007240000007 | tok_es | Spain (ES) | Visa |
| 4000007520000008 | tok_se | Sweden (SE) | Visa |
| 4000007560000009 | tok_ch | Switzerland (CH) | Visa |
| 4000008260000000 | tok_gb | United Kingdom (GB) | Visa |
| 4000058260000005 | tok_gb_debit | United Kingdom (GB) | Visa (debit) |
| Number | Token | Country | Brand |
|---|---|---|---|
| 4000000360000006 | tok_au | Australia (AU) | Visa |
| 4000001560000002 | tok_cn | China (CN) | Visa |
| 4000003440000004 | tok_hk | Hong Kong (HK) | Visa |
| 4000003920000003 | tok_jp | Japan (JP) | Visa |
| 3530111333300000 | tok_jcb | Japan (JP) | JCB |
| 4000005540000008 | tok_nz | New Zealand (NZ) | Visa |
| 4000007020000003 | tok_sg | Singapore (SG) | Visa |
3D Secure test card numbers
Not all cards support 3D Secure or require the customer be redirected to their card issuer's authentication page. Use the following card information to fully test 3D Secure payments.
| Number | Description |
|---|---|
| 4000000000003063 | 3D Secure is supported and required on this card. The value of the card source's card.three_d_secure attribute is required. 3D Secure must be completed for a charge to be successful. |
| 4000000000003089 | 3D Secure is supported but not required on this card. The value of the card source's card.three_d_secure attribute is recommended. Charges succeed whether 3D Secure is used or not. |
| 4000000000003055 | 3D Secure is supported but not required on this card. The value of the card source's card.three_d_secure attribute is optional. Charges succeed whether 3D Secure is used or not. |
| 378282246310005 | 3D Secure is not supported or required on this card. The value of the card source's card.three_d_secure attribute is not_supported. Proceed with a regular card payment instead. |
All other Visa and Mastercard test cards do not require verification from the customer's card issuer. The 3D Secure Source status is immediately set to chargeable upon source creation.
Testing for specific responses and errors
The following test cards can be used to create payments that produce specific responses—useful for testing different scenarios and error codes. Verification checks only run when the required information is provided (e.g., for cvc_check to be set to fail, a CVC code must be provided).
| Number | Description |
|---|---|
| 4000000000000077 | Charge succeeds and funds will be added directly to your available balance (bypassing your pending balance). |
| 4000000000000093 | Charge succeeds and domestic pricing is used (other test cards use international pricing). This card is only significant in countries with split pricing. |
| 4000000000000010 | The address_line1_check and address_zip_check verifications fail. If your account is blocking payments that fail ZIP code validation, the charge is declined. |
| 4000000000000028 | Charge succeeds but the address_line1_check verification fails. |
| 4000000000000036 | The address_zip_check verification fails. If your account is blocking payments that fail ZIP code validation, the charge is declined. |
| 4000000000000044 | Charge succeeds but the address_zip_check and address_line1_check verifications are both unavailable. |
| 4000000000005126 | Charge succeeds but refunding a captured charge fails with a failure_reason of expired_or_canceled_card. |
| 4000000000000101 | If a CVC number is provided, the cvc_check fails. If your account is blocking payments that fail CVC code validation, the charge is declined. |
| 4000000000000341 | Attaching this card to a Customer object succeeds, but attempts to charge the customer fail. |
| 4000000000009235 | Charge succeeds with a risk_level of elevated. |
| 4000000000000002 | Charge is declined with a card_declined code. |
| 4100000000000019 | Results in a charge with a risk level of highest. The charge is blocked as it's considered fraudulent. |
| 4000000000000127 | Charge is declined with an incorrect_cvc code. |
| 4000000000000069 | Charge is declined with an expired_card code. |
| 4000000000000119 | Charge is declined with a processing_error code. |
| 4242424242424241 | Charge is declined with an incorrect_number code as the card number fails the Luhn check. |
| Token | Description |
|---|---|
| tok_bypassPending | Charge succeeds and funds will be added directly to your available balance (bypassing your pending balance). |
| tok_domesticPricing | Charge succeeds and domestic pricing is used (other test cards use international pricing). This card is only significant in countries with split pricing. |
| tok_avsFail | The address_line1_check and address_zip_check verifications fail. If your account is blocking payments that fail ZIP code validation, the charge is declined. |
| tok_avsLine1Fail | Charge succeeds but the address_line1_check verification fails. |
| tok_avsZipFail | The address_zip_check verification fails. If your account is blocking payments that fail ZIP code validation, the charge is declined. |
| tok_avsUnchecked | Charge succeeds but the address_zip_check and address_line1_check verifications are both unavailable. |
| tok_refundFail | Charge succeeds but refunding a captured charge fails with a failure_reason of expired_or_canceled_card. |
| tok_cvcCheckFail | If a CVC number is provided, the cvc_check fails. If your account is blocking payments that fail CVC code validation, the charge is declined. |
| tok_chargeCustomerFail | Attaching this card to a Customer object succeeds, but attempts to charge the customer fail. |
| tok_riskLevelElevated | Charge succeeds with a risk_level of elevated and placed into review. |
| tok_chargeDeclined | Charge is declined with a card_declined code. |
| tok_chargeDeclinedFraudulent | Results in a charge with a risk level of highest. The charge is blocked as it's considered fraudulent. |
| tok_chargeDeclinedIncorrectCvc | Charge is declined with an incorrect_cvc code. |
| tok_chargeDeclinedExpiredCard | Charge is declined with an expired_card code. |
| tok_chargeDeclinedProcessingError | Charge is declined with a processing_error code. |
By default, passing address or CVC data with the card number causes the address and CVC checks to succeed. If this information isn't specified, the value of the checks is null. Any expiration date in the future is considered valid.
You can also provide invalid card details to test specific error codes resulting from incorrect information being provided. For example:
invalid_expiry_month: Use an invalid month (e.g., 13)invalid_expiry_year: Use a year in the past (e.g., 1970)invalid_cvc: Use a two digit number (e.g., 99)
Disputes
In test mode, you can use the test cards below to simulate a disputed transaction:
| Number | Token | Description |
|---|---|---|
| 4000000000000259 | tok_createDispute | With default account settings, charge succeeds, only to be disputed. |
| 4000000000001976 | tok_createDisputeInquiry | With default account settings, charge succeeds, only to be disputed as an inquiry. |
The following evidence, when submitted in the uncategorized_text, produces specific actions that are useful for testing the dispute flow:
| Evidence | Description |
|---|---|
winning_evidence |
The dispute is closed and marked as won. Your account is credited the amount of the charge and related fees. |
losing_evidence |
The dispute is closed and marked as lost. Your account is not credited. |
Rate limits
It is extremely unlikely for users to experience any rate limits with normal usage of the API, even at high volume. The most common causes for a user to experience rate limits are bugs, bulk data fetches, or extreme load testing.
Should your requests begin to receive 429 HTTP errors, reduce the frequency of your requests. Each failed request is perfectly safe to retry as rate limiting takes place before any other action and prevents the request from being processed. When reducing your request frequency, we recommend an exponential backoff by first waiting one second before trying again. If your request continues to receive the same response, wait two seconds, then four seconds, etc.
Rate limits for both test and live modes are identical. Requests made in test mode are an accurate representation of what to expect when making live requests. If you are experiencing rate limits but are unable to determine why, please let us know.
Sources
Use the following information when testing payments using Sources.
Redirect sources
When creating a test Source object that uses a redirect flow (e.g., iDEAL), you can follow the URL returned in the redirect[url] field. This leads to a Stripe page that displays information about the API request, and where you can either authorize or cancel the payment.
Authorizing the payment redirects you to the URL specified in redirect[return_url].
SEPA Direct Debit
You can mimic a successful or failed charge by first creating a test source with one of the following test IBAN account numbers. Use the resulting source in a charge request to create a test charge that is either successful or failed.
| Account Number | Description |
|---|---|
AT611904300235473201 |
The charge status transitions from pending to succeeded. |
AT861904300235473202 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
BE62510007547061 |
The charge status transitions from pending to succeeded. |
BE68539007547034 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
DK5000400440116243 |
The charge status transitions from pending to succeeded. |
DK8003450003179681 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
FR1420041010050500013M02606 |
The charge status transitions from pending to succeeded. |
FR8420041010050500013M02607 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
DE89370400440532013000 |
The charge status transitions from pending to succeeded. |
DE62370400440532013001 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
IE29AIBK93115212345678 |
The charge status transitions from pending to succeeded. |
IE02AIBK93115212345679 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
IT40S0542811101000000123456 |
The charge status transitions from pending to succeeded. |
IT60X0542811101000000123456 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
LU280019400644750000 |
The charge status transitions from pending to succeeded. |
LU980019400644750001 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
NL39RABO0300065264 |
The charge status transitions from pending to succeeded. |
NL91ABNA0417164300 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
PT50000201231234567890154 |
The charge status transitions from pending to succeeded. |
PT23000201231234567890155 |
The charge status transitions from pending to failed. |
| Account Number | Description |
|---|---|
ES0700120345030000067890 |
The charge status transitions from pending to succeeded. |
ES9121000418450200051332 |
The charge status transitions from pending to failed. |
Webhooks
You can send test webhooks to your integration's endpoint within your account's webhooks settings. The event data contained within these test webhooks is fabricated and not available in the API—its purpose is only to test that your endpoint is working and configured correctly.
To fully test your integration, perform actions using the API (in test mode) that cause legitimate webhooks to be sent. For instance, creating a charge triggers the charge.succeeded webhook that contains the charge data. You can then use the API to verify the resulting event data.
If you don't have a server set up to receive webhooks, but want to see example webhook requests, we suggest testing locally on your computer using a service like ngrok. This will allow you to inspect the requests we send.