Closed
Description
Is your feature request related to a problem? Please describe
This is a follow-up to #13002, but the bug was actually pre-existing:
- Sometimes (maybe around 1 in 10 times?) when you subscribe a team to Stripe, creating the subscription randomly fails:
- And in the backend, you'll see this error:
Error: No Stripe customer profile for 'team:123ff8cd-422f-4865-87eb-2d3767b2b16f'
- But if you try adding the same credit card / country / currency again, it works
This is because searching Stripe customers by attributionId
seems a bit inconsistent right after customer creation (we poll Stripe Search to confirm that a new customer is available in search results, but then when running the same query a few seconds later, it might come up empty again).
Describe the behaviour you'd like
Instead of polling Stripe Search like we do here:
gitpod/components/server/ee/src/user/stripe-service.ts
Lines 94 to 101 in 759e588
we should:
- Store the created Customer ID in the team/user or their cost center (but it should not be widely accessible, because querying via
attributionId
is preferred) - When trying to find a customer by
attributionId
, StripeService.findCustomerByAttributionId should check for a stored ID first, and fall back to search of there is no ID, or the customer for that ID was deleted or its metadata were modified
Describe alternatives you've considered
- Accept that subscribing sometimes fails and needs to be retried once? 😬
- Wait for a few more seconds after polling Stripe Search? 😬
Additional context
Metadata
Metadata
Assignees
Type
Projects
Status
Done