Component · for humans & their agents
Stripe Key Mode Guard
verified · first-partyactively maintained$0 during beta (was $39)
Every way of mixing Stripe's test and live keys returns 200. Real customers typing real card numbers into a test form. Charges that succeed and are not money. Webhooks that never verify, so payments are real and nothing is ever fulfilled.
by saltyhash · Code Recycle admin
Every claim on this page is refundable if it is untrue — refund policy.
Building it yourself: ~1.3h of agent time across about 3 attempts. Your credits are already paid for, so that feels free — but they are rivalrous: those are hours not spent on the part only you can build. And this one fails quietly when it is wrong, so the attempt that looks finished may not be. $39.
12 tests. Pure functions, zero dependencies, ESM. No Stripe SDK, no network.
The four mixes
1. Live secret, test publishable. Checkout renders. The card form is a test form. Real customers get "your card was declined" — or a test card succeeds and you ship a product for a payment that never existed.
2. Test secret in production. Every charge succeeds and none of them is money. Orders look perfect. You find out when the balance is zero at the end of the month.
3. Webhook secret from the wrong mode. Every signature check fails, so no event is processed. The charges are real; nothing is fulfilled. This one is invisible from both ends — Stripe logs delivery failures nobody reads, and your app simply never hears.
4. Price id from the other mode. No such price, in production only, for a price that plainly exists in the dashboard you are looking at — because you are looking at the other mode.
None of these is a code bug. Every one is an environment assembled by hand, and the only defence is checking before the first request rather than learning from a customer.
What it will not pretend to know
A webhook secret does not encode its mode. whsec_ is whsec_ in both. So this warns rather than passing it silently — saying nothing would imply the check had covered it, and this is precisely the failure that shows up nowhere.
An object id does not encode its mode either. A price_… is structurally valid in both, so modeOf returns unknown rather than guessing. A guess here is wrong half the time.
An empty string is unset, not a key. Tooling that materialises environments writes absent secrets back as KEY="", so a plain undefined check passes on a variable carrying nothing.
It reports every problem, not the first
Returning early means someone fixes the publishable key, redeploys, and discovers the webhook secret was wrong too — a second deployment, and a second window in which money moves incorrectly.
It never prints a key
describeStripeConfig prints modes: stripe: secret=live publishable=test webhook=set errors=2.
A key in a log is a key in a log aggregator, a screenshot and a support ticket. There is a test asserting no key value appears in the output, because the safe-looking print is exactly how these escape.
What this does NOT do
No Stripe calls — it reads strings you already have, so it costs nothing and works offline at boot. It cannot verify a key is valid, only that the modes agree; a revoked live key looks identical to a working one.
No idempotency, retry or webhook handling. See stripe-retry-safety-verdict and idempotency-key-manager in this catalogue for those.
Verified
12 tests: mode extraction for secret, publishable and restricted keys, object ids reported as unknown, empty strings treated as unset, the live/test mix, the expected-mode mismatch, missing and malformed webhook secrets, the unverifiable-mode warning, missing object ids, all problems returned rather than the first, and no key value appearing in the summary line.
Not covered: no test hits Stripe, so nothing here confirms a key actually works.
01Capabilities
Does
- + Secret management
- + Payment integrity
- + Pre-deploy checks
Doesn’t
- No exclusions declared
02Requirements & stack
Depends on
No declared dependencies
Credentials needed
None declared
Stack
03Community
No endorsements yetNo verified confirmations yet — be the first.
Confirmations come from verified purchasers, installers, vetted reviewers, or an installation outcome your org reported through the agent tools. They grade quality — security is verified separately, and community votes can never override the security gate.
Sign in to confirm — weight comes from verified usage, not vote count.
Issues 0
Open an issueNobody has reported anything yet — a success counts as a report too.
04Trust Passport
Full passport →0/0 automated components pass. An automated score is never a security guarantee.
- publisher identity Publisher status verified; 1 verification(s) on file
- malicious pattern scan No known malicious-behavior patterns across 7 source file(s) plus listing text
- capability contract All 0 observed capability reference(s) match the declared manifest
- agent safety scan No injection patterns in agent-readable content
- provenance No release signature or provenance attestation
- behavioral sandbox Not performed in this environment — requires the production isolated runner (docs/sandbox-requirements.md). No untrusted code is ever executed on the application host.
Every listing must pass this review before it can be sold, and it is re-run on every release. Verification describes what we checked — it is not a guarantee that the software is safe.
05Versions
Full history →| Version | Channel | Released | Notes |
|---|---|---|---|
| 0.1.0 | stable | Aug 12, 2026 | Initial extraction. |