-
-
Notifications
You must be signed in to change notification settings - Fork 33
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
Adds Subscription API #1914
Adds Subscription API #1914
Conversation
- new subscriptions api which supports /create, /update, /cancel - move /orgs/create with subscriptions to /subscriptions/create, keep /orgs/create simple - store subscription api calls as entries in new subscriptions db, with types 'create', 'update', 'cancel' - add SubscriptionData type for org.subData, also SubscriptionCreate, SubscriptionUpdate, SubscriptionCancel - add sparse unique index on org.subData.subId to avoid dupe subs - tests: move subscription tests to test_org_subs, add test for dupe subscription - support /subscriptions/update updates SubscriptionData on matching org - support /subscriptions/cancel delete SubscriptionData on matching org, and deletes the whole org if deleteOnCancel is set to true (the default)
tests: test cancelling subscription with and without readOnlyOnCancel set
collection delete: add option to ignore missing collection
rename subData -> subscription remove 'details' dict, just add planId string to Subscription model
…gging sent emails (disable by default) update no smtp server log message
Co-authored-by: Tessa Walsh <tessa@bitarchivist.net>
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.
Some feedback based on API docs!
status: str | ||
planId: str | ||
|
||
futureCancelDate: Optional[datetime] |
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.
Can this be any date time format, or UTC?
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.
It should be datetime UTC, believe it will return an ISO string in UTC.
…nce subscription data is now included in get / list endpoints, update tests
- add secret with echo server URL before starting - update k3d-ci and microk8s ci
- Follow-up to #1914, allows SubscriptionUpdate event to also update quotas. - Passes current usage info + current billing page URL to portalUrl request for external app to be able to respond with best portalUrl - get_origin() moved to utils to be available more generally. - Updates billing tab to show current plans, switches order of quotas to list execution time, storage first
Fixes #1905
(Different approach than originally suggested, but accomplishes same ends for tracking subscription history in SaaS setup)
Adds a new top-level
/api/subscriptions
endpoint and SubOps handler on the backend.The subscription api supports
/api/subscriptions/create
,/api/subscriptions/update
and/api/subscriptions/cancel
./api/subscriptions/create
creates a new org with subscription, extending the work done in Extends Org Create endpont + shared secret auth #1897. The original/api/orgs/create
is reverted as before, while this endpoint can be used to create a new org with additional options./api/subscriptions/update
can be used to update subscription data, including status, readOnlyOnCancel and extra details (see below)/api/subscriptions/cancel
can be used to cancel a subscription. By default, this will result in the org also be deleted, unlessreadOnlyOnCancel
was previous set.All subscription events are timestamped and also logged in the MongoDB subscription collection.
All operations can only be accessed via the shared secret auth added in #1897, or with superadmin login.
The Subscription optionally stored on the org in
subscription
is as follows:The
subId
is used to uniquely identify subscriptions, and must be unique if set (via sparse unique index on the Org).The
planId
field is used to identify an arbitrary plan for the subscription.status
andfutureCancelDate
can be used to display status and cancellation info for the user.readOnlyOnCancel
indicates where the whole Org should be deleted when a subscription is canceled via/api/subscriptions/cancel
.TODOs:
billing_enabled
is set in helm chartpaused_payment_failed
, clears it on statusactive