Pay as you go beside the subscriptions, the way OpenRouter charges:
- ./credits: append-only CreditLedger with idempotency keys and an
in-memory ledger; balance, FIFO lots and debt; charge refused with 402
below the app's floor or over a spending key's daily/weekly/monthly
limit; hold then settle or release; top-up quotes with a fee per rail
in integer arithmetic; refund eligibility (window, fee kept, rails that
never refund); expiry of old lots; auto top-up decision with backoff
and a failure cap; credit events applied idempotently; top-ups through
any PaymentProvider (OrangeCat: sats, never refundable).
- ./stripe: stripeCredits — top-up Checkout Session (saves the method
off-session when auto top-up is on), off-session PaymentIntent with an
Idempotency-Key, refunds, and webhook mapping for
checkout.session.completed, payment_intent.succeeded/payment_failed
and charge.refunded. The pass provider ignores top-up sessions.
- ./react: CreditBalance, TopUp, AutoTopUp, CreditActivity; PickerTier
gains optional rates for a pay-as-you-go tier.
No price, fee or threshold is built in; all are the app's config.
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r
Co-authored-by: Claude <noreply@anthropic.com>
* feat(paykit 0.6.0): Stripe subscriptions, intro coupon, portal, plan screens
Owner, 2026-12-03: a monthly subscription that renews until cancelled, a
yearly plan at a discount, and a discount on the first months.
- stripe: stripeBilling — mode=subscription Checkout Sessions with an
inline recurring price, an intro price as a duration=repeating coupon
under a deterministic id (read, created on resource_missing, a racing
resource_already_exists is the same coupon), Billing Portal sessions,
the subscription read back, and the signed webhook reduced to five
events. Reads the current and pre-2025-03-31 API shapes. No payment
method named: Stripe documents TWINT as supporting recurring payments.
The one-time provider ignores subscription checkouts, so one endpoint
carries both. StripeError gains `code`.
- checkout: SubscriptionPlan/Event/Record, applySubscriptionEvent (pure,
safe with repeated and out-of-order events), subscriptionAccessUntil,
subscriptionStanding.
- plans: subscriptionPricing (year per month, saving rounded down).
- react + styles.css: PlanPicker and PlanReview, styled through --pk-*
variables with --sk-* and system light/dark fallbacks. react is an
optional peer dependency.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r
* fix(paykit 0.6.0): cancelSubscription, unpaid periods grant nothing, unbroken tab names
- stripeBilling.cancelSubscription(id): DELETE /v1/subscriptions/{id}, for an
app's own reasons such as a deleted account; a missing one is null.
- applySubscriptionEvent / recordFromSnapshot: a past_due or unpaid
subscription already names the next period's end, which nobody paid for;
only a subscription in good standing or a paid invoice moves access.
- styles.css: no hyphens:auto on the tier switch.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019MDtmtfseicWGK2CMC2U5r
---------
Co-authored-by: Claude <noreply@anthropic.com>