@vocdoni/skills 0.5.3 → 0.7.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.claude-plugin/marketplace.json +29 -27
- package/CHANGELOG.md +38 -0
- package/README.md +66 -41
- package/bin/install.js +13 -2
- package/package.json +1 -1
- package/plugins/agentic-dev/.claude-plugin/plugin.json +2 -2
- package/plugins/agentic-dev/agents/model-router.md +105 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/SKILL.md +25 -13
- package/plugins/agentic-dev/skills/subagent-driven-development/references/audits.md +20 -13
- package/plugins/agentic-dev/skills/subagent-driven-development/references/dispatch.md +42 -1
- package/plugins/agentic-dev/skills/subagent-driven-development/references/ledger.md +11 -6
- package/plugins/agentic-dev/skills/subagent-driven-development/references/model-catalog.md +118 -0
- package/plugins/agentic-dev/skills/subagent-driven-development/references/models.md +126 -71
- package/plugins/agentic-dev/skills/subagent-driven-development/scripts/init-workspace.sh +2 -1
- package/plugins/agentic-dev/skills/subagent-driven-development/scripts/model-inventory.sh +142 -0
- package/plugins/claude-pi-subagent/plugins/pi-subagent/package-lock.json +4 -3
- package/plugins/vocdoni-comments/.claude-plugin/plugin.json +2 -2
- package/plugins/vocdoni-comments/hooks/hooks.json +28 -0
- package/plugins/vocdoni-comments/hooks/session-start.sh +45 -0
- package/plugins/vocdoni-contributing/.claude-plugin/plugin.json +3 -2
- package/plugins/vocdoni-contributing/hooks/hooks.json +14 -2
- package/plugins/vocdoni-contributing/hooks/session-start.sh +18 -6
- package/plugins/vocdoni-contributing/skills/contributing/SKILL.md +41 -7
- package/plugins/vocdoni-go/.claude-plugin/plugin.json +2 -2
- package/plugins/vocdoni-go/skills/vocdoni-backend-review/SKILL.md +522 -0
- package/plugins/vocdoni-go/skills/vocdoni-backend-review/references/prompts.md +260 -0
- package/plugins/vocdoni-go/skills/vocdoni-backend-review/scripts/untracked-list.sh +35 -0
- package/plugins/vocdoni-sdk/.claude-plugin/plugin.json +4 -5
- package/plugins/vocdoni-sdk/skills/vocdoni-ballot-protocol/SKILL.md +61 -38
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/SKILL.md +35 -21
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/approval-vote.ts +3 -3
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/basic-poll.ts +6 -6
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/csp-vote.ts +12 -7
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/multichoice-vote.ts +3 -3
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/quadratic-vote.ts +3 -3
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/ranked-vote.ts +3 -3
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/weighted-census.ts +3 -3
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/accounts.md +26 -15
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/census.md +9 -10
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/client.md +15 -13
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/csp.md +43 -18
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/elections.md +4 -4
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/errors.md +24 -21
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/removed-features.md +98 -0
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/results.md +0 -1
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/voting.md +30 -34
- package/plugins/vocdoni-sequencer/.claude-plugin/plugin.json +21 -0
- package/plugins/vocdoni-sequencer/skills/vocdoni-sequencer/SKILL.md +169 -0
- package/plugins/vocdoni-sequencer/skills/vocdoni-sequencer/references/removed-routes.md +60 -0
- package/plugins/davinci-sdk/.claude-plugin/plugin.json +0 -13
- package/plugins/davinci-sdk/skills/davinci-sdk/SKILL.md +0 -120
- package/plugins/davinci-sdk/skills/davinci-sdk/recipes/bootstrap.ts +0 -61
- package/plugins/davinci-sdk/skills/davinci-sdk/recipes/cast-vote.ts +0 -78
- package/plugins/davinci-sdk/skills/davinci-sdk/recipes/create-process.ts +0 -102
- package/plugins/davinci-sdk/skills/davinci-sdk/recipes/full-election.ts +0 -128
- package/plugins/davinci-sdk/skills/davinci-sdk/recipes/read-results.ts +0 -73
- package/plugins/davinci-sdk/skills/davinci-sdk/recipes/token-census.ts +0 -111
- package/plugins/davinci-sdk/skills/davinci-sdk/references/ballot-modes.md +0 -125
- package/plugins/davinci-sdk/skills/davinci-sdk/references/census.md +0 -168
- package/plugins/davinci-sdk/skills/davinci-sdk/references/contracts.md +0 -133
- package/plugins/davinci-sdk/skills/davinci-sdk/references/errors.md +0 -83
- package/plugins/davinci-sdk/skills/davinci-sdk/references/process.md +0 -225
- package/plugins/davinci-sdk/skills/davinci-sdk/references/protocol.md +0 -65
- package/plugins/davinci-sdk/skills/davinci-sdk/references/sequencer.md +0 -135
- package/plugins/davinci-sdk/skills/davinci-sdk/references/setup.md +0 -123
- package/plugins/davinci-sdk/skills/davinci-sdk/references/voting.md +0 -128
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/anonymous-vote.ts +0 -108
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/recipes/token-census.ts +0 -121
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/anonymous.md +0 -183
- package/plugins/vocdoni-sdk/skills/vocdoni-sdk/references/census3.md +0 -308
- package/plugins/vocdoni-stripe/.claude-plugin/plugin.json +0 -22
- package/plugins/vocdoni-stripe/skills/stripe-subscription/SKILL.md +0 -276
- package/plugins/vocdoni-stripe/skills/stripe-subscription/references/backend-contract.md +0 -142
- package/plugins/vocdoni-stripe/skills/stripe-subscription/references/product-templates.md +0 -132
- package/plugins/vocdoni-stripe/skills/stripe-subscription/references/stripe-cli.md +0 -212
- package/plugins/vocdoni-stripe/skills/stripe-subscription/scripts/clone-product.sh +0 -247
- package/plugins/vocdoni-stripe/skills/stripe-subscription/scripts/stripe-json.sh +0 -223
|
@@ -1,142 +0,0 @@
|
|
|
1
|
-
# What the SaaS backend reads from Stripe
|
|
2
|
-
|
|
3
|
-
Verified against `saas-backend` (`stripe/service.go`, `stripe/webhook.go`,
|
|
4
|
-
`stripe/client.go`, `db/plans.go`, `subscriptions/subscriptions.go`) in
|
|
5
|
-
September 2026. Re-check the line references if the backend has moved on.
|
|
6
|
-
|
|
7
|
-
## Products are plans
|
|
8
|
-
|
|
9
|
-
Stripe is the single source of truth for plans; Mongo `plans` is a cache.
|
|
10
|
-
|
|
11
|
-
| Product metadata key | Required | Parsed as | Effect |
|
|
12
|
-
| -------------------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------------------------------------------ |
|
|
13
|
-
| `organization` | yes (marker) | JSON object | plan limits: `teamMembers`, `subOrgs`, `maxProcesses`, `maxCensus`, `maxVotes`, `maxDaysDuration`, `customURL`, `drafts`, `customPlan` |
|
|
14
|
-
| `votingTypes` | yes (marker) | JSON object | `single`, `multiple`, `approval`, `cumulative`, `ranked`, `weighted` |
|
|
15
|
-
| `features` | yes (marker) | JSON object | `anonymous`, `overwrite`, `liveResults`, `2FAsms`, `2FAemail`, `personalization`, `emailReminder`, `whiteLabel`, `liveStreaming`, `phoneSupport` |
|
|
16
|
-
| `integratorLimits` | no | JSON object | `maxManagedOrgs`; the plan is an integrator plan only when it is `> 0` |
|
|
17
|
-
| `visibility` | no | string | exactly `private` hides the plan from `GET /plans`. Nothing else: a private plan is still fetchable by id and usable at checkout |
|
|
18
|
-
|
|
19
|
-
- A product missing any of the three marker keys is silently not a plan
|
|
20
|
-
(`service.go` `planProductMarkerKeys`, `isPlanProduct`).
|
|
21
|
-
- A marker present but not valid JSON makes the product skip with a warning.
|
|
22
|
-
- Only **active** products are listed (`client.go` `ListProducts`).
|
|
23
|
-
- `orgAddress`, `orgEmail`, `copiedFrom`, `copiedAt` (and the older
|
|
24
|
-
`restoredFrom` / `restoredAt` from a one-off migration) are **not read**.
|
|
25
|
-
They exist so a human can tell which customer a copy belongs to and where it
|
|
26
|
-
came from. Keep writing them.
|
|
27
|
-
|
|
28
|
-
## Prices
|
|
29
|
-
|
|
30
|
-
`GetProductPrices` lists **active** prices of the product. In
|
|
31
|
-
`processProductToPlan`:
|
|
32
|
-
|
|
33
|
-
- recurring interval `year` becomes the yearly price and amount, `month` the
|
|
34
|
-
monthly ones; other intervals and one-time prices are ignored;
|
|
35
|
-
- if several prices share an interval the last one listed wins, so keep one
|
|
36
|
-
active price per interval on a plan product;
|
|
37
|
-
- yearly price metadata `freeTrialDays` (integer) is honoured;
|
|
38
|
-
- the catalog **default plan** marker is `Default=true` on the metadata of the
|
|
39
|
-
product's `default_price`. Never set a default price on a per-customer copy.
|
|
40
|
-
|
|
41
|
-
Lookup keys are not used: the "lookup key" in the checkout endpoint is the
|
|
42
|
-
product id.
|
|
43
|
-
|
|
44
|
-
## Subscriptions
|
|
45
|
-
|
|
46
|
-
The only subscription metadata key read is **`address`**
|
|
47
|
-
(`webhook.go` `parseSubscriptionFromEvent`). It is parsed with
|
|
48
|
-
`common.HexToAddress`, so matching is case-insensitive and the `0x` prefix is
|
|
49
|
-
optional; garbage silently becomes the zero address.
|
|
50
|
-
|
|
51
|
-
On `customer.subscription.*` events:
|
|
52
|
-
|
|
53
|
-
- missing/zero address: error `subscription missing address metadata`;
|
|
54
|
-
- address with no organization: error `organization … not found`;
|
|
55
|
-
- product not in the plan cache: error `plan with Stripe ID … not found`.
|
|
56
|
-
|
|
57
|
-
Every error returns HTTP 500 to Stripe, the event is not marked processed, and
|
|
58
|
-
Stripe retries it for days. So a wrong address is not "no-op", it is a
|
|
59
|
-
permanently failing webhook.
|
|
60
|
-
|
|
61
|
-
On success the org gets `PlanID`, `StripeSubscriptionID`, `BillingPeriod`,
|
|
62
|
-
`StartDate`, `RenewalDate`, `Active` (only when status is `active`) and
|
|
63
|
-
`Email` (the Stripe customer email).
|
|
64
|
-
|
|
65
|
-
The previous plan is overwritten, not stacked or remembered. That includes a
|
|
66
|
-
plan the org holds with no Stripe subscription behind it (the free integrator
|
|
67
|
-
plan assigned at `integrator: true` creation), and a later cancel or delete of
|
|
68
|
-
the new subscription does not restore it. Every endpoint subscribed to the
|
|
69
|
-
account applies this, so a sandbox subscription rewrites the org in dev and
|
|
70
|
-
staging alike.
|
|
71
|
-
|
|
72
|
-
## Customers
|
|
73
|
-
|
|
74
|
-
The subscription metadata `address` is the only link between a subscription
|
|
75
|
-
and an org. The customer's metadata `address` is never read to route a
|
|
76
|
-
subscription; one Stripe customer may own subscriptions for several orgs.
|
|
77
|
-
|
|
78
|
-
After saving the org, the handler stamps the **customer** metadata `address`
|
|
79
|
-
with the org address, but only when it is empty. What happens when it is
|
|
80
|
-
already set depends on the backend version:
|
|
81
|
-
|
|
82
|
-
- `main` (since dd58581, #704; not in a release tag yet): it logs
|
|
83
|
-
"customer metadata address mismatch" if the value differs and carries on.
|
|
84
|
-
The webhook succeeds and the existing value is left untouched.
|
|
85
|
-
- v3.1.2 and older: it returns an error when the customer has any `address`,
|
|
86
|
-
even the same one. The org was already saved, so the data is correct, but
|
|
87
|
-
Stripe gets a 500 and retries the event. Noisy in webhook logs, harmless
|
|
88
|
-
for data; mention it if the user wonders about failing webhooks.
|
|
89
|
-
|
|
90
|
-
Either way, do not set customer metadata `address` by hand, before or after
|
|
91
|
-
creating the subscription, and do not treat an existing value pointing to
|
|
92
|
-
another org as a sign of the wrong customer.
|
|
93
|
-
|
|
94
|
-
The org's subscription `Email` is always overwritten with the Stripe customer
|
|
95
|
-
email, so a customer email that differs from the org manager's replaces it.
|
|
96
|
-
|
|
97
|
-
## How a new product reaches the backend
|
|
98
|
-
|
|
99
|
-
- On startup the backend syncs every active plan product (`InitializeStripeService`);
|
|
100
|
-
a failure is logged, not fatal.
|
|
101
|
-
- At runtime it reacts to `product.created`, `product.updated`,
|
|
102
|
-
`product.deleted` webhooks (`handleProductUpsert`, `handleProductDelete`).
|
|
103
|
-
It re-fetches the product to expand `default_price`. A product that goes
|
|
104
|
-
inactive or loses a marker is removed from the cache.
|
|
105
|
-
- `price.*` events are **not** handled. Create prices before the last product
|
|
106
|
-
update, or touch the product afterwards (`clone-product.sh` does this).
|
|
107
|
-
|
|
108
|
-
So a product created by hand shows up immediately only if the live webhook
|
|
109
|
-
endpoint subscribes to `product.*`; otherwise at the next backend restart.
|
|
110
|
-
|
|
111
|
-
## Integrator plans
|
|
112
|
-
|
|
113
|
-
`Subscriptions.IsIntegrator` is true when the org has its own
|
|
114
|
-
`IntegratorLimits.MaxManagedOrgs > 0`, or when its subscription is active and
|
|
115
|
-
the plan's `IntegratorLimits.MaxManagedOrgs > 0`. Name is irrelevant.
|
|
116
|
-
|
|
117
|
-
**The free integrator plan is found structurally**, nothing else:
|
|
118
|
-
`db/plans.go` `FreeIntegratorPlan` does a `FindOne` on
|
|
119
|
-
`integratorLimits.maxManagedOrgs > 0 AND monthlyPrice == 0 AND yearlyPrice == 0`.
|
|
120
|
-
No env var, config key or product id is involved at runtime (the
|
|
121
|
-
`STRIPE_FREE_INTEGRATOR_PRODUCT_ID` variable and the hardcoded id in
|
|
122
|
-
migration 0014 only rewrite old integer plan ids once, at migration time).
|
|
123
|
-
`Integrator Starter` and `Custom` are not referenced anywhere in code either;
|
|
124
|
-
every plan is generic.
|
|
125
|
-
|
|
126
|
-
Consequences:
|
|
127
|
-
|
|
128
|
-
- An org created with `integrator: true` (`POST /organizations`) fails with
|
|
129
|
-
`404` code `40023` "subscription plan not found: free integrator plan not
|
|
130
|
-
available" when no such plan exists, and nothing is persisted. Creating an
|
|
131
|
-
active product with the three markers, `integratorLimits.maxManagedOrgs > 0`
|
|
132
|
-
and either no recurring prices or zero-amount ones fixes it with no code
|
|
133
|
-
change; `visibility=private` keeps it out of the catalog.
|
|
134
|
-
- `FindOne` has no ordering, so two matching plans make the choice random.
|
|
135
|
-
Never put `integratorLimits` on the default `Free` plan, and never let an
|
|
136
|
-
integrator product be active while it still has no prices (a paid
|
|
137
|
-
`Integrator Starter` copy with zero prices matches the selector).
|
|
138
|
-
`clone-product.sh` creates copies inactive and activates them after their
|
|
139
|
-
prices exist for this reason.
|
|
140
|
-
- `DefaultPlan()` (the `Default=true` default-price marker on the `Free`
|
|
141
|
-
product) is checked before the integrator branch for every org creation,
|
|
142
|
-
so a broken default plan fails all signups with `400` code `40022`.
|
|
@@ -1,132 +0,0 @@
|
|
|
1
|
-
# Per-customer plan products (Custom / Integrator Starter)
|
|
2
|
-
|
|
3
|
-
## Why a product per customization
|
|
4
|
-
|
|
5
|
-
The backend reads every plan limit from the product's metadata (see
|
|
6
|
-
`backend-contract.md`). Two customers with different limits therefore need two
|
|
7
|
-
products. The catalog keeps one **template** per family:
|
|
8
|
-
|
|
9
|
-
| Template name | Family | Distinguishing metadata |
|
|
10
|
-
| -------------------- | ------------------------------------------------- | ----------------------------------------- |
|
|
11
|
-
| `Custom` | high-limit plan negotiated per client | `customPlan: true` inside `organization` |
|
|
12
|
-
| `Integrator Starter` | integrators managing orgs for their own customers | `integratorLimits: {"maxManagedOrgs": N}` |
|
|
13
|
-
|
|
14
|
-
A customer copy is a new product named `<Template> - <org email>`, private,
|
|
15
|
-
carrying the template's blocks with the agreed changes, plus these human-only
|
|
16
|
-
keys:
|
|
17
|
-
|
|
18
|
-
| Key | Value | Purpose |
|
|
19
|
-
| ------------ | ----------------------- | ---------------------------------------------------------- |
|
|
20
|
-
| `visibility` | `private` | keep it out of the public catalog (backend reads this one) |
|
|
21
|
-
| `orgAddress` | the org's `0x…` address | find the copy from the org |
|
|
22
|
-
| `orgEmail` | the org/customer email | find the copy from the customer |
|
|
23
|
-
| `copiedFrom` | template `prod_…` id | trace where the limits came from |
|
|
24
|
-
| `copiedAt` | ISO-8601 UTC timestamp | when it was cloned |
|
|
25
|
-
|
|
26
|
-
Older copies may carry `restoredFrom` / `restoredAt` instead of
|
|
27
|
-
`copiedFrom` / `copiedAt`; those came from a one-off migration. Write the
|
|
28
|
-
`copied*` pair for new copies and leave old ones alone.
|
|
29
|
-
|
|
30
|
-
## Resolving the template
|
|
31
|
-
|
|
32
|
-
Search is a substring match, so `name:'Custom'` also returns every
|
|
33
|
-
`Custom - client@example.org`. Always filter to the exact name and require
|
|
34
|
-
exactly one active hit:
|
|
35
|
-
|
|
36
|
-
```bash
|
|
37
|
-
$sj products search --limit 100 --query "active:'true' AND name:'Custom'" \
|
|
38
|
-
| jq '[.data[] | select(.name == "Custom")] | if length == 1 then .[0] else error("expected one template, got \(length)") end'
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
Show the user the template's blocks pretty-printed before asking for changes:
|
|
42
|
-
|
|
43
|
-
```bash
|
|
44
|
-
jq '.metadata | {organization: (.organization | fromjson), features: (.features | fromjson), votingTypes: (.votingTypes | fromjson), integratorLimits: ((.integratorLimits // "null") | fromjson)}'
|
|
45
|
-
```
|
|
46
|
-
|
|
47
|
-
## What to ask the user
|
|
48
|
-
|
|
49
|
-
- **Overrides** per block, as key/value changes (e.g. "2FAemail to 10000",
|
|
50
|
-
"maxCensus 80000", "whiteLabel true"). Keys must exist on the template; the
|
|
51
|
-
script refuses unknown block names and unknown top-level keys inside a
|
|
52
|
-
block, since the backend would silently ignore them. Check the spelling
|
|
53
|
-
with the user before the dry run rather than after it refuses.
|
|
54
|
-
- **Prices**: yearly and monthly amounts in cents. Default is the template
|
|
55
|
-
amount; custom plans are negotiated, so ask rather than assume.
|
|
56
|
-
- **Label**: short client name used in price nicknames
|
|
57
|
-
(`Custom yearly (Client)`), so the price list stays readable.
|
|
58
|
-
- **Org email**: defaults to the customer email; it becomes part of the
|
|
59
|
-
product name.
|
|
60
|
-
|
|
61
|
-
Write the overrides to a JSON file keyed by block:
|
|
62
|
-
|
|
63
|
-
```json
|
|
64
|
-
{ "features": { "2FAemail": 10000 }, "organization": { "maxCensus": 80000 } }
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
## Clone
|
|
68
|
-
|
|
69
|
-
```bash
|
|
70
|
-
scripts/clone-product.sh \
|
|
71
|
-
--template "Custom" \
|
|
72
|
-
--org-email client@example.org \
|
|
73
|
-
--org-address 0x0000000000000000000000000000000000000000 \
|
|
74
|
-
--label "Client" \
|
|
75
|
-
--override-file overrides.json \
|
|
76
|
-
--yearly 100000 --monthly 10000 \
|
|
77
|
-
--dry-run # first: paste the output into the confirmation table
|
|
78
|
-
```
|
|
79
|
-
|
|
80
|
-
Without `--dry-run` it prints `{"product": "prod_…", "name": "…", "prices": {"year": "price_…", "month": "price_…"}}`.
|
|
81
|
-
|
|
82
|
-
What the script does, in order, and why:
|
|
83
|
-
|
|
84
|
-
1. Reads the template and checks the three marker blocks parse as JSON.
|
|
85
|
-
2. Deep-merges the overrides into each block and re-serialises compactly.
|
|
86
|
-
3. `products create`, **inactive**, with name, description
|
|
87
|
-
(`<template description> Custom copy of <template id> for <label> (<email>).`),
|
|
88
|
-
the merged blocks and the keys above. No `default_price`: the catalog
|
|
89
|
-
default marker lives on a default price's metadata and a copy must never
|
|
90
|
-
become the default plan. Inactive because the backend syncs active
|
|
91
|
-
products on `product.created`, and an integrator product synced before
|
|
92
|
-
its prices exist has zero prices, which is exactly what the backend's
|
|
93
|
-
free-integrator selector matches. An integrator signing up in that window
|
|
94
|
-
would land on the client's plan.
|
|
95
|
-
4. One `prices create` per template interval (year, month), interval count,
|
|
96
|
-
currency, amount and `tax_behavior` from the template unless overridden, nickname
|
|
97
|
-
`<Template> yearly|monthly (<label>)`, and `freeTrialDays` copied if the
|
|
98
|
-
template's price had it. It refuses a template with more than one active
|
|
99
|
-
price per interval (the backend keeps the last one listed, so which to copy
|
|
100
|
-
is ambiguous), a price with no `unit_amount` unless you pass the amount,
|
|
101
|
-
and an integrator copy whose prices are all zero (it would compete with
|
|
102
|
-
the free integrator plan).
|
|
103
|
-
5. `products update … active=true`: the product becomes visible to the
|
|
104
|
-
backend only now, with both prices, through the `product.updated` webhook
|
|
105
|
-
it listens to (`price.*` events are ignored).
|
|
106
|
-
|
|
107
|
-
## Verify the copy before using it
|
|
108
|
-
|
|
109
|
-
```bash
|
|
110
|
-
$sj products retrieve prod_xxx | jq '{
|
|
111
|
-
name, active, visibility: .metadata.visibility, copiedFrom: .metadata.copiedFrom, copiedAt: .metadata.copiedAt,
|
|
112
|
-
orgAddress: .metadata.orgAddress, default_price,
|
|
113
|
-
blocks_ok: ([.metadata.organization, .metadata.features, .metadata.votingTypes] | map(fromjson | type == "object") | all),
|
|
114
|
-
managedOrgs: ((.metadata.integratorLimits // "{}") | fromjson | .maxManagedOrgs)
|
|
115
|
-
}'
|
|
116
|
-
$sj prices list --product prod_xxx --active | jq '[.data[] | {id, nickname, unit_amount, currency, interval: .recurring.interval}]'
|
|
117
|
-
```
|
|
118
|
-
|
|
119
|
-
Expect: `active: true`, `visibility: "private"`, `default_price: null`,
|
|
120
|
-
`blocks_ok: true`, exactly one price per interval, and for an integrator copy
|
|
121
|
-
`managedOrgs > 0`.
|
|
122
|
-
|
|
123
|
-
## Undo
|
|
124
|
-
|
|
125
|
-
Archive rather than delete, so invoices that reference the prices stay valid:
|
|
126
|
-
|
|
127
|
-
```bash
|
|
128
|
-
$sj products update prod_xxx -d active=false
|
|
129
|
-
```
|
|
130
|
-
|
|
131
|
-
The backend drops an inactive product from its plan cache on the next
|
|
132
|
-
`product.updated` webhook or restart.
|
|
@@ -1,212 +0,0 @@
|
|
|
1
|
-
# Stripe CLI cookbook
|
|
2
|
-
|
|
3
|
-
All commands below go through the wrapper, which refuses to run without
|
|
4
|
-
`STRIPE_ENV`. Agent shells usually drop variables between tool calls, so set
|
|
5
|
-
both at the start of every invocation, not once per session:
|
|
6
|
-
|
|
7
|
-
```bash
|
|
8
|
-
export STRIPE_ENV=live STRIPE_ACCOUNT_NAME='<account name>' sj=<skill dir>/scripts/stripe-json.sh # or STRIPE_ENV=sandbox
|
|
9
|
-
```
|
|
10
|
-
|
|
11
|
-
`STRIPE_ACCOUNT_NAME` is the name `stripe-json.sh env` printed and the user
|
|
12
|
-
confirmed; with it set the wrapper also refuses a different account in the
|
|
13
|
-
same mode (a second live account, another sandbox).
|
|
14
|
-
|
|
15
|
-
The wrapper adds `--live` for live, checks the banner (before the command
|
|
16
|
-
too, for anything that is not a `list` / `retrieve` / `search`), strips it,
|
|
17
|
-
turns `{"error": …}` bodies into a non-zero exit, and refuses `delete` /
|
|
18
|
-
`delete_*` / `cancel` / `void_invoice` / `mark_uncollectible` / `detach`
|
|
19
|
-
without `--confirm`. Everything it prints on stdout is JSON, so
|
|
20
|
-
pipe straight into `jq`.
|
|
21
|
-
|
|
22
|
-
## Quirks worth knowing
|
|
23
|
-
|
|
24
|
-
- **One active account.** `stripe config --list` shows it. `stripe switch` and
|
|
25
|
-
`stripe login` change it for every terminal. `--live` on a sandbox account
|
|
26
|
-
errors out; a sandbox-style command on the live account silently hits live
|
|
27
|
-
_test_ mode. The banner `▸ Running in <name> · live|sandbox` is the only
|
|
28
|
-
reliable signal, which is why the wrapper reads it.
|
|
29
|
-
- **Banner placement.** It goes to stderr for most commands and to stdout for
|
|
30
|
-
some. Never parse raw CLI output with `jq` directly.
|
|
31
|
-
- **API errors exit 0.** The CLI prints the error JSON and returns success.
|
|
32
|
-
- **Search is a substring match and lags.** `products search --query "name:'Custom'"`
|
|
33
|
-
returns every `Custom - …` copy; filter with `jq 'select(.name == "Custom")'`.
|
|
34
|
-
Search indexes update within about a minute, so use `list` for anything
|
|
35
|
-
that must reflect what you just created.
|
|
36
|
-
- **Boolean flags take no value.** `prices list --active`, not `--active true`.
|
|
37
|
-
Inside `-d` parameters they do: `-d active=false`.
|
|
38
|
-
- **Interactive prompts.** `subscriptions cancel`, `customers delete`,
|
|
39
|
-
`coupons delete` ask "are you sure" on a TTY and hang without one. Pass
|
|
40
|
-
`--confirm`.
|
|
41
|
-
- **Nested params** use bracket syntax: `-d "items[0][price]=price_xxx"`,
|
|
42
|
-
`-d "metadata[address]=0x…"`, `-d "expand[0]=discounts"`.
|
|
43
|
-
|
|
44
|
-
## Lookups
|
|
45
|
-
|
|
46
|
-
```bash
|
|
47
|
-
# backends that will act on every write (sandbox usually reaches dev and staging)
|
|
48
|
-
$sj webhook_endpoints list | jq '[.data[] | select(.status == "enabled") | .url]'
|
|
49
|
-
|
|
50
|
-
# customer by email (expect exactly one)
|
|
51
|
-
$sj customers list --email client@example.org | jq '.data | length, (.[0] | {id, name, email, currency, default_pm: .invoice_settings.default_payment_method})'
|
|
52
|
-
|
|
53
|
-
# saved payment methods (decides the collection default)
|
|
54
|
-
$sj payment_methods list --customer cus_xxx | jq '[.data[] | {id, type}]'
|
|
55
|
-
|
|
56
|
-
# product by exact name (active only)
|
|
57
|
-
$sj products search --limit 100 --query "active:'true' AND name:'Professional'" \
|
|
58
|
-
| jq '[.data[] | select(.name == "Professional")]'
|
|
59
|
-
|
|
60
|
-
# recurring prices of a product
|
|
61
|
-
$sj prices list --product prod_xxx --active --limit 100 \
|
|
62
|
-
| jq '[.data[] | select(.recurring != null) | {id, nickname, currency, unit_amount, interval: .recurring.interval, trial: .metadata.freeTrialDays}]'
|
|
63
|
-
|
|
64
|
-
# one org, one subscription: list-based, case-insensitive (search lags),
|
|
65
|
-
# paginated (100 per page is a hard cap, and a missed page is a missed duplicate).
|
|
66
|
-
# No --status: the default already returns every non-canceled subscription,
|
|
67
|
-
# including unpaid and paused ones that still hold the org.
|
|
68
|
-
# Pages are collected first and the filter runs only if every page succeeded:
|
|
69
|
-
# a failed page must stop the check, not shrink it to an empty "no duplicate".
|
|
70
|
-
addr=0x0000000000000000000000000000000000000000
|
|
71
|
-
pages="$(
|
|
72
|
-
after=()
|
|
73
|
-
while :; do
|
|
74
|
-
page="$($sj subscriptions list --limit 100 "${after[@]}")" || exit 1
|
|
75
|
-
printf '%s\n' "$page"
|
|
76
|
-
[[ "$(jq -r .has_more <<<"$page")" == true ]] || break
|
|
77
|
-
after=(--starting-after "$(jq -r '.data[-1].id' <<<"$page")")
|
|
78
|
-
done
|
|
79
|
-
)" && jq -s --arg a "$addr" '[.[].data[] | select(.status != "incomplete_expired") | select((.metadata.address // "" | ascii_downcase) == ($a | ascii_downcase)) | {id, status, customer}]' <<<"$pages" \
|
|
80
|
-
|| echo "duplicate check FAILED; do not continue" >&2
|
|
81
|
-
|
|
82
|
-
# customer's other subscriptions
|
|
83
|
-
$sj subscriptions list --customer cus_xxx | jq '[.data[] | {id, status, product: .items.data[0].price.product}]'
|
|
84
|
-
```
|
|
85
|
-
|
|
86
|
-
## Discounts
|
|
87
|
-
|
|
88
|
-
```bash
|
|
89
|
-
# existing coupons that could fit (valid, matching discount, redemptions left)
|
|
90
|
-
$sj coupons list --limit 100 | jq '[.data[] | select(.valid) | {id, name, percent_off, amount_off, currency, duration, duration_in_months, redeemed: .times_redeemed, max: .max_redemptions}]'
|
|
91
|
-
|
|
92
|
-
# a promotion code the user named. Since API 2025-09-30.clover the coupon sits
|
|
93
|
-
# at .promotion.coupon as a bare id; older versions embed it at .coupon.
|
|
94
|
-
$sj promotion_codes list --active --code SOMECODE \
|
|
95
|
-
| jq '.data[] | {id, code, coupon: (.promotion.coupon // .coupon | if type == "object" then .id else . end)}'
|
|
96
|
-
# then `coupons retrieve <coupon>` for its percent/amount and duration
|
|
97
|
-
|
|
98
|
-
# new single-use coupon (only when nothing fits)
|
|
99
|
-
$sj coupons create -d percent_off=100 -d duration=forever -d max_redemptions=1 \
|
|
100
|
-
-d "name=Client Name - free exception" | jq '{id, name, percent_off, duration, max_redemptions}'
|
|
101
|
-
# amount-based variant: -d amount_off=50000 -d currency=eur
|
|
102
|
-
# limited variant: -d duration=repeating -d duration_in_months=6
|
|
103
|
-
```
|
|
104
|
-
|
|
105
|
-
`max_redemptions` cannot be changed after creation. If you ever need to close
|
|
106
|
-
a coupon that was created without it, `coupons delete <id> --confirm` blocks
|
|
107
|
-
new redemptions and leaves existing discounts untouched.
|
|
108
|
-
|
|
109
|
-
## Create the subscription
|
|
110
|
-
|
|
111
|
-
```bash
|
|
112
|
-
# send_invoice (customer has no card, or you want an invoice emailed)
|
|
113
|
-
$sj subscriptions create \
|
|
114
|
-
-d customer=cus_xxx \
|
|
115
|
-
-d "items[0][price]=price_xxx" \
|
|
116
|
-
-d "metadata[address]=0x0000000000000000000000000000000000000000" \
|
|
117
|
-
-d collection_method=send_invoice -d days_until_due=30 \
|
|
118
|
-
-d "discounts[0][coupon]=COUPONID" # only if a discount was chosen
|
|
119
|
-
# -d "discounts[0][promotion_code]=promo_xxx" # promotion code instead
|
|
120
|
-
# -d trial_period_days=14
|
|
121
|
-
# -d backdate_start_date=1760000000 -d billing_cycle_anchor=1762000000
|
|
122
|
-
# -d cancel_at=1790000000
|
|
123
|
-
# -d "description=…"
|
|
124
|
-
|
|
125
|
-
# charge_automatically with the customer's default payment method
|
|
126
|
-
$sj subscriptions create -d customer=cus_xxx -d "items[0][price]=price_xxx" \
|
|
127
|
-
-d "metadata[address]=0x…" -d collection_method=charge_automatically
|
|
128
|
-
# a saved card that is NOT the customer's default is never picked up on its own:
|
|
129
|
-
# add: -d default_payment_method=pm_xxx
|
|
130
|
-
|
|
131
|
-
# charge_automatically WITHOUT a card: created incomplete, expires in 23h unless paid
|
|
132
|
-
# add: -d payment_behavior=default_incomplete
|
|
133
|
-
# then hand over: latest_invoice.hosted_invoice_url
|
|
134
|
-
|
|
135
|
-
# finalize the first invoice of a send_invoice subscription, only while it is
|
|
136
|
-
# still a draft (a trial invoice is already paid; a future anchor may have none)
|
|
137
|
-
$sj invoices retrieve in_xxx | jq -r .status # expect: draft
|
|
138
|
-
$sj invoices finalize_invoice in_xxx | jq '{id, status, total, amount_due, amount_paid, hosted_invoice_url}'
|
|
139
|
-
|
|
140
|
-
# a manually finalized invoice is not emailed; send it if the customer should get the email
|
|
141
|
-
$sj invoices send_invoice in_xxx | jq '{id, status, hosted_invoice_url}'
|
|
142
|
-
```
|
|
143
|
-
|
|
144
|
-
## Checkout link instead of a direct subscription
|
|
145
|
-
|
|
146
|
-
Mirrors what the app's own checkout does (tax, tax id collection, promotion
|
|
147
|
-
codes), but hosted so the link can be sent by hand. Stripe creates the
|
|
148
|
-
subscription when the customer pays; `subscription_data[metadata][address]`
|
|
149
|
-
is what makes the backend recognise it.
|
|
150
|
-
|
|
151
|
-
```bash
|
|
152
|
-
$sj checkout sessions create \
|
|
153
|
-
-d mode=subscription \
|
|
154
|
-
-d customer=cus_xxx \
|
|
155
|
-
-d "customer_update[name]=auto" -d "customer_update[address]=auto" \
|
|
156
|
-
-d "line_items[0][price]=price_xxx" -d "line_items[0][quantity]=1" \
|
|
157
|
-
-d "subscription_data[metadata][address]=0x0000000000000000000000000000000000000000" \
|
|
158
|
-
-d "automatic_tax[enabled]=true" -d "tax_id_collection[enabled]=true" \
|
|
159
|
-
-d allow_promotion_codes=true \
|
|
160
|
-
-d success_url="https://app.vocdoni.io/" -d cancel_url="https://app.vocdoni.io/" \
|
|
161
|
-
| jq '{id, url, expires_at: (.expires_at | todate)}'
|
|
162
|
-
# discount on the session instead of promotion codes: -d "discounts[0][coupon]=…" (then drop allow_promotion_codes)
|
|
163
|
-
# trial: -d "subscription_data[trial_period_days]=14"
|
|
164
|
-
```
|
|
165
|
-
|
|
166
|
-
Verify later with `checkout sessions retrieve cs_xxx | jq '{status, payment_status, subscription}'`.
|
|
167
|
-
|
|
168
|
-
## Read back for the final table
|
|
169
|
-
|
|
170
|
-
```bash
|
|
171
|
-
$sj subscriptions retrieve sub_xxx -d "expand[0]=discounts" -d "expand[1]=latest_invoice" | jq '{
|
|
172
|
-
id, status, customer, collection_method, days_until_due, metadata,
|
|
173
|
-
price: .items.data[0].price.id, amount: .items.data[0].price.unit_amount, currency,
|
|
174
|
-
period_end: (.items.data[0].current_period_end | todate),
|
|
175
|
-
discount: (.discounts[0] | if . then {id, coupon: (.source.coupon // .coupon | if type == "object" then .id else . end)} else null end),
|
|
176
|
-
invoice: (.latest_invoice | {id, status, total, amount_paid, hosted_invoice_url})
|
|
177
|
-
}'
|
|
178
|
-
|
|
179
|
-
# the Discount row: since API 2025-09-30.clover a discount no longer embeds its
|
|
180
|
-
# coupon (it is a bare id at .source.coupon), so read the coupon itself
|
|
181
|
-
$sj coupons retrieve COUPONID | jq '{id, percent_off, amount_off, currency, duration, duration_in_months, redeemed: "\(.times_redeemed)/\(.max_redemptions)"}'
|
|
182
|
-
```
|
|
183
|
-
|
|
184
|
-
## Undo (only if the user asks)
|
|
185
|
-
|
|
186
|
-
```bash
|
|
187
|
-
$sj subscriptions cancel sub_xxx --confirm # cancels now; invoices stay
|
|
188
|
-
$sj invoices void_invoice in_xxx --confirm # open invoice you do not want paid
|
|
189
|
-
$sj products update prod_xxx -d active=false # archive a cloned product (backend drops the plan)
|
|
190
|
-
$sj coupons delete COUPONID --confirm
|
|
191
|
-
```
|
|
192
|
-
|
|
193
|
-
## Stripe MCP equivalents
|
|
194
|
-
|
|
195
|
-
When the Stripe MCP server is connected instead of the CLI, use its tools for
|
|
196
|
-
the same phases. Names vary by server version; the usual mapping is:
|
|
197
|
-
|
|
198
|
-
| Cookbook call | MCP tool |
|
|
199
|
-
| --------------------------------------- | -------------------------------------------------------------------------------------- |
|
|
200
|
-
| `customers list --email` | `list_customers` (email filter) |
|
|
201
|
-
| `products search` / `products retrieve` | `list_products` / `search_stripe_resources` |
|
|
202
|
-
| `prices list --product` | `list_prices` (product filter) |
|
|
203
|
-
| `subscriptions list` | `list_subscriptions` |
|
|
204
|
-
| `coupons list` / `coupons create` | `list_coupons` / `create_coupon` |
|
|
205
|
-
| `subscriptions create` | `create_subscription` (check it accepts `metadata`, `collection_method`, `discounts`) |
|
|
206
|
-
| `products create` / `prices create` | `create_product` / `create_price` |
|
|
207
|
-
| `checkout sessions create` | `create_payment_link` is the closest (no `subscription_data.metadata`); prefer the CLI |
|
|
208
|
-
| `invoices finalize_invoice` | usually absent; use the CLI |
|
|
209
|
-
|
|
210
|
-
The environment guard with MCP is the `livemode` field on any object you read
|
|
211
|
-
back. If a call the workflow needs has no MCP tool, fall back to the CLI for
|
|
212
|
-
that call rather than skipping it.
|