Back to The Times of Claw

Connecting OpenClaw to Stripe: Automate Payment Workflows

Connecting OpenClaw to Stripe lets your AI agent check payment status, trigger invoices, and update CRM records automatically. Here's how to set it up.

Mark Rachapoom
Mark Rachapoom
·8 min read
Connecting OpenClaw to Stripe: Automate Payment Workflows

Connecting OpenClaw to Stripe means your AI agent can answer questions like "which customers have overdue invoices?" or "what did revenue look like last month?" — and act on the answers. This guide walks through building a Stripe skill for DenchClaw that gives your agent read and write access to your Stripe account.

Before starting, make sure you've followed the basic DenchClaw setup and understand what DenchClaw is. This tutorial assumes you have a running instance at localhost:3100.

What You'll Build#

By the end of this guide, your DenchClaw agent will be able to:

  • Query customer payment status from Stripe
  • List recent charges and subscriptions
  • Create invoices on demand
  • Sync Stripe customer data to your local CRM (DuckDB)
  • Receive webhook events and update records automatically

Step 1: Create a Restricted Stripe API Key#

Never give your agent your full Stripe secret key. Create a restricted key with only the permissions it needs:

  1. Go to Stripe Dashboard → Developers → API Keys
  2. Click Create restricted key
  3. Name it openclaw-agent
  4. Grant these permissions:
    • Customers: Read (or Read + Write if you need to create customers)
    • Charges: Read
    • Invoices: Read + Write (for invoice creation)
    • Subscriptions: Read
    • Webhook endpoints: Read
  5. Copy the key — it starts with rk_live_ (or rk_test_ for test mode)

Store it in your environment:

# Add to your shell profile or OpenClaw env config
export STRIPE_API_KEY="rk_test_your_key_here"

Step 2: Create the Stripe Skill#

Skills are markdown files in your workspace's skills/ directory. Create one for Stripe:

mkdir -p ~/.openclaw-dench/workspace/skills/stripe

Create the skill file:

cat > ~/.openclaw-dench/workspace/skills/stripe/SKILL.md << 'EOF'
# Stripe Skill
 
Use this skill when the user asks about payments, invoices, customers, charges, subscriptions, or revenue data.
 
## Authentication
 
The Stripe API key is available as `$STRIPE_API_KEY` in the environment. Always use this environment variable — never hardcode keys.
 
## API Base
 
All Stripe API calls use: `https://api.stripe.com/v1/`
 
Authentication: Basic auth with API key as username, empty password.
 
## Common Operations
 
### List recent charges

exec: curl -s -u "$STRIPE_API_KEY:"
"https://api.stripe.com/v1/charges?limit=10" | jq '.data[] | '


### Get customer by email

exec: curl -s -u "$STRIPE_API_KEY:"
"https://api.stripe.com/v1/customers?email=EMAIL&limit=1" | jq '.data[0]'


### List subscriptions for a customer

exec: curl -s -u "$STRIPE_API_KEY:"
"https://api.stripe.com/v1/subscriptions?customer=CUSTOMER_ID" | jq '.data[] | '


### Create an invoice

exec: curl -s -u "$STRIPE_API_KEY:"
-X POST https://api.stripe.com/v1/invoices
-d "customer=CUSTOMER_ID"
-d "auto_advance=false"


### List overdue invoices

exec: curl -s -u "$STRIPE_API_KEY:"
"https://api.stripe.com/v1/invoices?status=open&limit=100" |
jq '.data[] | select(.due_date < now) | '


## Data Types

Stripe amounts are in the smallest currency unit (cents for USD). Divide by 100 for display.

Unix timestamps need conversion: `date -r TIMESTAMP` on macOS, `date -d @TIMESTAMP` on Linux.

## Syncing to DuckDB

When asked to sync Stripe data to CRM, fetch from the API and write to DuckDB:

