Manage Stripe Payments from Your AI Agent with the Stripe Skill
If you're building applications that handle payments, subscriptions, or billing, you know Stripe is the go-to payment processor. But what if your AI agent could manage customers, create subscriptions, and handle invoices directly? The Stripe skill from ClawdHub makes this possible with managed OAuth authentication through the Maton gateway.
What This Skill Does
The Stripe skill provides a complete interface to Stripe's API, letting your AI agent:
- Manage customers - Create, update, and query customer records
- Handle subscriptions - Create recurring billing, upgrade/downgrade plans, cancel subscriptions
- Process payments - Create charges, payment intents, and handle refunds
- Manage products and prices - Set up your product catalog and pricing tiers
- Work with invoices - Generate, finalize, and track invoice payments
All of this happens through Maton's OAuth gateway, so you don't need to manage Stripe API keys directly in your agent.
Installation
npx clawdhub@latest install stripe-apiSetup
1. Get Your Maton API Key
- Sign up or sign in at maton.ai
- Go to maton.ai/settings
- Copy your API key
2. Set the Environment Variable
export MATON_API_KEY="your-maton-api-key"3. Connect Your Stripe Account
Create an OAuth connection to Stripe:
python <<'EOF'
import urllib.request, os, json
data = json.dumps({'app': 'stripe'}).encode()
req = urllib.request.Request('https://ctrl.maton.ai/connections', data=data, method='POST')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
req.add_header('Content-Type', 'application/json')
result = json.load(urllib.request.urlopen(req))
print(f"Open this URL to authorize: {result['connection']['url']}")
EOFOpen the returned URL in your browser to complete OAuth authorization with your Stripe account.
Usage Examples
List Your Customers
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/stripe/v1/balance')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
balance = json.load(urllib.request.urlopen(req))
for b in balance['available']:
print(f"Available: {b['amount']/100:.2f} {b['currency'].upper()}")
EOFCreate a New Customer
curl -X POST 'https://gateway.maton.ai/stripe/v1/customers' \
-H "Authorization: Bearer $MATON_API_KEY" \
-d "email=customer@example.com" \
-d "name=John Doe" \
-d "metadata[source]=clawdbot"Check Your Balance
python <<'EOF'
import urllib.request, os, json
req = urllib.request.Request('https://gateway.maton.ai/stripe/v1/balance')
req.add_header('Authorization', f'Bearer {os.environ["MATON_API_KEY"]}')
balance = json.load(urllib.request.urlopen(req))
for b in balance['available']:
print(f"Available: {b['amount']/100:.2f} {b['currency'].upper()}")
EOFCreate a Subscription
curl -X POST 'https://gateway.maton.ai/stripe/v1/subscriptions' \
-H "Authorization: Bearer $MATON_API_KEY" \
-d "customer=cus_XXX" \
-d "items[0][price]=price_XXX"Tips and Best Practices
Use test mode first: Stripe has a test mode with test API keys. Connect your test Stripe account first to experiment without processing real payments.
Understand Stripe's ID prefixes: All Stripe objects have predictable ID prefixes - cus_ for customers, sub_ for subscriptions, in_ for invoices, pi_ for payment intents. This makes it easy to identify what you're working with.
Amounts are in cents: When creating charges or prices, remember that amounts are in the smallest currency unit. $19.99 is 1999, not 19.99.
Use application/x-www-form-urlencoded: Unlike most APIs, Stripe uses form encoding for POST requests, not JSON. The examples above handle this correctly.
Handle pagination: Stripe returns paginated results. Use starting_after with the last item's ID to get the next page when has_more is true.
Common Use Cases
- SaaS billing automation: Have your agent check subscription status, handle upgrades, or process cancellations based on user requests
- Customer support: Quickly look up customer payment history, refund transactions, or update billing details
- Reporting: Generate daily revenue reports, track failed payments, or monitor subscription churn
- Dunning management: Automatically follow up on failed payments or expiring cards
Conclusion
The Stripe skill transforms your AI agent into a capable payment operations assistant. Whether you're managing a SaaS product, an e-commerce store, or any subscription-based service, having direct Stripe access from your agent streamlines billing workflows significantly.
Install the skill, connect your Stripe account through Maton's secure OAuth flow, and start automating your payment operations.
Links:
Comments (0)
No comments yet. Be the first to comment!