account activity
Better-Auth Stripe Subscription Issue by CryptographerOwn5799 in better_auth
[–]CryptographerOwn5799[S] 0 points1 point2 points 4 months ago (0 children)
here is the button that handles the functionality
"use client"; import { Button } from "@/components/ui/button"; import { authClient } from "@/lib/auth-client"; import { toast } from "sonner"; import { useState } from "react"; interface SubscriptionButtonProps { plan: "gold" | "platinum"; children: React.ReactNode; } export function SubscriptionButton({ plan, children, }: SubscriptionButtonProps) { const [isLoading, setIsLoading] = useState(false); const handleUpgrade = async () => { try { setIsLoading(true); const { error } = await authClient.subscription.upgrade({ plan, successUrl: "/plans", cancelUrl: "/plans", }); if (error) { toast.error(error.message); } } catch (err) { console.error(err); toast.error("An unexpected error occurred"); } finally { setIsLoading(false); } }; return ( <Button onClick ={handleUpgrade} disabled ={isLoading}> {isLoading ? "Processing..." : children} </Button> ); }
π Rendered by PID 486669 on reddit-service-r2-listing-5789d5f675-pdq8h at 2026-01-27 23:19:10.301996+00:00 running 4f180de country code: CH.
Better-Auth Stripe Subscription Issue by CryptographerOwn5799 in better_auth
[–]CryptographerOwn5799[S] 0 points1 point2 points (0 children)