```sql
INSERT OR REPLACE INTO stripe_customers 
SELECT * FROM (VALUES ('CUSTOMER_ID', 'EMAIL', 'NAME', STATUS, CREATED_TS));

Error Handling#

Stripe returns errors in this format:

{"error": {"type": "...", "message": "..."}}

Check for .error in responses. Common errors:

  • authentication_error: Bad API key
  • rate_limit_error: Too many requests — wait and retry
  • invalid_request_error: Bad parameters

Rate Limits#

Stripe allows 100 read requests/second in live mode, 25/second in test mode. For bulk operations, add sleep 0.1 between requests.

EOF


## Step 3: Test the Skill

In your DenchClaw chat, try:

What were the last 5 charges on my Stripe account?


The agent should:
1. Load the Stripe skill automatically (it's in the skills directory)
2. Execute the curl command against Stripe
3. Parse and display the results

If it doesn't load automatically, reference it explicitly:

Load the Stripe skill and show me the last 5 charges.


## Step 4: Sync Stripe Customers to DuckDB

One of the most useful automations: keep your Stripe customer data in DuckDB so you can query it alongside your other CRM data.

### Create the table

Open a DuckDB session and create the schema:

```sql
-- Run this in DuckDB or ask your agent to run it
CREATE TABLE IF NOT EXISTS stripe_customers (
  stripe_id VARCHAR PRIMARY KEY,
  email VARCHAR,
  name VARCHAR,
  created_at TIMESTAMP,
  currency VARCHAR,
  balance INTEGER,
  delinquent BOOLEAN,
  synced_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

CREATE TABLE IF NOT EXISTS stripe_subscriptions (
  subscription_id VARCHAR PRIMARY KEY,
  customer_id VARCHAR,
  status VARCHAR,
  price_id VARCHAR,
  current_period_start TIMESTAMP,
  current_period_end TIMESTAMP,
  cancel_at_period_end BOOLEAN,
  synced_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
);

Sync script#

Ask your agent to sync:

Sync all Stripe customers to the stripe_customers table in DuckDB. 
Fetch in pages of 100 until there are no more results.

Or create a skill that does this automatically. Add to your Stripe skill:

## Bulk Sync Procedure
 
To sync all customers:
1. Fetch first page: GET /v1/customers?limit=100
2. Insert each customer into stripe_customers table
3. If response has_more=true, fetch next page using starting_after=last_id
4. Repeat until has_more=false
5. Report total count synced

Step 5: Set Up Webhook Handling#

For real-time updates — when a payment succeeds, subscription cancels, invoice is paid — set up Stripe webhooks that feed into your agent.

See the OpenClaw Webhook Handling guide for the detailed webhook setup. For Stripe specifically:

Create a webhook endpoint in Stripe#

  1. Go to Stripe Dashboard → Developers → Webhooks
  2. Add endpoint: https://your-openclaw-domain.com/webhooks/stripe
  3. Select events:
    • payment_intent.succeeded
    • customer.subscription.deleted
    • invoice.payment_failed
    • customer.updated

Verify webhook signatures#

Stripe signs webhooks with a Stripe-Signature header. Always verify:

const stripe = require('stripe')(process.env.STRIPE_API_KEY);
 
function verifyStripeWebhook(rawBody, signature, secret) {
  try {
    return stripe.webhooks.constructEvent(rawBody, signature, secret);
  } catch (err) {
    throw new Error(`Webhook signature verification failed: ${err.message}`);
  }
}

Add to your Stripe skill:

## Webhook Event Handling
 
When a webhook arrives:
1. Verify the Stripe-Signature header
2. Parse the event type
3. For payment_intent.succeeded: update the relevant CRM record status to "paid"
4. For customer.subscription.deleted: update subscription status in DuckDB
5. For invoice.payment_failed: create a follow-up task in the CRM

Step 6: Build a Revenue Dashboard#

With Stripe data in DuckDB, you can ask your agent to generate revenue reports:

What was MRR last month vs the month before? 
Show me customers who haven't paid in 60+ days.
Which subscription tier generates the most revenue?

Or build a DenchClaw app that visualizes Stripe data using Chart.js:

// In a .dench.app
const charges = await duckdb.query(`
  SELECT 
    DATE_TRUNC('month', created_at) as month,
    SUM(amount) / 100 as revenue_usd
  FROM stripe_charges
  WHERE status = 'succeeded'
  GROUP BY 1
  ORDER BY 1 DESC
  LIMIT 12
`);

Practical Automation Examples#

Here are concrete prompts to try once you have the skill configured:

Revenue query:

Show me total revenue for the last 30 days broken down by day.

Customer lookup:

What subscriptions does customer@example.com have? Are they current or overdue?

Batch operation:

Find all customers with a failed payment in the last 7 days and list their emails.

CRM sync:

For each lead in my CRM with a Stripe customer ID, update their "payment_status" field 
with their current subscription status from Stripe.

Troubleshooting#

"Authentication failed" errors: Check that $STRIPE_API_KEY is exported in your environment and accessible to the OpenClaw process. Run echo $STRIPE_API_KEY in the same shell to verify.

Rate limit errors: Stripe's test mode limits are low (25 req/sec). Add delays between bulk requests and prefer paginated calls over many individual lookups.

Amounts look wrong: Remember Stripe stores amounts in cents. A charge of 2999 is $29.99 USD.

Webhooks not arriving: Stripe requires a publicly accessible HTTPS endpoint. Use ngrok for local development: ngrok http 19001.

FAQ#

Q: Can the agent create and send invoices automatically? A: Yes. With Write permissions on Invoices in your restricted key, the agent can create invoices and trigger Stripe to send them. Add a prompt like "Create an invoice for $X to customer Y and send it."

Q: Is it safe to give the agent Stripe write access? A: Use restricted keys and be explicit in your skill about which write operations are allowed. The skill file is your policy document — if you only include read operations in it, the agent will only read.

Q: Can I connect multiple Stripe accounts? A: Yes. Create separate skill files (e.g., stripe-production/SKILL.md and stripe-staging/SKILL.md) with different API keys.

Q: Does this work with Stripe Connect? A: Yes. For Connect platforms, add the Stripe-Account: acct_xxx header to API calls to operate on connected accounts.

Q: How do I handle PCI compliance? A: DenchClaw never handles raw card data — it only communicates with Stripe's API, which handles all PCI-sensitive operations. The API key in your environment is the only sensitive credential.

Ready to try DenchClaw? Install in one command: npx denchclaw. Full setup guide →

Mark Rachapoom

Written by

Mark Rachapoom

Building the future of AI CRM software.

Continue reading

DENCH

© 2026 DenchHQ · San Francisco, CA