A checkout can create a second Stripe customer for an organization when Stripe answers after the request has ended #315

Open
opened 2026-10-31 03:37:01 +00:00 by cgalo5758 · 0 comments
Owner

What happens

When a member of an organization with no Stripe customer starts a checkout, the console creates the organization's Stripe customer, records it, and then creates the checkout session. Both Stripe calls are made without the request's context, so the request's 32-second timeout does not stop them: each runs under the Stripe library's own limits, an 80-second timeout and two retries.

When Stripe answers the customer create after the request has ended, the customer exists at Stripe, but the console's record of it is written under the ended request and fails. The member's next checkout finds no customer for the organization and creates another one.

What should happen

A checkout never leaves an organization with a second Stripe customer. Both calls end with the request, as the subscription reconcile's and the plan change's Stripe calls do, and a customer Stripe made for the organization is found and recorded before another is created.

Where

internal/server/billing.go (createStripeCustomer, HandleCheckout)

Why it matters

When Stripe is slow, one organization can end up with two Stripe customers, and its invoices and payment methods split between them.

Related: #285, #295, #313.

### What happens When a member of an organization with no Stripe customer starts a checkout, the console creates the organization's Stripe customer, records it, and then creates the checkout session. Both Stripe calls are made without the request's context, so the request's 32-second timeout does not stop them: each runs under the Stripe library's own limits, an 80-second timeout and two retries. When Stripe answers the customer create after the request has ended, the customer exists at Stripe, but the console's record of it is written under the ended request and fails. The member's next checkout finds no customer for the organization and creates another one. ### What should happen A checkout never leaves an organization with a second Stripe customer. Both calls end with the request, as the subscription reconcile's and the plan change's Stripe calls do, and a customer Stripe made for the organization is found and recorded before another is created. ### Where `internal/server/billing.go` (`createStripeCustomer`, `HandleCheckout`) ### Why it matters When Stripe is slow, one organization can end up with two Stripe customers, and its invoices and payment methods split between them. Related: #285, #295, #313.
cgalo5758 added the
kind
bug
area/billing
labels 2026-10-31 03:37:01 +00:00
Sign in to join this conversation.
No labels area/billing
kind
bug
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: wiki-cafe/member-console#315