Content

How to Connect Stripe to Claude Code

Claude Code can call Stripe through Swytchcode. The model names the action. The runtime checks the allow list, attaches the credential, and retries the write safely.

IntegrationsOct 16, 2026

Key takeaways

  • -Claude Code should call Stripe through an execution layer, not with a secret key pasted into the chat.
  • -Discover the current method instead of hardcoding one. Catalog ids change.
  • -The runtime attaches the credential. The model only names the tool.
  • -Writes are retried only with an idempotency key. A new request is a second charge or a second refund.
  • -Sandbox and production endpoints live in the manifest, outside the model's reach.

Claude Code can call Stripe. It should not be the thing holding the secret key, choosing the base URL, or deciding that a timed-out payment is safe to send again as a brand-new request.

Swytchcode is the execution kernel between Claude Code and Stripe. The model decides what it wants. The runtime checks that the method is allowed, validates the input, evaluates policy, attaches the credential, sends the request, and returns a result the agent can trust. The same eight stages are described in AI agent execution layer architecture. This page is the Claude Code path. The same idea for any agent runtime is How to Connect Stripe to an AI Agent Without Double Refunds.

Connect the runtime, not a pasted key

The usual shortcut is a Stripe secret in CLAUDE.md, a .env file the model can read, or a message that starts with the key. Claude Code will use that key. It will also repeat it if a later prompt asks what credentials it has, because the key is in the context.

Do this instead:

npm install -g swytchcode
swy login
swy init --editor=claude --mode=sandbox

swy get stripe
swy discover "refund a charge" --project stripe
swy auth connect stripe

swy init --editor=claude registers the MCP server Claude Code calls. The editor setup is in How to Connect Swytchcode MCP Server. swy get stripe downloads the integration. It does not turn every Stripe action on. You add the methods this project is allowed to call. swy discover prints the current method for the job you described. Use that name. Do not copy a method id out of an old blog post. Catalog ids change as the integration is updated.

swy auth connect stripe stores the credential outside the chat. On a call, the runtime attaches it. The model names the tool. It does not see the secret, so a prompt that asks Claude Code to print the Stripe key has nothing to print. How that works is credential brokering. Docs: authentication and exec.

Allow the actions you mean

"Access to Stripe" is not a permission a reviewer can read. Stripe has many writes that move money in different ways. A refund of a charge, a change to a customer balance, and a payout are not the same action. An agent told to "refund this" will pick one and sound sure.

The allow list is the file of methods you added. If the method is not on that list, the call stops before any request is sent. That is the first stage of the execution layer, and it is the answer to "what can this agent touch?" Read the schema with swy info on the method discover returned, so the agent works from the current fields rather than a remembered request. Claude Code inventing an endpoint is a separate failure, covered in Why Claude Code Guesses API Endpoints.

Policy is a different file from the allow list. The allow list says the method may exist. Policy says whether this call, with these arguments, should run. A rule can block it, hold it for a person in Slack or Telegram, or cap a value. Policy runs before the credential is attached, so a blocked call never touches the key or the network. An approval that nobody answers expires after 48 hours and the command does not run. The files and the rules are in Policy-as-Code for AI Agents and How to Set Up Policy Guardrails.

Money fields and retries

Stripe amounts are integers in the smallest unit of the currency. A person says "five hundred dollars." The API does not want the words five hundred. If the model copies a human figure straight into the amount field, the charge or the refund is the wrong size. Read the field in swy info for the method you added. Do not rely on a sentence in the prompt that says "remember the units."

A policy can hold a large amount for a person. Put that rule in the policy file, not in the chat. The model can be talked out of a sentence in CLAUDE.md. It cannot skip a rule the runtime evaluates before the request.

The other money bug is the retry. Claude Code will try a tool again when the first attempt looks like it failed. A payment or a refund that timed out has often succeeded at Stripe and failed on the way back. If the second attempt is a new request, the customer is charged or refunded twice.

Swytchcode retries 429, 503, and 504 responses, and network errors. A POST or PATCH is retried only when an idempotency key is set. The runtime keeps that key. The model does not mint a new one on the second try. The detail is in How Swytchcode Retries Failed API Calls and Idempotency Explained.

If the same write is driven from the Anthropic Agent SDK rather than from Claude Code's tools, the SDK will run the tool more than once. The safe retry is still the runtime's, not the model's. See Making Anthropic Agent SDK Tool Calls Idempotent.

Test it in sandbox. Run a small write, drop the response, and run the same call again. One result on the Stripe side is the pass. Two results is the finding, even if the chat showed one success.

Sandbox and production

Test keys and live keys look almost the same in a file. They do not look the same on a bank statement. The model should not be the thing choosing which one is in use.

Sandbox and production are endpoints in the manifest, chosen by the mode of the project. Initialise with --mode=sandbox until you mean to run live. The model cannot point a tool at the other base URL, because it never sets the base URL. That is stage 4 of the execution layer: resolve the endpoint, outside the model's reach.

The request then goes from your machine to Stripe. Swytchcode does not proxy the call or store the payment body. The credential stays out of the model's context. Every call and every policy decision is written to a local audit log, with sensitive values redacted.

swy audit network
swy audit policy

Network is what ran. Policy is what was blocked or held, and which rule did it. The held calls are the ones a chat transcript drops. Exit codes, so a policy block is not mistaken for a Stripe error, are in "swy exec" Explained.

Fintech connections beyond a single provider are in Connect Fintech APIs to Claude. The product page is the AI agent integration platform.

FAQ

How do I connect Stripe to Claude Code?

Install the CLI, initialise the project for Claude in sandbox, download Stripe, discover the method you need, add that method, and connect the credential: swy init --editor=claude --mode=sandbox, swy get stripe, swy discover for the job, swy auth connect stripe. Claude Code calls the method through MCP. It does not receive the secret key.

Can I paste a Stripe secret into Claude Code?

You can, and the key is then in the conversation. Connect it with swy auth connect stripe so the runtime attaches it at execution and the model never sees it.

How do I stop a retried payment from running twice?

Retry the same call. Swytchcode sends the idempotency key again on a POST or PATCH. A brand-new request is a second payment or a second refund. Timeouts are the usual trigger: Stripe did the work, and the response never came back.

How do I keep Claude Code on Stripe test mode?

Initialise with --mode=sandbox. The runtime uses the sandbox endpoint from the manifest. Do not leave test and live keys in the prompt for the model to choose between.

What if I do not know the Stripe method name?

Ask discover, in the project, after swy get stripe. The name it prints is the one to add and execute. Names in old notes go stale.

Is this different from connecting Stripe to an AI agent?

The rules are the same. This page is the Claude Code setup: MCP, the editor, and the chat as the place people paste keys. The agent-runtime version is How to Connect Stripe to an AI Agent Without Double Refunds.

More content