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

  • -In this article we explore how to connect Stripe to Claude Code without pasting a Stripe secret key into the chat.
  • -To understand how Claude Code should call Stripe: the call goes through Swytchcode, which attaches the credential. Claude names the tool and does not hold the key.
  • -Find the current Stripe method with swy discover. Do not hardcode a method id, because catalog ids change.
  • -Stripe writes are retried only when an idempotency key is set. A new request is a second charge or a second refund.
  • -Sandbox or production for the Stripe connection is set once at swy init and stored in .swytchcode/tooling.json. It is not an environment variable.

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 the result. 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 pasted into the chat or into a project file the model can read. Claude Code will use that key, and it will repeat it if a later prompt asks. Swytchcode has no project env file for credentials. swy auth connect stripe stores the key outside the project.

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 allow, deny, or hold the call, and it can read the arguments. Policy runs before the credential is injected, so a blocked call never touches the key or the network. Approval workflows, on Business and Enterprise, hold the call for Slack or Telegram. If nobody approves within 48 hours, the call never runs. 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.

Retries back off on rate limits. 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 response is checked on the way back, including a 200 whose body says the action failed. 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 or production is the project mode. Set it once with swy init --mode=sandbox until you mean to run live. It is stored in tooling.json and it is not an environment variable. The model does not choose the mode.

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 mode is stored in tooling.json. 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