# Handle Stripe webhooks without running a server

Source: https://clickruntime.com/use-cases/stripe-webhooks

> Tell your assistant what should happen when Stripe sends an event. ClickRuntime gives you the endpoint URL, verifies the Stripe-Signature header, ignores repeat deliveries and runs your code.

## Can Claude or ChatGPT handle Stripe webhooks?

Not directly: Stripe sends webhooks to an HTTPS endpoint that must answer every time, and an assistant isn't a server. With ClickRuntime connected, Claude, ChatGPT or another assistant creates an automation with a trigger link you add in Stripe as the endpoint. ClickRuntime checks the Stripe-Signature header, drops repeat deliveries, and runs the script for each event.

### Why the assistant can't do this on its own

- Stripe needs an endpoint that's always up. A chat is only active while you type.
- Signatures must be checked against your endpoint secret, which has to be stored somewhere safe, not pasted into a conversation.
- Stripe retries deliveries, so you need memory of which events were already handled. ClickRuntime gives each automation state and a stable event id.

## Set it up from your AI assistant

Prompt to copy:

> Create a ClickRuntime automation: when Stripe sends checkout.session.completed, post the customer email and amount to #sales in Slack. Check the Stripe signature and handle each event only once.

1. **Connect ClickRuntime to your assistant.** Add ClickRuntime as a connector (MCP server) in ChatGPT, Claude, Cursor or another MCP client, using https://clickruntime.com/api/mcp. You sign in with Google or email; there is no API key to copy. This is done once per assistant.
2. **Paste the prompt.** Start a new chat and paste: “Create a ClickRuntime automation: when Stripe sends checkout.session.completed, post the customer email and amount to #sales in Slack. Check the Stripe signature and handle each event only once.” Change the details (times, channels, addresses) to yours.
3. **Read the draft.** The assistant restates what will happen, asks for anything missing, such as your timezone or which channel to post to, and saves a draft automation. A draft never runs on its own, so nothing happens until you agree.
4. **Connect accounts and save keys.** The assistant gives you the trigger link. In Stripe, go to Developers → Webhooks, add it as an endpoint for checkout.session.completed, and copy the signing secret. Save it in the ClickRuntime dashboard in the trigger link's signature settings (provider Stripe), or as STRIPE_WEBHOOK_SECRET. It also asks you to connect Slack for notifications and pick the channel.
5. **Test it.** Send a test event from Stripe's webhook page, or use `stripe trigger checkout.session.completed` with the Stripe CLI. The assistant looks at the stored event, confirms the signature passed, and checks the Slack message.
6. **Turn it on.** The assistant tells you what will run, when, and which services it will contact, then asks your permission to turn it on. From then on it runs on ClickRuntime's servers, and you can close the chat.
7. **Check it in the ClickRuntime dashboard.** Every delivery shows as an incoming event with whether the Stripe signature passed, the run it started and its result. If your code had a bug, fix it with your assistant and replay the stored events. Stripe doesn't have to resend anything.

Connector setup for each assistant: https://clickruntime.com/assistants

## What the assistant writes

`stripe_checkout_to_slack.py`

```python
from clickruntime import on_event, credentials, verify, state, notify, log

@on_event
def handle(event):
    secret = credentials.secret("STRIPE_WEBHOOK_SECRET")
    if not verify.stripe(event.body, event.header("Stripe-Signature"), secret):
        log.warning("Bad Stripe signature")
        return {"skipped": "bad signature"}

    body = event.json
    if body["type"] != "checkout.session.completed":
        return {"skipped": body["type"]}
    if state.get("seen:" + body["id"]):
        return {"skipped": "already handled"}

    session = body["data"]["object"]
    amount = (session.get("amount_total") or 0) / 100
    currency = (session.get("currency") or "").upper()
    email = (session.get("customer_details") or {}).get("email", "unknown")

    notify.slack(f"New payment: {amount:,.2f} {currency} from {email}", channel="#sales")
    state.set("seen:" + body["id"], True)
    return {"posted": body["id"], "amount": amount}
```

- `verify.stripe` checks the signature against the raw body with a 5-minute tolerance. Turning on Stripe signature checks for the trigger link does the same before the script runs.
- Stripe's event id is stored after handling, so retries and replays don't post twice.
- Only fields Stripe actually sends in checkout.session.completed are used; the assistant checks them against a stored test event.

## Trigger link, not a schedule

Use the trigger link. Stripe pushes events as they happen, and each event is one run.

Use a schedule only for summaries, such as a daily revenue total from Stripe's API. That can be the same automation's @on_trigger handler.

