diff --git a/docs/components/landing/hero.tsx b/docs/components/landing/hero.tsx index fda62a60..82d39b16 100644 --- a/docs/components/landing/hero.tsx +++ b/docs/components/landing/hero.tsx @@ -1,6 +1,6 @@ "use client"; -import { Fragment, useEffect, useId, useState } from "react"; +import { useEffect, useId, useState } from "react"; import useMeasure from "react-use-measure"; import Link from "next/link"; import clsx from "clsx"; @@ -207,131 +207,161 @@ function CodePreview() { 0 ? height : undefined }} - className="from-stone-100 to-stone-200 dark:to-black/90 dark:via-stone-950/10 dark:from-stone-950/90 relative overflow-hidden rounded-sm bg-gradient-to-tr ring-1 ring-white/10 backdrop-blur-lg" + className="relative overflow-hidden rounded-xl" > -
-
-
-
- + {/* Dynamic background based on theme */} +
-
- {tabs.map((tab) => ( - - ))} -
+ {/* Glass layers - responsive to theme */} +
+
+
-
-
- -
- - - - {({ - className, - style, - tokens, - getLineProps, - getTokenProps, - }) => ( -
-												
-													{tokens.map((line, lineIndex) => (
-														
- {line.map((token, tokenIndex) => ( - - ))} -
- ))} -
-
- )} -
-
- - - +
+ + {/* Inner glow - theme specific */} +
+ + {/* Liquid glass reflection effect - adaptive */} +
+
+
+
+
+
+
+ + +
+ {tabs.map((tab) => ( + + ))} +
+ +
+
+ +
+ + + + {({ + className, + style, + tokens, + getLineProps, + getTokenProps, + }) => ( +
+													
+														{tokens.map((line, lineIndex) => (
+															
+ {line.map((token, tokenIndex) => ( + + ))} +
+ ))} +
+
+ )} +
+
+ + + + + +

Demo

+ +
+
diff --git a/packages/stripe/src/hooks.ts b/packages/stripe/src/hooks.ts index cd126281..093d8143 100644 --- a/packages/stripe/src/hooks.ts +++ b/packages/stripe/src/hooks.ts @@ -74,12 +74,15 @@ export async function onCheckoutSessionCompleted( ], }); } - await options.subscription?.onSubscriptionComplete?.({ - event, - subscription: dbSubscription as Subscription, - stripeSubscription: subscription, - plan, - }); + await options.subscription?.onSubscriptionComplete?.( + { + event, + subscription: dbSubscription as Subscription, + stripeSubscription: subscription, + plan, + }, + ctx, + ); return; } } @@ -183,14 +186,14 @@ export async function onSubscriptionUpdated( subscription.status === "trialing" && plan.freeTrial?.onTrialEnd ) { - await plan.freeTrial.onTrialEnd({ subscription }, ctx.request); + await plan.freeTrial.onTrialEnd({ subscription }, ctx); } if ( subscriptionUpdated.status === "incomplete_expired" && subscription.status === "trialing" && plan.freeTrial?.onTrialExpired ) { - await plan.freeTrial.onTrialExpired(subscription, ctx.request); + await plan.freeTrial.onTrialExpired(subscription, ctx); } } } catch (error: any) { diff --git a/packages/stripe/src/index.ts b/packages/stripe/src/index.ts index 3e3e3b4b..9e3ed636 100644 --- a/packages/stripe/src/index.ts +++ b/packages/stripe/src/index.ts @@ -91,12 +91,15 @@ export const stripe = (options: O) => { }); } const isAuthorized = ctx.body?.referenceId - ? await options.subscription?.authorizeReference?.({ - user: session.user, - session: session.session, - referenceId, - action, - }) + ? await options.subscription?.authorizeReference?.( + { + user: session.user, + session: session.session, + referenceId, + action, + }, + ctx, + ) : true; if (!isAuthorized) { throw new APIError("UNAUTHORIZED", { @@ -387,6 +390,8 @@ export const stripe = (options: O) => { subscription, }, ctx.request, + //@ts-expect-error + ctx, ); const freeTrail = plan.freeTrial @@ -1035,11 +1040,14 @@ export const stripe = (options: O) => { if (!customer) { logger.error("#BETTER_AUTH: Failed to create customer"); } else { - await options.onCustomerCreate?.({ - customer, - stripeCustomer, - user, - }); + await options.onCustomerCreate?.( + { + customer, + stripeCustomer, + user, + }, + ctx, + ); } } }, diff --git a/packages/stripe/src/stripe.test.ts b/packages/stripe/src/stripe.test.ts index e8abe3e4..d1b0f8ba 100644 --- a/packages/stripe/src/stripe.test.ts +++ b/packages/stripe/src/stripe.test.ts @@ -561,6 +561,10 @@ describe("stripe", async () => { stripeSubscription: expect.any(Object), plan: expect.any(Object), }), + expect.objectContaining({ + context: expect.any(Object), + _flag: expect.any(String), + }), ); const updateEvent = { diff --git a/packages/stripe/src/types.ts b/packages/stripe/src/types.ts index 4fcd0136..cf2da45f 100644 --- a/packages/stripe/src/types.ts +++ b/packages/stripe/src/types.ts @@ -1,4 +1,9 @@ -import type { InferOptionSchema, Session, User } from "better-auth"; +import type { + GenericEndpointContext, + InferOptionSchema, + Session, + User, +} from "better-auth"; import type Stripe from "stripe"; import type { subscriptions, user } from "./schema"; @@ -70,7 +75,7 @@ export type StripePlan = { data: { subscription: Subscription; }, - request?: Request, + ctx: GenericEndpointContext, ) => Promise; /** * A function that will be called when the trial @@ -80,7 +85,7 @@ export type StripePlan = { */ onTrialExpired?: ( subscription: Subscription, - request?: Request, + ctx: GenericEndpointContext, ) => Promise; }; }; @@ -186,7 +191,7 @@ export interface StripeOptions { stripeCustomer: Stripe.Customer; user: User; }, - request?: Request, + ctx: GenericEndpointContext, ) => Promise; /** * A custom function to get the customer create @@ -199,7 +204,7 @@ export interface StripeOptions { user: User; session: Session; }, - request?: Request, + ctx: GenericEndpointContext, ) => Promise<{}>; /** * Subscriptions @@ -233,7 +238,7 @@ export interface StripeOptions { subscription: Subscription; plan: StripePlan; }, - request?: Request, + ctx: GenericEndpointContext, ) => Promise; /** * A callback to run after a user is about to cancel their subscription @@ -258,7 +263,7 @@ export interface StripeOptions { * and belongs to the user * * @param data - data containing user, session and referenceId - * @param request - Request Object + * @param ctx - the context object * @returns */ authorizeReference?: ( @@ -272,7 +277,7 @@ export interface StripeOptions { | "cancel-subscription" | "restore-subscription"; }, - request?: Request, + ctx: GenericEndpointContext, ) => Promise; /** * A callback to run after a user has deleted their subscription @@ -287,7 +292,7 @@ export interface StripeOptions { * parameters for session create params * * @param data - data containing user, session and plan - * @param request - Request Object + * @param ctx - the context object */ getCheckoutSessionParams?: ( data: { @@ -296,7 +301,7 @@ export interface StripeOptions { plan: StripePlan; subscription: Subscription; }, - request?: Request, + ctx: GenericEndpointContext, ) => | Promise<{ params?: Stripe.Checkout.SessionCreateParams;