Skip to content

Conversation

@emma-sg
Copy link
Member

@emma-sg emma-sg commented Oct 28, 2025

For context & flow diagram, see https://github.com/webrecorder/cashew/pull/59

@emma-sg emma-sg marked this pull request as draft October 28, 2025 22:45
@emma-sg emma-sg force-pushed the additional-minutes-addon-purchase branch 2 times, most recently from 4ee2020 to 82a6295 Compare November 4, 2025 23:40
@emma-sg emma-sg force-pushed the additional-minutes-addon-purchase branch from 5ad2648 to 93fd027 Compare November 10, 2025 22:31
@emma-sg emma-sg force-pushed the additional-minutes-addon-purchase branch 3 times, most recently from 96a7dd3 to 6f3a5d4 Compare November 17, 2025 19:01
- 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
@emma-sg emma-sg force-pushed the additional-minutes-addon-purchase branch from e583fe7 to 9fa5509 Compare November 18, 2025 20:12
).items():
if field == "context" or value is None:
continue
inc = max(value, -org.quotas.model_dump().get(field, 0))
Copy link
Member

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?

Copy link
Member Author

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(
Copy link
Member

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..

Copy link
Member Author

@emma-sg emma-sg Nov 18, 2025

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants