diff --git a/account/src/lib/user-utils.ts b/account/src/lib/user-utils.ts index 048671e..e7e5386 100644 --- a/account/src/lib/user-utils.ts +++ b/account/src/lib/user-utils.ts @@ -82,7 +82,6 @@ export async function upgradeUser(userId: T.UUID, subscription?: T.StripeSubscri export async function downgradeUser(userId: T.UUID, subscriptionId?: string): Promise { await deleteCouchDbAuthUser(userId); if (subscriptionId) { - console.log("deleting sub id", subscriptionId); stripe.subscriptions.del(subscriptionId); } const user = await updateLingdocsUser(userId, { diff --git a/account/src/routers/payment-router.ts b/account/src/routers/payment-router.ts index b32d411..d291065 100644 --- a/account/src/routers/payment-router.ts +++ b/account/src/routers/payment-router.ts @@ -37,23 +37,17 @@ paymentRouter.post( } } let subscription: Stripe.Subscription; - let status: Stripe.Subscription.Status; // Handle the event const userId = event.data.object.metadata.userId as T.UUID; switch (event.type) { case 'customer.subscription.deleted': subscription = event.data.object; - status = subscription.status; - console.log(`Subscription status is ${status}.`); - console.log(`Downgrading user ${userId}.`); await downgradeUser(userId); // Then define and call a method to handle the subscription deleted. // handleSubscriptionDeleted(subscriptionDeleted); break; case 'customer.subscription.created': subscription = event.data.object; - status = subscription.status; - console.log(`Upgrading user ${userId}.`); await upgradeUser(userId, subscription); // TODO: save subscription to db break; @@ -81,8 +75,10 @@ paymentRouter.post("/create-checkout-session", async (req, res, next) => { } try { const source = req.query.source; - const returnUrl = source === "dictionary" + const returnUrl = source === "account" ? "https://dictionary.lingdocs.com/account" + : source === "wordlist" + ? "https://dictionary.lingdocs.com" : "https://account.lingdocs.com/user"; const price = req.body.priceId; const session = await stripe.checkout.sessions.create({ diff --git a/website/src/components/UpgradePrices.tsx b/website/src/components/UpgradePrices.tsx index 1d4b663..c021367 100644 --- a/website/src/components/UpgradePrices.tsx +++ b/website/src/components/UpgradePrices.tsx @@ -8,15 +8,15 @@ const prices = [ priceId: "price_1Lt8NqJnpCQCjf9p4FAEIOMw", }, ]; -const checkoutPortalUrl = "https://account.lingdocs.com/payment/create-checkout-session/?source=dictionary"; +const checkoutPortalUrl = "https://account.lingdocs.com/payment/create-checkout-session/"; -function UpgradePrices() { +function UpgradePrices({ source }: { source: "account" | "wordlist" }) { return
Subscription options
{prices.map(({ priceId, label }) =>
diff --git a/website/src/screens/Account.tsx b/website/src/screens/Account.tsx index 039fc7e..991659a 100644 --- a/website/src/screens/Account.tsx +++ b/website/src/screens/Account.tsx @@ -191,7 +191,7 @@ const Account = ({ user, loadUser }: { user: AT.LingdocsUser | undefined, loadUs
  • Save text, audio, or visual context for words
  • Review words with Anki-style spaced repetition
  • - +
    diff --git a/website/src/screens/Wordlist.tsx b/website/src/screens/Wordlist.tsx index 01b59a5..eec2aa2 100644 --- a/website/src/screens/Wordlist.tsx +++ b/website/src/screens/Wordlist.tsx @@ -276,7 +276,7 @@ function Wordlist({ options, wordlist, isolateEntry, optionsDispatch, user }: {
  • Save text, audio, or visual context for words
  • Review words with Anki-style spaced repetition
  • - {user ? : Sign In} + {user ? : Sign In}
    ;