Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion auto-analyst-frontend/app/api/checkout-sessions/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe only if the secret key exists
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down
2 changes: 1 addition & 1 deletion auto-analyst-frontend/app/api/coupon-details/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ export const dynamic = 'force-dynamic'

const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe only if the secret key exists
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down Expand Up @@ -58,8 +58,8 @@ export async function POST(request: NextRequest) {
// Handle cancel_at_period_end flag
if (subscription.cancel_at_period_end) {
updateData.cancel_at_period_end = 'true'
updateData.willCancelAt = subscription.current_period_end
? new Date(subscription.current_period_end * 1000).toISOString()
updateData.willCancelAt = subscription.items?.data[0]?.current_period_end
? new Date(subscription.items.data[0].current_period_end * 1000).toISOString()
: new Date().toISOString()

// Override status display for UI purposes
Expand Down
2 changes: 1 addition & 1 deletion auto-analyst-frontend/app/api/payment-details/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe only if the secret key exists
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down
10 changes: 5 additions & 5 deletions auto-analyst-frontend/app/api/trial/cancel/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down Expand Up @@ -126,8 +126,8 @@ export async function POST(request: NextRequest) {
canceledAt: now.toISOString(),
lastUpdated: now.toISOString(),
subscriptionCanceled: 'true',
willCancelAt: stripeSubscription?.current_period_end
? new Date(stripeSubscription.current_period_end * 1000).toISOString()
willCancelAt: stripeSubscription?.items?.data[0]?.current_period_end
? new Date(stripeSubscription.items.data[0].current_period_end * 1000).toISOString()
: now.toISOString()
})

Expand All @@ -151,8 +151,8 @@ export async function POST(request: NextRequest) {
remaining: Math.max(0, parseInt(subscriptionData.total as string || '0') - parseInt(subscriptionData.used as string || '0'))
},
stripeStatus: stripeSubscription?.status || (isLegacyUser ? 'legacy' : 'unknown'),
willCancelAt: !(isTrial || isLegacyActive) && stripeSubscription?.current_period_end
? new Date(stripeSubscription.current_period_end * 1000).toISOString()
willCancelAt: !(isTrial || isLegacyActive) && stripeSubscription?.items?.data[0]?.current_period_end
? new Date(stripeSubscription.items.data[0].current_period_end * 1000).toISOString()
: undefined
})

Expand Down
4 changes: 2 additions & 2 deletions auto-analyst-frontend/app/api/trial/start/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down Expand Up @@ -114,7 +114,7 @@ export async function POST(request: NextRequest) {

// Apply discount if coupon is valid
if (couponId) {
subscriptionParams.coupon = couponId
subscriptionParams.discounts = [{ coupon: couponId }]
}

// Create subscription with trial
Expand Down
2 changes: 1 addition & 1 deletion auto-analyst-frontend/app/api/update-credits/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe only if the secret key exists
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { CreditConfig } from '@/lib/credits-config'
// Initialize Stripe
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down
10 changes: 5 additions & 5 deletions auto-analyst-frontend/app/api/webhooks/route.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ export const dynamic = 'force-dynamic'
// Initialize Stripe only if the secret key exists
const stripe = process.env.STRIPE_SECRET_KEY
? new Stripe(process.env.STRIPE_SECRET_KEY, {
apiVersion: '2025-02-24.acacia',
apiVersion: '2025-05-28.basil',
})
: null

Expand Down Expand Up @@ -225,8 +225,8 @@ export async function POST(request: NextRequest) {
const invoice = event.data.object as Stripe.Invoice

// Check if this is for a subscription payment
if (invoice.subscription) {
const subscription = await stripe.subscriptions.retrieve(invoice.subscription as string)
if ((invoice as any).subscription_id) {
const subscription = await stripe.subscriptions.retrieve((invoice as any).subscription_id as string)

// Get customer and user info
const customerId = subscription.customer as string
Expand Down Expand Up @@ -284,8 +284,8 @@ export async function POST(request: NextRequest) {
const invoice = event.data.object as Stripe.Invoice

// Handle failed payment after trial
if (invoice.subscription && invoice.billing_reason === 'subscription_cycle') {
const subscription = await stripe.subscriptions.retrieve(invoice.subscription as string)
if ((invoice as any).subscription_id && invoice.billing_reason === 'subscription_cycle') {
const subscription = await stripe.subscriptions.retrieve((invoice as any).subscription_id as string)

// Get customer and user info
const customerId = subscription.customer as string
Expand Down
28 changes: 23 additions & 5 deletions auto-analyst-frontend/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion auto-analyst-frontend/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
"@types/nodemailer": "^6.4.17",
"@types/react-plotly.js": "^2.6.3",
"@types/react-syntax-highlighter": "^15.5.13",
"@types/stripe": "^8.0.417",
"@upstash/redis": "^1.34.5",
"axios": "^1.7.9",
"class-variance-authority": "^0.7.1",
Expand Down Expand Up @@ -74,7 +75,7 @@
"rehype-raw": "^7.0.0",
"remark-gfm": "^4.0.0",
"shadcn-ui": "^0.9.5",
"stripe": "^17.7.0",
"stripe": "^18.2.1",
"tailwind-merge": "^2.6.0",
"tailwindcss-animate": "^1.0.7",
"uuid": "^11.1.0",
Expand Down
Loading