mirror of
https://github.com/Komediruzecki/token-circles.git
synced 2026-10-20 09:46:43 +02:00
A Checkout Session that enables automatic_tax AND tax_id_collection AND attaches an existing customer must also send customer_update[name]=auto and customer_update[address]=auto, or Stripe refuses the Session. Only accounts with a stripe_customer_id take that branch, so the bug was invisible until someone re-subscribed after canceling or switched tier -- first-time checkout takes the customer_email branch and always worked. stripePost also relayed Stripe's own wording to the page, so "tax ID collection requires a customer name" landed in front of the one person who could not act on it. Stripe's message, type, code, param and request id now go to the logs; the response carries a plain sentence. A 4xx says it has been logged on our side (permanent -- retrying will not help), a 5xx keeps "try again shortly", and a card_error becomes a 402 with Stripe's text intact. 0025 adds users.subscription_interval, nullable. Without it a row saying plan='advanced' could be EUR 6/month or EUR 60/year and MRR was unknowable. Checkout stamps it on both the session and the subscription; the webhook falls back to resolving it from the Price, so existing subscriptions fill in on their next customer.subscription.* event. The session branch COALESCEs (null means "not stamped") while applySubscription writes through (null means "clear it, no longer entitled"). Settings now names a comped plan as granted with no payment method attached, instead of offering Manage billing -- which opens the Stripe portal and 400s, there being no customer to manage.
12 lines
774 B
SQL
12 lines
774 B
SQL
-- Which billing period a subscriber is actually on.
|
|
--
|
|
-- 0003 recorded the plan and the renewal date but not the interval, so a row saying
|
|
-- plan='advanced' could be €6/month or €60/year and nothing in the database could tell them
|
|
-- apart. That makes recurring revenue unknowable rather than merely unreported: any MRR figure
|
|
-- would be a guess about which half of the price list each subscriber is on.
|
|
--
|
|
-- Nullable on purpose. Existing rows stay NULL until their next customer.subscription.* event
|
|
-- backfills them (billing.ts resolves the interval from the Price id when the metadata is absent,
|
|
-- so old subscriptions self-correct rather than needing a data migration).
|
|
ALTER TABLE users ADD COLUMN subscription_interval TEXT; -- 'monthly' | 'annual' | NULL
|