Testing use cases
Learn how to test your integration.
Sandboxes are Stripe’s testing environment. They allow you to test your integration without making actual charges or payments. Sandboxes simulate creating real objects without affecting actual transactions or moving real money. You can access your sandboxes using the account picker or on the Sandboxes page in the Dashboard. We recommend using our quality assurance (QA) testing use cases and importing our Postman collection to help you in the testing process.
Testing environments
In a sandbox, you can charge test credit cards and create test products and prices. Sandboxes let you simulate transactions to make sure that your integration works correctly. This helps identify bugs or errors in your Stripe implementation before you go live with actual payments.
After you create a Stripe account, Stripe places you in a sandbox. You can find a set of test API keys on the Stripe Dashboard home page or the API keys page. You can use these API keys to create and retrieve simulated data by making requests to the Stripe API.
To start accepting real payments, you need to set up your Stripe account, exit your sandbox with the account picker, and use the live API keys in your integration. Store live secret keys in a secrets vault or environment variables. Don’t store keys in source code or configuration files checked into version control. For more information, see Best practices for managing secret API keys.
Impact on live mode when using the test mode sandbox
If you change settings in the Dashboard while in the test mode sandboxes, you might also change them in live mode. Many Dashboard pages have a notification box and disable live mode settings while in the test mode sandbox. In this case, any settings still enabled are safe to use. If you don’t see the notification, assume any changes made in the test mode sandbox affect live mode settings (unless you see a test data banner).
Compare sandboxes
Your Stripe account includes a test mode sandbox and the ability to create additional sandboxes. Although test mode is a sandbox, it differs from the general sandboxes that you create. Understanding these differences can help you build your testing strategy.
| Test mode sandbox | General sandboxes | |
|---|---|---|
| Number of sandboxes | Use one sandbox. | Use up to five sandboxes. The test mode sandbox doesn’t count toward the limit of five. |
| Access control | Grant all users the same roles and access as live mode. | Control access more strictly. When the sandbox access level is set to private, only admins automatically have access. You can invite users to sandboxes only, without granting access to live mode. When the sandbox access level is set to all team members, all users with roles receive the same roles and access. |
| Settings | Share settings between live mode and the test mode sandbox. You can’t test many settings independently. | Isolate settings completely for each sandbox. Copy settings from live mode at creation time, and test independently from your live integration. |
| API support | Supports V1 and partially supports V2. | Supports V1 and V2. |
| Deletion | Can’t be deleted. | Can be deleted. |
| Apps | Installs require the app to support a test mode sandbox. | Installs require the app to support sandboxes. |
| Product limitations | You can’t test IC+ pricing in test mode sandbox. | You can’t test IC+ pricing in a sandbox. |
| Rate limits | Maintain consistent rate limits. | Maintain consistent rate limits. |
| Test card numbers | Use the same test card numbers. | Use the same test card numbers. |
Sandboxes versus live mode
All Stripe API requests occur in either a sandbox or live mode. API objects in one mode aren’t accessible to the other. For example, a test product object can’t be part of a live mode payment.
| Type | When to use | Objects | How to use | Considerations |
|---|---|---|---|---|
| Sandboxes | Use a sandbox, and its associated test API keys, as you build your integration. In a sandbox, card networks and payment providers don’t process payments. | API calls return simulated objects. For example, you can retrieve and use test account, payment, customer, charge, refund, transfer, balance, and subscription objects. |
Use test credit cards and accounts. You can’t accept real payment methods or work with real accounts. | Identity doesn’t perform any verification checks. Also, Connect account objects don’t return sensitive fields. |
| Live mode | Use live mode, and its associated live API keys, when you’re ready to launch your integration and accept real money. In live mode, card networks and payment providers do process payments. | API calls return real objects. For example, you can retrieve and use real account, payment, customer, charge, refund, transfer, balance, and subscription objects. |
Accept real credit cards and work with customer accounts. You can accept actual payment authorizations, charges, and captures for credit cards and accounts. | Disputes have a more nuanced flow and a simpler testing process. Also, some payment methods have a more nuanced flow and require more steps. |
Being in a sandbox in the Dashboard doesn’t affect your integration code. Your test and live mode API keys affect the behavior of your code.
Create an additional sandbox
To create and set up an additional sandbox in the Dashboard:
Create the sandbox
- Go to the Sandboxes page in the Dashboard.
- Click Create in the top right.
Manage access
New sandboxes are private by default and don’t automatically give access to other team members. You can grant access to all team members:
- Go to the Sandboxes page in the Dashboard.
- Click the overflow menu () for the sandbox.
- Select Change access.
You can manage individual-level access in any of these ways:
- Grant access to a specific sandbox.
- Grant testing-only access.
- Grant access to all sandboxes.
Get your sandbox credentials
Use these credentials to connect your integration to the sandbox. Save them where your team can access them for testing.
- Copy the test API keys for the sandbox.
- Copy the sandbox account ID.
Update test environment
You can update any references that depend on test data you created earlier.
- Set up any resources you need for testing, such as products, customers, subscriptions, and payment methods.
- Update any part of your testing processes that depends on specific test object IDs. This changes when you create new objects in a sandbox.
(Optional) Set up simulations
Set up simulations to test your Billing integration. Simulations let you move time forward in the sandbox so resources such as subscriptions change state and trigger webhook events.
Test card numbers
Stripe provides a set of test card numbers that you can use to simulate various payment scenarios. You can use these test card numbers to create simulated payments in sandboxes without processing actual payments or charges.
When you use test card numbers, you can enter any expiration date in the future and any three-digit CVC code to simulate a successful payment. If you want to simulate a failed payment, you can use specific test card numbers and CVC codes provided by Stripe.
Test card numbers are only valid in sandboxes. Don’t use them for real payments.
Delete test data
To delete all of your test data from your Stripe account, complete the following steps:
- Log in to the Dashboard using your existing Stripe account.
- While in your sandbox, click Developers > Overview.
- Under Test data, click Review test data. The dialog gives you a list of all of your existing test data objects.
- Click Delete test data to initiate the deletion process. You can’t undo the deletion of your test data.
Sandboxes are temporarily unusable while the deletion process occurs.
Note
You must manually delete Meters because the object isn’t supported by the automated test data deletion process.
Test email
By default, Stripe doesn’t email customers in sandboxes. For example, paying an invoice in a sandbox doesn’t send a receipt email to the customer. Invoices finalized through the API in sandboxes also don’t send a receipt email to the customer.
If you want Stripe to email customers in a sandbox, you can do the following in the Dashboard:
- Create and manually send an invoice to a specific customer.
- Manually send a receipt for a paid invoice.
To verify emails for invoices and receipts, set the email address for your Team on the Customer object or receipt_ attribute on the PaymentIntent.
Testing use cases
The following table contains quality assurance (QA) testing use cases:
| Use case | Action |
|---|---|
| Charge success (capturing immediately) |
|
| PaymentIntent authorization success (capturing funds for later) |
|
| PaymentIntent capture success (capturing immediately or capturing funds for later) |
|
| Charge fail | The charge appears as Failed in the Dashboard under Payments.
|
| Radar block | No matter which version of Radar you use, it might block a charge because of high risk or a rule. The response is the same as what you get when a charge fails. |
| Charge disputed |
|
Charge inquiry opened |
Inquiries are similar to disputes, with three key distinctions: no funds are withdrawn unless we elevate an inquiry to a dispute, they remain refundable until disputed, and have a different set of statuses. In this case, Stripe fires a
|
Dispute won |
|
Dispute lost |
When a customer loses a dispute, Stripe updates the existing
|
Inquiry won |
When you win an inquiry, your balance remains the same, as no funds were removed when you initially opened the inquiry. Stripe updates the existing
|
Inquiry lost |
|
Charge refunded |
The charge appears as Refunded in the Dashboard under Payments.
|
Charge partially refunded |
|
| Account balance goes negative | Make sure to test for a negative balance on Stripe and verify that your bank accounts can accept debits from us. |
| Successful payout | If you enable webhooks for a successful payout (recommended), test your handling of the event. |
| Failed payout | If you enable webhooks for a failed payout (recommended), test your handling of the event. |
Stripe’s Postman collection
Postman is a widely-used API development tool. To help integrate Stripe, we provide a Payments-specific Postman collection with the tools you need to test the server-side component of your integration.
Import the collection
To begin, you need to access the Postman app. You can use either the browser or desktop version. After launching the app, import the collection.
To start this process on the web, press the Import button at the top-left corner, followed by the Link option. Insert the Payments collection link. If you’re using the Postman desktop app, click File > Import. After successfully importing, the collection appears under Collections.
Use the collection
To use the collection, go to the collection you just imported and click Variables. Copy your Stripe sandbox secret key from the Stripe Dashboard, and paste it into the Initial Value field of the secret_key row. After you complete this step, you can begin making requests.
During collection runtime, scripts populate other variables. For example, when creating a customer, price, charge or PaymentIntent, the system saves that ID through a script in the collection, making it accessible for later requests, such as issuing a refund.