-
Notifications
You must be signed in to change notification settings - Fork 350
Subscription #423
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
Open
jahooma
wants to merge
28
commits into
main
Choose a base branch
from
subscription
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+11,803
−61
Open
Subscription #423
Changes from all commits
Commits
Show all changes
28 commits
Select commit
Hold shift + click to select a range
75a228f
Initial backend impl
jahooma 00af124
Review fixes
jahooma 8e31469
Plans to tiered subscription. Don't store plan name/tier in db
jahooma 66463e9
Extract getUserByStripeCustomerId helper
jahooma b807cfa
migrateUnusedCredits: remove filter on free/referral
jahooma 8976298
Add .env.example for stripe price id
jahooma ed2a1d9
Remove subscription_count. Add more stripe status enums
jahooma 31db66e
cleanup
jahooma 458616a
Generate migration
jahooma c39155b
More reviewer improvments
jahooma cba210d
Update migrateUnusedCredits query
jahooma 40a0b2e
Rename Flex to Strong
jahooma 76f71c4
Add subscription tiers. Extract util getStripeId
jahooma 9184aa2
Web routes to cancel, change tier, create subscription, or get subscr…
jahooma 3f81504
Web subscription UI
jahooma 5e9b314
Fix billing test to mock subscription endpoint
jahooma 7f5e135
Remove subscription client UI (moved to subscription-client branch)
jahooma 7059836
Add subscription grant type to usage-display for typecheck compatibility
jahooma 1509a09
Update tier usage limits (1x, 3x, 8x)
jahooma 1b1176c
Fixes from reviewer
jahooma f95faaa
Cleanup tier mapping code
jahooma f114adf
Tweaks and don't downgrade tier immediately if switch plans
jahooma 8eafcfb
scheduled_tier used for downgrade
jahooma a6f9ba1
Don't default to a tier when creating a subscription
jahooma 40921f7
Unit subscription.ts with DI patterns and unit tests
jahooma 1fe1966
Update description of row of migrated credits
jahooma 4a6d7c0
Simplify getStripeId. Move null checks into callers
jahooma f00eeb4
Split try catch in two
jahooma File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| export const SUBSCRIPTION_DISPLAY_NAME = 'Strong' as const | ||
|
|
||
| export interface TierConfig { | ||
| monthlyPrice: number | ||
| creditsPerBlock: number | ||
| blockDurationHours: number | ||
| weeklyCreditsLimit: number | ||
| } | ||
|
|
||
| export const SUBSCRIPTION_TIERS = { | ||
| 100: { | ||
| monthlyPrice: 100, | ||
| creditsPerBlock: 400, | ||
| blockDurationHours: 5, | ||
| weeklyCreditsLimit: 4000, | ||
| }, | ||
| 200: { | ||
| monthlyPrice: 200, | ||
| creditsPerBlock: 1200, | ||
| blockDurationHours: 5, | ||
| weeklyCreditsLimit: 12000, | ||
| }, | ||
| 500: { | ||
| monthlyPrice: 500, | ||
| creditsPerBlock: 3200, | ||
| blockDurationHours: 5, | ||
| weeklyCreditsLimit: 32000, | ||
| }, | ||
| } as const satisfies Record<number, TierConfig> | ||
|
|
||
| export type SubscriptionTierPrice = keyof typeof SUBSCRIPTION_TIERS | ||
|
|
||
| export const DEFAULT_TIER = SUBSCRIPTION_TIERS[200] | ||
|
|
||
| export function createSubscriptionPriceMappings(priceIds: Record<SubscriptionTierPrice, string>) { | ||
| const priceToTier = Object.fromEntries( | ||
| Object.entries(priceIds).map(([tier, priceId]) => [priceId, Number(tier) as SubscriptionTierPrice]), | ||
| ) as Record<string, SubscriptionTierPrice> | ||
|
|
||
| function getTierFromPriceId(priceId: string): SubscriptionTierPrice | null { | ||
| return priceToTier[priceId] ?? null | ||
| } | ||
|
|
||
| function getPriceIdFromTier(tier: SubscriptionTierPrice): string | null { | ||
| return priceIds[tier] ?? null | ||
| } | ||
|
|
||
| return { getTierFromPriceId, getPriceIdFromTier } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.