-
Notifications
You must be signed in to change notification settings - Fork 11
Add Autumn billing SDK and Better Auth plugin integration #375
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
Closed
Closed
Changes from all commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
b3e0173
Install Autumn SDK and integrate with Better Auth
urjitc a7fc39f
Enforce Autumn credits on premium chat models
urjitc c9ee946
Create billing page with usage display, pricing table, and upgrade modal
urjitc a0af9cf
Fix AutumnProvider backend URL fallback
urjitc 3396d3c
Await Autumn billing track in chat finish
urjitc dd23094
Fix billing portal loading and pricing formatting
urjitc f7c9fe7
Merge pull request #378 from ThinkEx-OSS/capy/billing-ui-implementation
capy-ai[bot] e7c4c4c
Merge pull request #376 from ThinkEx-OSS/capy/gate-premium-messages
capy-ai[bot] a96f1d9
Replace missing auth billing methods with standalone Autumn SDK
urjitc 947ce02
Fix plan price display to use dollar amounts returned by Autumn SDK
urjitc 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
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 |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| diff --git a/dist/better-auth/chunk-LRULDM7S.mjs b/dist/better-auth/chunk-LRULDM7S.mjs | ||
| index 31334ee65452ccbf47388e1d4cd79ce7d1f908ce..4e24d0ed9013cd9968df667738d47aba98afd2e2 100644 | ||
| --- a/dist/better-auth/chunk-LRULDM7S.mjs | ||
| +++ b/dist/better-auth/chunk-LRULDM7S.mjs | ||
| @@ -6,7 +6,7 @@ import { | ||
| } from "./chunk-GJAMWZNZ.mjs"; | ||
|
|
||
| // src/better-auth/utils/createAutumnEndpoint.ts | ||
| -import { createAuthEndpoint } from "better-auth/plugins"; | ||
| +import { createAuthEndpoint } from "better-auth/api"; | ||
| var getRouteConfig = (routeName) => { | ||
| const route = routeConfigs.find((r) => r.route === routeName); | ||
| if (!route) throw new Error(`Route not found: ${routeName}`); |
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,2 @@ | ||
| patchedDependencies: | ||
| autumn-js@1.2.9: patches/autumn-js@1.2.9.patch |
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 |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| "use client"; | ||
|
|
||
| import { useEffect } from "react"; | ||
| import { useRouter } from "next/navigation"; | ||
| import { AnonymousSessionHandler } from "@/components/layout/SessionHandler"; | ||
| import { Skeleton } from "@/components/ui/skeleton"; | ||
| import { useSession } from "@/lib/auth-client"; | ||
|
|
||
| function BillingAccessGate({ children }: { children: React.ReactNode }) { | ||
| const { data: session, isPending } = useSession(); | ||
| const router = useRouter(); | ||
|
|
||
| useEffect(() => { | ||
| if (!isPending && (!session || session.user?.isAnonymous)) { | ||
| router.replace("/auth/sign-up?redirect_url=%2Fbilling"); | ||
| } | ||
| }, [isPending, router, session]); | ||
|
|
||
| if (isPending || !session || session.user?.isAnonymous) { | ||
| return ( | ||
| <main className="mx-auto flex min-h-screen w-full max-w-4xl flex-col gap-8 px-4 py-12 md:px-6"> | ||
| <div className="space-y-3 text-center"> | ||
| <Skeleton className="mx-auto h-10 w-56" /> | ||
| <Skeleton className="mx-auto h-4 w-72" /> | ||
| </div> | ||
| <div className="space-y-4 rounded-2xl border bg-card p-6"> | ||
| <Skeleton className="h-7 w-32" /> | ||
| <Skeleton className="h-4 w-56" /> | ||
| <Skeleton className="h-2 w-full" /> | ||
| </div> | ||
| <div className="grid gap-4 md:grid-cols-2"> | ||
| <Skeleton className="h-64 rounded-2xl" /> | ||
| <Skeleton className="h-64 rounded-2xl" /> | ||
| </div> | ||
| </main> | ||
| ); | ||
| } | ||
|
|
||
| return <>{children}</>; | ||
| } | ||
|
|
||
| export default function BillingLayout({ | ||
| children, | ||
| }: { | ||
| children: React.ReactNode; | ||
| }) { | ||
| return ( | ||
| <AnonymousSessionHandler> | ||
| <BillingAccessGate>{children}</BillingAccessGate> | ||
| </AnonymousSessionHandler> | ||
| ); | ||
| } |
Oops, something went wrong.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: ThinkEx-OSS/thinkex
Length of output: 3182
🏁 Script executed:
Repository: ThinkEx-OSS/thinkex
Length of output: 233
🏁 Script executed:
rg "patchedDependencies" -A 10 package.jsonRepository: ThinkEx-OSS/thinkex
Length of output: 160
🏁 Script executed:
Repository: ThinkEx-OSS/thinkex
Length of output: 94
🌐 Web query:
pnpm patchedDependencies semver range version matching behavior💡 Result:
pnpm's patchedDependencies field in pnpm-workspace.yaml or package.json uses semver ranges in keys to match installed package versions. For a given installed version of a package (e.g., foo@2.1.0), pnpm selects the patch using strict priority: 1. Exact version match (highest priority, e.g., "foo@2.1.0") 2. First matching version range (e.g., "foo@^2.0.0") 3. Name-only fallback (e.g., "foo") Exact matches override ranges. The highest priority matching entry is applied; lower ones are skipped for that version. Avoid overlapping ranges; use exclusions for sub-ranges (e.g., "foo@>=2.0.0 <2.2.0 || >2.8.0"). Example from docs: patchedDependencies: foo: patches/foo-1.patch # name-only foo@^2.0.0: patches/foo-2.patch # range foo@2.1.0: patches/foo-3.patch # exact For foo@2.1.0: foo-3.patch applies (exact). For foo@2.0.1: foo-2.patch (range, matches ^2.0.0, no exact). For foo@1.0.0: foo-1.patch (name-only). Special: "*" acts like name-only but fails install on patch error (unlike name-only). This uses standard semver range matching (via semver library). Feature added ~pnpm 10.13+ via PR
#9236(merged Mar 2025). Patch failure handling: - Exact/range: fails install by default (configurable via ignorePatchFailures/allowUnusedPatches). - Name-only: ignores failures by default.Citations:
Pin
autumn-jsto the exact patched version.Dependency uses
^1.2.9(allows upgrades to 1.x.x), butpatchedDependenciestargets exact version1.2.9. If the package resolves to 1.2.10 or 1.3.0, pnpm won't apply the patch and installation will silently proceed without it.Proposed fix
📝 Committable suggestion
🤖 Prompt for AI Agents