From 27968dd0878b21122579a09a9196c0573c27624c Mon Sep 17 00:00:00 2001 From: Karol Wypchlo Date: Thu, 4 Mar 2021 15:00:43 +0100 Subject: [PATCH] payments --- .../src/pages/api/stripe/createCheckoutSession.js | 1 - packages/dashboard/src/pages/payments.js | 8 +++++++- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js b/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js index 4d5a737e..f7a2b0fb 100644 --- a/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js +++ b/packages/dashboard/src/pages/api/stripe/createCheckoutSession.js @@ -41,7 +41,6 @@ export default async (req, res) => { } const customer = await getStripeCustomer(user, authorization); - console.log(customer); const session = await stripe.checkout.sessions.create({ mode: "subscription", payment_method_types: ["card"], diff --git a/packages/dashboard/src/pages/payments.js b/packages/dashboard/src/pages/payments.js index 0b05d059..945041a7 100644 --- a/packages/dashboard/src/pages/payments.js +++ b/packages/dashboard/src/pages/payments.js @@ -2,7 +2,7 @@ import dayjs from "dayjs"; import Layout from "../components/Layout"; import useSWR from "swr"; import ky from "ky/umd"; -import { useState } from "react"; +import { useEffect, useState } from "react"; const plans = [ { @@ -67,6 +67,12 @@ export default function Payments() { } }; + useEffect(() => { + if (activePlan && isPaidTier(activePlan.tier)) { + setSelectedPlan(activePlan); + } + }, [activePlan, selectedPlan, setSelectedPlan]); + return (