OpenAI continues to improve in both it's models and it's applicability to essentially everything we...
Working with the Stripe API
Stripe is a top provider of payment infrastructure and long known for having a fantastic developer experience and really high quality documentation.
Stripe exposes a number of APIs that cover various use cases of their platform. In this guide, we’ll walk you through how to use Bruno to explore and test Stripe’s Payment, Billing, and Identity APIs.
We've curated a public repo on Github that contain Stripe API collections for Bruno which allow you to create request templates for all API resources, list available parameters, and configure variables for authenticating API requests with your account.
Let's get started! 👨💻👩💻
Getting Started with the Stripe API Collection in Bruno
To begin, you’ll need to download and install Bruno, which is available for Windows, macOS, and Linux.
Once installed, you’ll fetch 🐕 your API collection for Stripe.
Step 1: Clone the repo from Github into Bruno
- Clone the public Github Repo for Stripe's Bruno Collections
- Open the collection in Bruno
If unfamiliar with Git, follow these instructions on cloning a repository.
Step 2: Set Up the Environment
- Click on Environment Variables and create a new environment called Stripe Test.
- Add a variable called
secret_key
and set the value to your test Stripe secret key. Mark this as 'secret'.You can get a test secret key by registering for a Stripe account. Once registered, navigate to the Stripe Dashboard, switch to Test Mode, click Developers in the bottom-left corner, select API keys, and then click Reveal test key
Step 3: Configure Authentication
- In your Stripe API Collection, open the Settings.
- Under Auth, select Bearer Token and set the token value to
.
- Save the changes. This configuration ensures that all requests in the Stripe collection use your test account credentials for authentication.
Step 4: Configure Environment
- Open Environments and select Configure
- Add a new Environment
- Add a Variable with the name
baseURL
and set the value tohttps://api.stripe.com
- Save the changes.
At this point, you’re ready to explore Stripe’s APIs using Bruno.
Exploring the Stripe API Using Bruno
The Stripe API is organized into several key resources, including Customers, Payments, and Checkout Sessions. Each resource in the collection includes all possible request methods (GET, POST, DELETE, etc.) and parameters.
Here’s an example of creating a customer using Bruno.
Example: Creating a Customer
To create a customer, follow these steps:
- Navigate to Customers
- Select Create a Customer request
- In the Body, add the following fields and select the box to apply them:
- Name
- Description
- Change Auth to Inherit
- Click Send.
If everything is set up correctly, you’ll receive a response from Stripe with the newly created customer’s information. Bruno’s response viewer makes it easy to review and understand the data.
Creating a Prebuilt Checkout Form
The Checkout API lets you create prebuilt hosted forms for checkout that can accept a variety of payments.
Here’s how to generate a checkout form for a 😳 $4,000 dog bone 🍖 for Bruno (what a treat!):
- Navigate to the Checkout folder
- Select Create a session request
- In the Body, add the following fields and select the box to apply them:
line_items[0][price_data][product_data][name] | dog bone |
line_items[0][price_data][product_data][description] | outrageously expensive bone |
line_items[0][price_data][unit_amount] | 400000 |
line_items[0][quantity] | 1 |
payment_method_types[0] | card |
mode | payment |
success_url |
https://example.com/success |
cancel_url | https://example.com/cancel |
4. Change Auth to Inherit
5. Click Send in Bruno. If successful, you’ll receive a response that includes a checkout URL which you can use to preview the checkout form.
You can make a test payment using the 4242 4242 4242 4242 card number, any future expiration date, and any 3-digit CVC.
Test Advanced Use Cases
Once you’re familiar with how to make API requests to the Stripe API with Bruno, try combining multiple Stripe APIs to test more advanced scenarios. Here are a few ideas:
- Create a Subscription: Use the Checkout API to create recurring payments for subscription plans.
- Save Customer Payment Methods: After collecting payment information using Checkout, associate the payment method with a customer.
- Advanced Error Handling: Test how your app responds to failed payments, expired cards, or API rate limits.
Why Use Bruno Instead of Postman?
Here’s a few reasons why devs are choosing Bruno as an API client:
Feature | Bruno | Others |
---|---|---|
Pricing | Open Source & Affordable Paid Plans | Free & Expensive Paid Plans |
Data Storage | All data stored locally | Required Cloud sync |
Collaboration | Local projects, Native Git sync | Cloud-based sharing |
UI/UX | Clean, modern interface | Complex, Bloated |
Bruno Advantages
- Local-First: Bruno saves everything locally, which makes it faster and more secure for those who don’t want to store their collections in the cloud.
- Native Git: Directly sync, version, store, and collaborate with your team and other consumers via whatever git provider you choose. Don't hassle maintaining your collections in a proprietary cloud storage system.
- Open Source: You have full control over the tool and can contribute to its development.
- Lightweight: Bruno is fast, simple, and focused on API development without unnecessary bloat.
Summary
Using Bruno to test and explore Stripe’s APIs is simple, powerful, and available through git. From setting up authentication to building complex API requests, Bruno offers a lightweight, open-source way to manage your API workflows.
With Bruno, you can:
- Authenticate requests using your Stripe secret key.
- Explore resources like Customers and Checkout Sessions.
- Create simple or advanced test payment flows.
We look forward to seeing what you create using Stripe and Bruno. If you'd like Stripe to maintain their own Bruno collections on Github, let them know @StripeDev !