-
-
Notifications
You must be signed in to change notification settings - Fork 61
Add-on minute checkout session setup #2944
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
base: main
Are you sure you want to change the base?
Conversation
4ee2020 to
82a6295
Compare
5ad2648 to
93fd027
Compare
96a7dd3 to
6f3a5d4
Compare
- add get_checkout_url method to create checkout session for additional minutes - add /checkout/execution-minutes endpoint to handle addon purchase requests (this will need to be updated in dev/prod playbooks) - update CI workflows to remove portalUrl suffix from secret value - add test endpoint in echo server to mock checkout response
convert to json before converting to output type more debugging fix model type pass return url to checkout session request fix fn ordering correctly pass in headers include content-type header fix double encoding as json properly dump model to dict in requests
try using `org_dep` directly in quotas endpoint this should be safe, since there's still a check for if user is superuser allow shared secret in org dep
- adds separate "add-ons" section to display extra execution minutes and gifted execution minutes when present - renames renderQuotas to renderMonthlyQuotas for clarity
entire orgs router - renames `shared_secret_or_active_user` to `shared_secret_or_superuser` to better reflect that it only allows superuser, not all users - moves the `quotas` endpoint to the app router to allow using `org_superuser_or_shared_secret_dep` dependency specifically - removes its user dependency & extra check for superuser, since user is required to be superuser in `superuser_or_shared_secret_dep` (depended on by `org_superuser_or_shared_secret_dep`) - adds a couple more types to `init_subs` arguments
seconds instead of quota
time when running other tests
e583fe7 to
9fa5509
Compare
| ).items(): | ||
| if field == "context" or value is None: | ||
| continue | ||
| inc = max(value, -org.quotas.model_dump().get(field, 0)) |
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.
This is to avoid setting the quota to be <0, right?
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.
Exactly, it clips values below the the field's current value * -1 to that. Do you think we should error instead?
| "quotas": update, | ||
| "quotaUpdates": quota_updates, | ||
| } | ||
| updated_org = await self.orgs.find_one_and_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.
This is needed because we want to store the absolute quota update in quotaUpdates, so it needs to add first, then store the absolute entry in quotaUpdates, right?
As a result, we can't do it just one pass..
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.
Yeah, we hadn't previously had this come up because we were previously just receiving new absolute values. It might be possible to do it all within one update with $arrayElemAt or something, but I wasn't able to figure out a way to do it. The other option here would just be to wrap everything in a transaction — that might be the easiest solution here.
For context & flow diagram, see https://github.com/webrecorder/cashew/pull/59