Agentic Credit Card Automation
Effortlessly create virtual cards with Stripe and automate purchases using Browserbase.
Here are the steps:
- Set up your environment
- Create a Stripe Cardholder
- Create a Virtual Card with spending controls
- Retrieve Virtual Card Details
- Make a Purchase
Set up your environment
Before starting, install dependencies and configure authentication keys. The .env file securely stores API keys for Stripe, Browserbase, and optional AI models for Stagehand.
You will need the following keys:
- Stripe API key
- Browserbase Project ID & API Key
- (Optional) LLM API key for Stagehand
Create a StripeCardholder
A cardholder must be created before issuing virtual cards. The cardholder will have a verified billing address and will be eligible to receive virtual cards.
Create a Virtual Card
Once you have a cardholder, you can create a virtual card under their name. This step generates a virtual card with a predefined spending limit. Stripe allows you to customize the card’s spending controls, including setting daily, monthly, or per-transaction limits. Find more information on spending controls in the Stripe docs.
Retrieve Virtual Card Details
After creating a virtual card, you’ll need to retrieve its details (card number, expiration date, and CVC) to use it for transactions. The returned data can be used to automatically enter the card details when needed.
Make a Purchase
In this step, you will automate filling in the credit card payment form. This example walks you through navigating to the Red Cross donation page, selecting a donation amount, and completing the payment process using the virtual card details retrieved earlier.
🎉 You made an online purchase with Stripe and Browserbase!
Was this page helpful?