Skip to content

Commit 7603710

Browse files
authored
add node and python readmes for stripe (#14)
1 parent a2f1eb6 commit 7603710

File tree

2 files changed

+247
-0
lines changed

2 files changed

+247
-0
lines changed
Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# πŸš€ Agentic Credit Card Automation - Node.js
2+
3+
Effortlessly create virtual cards with **Stripe** and automate purchases using **Browserbase** in Node.js/TypeScript.
4+
5+
## πŸ“Œ Overview
6+
7+
This Node.js implementation enables you to:
8+
- **Create virtual cards** with spending controls using Stripe Issuing
9+
- **Retrieve virtual card details** securely
10+
- **Automate online purchases** with Playwright and Browserbase
11+
12+
## πŸ› οΈ Setup
13+
14+
### Prerequisites
15+
- Node.js 18+
16+
- npm or yarn
17+
- Stripe account with Issuing enabled
18+
- Browserbase account
19+
20+
### Installation
21+
22+
1. **Install dependencies**:
23+
```bash
24+
npm install
25+
```
26+
27+
2. **Configure environment variables**:
28+
Create a `.env` file in this directory:
29+
```env
30+
STRIPE_API_KEY=sk_test_your_stripe_secret_key
31+
BROWSERBASE_API_KEY=your_browserbase_api_key
32+
BROWSERBASE_PROJECT_ID=your_browserbase_project_id
33+
```
34+
35+
3. **Install Playwright browsers**:
36+
```bash
37+
npm run postinstall
38+
```
39+
40+
## πŸš€ Usage
41+
42+
### Step 1: Create a Cardholder
43+
```bash
44+
npx tsx 1-create-cardholder.ts
45+
```
46+
47+
### Step 2: Create a Virtual Card
48+
```bash
49+
npx tsx 2-create-card.ts
50+
```
51+
⚠️ **Important**: Update the `cardholderId` variable with the ID from Step 1
52+
53+
### Step 3: Retrieve Card Details
54+
```bash
55+
npx tsx 3-get-card.ts
56+
```
57+
⚠️ **Important**: Update the `cardId` variable with the ID from Step 2
58+
59+
### Step 4: Make an Automated Payment
60+
```bash
61+
npx tsx 4-make-payment.ts
62+
```
63+
⚠️ **Important**: Update the `cardId` variable with the ID from Step 2
64+
65+
## πŸ“ Files
66+
67+
| File | Description |
68+
|------|-------------|
69+
| `1-create-cardholder.ts` | Creates a Stripe cardholder with billing information |
70+
| `2-create-card.ts` | Creates a virtual card with spending limits |
71+
| `3-get-card.ts` | Retrieves card details including sensitive information |
72+
| `4-make-payment.ts` | Automates a donation using Playwright and Browserbase |
73+
| `package.json` | Node.js dependencies and scripts |
74+
| `.env` | Environment variables (not tracked in git) |
75+
76+
## πŸ”§ Configuration
77+
78+
### Spending Controls
79+
Edit `2-create-card.ts` to customize:
80+
- **Allowed categories**: Restrict card usage to specific merchant categories
81+
- **Spending limits**: Set daily/monthly/yearly limits
82+
- **Blocked categories**: Prevent usage at certain merchant types
83+
84+
### Payment Automation
85+
Modify `4-make-payment.ts` to:
86+
- Change the target website
87+
- Customize form filling logic
88+
- Add error handling and validation
89+
90+
## πŸ” Security Notes
91+
92+
- Never commit `.env` files to version control
93+
- Use test API keys for development
94+
- Implement proper error handling in production
95+
- Consider using Stripe webhooks for real-time updates
96+
97+
## πŸ“– Documentation
98+
99+
For full API documentation and advanced usage:
100+
πŸ“„ **[Stripe Issuing API](https://stripe.com/docs/issuing)**
101+
πŸ“„ **[Browserbase Documentation](https://docs.browserbase.com)**
102+
103+
## 🎯 Example Use Cases
104+
105+
- **Expense management**: Create cards for specific projects or employees
106+
- **Testing payments**: Automate payment flow testing
107+
- **Subscription management**: Programmatically manage recurring payments
108+
- **Budget enforcement**: Set spending limits per card or category
Lines changed: 139 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,139 @@
1+
# πŸš€ Agentic Credit Card Automation - Python
2+
3+
Effortlessly create virtual cards with **Stripe** and automate purchases using **Browserbase** in Python.
4+
5+
## πŸ“Œ Overview
6+
7+
This Python implementation enables you to:
8+
- **Create virtual cards** with spending controls using Stripe Issuing
9+
- **Retrieve virtual card details** securely
10+
- **Automate online purchases** with Playwright and Browserbase
11+
12+
## πŸ› οΈ Setup
13+
14+
### Prerequisites
15+
- Python 3.8+
16+
- pip or poetry
17+
- Stripe account with Issuing enabled
18+
- Browserbase account
19+
20+
### Installation
21+
22+
1. **Install dependencies**:
23+
```bash
24+
pip install -r requirements.txt
25+
```
26+
27+
2. **Configure environment variables**:
28+
Create a `.env` file in this directory:
29+
```env
30+
STRIPE_API_KEY=sk_test_your_stripe_secret_key
31+
BROWSERBASE_API_KEY=your_browserbase_api_key
32+
BROWSERBASE_PROJECT_ID=your_browserbase_project_id
33+
```
34+
35+
3. **Install Playwright browsers**:
36+
```bash
37+
playwright install
38+
```
39+
40+
## πŸš€ Usage
41+
42+
### Step 1: Create a Cardholder
43+
```bash
44+
python create_cardholder.py
45+
```
46+
47+
### Step 2: Create a Virtual Card
48+
```bash
49+
python create_card.py
50+
```
51+
⚠️ **Important**: Update the `cardholder_id` variable with the ID from Step 1
52+
53+
### Step 3: Retrieve Card Details
54+
```bash
55+
python get_card.py
56+
```
57+
⚠️ **Important**: Uncomment and update the `card_id` variable with the ID from Step 2
58+
59+
### Step 4: Make an Automated Payment
60+
```bash
61+
python make-payment.py
62+
```
63+
⚠️ **Important**: Update the `cardId` variable with the ID from Step 2
64+
65+
## πŸ“ Files
66+
67+
| File | Description |
68+
|------|-------------|
69+
| `create_cardholder.py` | Creates a Stripe cardholder with billing information |
70+
| `create_card.py` | Creates a virtual card with spending limits |
71+
| `get_card.py` | Retrieves card details including sensitive information |
72+
| `make-payment.py` | Automates a donation using Playwright and Browserbase |
73+
| `requirements.txt` | Python dependencies |
74+
| `.env` | Environment variables (not tracked in git) |
75+
76+
## πŸ”§ Configuration
77+
78+
### Spending Controls
79+
Edit `create_card.py` to customize:
80+
- **Allowed categories**: Restrict card usage to specific merchant categories
81+
- **Spending limits**: Set daily/monthly/yearly limits
82+
- **Blocked categories**: Prevent usage at certain merchant types
83+
84+
### Payment Automation
85+
Modify `make-payment.py` to:
86+
- Change the target website
87+
- Customize form filling logic
88+
- Add error handling and validation
89+
90+
## 🐍 Python-Specific Features
91+
92+
### Virtual Environment (Recommended)
93+
```bash
94+
python -m venv venv
95+
source venv/bin/activate # On Windows: venv\Scripts\activate
96+
pip install -r requirements.txt
97+
```
98+
99+
### Error Handling
100+
The Python implementation includes:
101+
- Environment variable validation
102+
- Stripe API error handling
103+
- Playwright timeout management
104+
105+
### Dependencies
106+
- **stripe**: Official Stripe Python library
107+
- **browserbasehq**: Browserbase SDK for Python
108+
- **playwright**: Browser automation framework
109+
- **python-dotenv**: Environment variable management
110+
111+
## πŸ” Security Notes
112+
113+
- Never commit `.env` files to version control
114+
- Use test API keys for development
115+
- Implement proper exception handling in production
116+
- Consider using Stripe webhooks for real-time updates
117+
- Always validate sensitive card data before use
118+
119+
## πŸ“– Documentation
120+
121+
For full API documentation and advanced usage:
122+
πŸ“„ **[Stripe Python SDK](https://stripe.com/docs/api/python)**
123+
πŸ“„ **[Browserbase Python SDK](https://docs.browserbase.com/sdk/python)**
124+
πŸ“„ **[Playwright Python](https://playwright.dev/python/)**
125+
126+
## 🎯 Example Use Cases
127+
128+
- **Financial automation**: Automate expense reporting and payment processing
129+
- **E-commerce testing**: Test payment flows across multiple platforms
130+
- **Budget management**: Create spending-limited cards for different departments
131+
- **Subscription automation**: Programmatically manage recurring payments
132+
133+
## 🚨 Troubleshooting
134+
135+
### Common Issues
136+
- **Import errors**: Ensure all dependencies are installed via `pip install -r requirements.txt`
137+
- **Playwright errors**: Run `playwright install` to download browser binaries
138+
- **Stripe API errors**: Verify your API keys and account permissions
139+
- **Environment variables**: Double-check your `.env` file formatting

0 commit comments

Comments
Β (0)