## Limits

- Each delivered event is one run, so subscribe the endpoint only to the event types you use.
- Runs have a time limit; long work such as generating reports should run on a schedule instead.
- Stripe expects a quick 2xx response. ClickRuntime accepts the event and stores it, so a failed run can be replayed later.

## Troubleshooting

### Every event fails the signature check.

The secret is from a different endpoint or from test mode. Each Stripe endpoint has its own signing secret; copy the one for this endpoint and save it again.

### Stripe shows failed deliveries.

Check the endpoint URL is the trigger link exactly, with nothing added. The event list in the ClickRuntime dashboard shows whether anything arrived.

### Some payments are missing in Slack.

The endpoint may not be subscribed to that event type, or test and live mode are mixed. Ask your assistant to list recent incoming events and compare.

## Related

- [Stripe automations](https://clickruntime.com/apps/stripe)
- [Slack automations](https://clickruntime.com/apps/slack)
- [Google Sheets automations](https://clickruntime.com/apps/google-sheets)
- [HubSpot automations](https://clickruntime.com/apps/hubspot)
- [stripe-payments-to-sheets](https://clickruntime.com/templates/stripe-payments-to-sheets)
- [weekly-stripe-revenue](https://clickruntime.com/templates/weekly-stripe-revenue)
- [get-alerted-when-a-stripe-refund-is-issued](https://clickruntime.com/templates/get-alerted-when-a-stripe-refund-is-issued)
- [Webhook automation](https://clickruntime.com/use-cases/webhook-automation)
- [React to GitHub events](https://clickruntime.com/use-cases/github-webhooks)
- [Form submissions to Google Sheets](https://clickruntime.com/use-cases/form-to-google-sheets)
- [AWS Lambda + EventBridge alternative](https://clickruntime.com/alternatives/aws-lambda-eventbridge)
- [Google Apps Script alternative](https://clickruntime.com/alternatives/google-apps-script)
- [Pipedream alternative](https://clickruntime.com/alternatives/pipedream)
- [Docs: trigger-links](https://clickruntime.com/docs/trigger-links)
- [Docs: troubleshooting](https://clickruntime.com/docs/troubleshooting)

## Extend it: what you can add next

The first version is rarely the last. Because the automation is a Python script with memory, AI and any API available, you grow it by asking your assistant for the change. Each change is a new version, and a failed deploy never replaces the working one.

- **Log each payment as a row in a Google Sheet** (Any app or API)
  Prompt: "Add to my Stripe checkouts automation: also add a row to my Payments sheet with date, email, amount and currency."
- **Handle refunds and failed payments in the same automation** (Multi-step logic)
  Prompt: "Change my Stripe checkouts automation so it also handles charge.refunded and invoice.payment_failed, posting each to #billing with the reason."
- **Keep a running monthly revenue total and include it in each post** (Memory between runs)
  Prompt: "Change my Stripe checkouts automation so each Slack post also says the total for this month so far."
- **A daily revenue summary at 18:00** (Schedules)
  Prompt: "Add to my Stripe checkouts automation: every day at 18:00, post the day's total and number of payments to #sales."
- **Summarise refund reasons into themes each week** (Built-in AI)
  Prompt: "Add to my Stripe checkouts automation: every Friday, email me a short summary of this week's refund reasons grouped by theme."
- **Tag the customer in HubSpot when they pay** (Any app or API)
  Prompt: "Add to my Stripe checkouts automation: when a checkout completes, set the HubSpot contact with that email to customer."
- **Accept Shopify orders through a second trigger link into the same channel** (Trigger links)
  Prompt: "Create a second automation like my Stripe checkouts one for Shopify orders/create, posting to the same #sales channel."

## Questions

### Can Claude handle Stripe webhooks?

Yes, with ClickRuntime. Claude writes the handler and ClickRuntime gives you an always-on endpoint that checks the Stripe signature and runs it for each event.

### Do I need a server for Stripe webhooks?

No. The automation's trigger link is the endpoint. ClickRuntime receives the event, stores it and runs your script.

### How is the signature checked?

With Stripe's signing secret, either by the trigger link before the script runs or in the script with verify.stripe, against the raw body.

### What if Stripe sends the same event twice?

The platform deduplicates deliveries, and the script also stores the Stripe event id so a retry or replay is skipped.

### Can I replay an event after fixing a bug?

Yes. Stored events can be replayed from the ClickRuntime dashboard or by asking your assistant.

### What does it cost?

One run per event. The free plan includes 250 runs a month with webhooks included.
