From a1a31e50adc239f871e42e827bdf01535c92b32d Mon Sep 17 00:00:00 2001 From: Tanmay Deep Sharma Date: Mon, 1 Dec 2025 20:01:59 +0530 Subject: [PATCH] add UI for stripe_v2 --- .../dashboard/api/enterprise/account.js | 44 ++ .../dashboard/i18n/locale/en/settings.json | 93 ++++ .../dashboard/settings/billing/Index.vue | 413 ++++++++++++++---- .../components/CancelSubscriptionModal.vue | 141 ++++++ .../components/CancellationFeedbackForm.vue | 117 +++++ .../billing/components/ChangePlanModal.vue | 147 +++++++ .../billing/components/CreditHistoryModal.vue | 146 +++++++ .../billing/components/CreditPackageCard.vue | 78 ++++ .../settings/billing/components/PlanCard.vue | 99 +++++ .../components/PurchaseCreditsModal.vue | 112 +++++ .../billing/components/SeatStepper.vue | 104 +++++ .../billing/components/SubscriptionRow.vue | 56 +++ .../dashboard/store/modules/accounts.js | 142 ++++++ .../dashboard/store/mutation-types.js | 5 +- 14 files changed, 1601 insertions(+), 96 deletions(-) create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/CancelSubscriptionModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/CancellationFeedbackForm.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/ChangePlanModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/CreditHistoryModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/CreditPackageCard.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/PlanCard.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/PurchaseCreditsModal.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/SeatStepper.vue create mode 100644 app/javascript/dashboard/routes/dashboard/settings/billing/components/SubscriptionRow.vue diff --git a/app/javascript/dashboard/api/enterprise/account.js b/app/javascript/dashboard/api/enterprise/account.js index 3f12dc007..de80a3c0d 100644 --- a/app/javascript/dashboard/api/enterprise/account.js +++ b/app/javascript/dashboard/api/enterprise/account.js @@ -6,6 +6,7 @@ class EnterpriseAccountAPI extends ApiClient { super('', { accountScoped: true, enterprise: true }); } + // V1 endpoints checkout() { return axios.post(`${this.url}checkout`); } @@ -23,6 +24,49 @@ class EnterpriseAccountAPI extends ApiClient { action_type: action, }); } + + // V2 Billing endpoints + get v2BillingUrl() { + const accountId = this.accountIdFromRoute; + return `/enterprise/api/v2/accounts/${accountId}/billing`; + } + + getCreditGrants() { + return axios.get(`${this.v2BillingUrl}/credit_grants`); + } + + getPricingPlans() { + return axios.get(`${this.v2BillingUrl}/pricing_plans`); + } + + getTopupOptions() { + return axios.get(`${this.v2BillingUrl}/topup_options`); + } + + topupCredits(credits) { + return axios.post(`${this.v2BillingUrl}/topup`, { credits }); + } + + subscribeToPlan(pricingPlanId, quantity) { + return axios.post(`${this.v2BillingUrl}/subscribe`, { + pricing_plan_id: pricingPlanId, + quantity, + }); + } + + cancelSubscription(reason = null, feedback = null) { + return axios.post(`${this.v2BillingUrl}/cancel_subscription`, { + reason, + feedback, + }); + } + + changePricingPlan(pricingPlanId, quantity) { + return axios.post(`${this.v2BillingUrl}/change_pricing_plan`, { + pricing_plan_id: pricingPlanId, + quantity, + }); + } } export default new EnterpriseAccountAPI(); diff --git a/app/javascript/dashboard/i18n/locale/en/settings.json b/app/javascript/dashboard/i18n/locale/en/settings.json index b53bfed7b..58be53b6a 100644 --- a/app/javascript/dashboard/i18n/locale/en/settings.json +++ b/app/javascript/dashboard/i18n/locale/en/settings.json @@ -382,6 +382,8 @@ "BILLING_SETTINGS": { "TITLE": "Billing", "DESCRIPTION": "Manage your subscription here, upgrade your plan and get more for your team.", + "BILLING_PORTAL": "Billing Portal", + "VIEW_ALL_PLANS": "View all plans", "CURRENT_PLAN": { "TITLE": "Current Plan", "PLAN_NOTE": "You are currently subscribed to the **{plan}** plan with **{quantity}** licenses", @@ -394,6 +396,25 @@ "DESCRIPTION": "View your previous invoices, edit your billing details, or cancel your subscription.", "BUTTON_TXT": "Go to the billing portal" }, + "SUBSCRIPTION": { + "TITLE": "Subscription", + "DESCRIPTION": "Manage your current plan, seats, and billing cycle.", + "CURRENT_PLAN": "Current plan", + "NUMBER_OF_SEATS": "Number of seats", + "RENEWS_ON": "Renews on", + "ENDS_ON": "Ends on", + "CANCELLED_ON": "Cancelled on", + "CHANGE_PLAN": "Change", + "CHANGE_SEATS": "Change", + "CANCEL_SUBSCRIPTION": "Cancel" + }, + "CAPTAIN_AI": { + "TITLE": "Captain AI", + "DESCRIPTION": "Purchase and manage credits for Captain AI features.", + "AI_CREDITS": "AI credits", + "PURCHASE_CREDITS": "Purchase credits", + "VIEW_HISTORY": "View credit history" + }, "CAPTAIN": { "TITLE": "Captain", "DESCRIPTION": "Manage usage and credits for Captain AI.", @@ -402,6 +423,78 @@ "RESPONSES": "Responses", "UPGRADE": "Captain is not available on the free plan, upgrade now to get access to assistants, copilot and more." }, + "CHANGE_PLAN_MODAL": { + "TITLE": "Change plan", + "DESCRIPTION": "Select a plan that best fits your needs.", + "SUBSCRIBE_TITLE": "Choose a plan", + "SUBSCRIBE_DESCRIPTION": "Select a plan to subscribe and unlock all features.", + "CURRENT_PLAN": "Current plan", + "CREDITS_MONTH": "{credits} credits/month", + "PER_USER_MONTH": "/user/month", + "AI_CREDITS_MONTH": "AI credits/month", + "CANCEL": "Cancel", + "SELECT_PLAN": "Select plan", + "CHANGE_PLAN": "Change plan", + "SUBSCRIBE": "Subscribe" + }, + "CANCEL_MODAL": { + "TITLE": "Cancel subscription", + "WARNING_TITLE": "You're about to cancel your {plan} plan", + "WARNING_DESCRIPTION": "Your subscription will remain active until {date}. After that, you'll lose access to:", + "FEATURE_AI_CREDITS": "AI credits for Captain features", + "FEATURE_TEAM_COLLABORATION": "Team collaboration tools", + "FEATURE_PRIORITY_SUPPORT": "Priority customer support", + "KEEP_SUBSCRIPTION": "Keep subscription", + "CANCEL_SUBSCRIPTION": "Cancel subscription" + }, + "FEEDBACK_MODAL": { + "TITLE": "Help us improve", + "DESCRIPTION": "We're sorry to see you go. Please help us improve by sharing your reason for cancelling.", + "REASON_LABEL": "Why are you cancelling?", + "REASONS": { + "TOO_EXPENSIVE": "It's too expensive", + "NOT_USING": "I'm not using it enough", + "MISSING_FEATURES": "Missing features I need", + "BETTER_ALTERNATIVE": "Found a better alternative", + "TECHNICAL_ISSUES": "Technical issues", + "OTHER": "Other reason" + }, + "FEEDBACK_LABEL": "Additional feedback (optional)", + "FEEDBACK_PLACEHOLDER": "Tell us more about your experience...", + "GO_BACK": "Go back", + "SUBMIT_CANCEL": "Submit and cancel" + }, + "PURCHASE_MODAL": { + "TITLE": "Purchase AI credits", + "DESCRIPTION": "Choose a credit package that suits your needs.", + "MOST_POPULAR": "Most popular", + "CREDITS": "credits", + "NOTE": "Credits will be added to your account immediately and are non-refundable. Unused credits expire after 12 months.", + "CANCEL": "Cancel", + "PURCHASE": "Purchase" + }, + "CREDIT_HISTORY": { + "TITLE": "Credit history", + "DESCRIPTION": "View your credit purchases and allocations.", + "NAME": "Name", + "CREDITS": "Credits", + "SOURCE": "Source", + "EFFECTIVE_AT": "Effective at", + "EXPIRES_AT": "Expires at", + "NO_RECORDS": "No credit history found.", + "CLOSE": "Close" + }, + "HELP": { + "TITLE": "Need help?", + "DESCRIPTION": "Do you face any issues in billing? We are here to help.", + "CHAT": "Chat with us" + }, + "ALERTS": { + "PLAN_CHANGED": "Your plan has been changed successfully.", + "SEATS_UPDATED": "Number of seats updated successfully.", + "SUBSCRIPTION_CANCELLED": "Your subscription has been scheduled for cancellation.", + "CREDITS_PURCHASED": "Credits purchased successfully." + }, "CHAT_WITH_US": { "TITLE": "Need help?", "DESCRIPTION": "Do you face any issues in billing? We are here to help.", diff --git a/app/javascript/dashboard/routes/dashboard/settings/billing/Index.vue b/app/javascript/dashboard/routes/dashboard/settings/billing/Index.vue index 4ae140120..7243d9513 100644 --- a/app/javascript/dashboard/routes/dashboard/settings/billing/Index.vue +++ b/app/javascript/dashboard/routes/dashboard/settings/billing/Index.vue @@ -1,124 +1,252 @@ @@ -137,92 +265,187 @@ onMounted(handleBillingPageLogic); + > + + + diff --git a/app/javascript/dashboard/routes/dashboard/settings/billing/components/CancelSubscriptionModal.vue b/app/javascript/dashboard/routes/dashboard/settings/billing/components/CancelSubscriptionModal.vue new file mode 100644 index 000000000..1aa770621 --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/billing/components/CancelSubscriptionModal.vue @@ -0,0 +1,141 @@ + + + diff --git a/app/javascript/dashboard/routes/dashboard/settings/billing/components/CancellationFeedbackForm.vue b/app/javascript/dashboard/routes/dashboard/settings/billing/components/CancellationFeedbackForm.vue new file mode 100644 index 000000000..5d1c8645c --- /dev/null +++ b/app/javascript/dashboard/routes/dashboard/settings/billing/components/CancellationFeedbackForm.vue @@ -0,0 +1,117 @@ + + +