refactor: remove embedded checkout components and update billing API integration for streamlined checkout flow

This commit is contained in:
Usman Baig
2026-02-20 03:51:20 +01:00
parent 96b3919e52
commit 17106517d9
7 changed files with 27 additions and 269 deletions

View File

@@ -16,6 +16,7 @@ import {
type Organization,
type OrganizationMember,
} from '@/lib/api/organization'
import { createCheckoutSession } from '@/lib/api/billing'
import { createSite, type Site } from '@/lib/api/sites'
import { setSessionAction } from '@/app/actions/auth'
import { useAuth } from '@/lib/auth/context'
@@ -217,14 +218,18 @@ function WelcomeContent() {
try {
trackWelcomePlanContinue()
const intent = JSON.parse(raw)
const params = new URLSearchParams({
const { url } = await createCheckoutSession({
plan_id: intent.planId,
interval: intent.interval || 'month',
limit: String(intent.limit ?? 100000),
limit: intent.limit ?? 100000,
})
localStorage.removeItem('pulse_pending_checkout')
setRedirectingCheckout(true)
router.push(`/checkout?${params.toString()}`)
if (url) {
setRedirectingCheckout(true)
window.location.href = url
return
}
throw new Error('No checkout URL returned')
} catch (err: unknown) {
setPlanError(getAuthErrorMessage(err) || (err as Error)?.message || 'Failed to start checkout')
localStorage.removeItem('pulse_pending_checkout')