From a92fdf77ce20fd18cc819029927a738c8b27a7f4 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 19 Feb 2025 01:12:48 +0100 Subject: [PATCH] add lifetime deal --- .../{plus_tier_logo.png => pro_tier_logo.png} | Bin src/routes/payment/+server.ts | 5 + src/routes/pricing/+page.svelte | 167 +++++++++++++++++- src/routes/profile/+page.svelte | 2 +- 4 files changed, 166 insertions(+), 8 deletions(-) rename src/lib/images/{plus_tier_logo.png => pro_tier_logo.png} (100%) diff --git a/src/lib/images/plus_tier_logo.png b/src/lib/images/pro_tier_logo.png similarity index 100% rename from src/lib/images/plus_tier_logo.png rename to src/lib/images/pro_tier_logo.png diff --git a/src/routes/payment/+server.ts b/src/routes/payment/+server.ts index ad1c1646..2d91d188 100644 --- a/src/routes/payment/+server.ts +++ b/src/routes/payment/+server.ts @@ -76,6 +76,8 @@ export const POST = async ({ request, locals }) => { const userId = payload?.meta?.custom_data?.userId; const { status, refunded } = payload?.data?.attributes || {}; + const productName = payload?.data?.attributes?.first_order_item?.product_name; + if (!userId || status === undefined) { console.error("Missing userId or status in payload:", payload); return new Response( @@ -91,11 +93,14 @@ export const POST = async ({ request, locals }) => { // Update the user and log the payment try { + await locals.pb.collection("users").update(userId, { tier, freeTrial: false, + lifetime: productName?.includes("Life Time"), }); + const paymentData = { user: userId, data: payload }; await locals.pb.collection("payments").create(paymentData); } catch (dbError) { diff --git a/src/routes/pricing/+page.svelte b/src/routes/pricing/+page.svelte index 21e119d0..1d6d5473 100644 --- a/src/routes/pricing/+page.svelte +++ b/src/routes/pricing/+page.svelte @@ -2,14 +2,15 @@ import { openLemonSqueezyUrl } from "$lib/lemonsqueezy"; //import Discount from '$lib/components/Discount.svelte'; import { onMount } from "svelte"; - import SEO from "$lib/components/SEO.svelte"; + import life_time_access_logo from "$lib/images/life_time_access_logo.png"; + import pro_tier_logo from "$lib/images/pro_tier_logo.png"; + import free_tier_logo from "$lib/images/free_tier_logo.png"; - //import proTierLogo from "$lib/images/pro_tier_logo.png"; + import SEO from "$lib/components/SEO.svelte"; export let data; export let form; - let cloudFrontUrl = import.meta.env.VITE_IMAGE_URL; let mode = true; //let mode = false; const emailAddress = "support@stocknear.com"; @@ -41,7 +42,10 @@ async function purchasePlan(subscriptionType: string = "") { if (data?.user) { let subId = ""; - if (mode) { + + if (subscriptionType === "lifeTime") { + subId = import.meta.env.VITE_LEMON_SQUEEZY_LIFE_TIME_ACCESS_ID; + } else if (mode) { subId = import.meta.env.VITE_LEMON_SQUEEZY_ANNUAL_ID; } else { subId = import.meta.env.VITE_LEMON_SQUEEZY_MONTHLY_ID; @@ -83,7 +87,7 @@ />
+ + + +
+
+ + Limited Offer + +
+ +
+ Lifetime tier +

Lifetime

+
+ +
+
+ $449 +
+
+ +
    +
  1. + + Everything in Pro Tier. +
  2. +
  3. + + Pay Once and use forever. +
  4. +
  5. + + + If you ❤️ Stocknear and want to support us, this is the best way. +
  6. +
+ +
+
+ + Unlimited feature updates +
+ + +
+ + diff --git a/src/routes/profile/+page.svelte b/src/routes/profile/+page.svelte index 2e8ac863..d5851f4b 100644 --- a/src/routes/profile/+page.svelte +++ b/src/routes/profile/+page.svelte @@ -556,7 +556,7 @@ Please wait a moment; you will be updated to Pro in a second. - {:else if subscriptionData?.first_order_item?.product_name === "Pro Subscription (Lifetime Access)"}{:else} + {:else if subscriptionData?.first_order_item?.product_name?.includes("Life Time")}{:else} Get Full Access with Pro Subscription.