nodecode-stripe
A Nodecode cell that gives the model the operator's Stripe account through Stripe's REST API: the balance, customers, invoices, subscriptions, charges and payment intents, read-only unless the operator allows three small writes. Every answer opens with the mode the key works in, so live data is never mistaken for test data.
Written for Nodecode from Stripe's public API reference; no Stripe code is in here. MIT licensed.
Tools
| Tool | What it does |
|---|---|
stripe_balance |
The balance per currency: available, pending, and instant available or connect reserved when Stripe reports them. |
stripe_list |
customers, invoices, subscriptions, charges or payment_intents, newest first, one line each. Filters: created_after / created_before (a UTC date, a date-time or Unix seconds), customer (not for customers), email (customers), status (invoices and subscriptions), subscription (invoices), payment_intent (charges); limit and starting_after page. |
stripe_get |
One object by resource and id, with its metadata; an invoice with its lines and hosted page. |
stripe_search |
Stripe's search query language over the same five resources, e.g. email:'ann@example.com', status:'past_due', metadata['order_id']:'6735'; limit and page page. |
stripe_create_customer |
A write: a new customer from email and/or name, description, metadata. |
stripe_update |
A write: the description and/or metadata of one customer, invoice, subscription, charge or payment intent, nothing else. An empty description clears it; a metadata key set to "" or null is unset, and true and false are sent as those words. |
stripe_refund |
A write: refund one charge (ch_ or py_) or payment_intent (pi_), all of it or amount in the currency's smallest unit, with an optional reason (duplicate, fraudulent, requested_by_customer) and metadata. |
Amounts read in currency units with their code: 10.50 USD, 500 JPY
(zero-decimal currencies whole), 1.500 KWD (three-decimal ones in
thousandths). A refund's amount is sent the way Stripe counts it, in the
smallest unit (1050 for 10.50 USD).
The operator checks the connection with /stripe: one balance read, which
names the mode, the kind of key, the API version and whether writes run.
Live or test
Every answer, refusals included, opens with one of:
[Stripe LIVE mode: real customers and real money]- the key issk_live_orrk_live_, or Stripe's answer sayslivemode: true.[Stripe test mode]- the key issk_test_orrk_test_and nothing says live.[Stripe mode unknown: ...]- any other key; it is treated as live.
Writes
The three writes are refused before any request unless the operator turns
allow_writes on. With a live key (or one whose mode is unknown) they also
need allow_live_writes; with only allow_writes, writes run in test mode
alone. The set is small on purpose: creating a customer and labelling objects
are routine and easily undone; a refund moves money and cannot be taken back,
so the primer tells the model to say the amount back first. Cancelling
subscriptions, charging, creating invoices and payouts are left out.
Each write carries an Idempotency-Key header: a fresh nodecode- key, or
the idempotency_key the call gives (letters, digits, - and _, at most
255). A write whose request may not have reached Stripe (a timeout, a
dropped connection or a 5xx) names its key in the refusal, so the model
repeats it with the same key and Stripe applies it at most once.
Settings
The stripe section of ~/.nodecode/config.jsonc (see
config.example.jsonc):
| Setting | Default | Meaning |
|---|---|---|
base_url |
https://api.stripe.com |
Where Stripe's API answers: https://, or http:// on this machine (localhost, 127.0.0.0/8, ::1) for a local stripe-mock. |
api_key_env |
STRIPE_API_KEY |
The environment variable holding the key. |
api_key |
none | A key written in the config instead; the environment variable wins. |
stripe_version |
2026-11-18.endive |
The Stripe-Version header every call sends, so answers keep the shape this cell reads. account sends none and the account's default version answers. |
allow_writes |
false |
Let the model call the three writes. |
allow_live_writes |
false |
With allow_writes, let them run with a live key too. |
timeout |
30 |
One API call's ceiling, in seconds. |
max_results |
10 |
The most objects one list or search asks for, and the default (Stripe's own ceiling is 100). |
max_chars |
20000 |
How many characters one answer carries; a longer one is clipped and says so. |
The key
Use a restricted key (rk_)
with read access to exactly the resources above, and write access only if
you turn writes on (Customers, and Refunds for refunds). Start with a
test-mode key. A missing permission comes back as words naming it.
- The key rides the
Authorization: Bearerheader only: never the URL, the body or an answer. It is sent only overhttps, or to this machine. - No redirect is followed with the key: on a Nodecode whose HTTP client takes
:max-redirects, it is set to 0 and a 3xx comes back as words namingbase_url. An older client follows redirects on its own terms. - Every answer and error has the key scrubbed out, and every
client_secret(anysecretor*_secretmember, at any depth) is taken out of Stripe's answer before it is read, and scrubbed from the answer too. An error's body is read the same way, so acard_errorthat carries its payment intent cannot show that intent'sclient_secret. - Secrets are scrubbed before an answer or error is cut to its length, so a secret the cut would split cannot show a part of itself.
- A key shorter than eight characters, or holding a blank or a character outside printable ASCII, is refused before any request.
What is refused
- A
base_urlthat is not a plainscheme://host[:port]: userinfo (user@), a backslash, blanks or control characters, a query, a fragment, a bad port, a scheme other than http(s), orhttp://to another machine. - An id that is not the resource's kind (
cus_,in_,sub_,ch_orpy_,pi_) followed by letters, digits and_alone, so nothing but the id reaches the path. - A filter the resource does not take, a status Stripe does not know, a
limitoutside 1 tomax_results, a date that is not one, a query or text value with a line break, metadata past Stripe's limits (50 keys, keys of 1 to 40 characters without[], values up to 500 characters). - Every value is percent-encoded into the query or form body, so no value can add a parameter of its own.
Tests
test/cell-test.lisp runs offline against a stubbed Stripe API:
.github/test-cell.sh tools/nodecode-stripe