chore(dev): told referrals

This commit is contained in:
Soumyadas15 2025-06-16 14:52:29 +05:30
parent 7c5eea5c34
commit 0e9aaa6789
4 changed files with 34 additions and 27 deletions

View File

@ -14,6 +14,8 @@ from services.supabase import DBConnection
from utils.auth_utils import get_current_user_id_from_jwt from utils.auth_utils import get_current_user_id_from_jwt
from pydantic import BaseModel from pydantic import BaseModel
from utils.constants import MODEL_ACCESS_TIERS, MODEL_NAME_ALIASES from utils.constants import MODEL_ACCESS_TIERS, MODEL_NAME_ALIASES
import os
# Initialize Stripe # Initialize Stripe
stripe.api_key = config.STRIPE_SECRET_KEY stripe.api_key = config.STRIPE_SECRET_KEY
@ -542,7 +544,6 @@ async def create_checkout_session(
logger.exception(f"Error updating subscription {existing_subscription.get('id') if existing_subscription else 'N/A'}: {str(e)}") logger.exception(f"Error updating subscription {existing_subscription.get('id') if existing_subscription else 'N/A'}: {str(e)}")
raise HTTPException(status_code=500, detail=f"Error updating subscription: {str(e)}") raise HTTPException(status_code=500, detail=f"Error updating subscription: {str(e)}")
else: else:
# --- Create New Subscription via Checkout Session ---
session = stripe.checkout.Session.create( session = stripe.checkout.Session.create(
customer=customer_id, customer=customer_id,
payment_method_types=['card'], payment_method_types=['card'],

View File

@ -3,6 +3,7 @@
import { Separator } from '@/components/ui/separator'; import { Separator } from '@/components/ui/separator';
import Link from 'next/link'; import Link from 'next/link';
import { usePathname } from 'next/navigation'; import { usePathname } from 'next/navigation';
import Script from 'next/script';
export default function PersonalAccountSettingsPage({ export default function PersonalAccountSettingsPage({
children, children,
@ -16,30 +17,31 @@ export default function PersonalAccountSettingsPage({
{ name: 'Billing', href: '/settings/billing' }, { name: 'Billing', href: '/settings/billing' },
]; ];
return ( return (
<div className="space-y-6 w-full"> <>
<Separator className="border-subtle dark:border-white/10" /> <Script async src="https://cdn.tolt.io/tolt.js" data-tolt="pk_svc8UjqvSEMSSpDuxKH63UmV"></Script>
<div className="flex flex-col space-y-8 lg:flex-row lg:space-x-12 lg:space-y-0 w-full max-w-6xl mx-auto px-4"> <div className="space-y-6 w-full">
<aside className="lg:w-1/4 p-1"> <Separator className="border-subtle dark:border-white/10" />
<nav className="flex flex-col space-y-1"> <div className="flex flex-col space-y-8 lg:flex-row lg:space-x-12 lg:space-y-0 w-full max-w-6xl mx-auto px-4">
{items.map((item) => ( <aside className="lg:w-1/4 p-1">
<Link <nav className="flex flex-col space-y-1">
key={item.href} {items.map((item) => (
href={item.href} <Link
className={`px-3 py-2 rounded-md text-sm font-medium transition-colors ${ key={item.href}
pathname === item.href href={item.href}
? 'bg-accent text-accent-foreground' className={`px-3 py-2 rounded-md text-sm font-medium transition-colors ${pathname === item.href
: 'text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground' ? 'bg-accent text-accent-foreground'
}`} : 'text-muted-foreground hover:bg-accent/50 hover:text-accent-foreground'}`}
> >
{item.name} {item.name}
</Link> </Link>
))} ))}
</nav> </nav>
</aside> </aside>
<div className="flex-1 bg-card-bg dark:bg-background-secondary p-6 rounded-2xl border border-subtle dark:border-white/10 shadow-custom"> <div className="flex-1 bg-card-bg dark:bg-background-secondary p-6 rounded-2xl border border-subtle dark:border-white/10 shadow-custom">
{children} {children}
</div>
</div> </div>
</div> </div>
</div> </>
); );
} }

View File

@ -123,7 +123,7 @@ export default function RootLayout({
'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f); 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-PCHSN4M2');`} })(window,document,'script','dataLayer','GTM-PCHSN4M2');`}
</Script> </Script>
{/* End Google Tag Manager */} <script async src="https://cdn.tolt.io/tolt.js" data-tolt="pk_svc8UjqvSEMSSpDuxKH63UmV"></script>
</head> </head>
<body <body

View File

@ -1500,6 +1500,7 @@ export interface CreateCheckoutSessionRequest {
price_id: string; price_id: string;
success_url: string; success_url: string;
cancel_url: string; cancel_url: string;
referral_id?: string;
} }
export interface CreatePortalSessionRequest { export interface CreatePortalSessionRequest {
@ -1589,13 +1590,16 @@ export const createCheckoutSession = async (
throw new NoAccessTokenAvailableError(); throw new NoAccessTokenAvailableError();
} }
// Add referral ID to request if available
const requestBody = { ...request };
const response = await fetch(`${API_URL}/billing/create-checkout-session`, { const response = await fetch(`${API_URL}/billing/create-checkout-session`, {
method: 'POST', method: 'POST',
headers: { headers: {
'Content-Type': 'application/json', 'Content-Type': 'application/json',
Authorization: `Bearer ${session.access_token}`, Authorization: `Bearer ${session.access_token}`,
}, },
body: JSON.stringify(request), body: JSON.stringify(requestBody),
}); });
if (!response.ok) { if (!response.ok) {