diff --git a/app/pricing/page.tsx b/app/pricing/page.tsx index b131172a..9a759221 100644 --- a/app/pricing/page.tsx +++ b/app/pricing/page.tsx @@ -18,17 +18,35 @@ declare global { } } +async function getCustomerSecret() { + const res = await fetch(`/api/v3/user/subscription-portal/customer-session`, { + method: "POST", + headers: { + "X-Api-Key": process.env.PEPY_API_KEY! + } + }); + + const body = await res.json(); + return body["customerSecret"]; +} + export default function Home() { const {user, error} = useUser(); + const [customerSecret, setCustomerSecret] = useState(null); + useEffect(() => { + if (user !== null) { + getCustomerSecret().then(secret => setCustomerSecret(secret)); + } + }, [user]); - console.log(user); + console.log("Customer Secret", customerSecret) const stripePricingTable = ( <> );