fix(billing): collect the customer's VAT and legal name at checkout

A company that pays for OpenShorts is never asked for its fiscal data:
the Checkout Session carried no `tax_id_collection`, and
`ensure_stripe_customer` creates the customer with an e-mail and nothing
else. So every B2B invoice goes out addressed to an e-mail address, and
the buyer writes to support asking for a corrected one (ticket #4520) —
which cannot be done in place, because the invoice is issued and its
customer data frozen, so it takes a rectificativa in the accounting.

`customer_update.name` is what makes Checkout save the collected name
onto an EXISTING customer, and we always pass one, so without it the
tax ID would land while the name stayed empty. Not `required`: the form
only shows in supported countries and forcing it adds a field to a
funnel that already converts at ~1%.

Claude-Session: https://claude.ai/code/session_01HmESVgJzPkP3LuUB6fmRL3
This commit is contained in:
juancarlos.cavero 2026-09-10 18:25:52 +02:00
parent 8f64c8385a
commit b08df5568a

View file

@ -182,6 +182,20 @@ async def create_checkout(body: CheckoutRequest, request: Request):
success_url=f"{fe}/#/account?checkout=success", success_url=f"{fe}/#/account?checkout=success",
cancel_url=f"{fe}/#/pricing?checkout=cancel", cancel_url=f"{fe}/#/pricing?checkout=cancel",
allow_promotion_codes=True, allow_promotion_codes=True,
# Business customers need their legal name and VAT on the invoice to
# deduct the tax, and this is the only place they can ever type them:
# nothing in the dashboard asks for fiscal data. Without it every
# company is invoiced as an anonymous e-mail address and writes to
# support asking for a corrected invoice (ticket #4520), which cannot
# be done in place — the invoice is already issued and its customer
# data frozen, so it takes a rectificativa in the accounting.
# ``customer_update.name`` is required for Checkout to save the name
# onto an EXISTING customer (we always pass one); ``address`` saves the
# billing address the same way. Not made ``required``: it is shown only
# in supported countries and forcing it would add a field to a funnel
# that already converts at ~1%.
tax_id_collection={"enabled": True},
customer_update={"name": "auto", "address": "auto"},
metadata={ metadata={
"user_id": str(user.id), "user_id": str(user.id),
"kind": entry["kind"], "kind": entry["kind"],