Skip to main content

Quick Start: Simulate a Stripe Payment in 10 minutes

PayLab is an open platform for simulating Payment Service Providers (PSPs). We host mock APIs for many popular PSPs, allowing you to test and simulate payment flows quickly and easily. In this guide, we’ll walk you through how to use our mock Stripe API to complete a payment. The process is completely free and requires no signup!

Access our open API

Visit the PayLab Developer Console to manage your API keys and explore our interactive API documentation. Once you've obtained an API key, go to any API documentation page, click Authorize and enter your API key. You’re now ready to start using our APIs!

Detailed instructions: create an API key
  1. Go to PayLab Developer Console.
  2. In the side menu, go to API Keys and click Create API Key.
  3. Enter a name for your API key, and click Create.
  4. Copy the API key and store it somewhere safely.

Step 1. Create a payment intent

info

A Payment Intent is the core object in Stripe that represents the intention to collect a payment from a customer. To complete a payment, you first create a Payment Intent and then confirm it. The payment intent progresses through various states during the process. For more details, refer to Stripe's Payment intent lifecycle documentation.

In the Developer Console, go to the Mock Stripe Payment Intent API.

  1. Expand the POST /payment_intents endpoint, and click Try it out.
  2. Use the pre-filled example request body and click Execute.

The API will return a response containing the newly created Payment Intent object. Feel free to experiment with different request bodies!

Step 2. Retrieve the payment intent

Copy the id value from the payment intent created in Step 1. Let's retrieve the payment intent by its ID.

  1. Expand the GET /payment_intents/{id} endpoint, and click Try it out.
  2. Paste the payment intent id into the Parameters section and click Execute.

The API will return the same Payment Intent object. Notice that its status is requires_payment_method, which is the initial state of a Payment Intent.

Step 3. Confirm the payment intent

Let’s complete the payment by confirming the Payment Intent:

  1. Expand the POST /payment_intents/{id}/confirm endpoint, and click Try it out.
  2. Paste the payment intent id into the Parameters section and click Execute.
tip

You may notice the simulate object in the example request body. This object allows you to simulate specific PSP behaviors. In this case, it tells the API to simulate a successful payment. The simulate object is a powerful and unified construct provided by PayLab, enabling you to simulate various payment scenarios!

The response will show that the Payment Intent’s status has changed to processing, meaning the payment is being processed asynchronously.

Step 4. Retrieve the payment intent and check status again

Finally, let's check if the payment is successful by retrieving the payment intent again.

  1. Expand the GET /payment_intents/{id} endpoint, and click Try it out.
  2. Paste the payment intent id into the Parameters section and click Execute.

The response will show the Payment Intent object with its status updated to succeeded. Congratulations! you’ve completed a full payment flow using the Stripe Payment Intent API.

Key Highlights

  • PayLab Mock PSPs are stateful - the payment intents and transactions are persisted - which means you can conveniently retrieve a transaction anytime. Be cautious what you send to our hosted APIs, never send real card information!
  • Our Mock PSPs track the lifecycle of a payment. As demonstrated above, the Payment Intent status transitions through requires_payment_method, processing, and succeeded, just like a real PSP.
  • Want to simulate a failed payment or a different flow? Use the simulate object in your request body. For more details, see Simulate object guide.
  • Need to receive payment updates via webhooks? We’ve got you covered! Check out the Register webhooks guide for more information.