This repository was archived by the owner on Jul 28, 2024. It is now read-only.
forked from mckaywrigley/chatbot-ui
-
Notifications
You must be signed in to change notification settings - Fork 18
Refactor: Stripe Handling + New ULTRA Plan #300
Open
1orZero
wants to merge
141
commits into
chat-everywhere
Choose a base branch
from
derek/20240527-stripe-ultra-subscription
base: chat-everywhere
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.
Open
Changes from all commits
Commits
Show all changes
141 commits
Select commit
Hold shift + click to select a range
aa5399f
Fix File list query
1orZero 4c04384
chore: Update subscription plan payment links and add new plans
1orZero 6234389
chore: Enable chat with document feature
1orZero a2734e8
chore: Update SettingsModel dialog panel width for better responsiveness
1orZero 9520363
chore: Add PlanComparison component to Settings_Account
1orZero 717e7eb
chore: Move payment links to const file
1orZero b67415e
Update the style of the Tier badge
1orZero bc3cbf5
refactor: Update PlanComparison component to display current plan and…
1orZero 0322488
chore: Update payment links and use CONST variable instead of env var…
1orZero be82c27
chore: Update const file
1orZero 698896f
refactor: Update handleCheckoutSessionCompleted function to use UserP…
1orZero a1ac3a1
feat: Add enums for PaidPlan and TopUpRequest
1orZero 9f95618
refactor: Move strip config to a new file from const file
1orZero a7b08e4
refactor: Update const variable name
1orZero 92964e8
refactor: Refactor handleCheckoutSessionCompleted function
1orZero f8fd4a4
refactor: Add error logging to stripe webhook handler
1orZero 5a72aa6
refactor: Add SubscriptionPlan type and update user.ts to use it
1orZero b62a782
refactor: Add getSubscriptionPlanByPaidPlan function to utils/app/pai…
1orZero f6f2383
refactor: Remove unused constant in stripe_config.ts
1orZero acb7446
refactor: Update updateUserAccount function to support extending pro/…
1orZero ac41bd6
refactor: Update handleCheckoutSessionCompleted function to use UserP…
1orZero 805f2a8
refactor: Update import statement for getCustomerEmailByCustomerID in…
1orZero 174a8e0
refactor: Update subscription event handling in stripe webhook handler
1orZero b4a75d3
refactor: rename file to paid_plan to paid_plan_helper
1orZero 415bf96
refactor: Update import statement for getCustomerEmailByCustomerID in…
1orZero 97f6072
refactor: Update localization for Chinese (Simplified) and Chinese (T…
1orZero a96b756
refactor: Add Tabs component for UI tab functionality
1orZero 208657f
refactor: Add UltraYearly option to PaidPlan enum
1orZero ce36427
refactor: Update payment links for Pro and Ultra plans
1orZero 5f25e16
refactor: Add support for yearly Ultra plan subscription
1orZero fd433e5
refactor: Update updateUserAccount function to extend membership
1orZero 1a73f75
refactor: Update payment links for Pro and Ultra plans
1orZero 3f1a88a
Refactor: Remove the updateUserAccount and make the function more atomic
1orZero 5b77027
refactor: Update handleCheckoutSessionCompleted to use strip_helper f…
1orZero 8e801fb
refactor: Update handleCustomerSubscriptionUpdated to use strip_helpe…
1orZero ea625c4
refactor: Update handleCustomerSubscriptionDeleted to use downgradeUs…
1orZero c87f6c4
refactor: Update handleCustomerSubscriptionDeleted to use downgradeUs…
1orZero ad40b13
refactor: Add support for monthly and yearly payment options in Chine…
1orZero 246896b
feat: Add logic to handle one-time plan purchase for users already on…
1orZero 27381da
refactor: Update payment links for staging
1orZero 30be37f
fix: Calculate membership expiration date for Ultra Yearly plan
1orZero e4dc0c5
refactor: Update getSubscriptionPlanByPaidPlan to handle Ultra Yearly…
1orZero 4d816e9
refactor: Remove console.log statements from handleCustomerSubscripti…
1orZero a586f02
refactor: Update PlanComparison component to improve UI and readability
1orZero d3ab5df
refactor: Improve UI and readability of PlanComparison component
1orZero 10b18df
refactor: update the stripe product type format
1orZero fb28020
refactor: Add API endpoint for changing subscription plan
1orZero 9d89727
refactor: Add API endpoint for changing subscription plan
1orZero 97406b7
refactor: Update handleCustomerSubscriptionDeleted to use getCustomer…
1orZero 4505d49
refactor: Update handleCustomerSubscriptionUpdated to use getCustomer…
1orZero e72ed64
refactor: Update getCustomerEmailByCustomerID function in strip_helper
1orZero 5465e05
refactor: Improve PlanComparison component UI and readability
1orZero 06dc18c
refactor: Update localization for Chinese (Simplified) and Chinese (T…
1orZero d2f6c34
refactor: Update stripe_config.ts to import StripeProduct type from '…
1orZero 5b95c05
refactor: Update stripe product type format
1orZero 80837ce
refactor: Update getPaidPlan function name to getDbSubscriptionPlanBy…
1orZero 15db06c
refactor: Update getPaidPlan function name to getPaidPlanByPlanCode
1orZero 3334507
refactor: Extract calculateMembershipExpirationDate function to strip…
1orZero 1e525da
refactor: Extract getPriceIdByPaidPlan function to paid_plan_helper
1orZero fd8c788
refactor: Import dayjs plugin for UTC in handleCheckoutSessionCompleted
1orZero d65fd4c
refactor: Add newPaidPlan validation and update subscription plan in …
1orZero 1c0fe25
refactor: Update stripe product type format
1orZero 2c10c83
refactor: Update getPaidPlan function name to getDbSubscriptionPlanBy…
1orZero b24fa08
refactor: Update stripe helper functions and import StripeProduct type
1orZero 315958d
refactor: Update BaseStripeProduct property name to productValue
1orZero f9f205b
refactor: Update handleCheckoutSessionCompleted to use productValue i…
1orZero 6f4a5d3
refactor: Update stripe product list based on environment
1orZero 5f90446
refactor: Update handleCheckoutSessionCompleted to include Top Up Req…
1orZero 284120c
refactor: Update stripe helper functions and import StripeProduct type
1orZero 1b2045a
refactor: Update handleCheckoutSessionCompleted to use getProductByCh…
1orZero d303329
refactor: Extend expiration date or change plan for Monthly Pro/Ultra…
1orZero 0ba779e
refactor: Add second receiver email for resend functionality
1orZero 3eed887
refactor: Update StripeProduct type and add mode property
1orZero ce7c568
refactor: Update sendReportForStripeWebhookError to include error cause
1orZero 850f3dd
refactor: Update stripe product list based on environment
1orZero c833e77
refactor: Update getProductByCheckoutSessionId to include mode parameter
1orZero 8217956
refactor: Update handleCustomerSubscriptionUpdated to include mode pa…
1orZero e8b53c1
refactor: Update handleCheckoutSessionCompleted to include session mo…
1orZero 9ede547
refactor: Update error message in getProductByProductId to improve cl…
1orZero 9c46dab
refactor: Update localization files for Chinese translations
1orZero 0b93c06
refactor: Update change-subscription-plan API to use new price id for…
1orZero 1200e39
refactor: Update useChangeSubscriptionPlan to include toast error mes…
1orZero abb1910
refactor: Update stripe_config imports to reflect new file structure
1orZero 42f3318
refactor: Update stripe product list based on environment
1orZero 249acf3
refactor: Update ULTRA monthly subscription payment links
1orZero cd7a2a0
refactor: Update STRIPE_PAID_PLAN_LINKS in const.ts
1orZero 80a29ad
refactor: Update package.json with type-check script
1orZero f34f017
refactor: Update ULTRA yearly and monthly subscription payment links
1orZero cb07ff3
refactor: Update STRIPE_PAID_PLAN_LINKS in const.ts
1orZero 9c9d534
refactor: Remove unused subscription JSON file
1orZero 5230cfd
refactor: Update useChangeSubscriptionPlan to accept priceId parameter
1orZero a6047bd
refactor: Add useUserSubscriptionDetail hook for fetching user subscr…
1orZero 81bdbdb
refactor: Remove useChangeSubscriptionPlan hook and related code
1orZero eb7f126
refactor: Add user subscription detail fetching and error handling
1orZero 7ae32b2
refactor: Update PlanComparison component to include isPaidUser prop
1orZero e388ec6
refactor: Remove change subscription plan API endpoint
1orZero 89c6c1e
refactor: Add user subscription detail API endpoint
1orZero 39b1dcf
refactor: Update fetchSubscriptionIdByUserId to return null if no sub…
1orZero 41cebf5
refactor: Add UserSubscriptionDetail interface for user subscription …
1orZero 4dbcc47
refactor: Update PaidPlanLinks type to use AvailablePaidPlanType
1orZero 7b0f604
refactor: Add ChangeSubscriptionButton component for managing user su…
1orZero 531c224
refactor: Update localization for subscription change messages in Chi…
1orZero 769842a
refactor: Remove unused import in stripe_config.ts
1orZero 1026221
Merge branch 'chat-everywhere' into derek/20240527-stripe-ultra-subsc…
1orZero 00b3318
Merge branch 'chat-everywhere' of https://github.com/exploratortech/c…
1orZero ebcf55f
Merge branch 'chat-everywhere' into derek/20240527-stripe-ultra-subsc…
1orZero f9e549b
chore: update package
1orZero 65ddaf8
refactor: handle when no subscription data from stripe
1orZero 4ce9d68
Merge branch 'chat-everywhere' into derek/20240527-stripe-ultra-subsc…
1orZero 1562981
feat(tests): add account data and update pro user login
1orZero 0a73f02
feat(api): add Chinese prompt for TW users
1orZero fbee487
feat(llm): add Chinese response for Taiwan users
1orZero 8976179
feat(cypress): add TEST_PAYMENT_USER constant
1orZero 74cf745
feat(cypress): add payment flow test skeleton
1orZero a699f30
feat(api): add test-payment-event endpoint
1orZero 686fba7
feat(stripe): add test event handling for non-prod
1orZero d332b39
feat(api): add reset test payment user subscription
1orZero 395ac13
feat(api): add test payment event for ultra plan
1orZero c96b326
feat(stripe): add fake event handling for testing
1orZero 36f8482
feat(stripe): add isFakeEvent param to handleSubscription
1orZero 5b75602
feat(api): add plan selection to test payment event
1orZero b83817d
feat(stripe): handle fake events in non-prod env
1orZero 8bd04db
feat(test): add payment flow e2e tests
1orZero 59a4336
Merge branch 'chat-everywhere' into derek/20240527-stripe-ultra-subsc…
1orZero b047c4e
Merge branch 'chat-everywhere' into derek/20240527-stripe-ultra-subsc…
1orZero a4982af
fix(UX): correct plan type in expiration date display condition
1orZero 040ee13
fix(subscription): adjust fake event expiration period to one month
1orZero 1749f51
test(e2e): add verification for plan expiration dates
1orZero 72ae377
refactor(api): rename test-payment-event to test-subscription-plan-pa…
1orZero 4c9a6d2
docs(api): clarify purpose of test subscription payment file
1orZero 8ec4c2d
feat(stripe): add support for fake events in subscription deletion
1orZero 208a7b6
feat(api): add test endpoint for subscription cancellation
1orZero a28cc97
test(e2e): implement downgrade flow verification
1orZero cc3fbeb
Merge branch 'chat-everywhere' into derek/20240527-stripe-ultra-subsc…
1orZero aa54ef4
fix(lint): expand firebase directory scope in .eslintignore
1orZero ac7fd20
fix(UserSettings): remove unused user prop from ChangeSubscriptionButton
1orZero 63cb574
fix(config): correct environment variable reference in Settings_Accou…
1orZero 96b3d19
refactor(subscriptions): adjust expiration date to include an extra d…
1orZero f10d86e
test(payment): extend expiration date by an extra day for Test Downgrade
1orZero a54e7ba
refactor(tests): rename test for subscription removal event accuracy
1orZero 5cd9451
fix(payment): update description for subscription cancellation test
1orZero 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1,2 @@ | ||
| firebase/functions/.eslintrc.js | ||
| firebase/* |
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,98 @@ | ||
| import { useMemo } from 'react'; | ||
| import { useTranslation } from 'react-i18next'; | ||
|
|
||
| import { OrderedSubscriptionPlans } from '@/utils/app/const'; | ||
|
|
||
| import type { StripeProductPaidPlanType } from '@/types/stripe-product'; | ||
| import type { UserSubscriptionDetail } from '@/types/user'; | ||
|
|
||
| import { | ||
| Dialog, | ||
| DialogContent, | ||
| DialogDescription, | ||
| DialogHeader, | ||
| DialogTitle, | ||
| DialogTrigger, | ||
| } from '@/components/ui/dialog'; | ||
|
|
||
| const ChangeSubscriptionButton: React.FC<{ | ||
| plan: StripeProductPaidPlanType; | ||
| userSubscription: UserSubscriptionDetail | undefined; | ||
| }> = ({ plan, userSubscription }) => { | ||
| const { t } = useTranslation('model'); | ||
|
|
||
| const showUpgradeButton = useMemo(() => { | ||
| if (!userSubscription) return false; | ||
| if (!userSubscription.userPlan) return false; | ||
| return ( | ||
| OrderedSubscriptionPlans.indexOf(plan) > | ||
| OrderedSubscriptionPlans.indexOf(userSubscription.userPlan) | ||
| ); | ||
| }, [userSubscription, plan]); | ||
|
|
||
| const showDowngradeButton = useMemo(() => { | ||
| if (!userSubscription) return false; | ||
| if (!userSubscription.userPlan) return false; | ||
| return ( | ||
| OrderedSubscriptionPlans.indexOf(plan) < | ||
| OrderedSubscriptionPlans.indexOf(userSubscription.userPlan) | ||
| ); | ||
| }, [userSubscription, plan]); | ||
|
|
||
| // Only show upgrade/downgrade button if user has a valid subscription | ||
| if (!userSubscription) return null; | ||
|
|
||
| return ( | ||
| <Dialog> | ||
| <DialogTrigger> | ||
| {showDowngradeButton ? ( | ||
| <div className="flex flex-col items-center"> | ||
| <a | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| className="mt-4 w-full cursor-pointer rounded-lg border border-none bg-white bg-gradient-to-r from-[#fd68a6] to-[#6c62f7] px-4 py-2 text-center text-sm font-semibold text-white shadow focus:outline-none" | ||
| > | ||
| {t(`Downgrade to ${plan === 'pro' ? 'Pro' : 'Ultra'} Plan`)} | ||
| </a> | ||
| </div> | ||
| ) : showUpgradeButton ? ( | ||
| <div className="flex flex-col items-center"> | ||
| <a | ||
| target="_blank" | ||
| rel="noreferrer" | ||
| className="mt-4 w-full cursor-pointer rounded-lg border border-none bg-white bg-gradient-to-r from-[#fd68a6] to-[#6c62f7] px-4 py-2 text-center text-sm font-semibold text-white shadow focus:outline-none" | ||
| > | ||
| {t(`Upgrade to ${plan === 'pro' ? 'Pro' : 'Ultra'} Plan`)} | ||
| </a> | ||
| </div> | ||
| ) : null} | ||
| </DialogTrigger> | ||
| <DialogContent> | ||
| <DialogHeader> | ||
| <DialogTitle className="text-white"> | ||
| {t('Need Assistance with Subscription Change?')} | ||
| </DialogTitle> | ||
| <DialogDescription className="p-4"> | ||
| {t( | ||
| 'If you wish to upgrade or downgrade your subscription, kindly contact our support team via email at', | ||
| )} | ||
| <a | ||
| href={`mailto:[email protected]?subject=${ | ||
| showDowngradeButton | ||
| ? 'Required%20downgrade%20subscription' | ||
| : showUpgradeButton | ||
| ? 'Required%20upgrade%20subscription' | ||
| : 'Subscription%20Inquiry' | ||
| }`} | ||
| > | ||
| [email protected] | ||
| </a> | ||
| . | ||
| </DialogDescription> | ||
| </DialogHeader> | ||
| </DialogContent> | ||
| </Dialog> | ||
| ); | ||
| }; | ||
|
|
||
| export default ChangeSubscriptionButton; |
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.