-
Notifications
You must be signed in to change notification settings - Fork 1.3k
[usage] Use createStripeSubscription behind feature flag #14332
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
started the job as gitpod-build-lau-ff-stripe-13198.2 because the annotations in the pull request description changed |
70a42ae
to
2775cfc
Compare
da6df28
to
ca2970c
Compare
"createStripeSubscriptionOnUsage", | ||
false, | ||
{ | ||
user: user, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Question: which user/team should we be feature flagging for now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think if you run through the subscription workflow in staging for both a user and a team, and it works through the usage component, then I'd largely go and enable it for all in prod, but monitor.
Adding specific target rules here is mostly for completeness, and for if it does go wrong that we can disable for all but reproduce for our team or something like that.
"createStripeSubscriptionOnUsage", | ||
false, | ||
{ | ||
user: user, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should supply the team_id
as well for the case when it's enabled by a team
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Absolutely - will add it.
ca2970c
to
fdbbf7c
Compare
@@ -2177,6 +2178,7 @@ export class GitpodServerEEImpl extends GitpodServerImpl { | |||
|
|||
const user = this.checkAndBlockUser("subscribeToStripe"); | |||
|
|||
let team: Team | undefined; | |||
try { | |||
if (attrId.kind === "team") { | |||
const team = await this.guardTeamOperation(attrId.teamId, "update"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I this that when this is declared as a const
it will shadow the let team
above and won't actually get assigned
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oops good catch!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fixed - thanks 🙏🏽
fdbbf7c
to
bd15072
Compare
} else { | ||
await this.stripeService.setDefaultPaymentMethodForCustomer(customerId, setupIntentId); | ||
await this.stripeService.createSubscriptionForCustomer(customerId, attributionId); | ||
} | ||
|
||
// Creating a cost center for this customer | ||
const { costCenter } = await this.usageService.setCostCenter({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a follow-up, we should then move the cost-center setting into the CreateStripeSubscription
call
Description
Uses the CreateStripeSubscription RPC behind a feature flag.
Related Issue(s)
Relates #13198
How to test
I tested by:
kubectl port-forward server 9500:9500
curl localhost:9500/metrics
gitpod_server_stripe_client_requests_completed_duration_seconds
metric.Release Notes
Documentation
Werft options:
If enabled this will build
install/preview
Valid options are
all
,workspace
,webapp
,ide