feat: integrate Stripe for embedded checkout; update billing API to return client_secret and adjust checkout flow in components

This commit is contained in:
Usman Baig
2026-02-20 03:41:35 +01:00
parent 6d277b126e
commit 0bbbb8a1af
9 changed files with 291 additions and 29 deletions

View File

@@ -16,7 +16,7 @@ import {
OrganizationInvitation,
Organization
} from '@/lib/api/organization'
import { getSubscription, createPortalSession, getInvoices, cancelSubscription, changePlan, createCheckoutSession, SubscriptionDetails, Invoice } from '@/lib/api/billing'
import { getSubscription, createPortalSession, getInvoices, cancelSubscription, changePlan, SubscriptionDetails, Invoice } from '@/lib/api/billing'
import { TRAFFIC_TIERS, PLAN_ID_SOLO, getTierIndexForLimit, getLimitForTierIndex, getSitesLimitForPlan } from '@/lib/plans'
import { getAuditLog, AuditLogEntry, GetAuditLogParams } from '@/lib/api/audit'
import { getNotificationSettings, updateNotificationSettings } from '@/lib/api/notification-settings'
@@ -351,9 +351,12 @@ export default function OrganizationSettings() {
setShowChangePlanModal(false)
loadSubscription()
} else {
const { url } = await createCheckoutSession({ plan_id: PLAN_ID_SOLO, interval, limit })
if (url) window.location.href = url
else throw new Error('No checkout URL')
const params = new URLSearchParams({
plan_id: PLAN_ID_SOLO,
interval,
limit: String(limit),
})
router.push(`/checkout?${params.toString()}`)
}
} catch (error: any) {
toast.error(getAuthErrorMessage(error) || error.message || 'Something went wrong.')