-
Notifications
You must be signed in to change notification settings - Fork 1
Unify pricing to Free & Pro (0/mo), Autumn billing, Convex cost controls, Kimi K2 models #93
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Jackson57279
merged 3 commits into
open-lovable-gui
from
capy/unify-pricing-to-20m-99074871
Sep 9, 2025
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
7d8a7fb
Capy jam: Unify pricing to Free and Pro (0/mo); wire Autumn checkout/…
Jackson57279 922f86c
Capy jam: Remove Enterprise references from UI; add Save preview acti…
Jackson57279 8753666
Resolve merge conflicts: pricing pages/components unified to two tier…
Jackson57279 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| Capy jam: Unify pricing to Free and Pro (0/mo); wire Autumn checkout/portal; consolidate Autumn wrapper; reduce Convex writes on home; default sequential thinking to Kimi K2; update env example |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,14 +1,2 @@ | ||
| "use client"; | ||
| import { AutumnProvider } from "autumn-js/react"; | ||
| import { api } from "./convex/_generated/api"; | ||
| import { useConvex } from "convex/react"; | ||
|
|
||
| export function AutumnWrapper({ children }: { children: React.ReactNode }) { | ||
| const convex = useConvex(); | ||
|
|
||
| return ( | ||
| <AutumnProvider convex={convex} convexApi={(api as any).autumn}> | ||
| {children} | ||
| </AutumnProvider> | ||
| ); | ||
| } | ||
| export { AutumnWrapper } from "./app/components/AutumnWrapper"; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,45 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
| import { getAuth } from '@clerk/nextjs/server'; | ||
| import { autumn } from '@/convex/autumn'; | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const auth = getAuth(request); | ||
| if (!auth.userId) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); | ||
| } | ||
|
|
||
| const { returnUrl } = await request.json().catch(() => ({ returnUrl: undefined })); | ||
| const origin = request.headers.get('origin') || process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'; | ||
Jackson57279 marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
|
||
| if (process.env.AUTUMN_SECRET_KEY) { | ||
| try { | ||
| const mockCtx = { auth: { getUserIdentity: () => ({ subject: auth.userId, name: '', email: '' }) } } as any; | ||
| const result: any = await autumn.billingPortal(mockCtx, { returnUrl: returnUrl || `${origin}/pricing` }); | ||
| const url = result?.url || result?.portalUrl || result?.redirectUrl; | ||
| if (url) { | ||
| return NextResponse.json({ url }); | ||
| } | ||
| } catch (e) { | ||
| // fall through to Stripe | ||
| } | ||
| } | ||
|
|
||
| // Fallback to Stripe portal | ||
| const stripeRes = await fetch(`${origin}/api/stripe/customer-portal`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify({ returnUrl: returnUrl || `${origin}/pricing` }) | ||
| }); | ||
|
|
||
| if (!stripeRes.ok) { | ||
| const err = await stripeRes.text(); | ||
| return NextResponse.json({ error: err || 'Failed to create portal session' }, { status: 500 }); | ||
| } | ||
|
|
||
| const data = await stripeRes.json(); | ||
| return NextResponse.json({ url: data.url }); | ||
| } catch (error) { | ||
| return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,49 @@ | ||
| import { NextRequest, NextResponse } from 'next/server'; | ||
| import { getAuth } from '@clerk/nextjs/server'; | ||
| import { autumn } from '@/convex/autumn'; | ||
|
|
||
| export async function POST(request: NextRequest) { | ||
| try { | ||
| const auth = getAuth(request); | ||
| if (!auth.userId) { | ||
| return NextResponse.json({ error: 'Unauthorized' }, { status: 401 }); | ||
| } | ||
|
|
||
| const { priceId } = await request.json().catch(() => ({ priceId: undefined })); | ||
|
|
||
| const mockCtx = { auth: { getUserIdentity: () => ({ subject: auth.userId, name: '', email: '' }) } } as any; | ||
|
|
||
| if (process.env.AUTUMN_SECRET_KEY) { | ||
| try { | ||
| const result: any = await autumn.checkout(mockCtx, { priceId }); | ||
| const url = result?.url || result?.sessionUrl || result?.redirectUrl; | ||
| if (url) { | ||
| return NextResponse.json({ url }); | ||
| } | ||
| } catch (e) { | ||
| // fall through to Stripe | ||
| } | ||
| } | ||
|
|
||
| // Fallback to Stripe | ||
| const origin = request.headers.get('origin') || process.env.NEXT_PUBLIC_APP_URL || 'http://localhost:3000'; | ||
| const stripeRes = await fetch(`${origin}/api/stripe/create-checkout-session`, { | ||
| method: 'POST', | ||
| headers: { 'Content-Type': 'application/json' }, | ||
| body: JSON.stringify({ | ||
| priceId: priceId || process.env.NEXT_PUBLIC_STRIPE_PRO_PRICE_ID, | ||
| mode: 'subscription' | ||
| }) | ||
| }); | ||
|
|
||
| if (!stripeRes.ok) { | ||
| const err = await stripeRes.text(); | ||
| return NextResponse.json({ error: err || 'Failed to create checkout session' }, { status: 500 }); | ||
| } | ||
|
|
||
| const { sessionId } = await stripeRes.json(); | ||
| return NextResponse.json({ provider: 'stripe', sessionId }); | ||
| } catch (error) { | ||
| return NextResponse.json({ error: 'Internal server error' }, { status: 500 }); | ||
| } | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.