From 146cb4fd9cb9cd4b689b71595f4e95955a758d65 Mon Sep 17 00:00:00 2001 From: MuslemRahimi Date: Wed, 17 Jul 2024 20:24:29 +0200 Subject: [PATCH] add life time access --- ...ier_logo.png => life_time_access_logo.png} | Bin src/routes/community/profile/+page.server.ts | 2 +- src/routes/community/profile/+page.svelte | 14 ++- src/routes/payment/+server.ts | 6 +- src/routes/pricing/+page.svelte | 115 +++++++++++++++--- 5 files changed, 110 insertions(+), 27 deletions(-) rename src/lib/images/{pro_tier_logo.png => life_time_access_logo.png} (100%) diff --git a/src/lib/images/pro_tier_logo.png b/src/lib/images/life_time_access_logo.png similarity index 100% rename from src/lib/images/pro_tier_logo.png rename to src/lib/images/life_time_access_logo.png diff --git a/src/routes/community/profile/+page.server.ts b/src/routes/community/profile/+page.server.ts index 9c9be189..2f8e05a2 100644 --- a/src/routes/community/profile/+page.server.ts +++ b/src/routes/community/profile/+page.server.ts @@ -13,7 +13,7 @@ export const load = async ({ locals}) => { }))?.at(0)?.data?.data?.attributes ?? {} ; //console.log(output) - + return output; }; diff --git a/src/routes/community/profile/+page.svelte b/src/routes/community/profile/+page.svelte index 110ea584..d6730999 100644 --- a/src/routes/community/profile/+page.svelte +++ b/src/routes/community/profile/+page.svelte @@ -923,7 +923,11 @@ onDestroy(async () => { Current Plan: + {#if subscriptionData?.first_order_item?.product_name === 'Pro Subscription (Life Time Access)'} + Life Time Access + {:else} {['Active', 'Paid', 'On Trial', 'Cancelled']?.includes(subscriptionData?.status_formatted) ? subscriptionData?.product_name : data?.user?.freeTrial === true ? 'Free Trial Subscription' : 'Free Subscription'} + {/if} {subscriptionData?.product_name?.includes('Monthly') ? '$49.99 billed every month' : '$499 billed every year'} @@ -932,11 +936,11 @@ onDestroy(async () => { {#if subscriptionData?.status_formatted === 'Active' || subscriptionData?.status_formatted === 'On Trial'}
-
- diff --git a/src/routes/payment/+server.ts b/src/routes/payment/+server.ts index 97f3ac61..b9e50f61 100644 --- a/src/routes/payment/+server.ts +++ b/src/routes/payment/+server.ts @@ -30,7 +30,7 @@ export const POST = async ({ request, locals }) => { // Print out the data (replace this with your actual handling logic) const output = JSON.parse(body); - console.log('Received payment data:', output); + //console.log('Received payment data:', output); const userId = output?.meta?.custom_data?.userId; const status = output?.data?.attributes?.status; const refunded = output?.data?.attributes?.refunded; @@ -52,10 +52,14 @@ export const POST = async ({ request, locals }) => { 'tier': tier }); + /* if(status !== 'paid') { const data = {'user': userId, 'data': output} await locals.pb.collection('payments').create(data); } + */ + const data = {'user': userId, 'data': output} + await locals.pb.collection('payments').create(data); } catch(e) { console.log(e) diff --git a/src/routes/pricing/+page.svelte b/src/routes/pricing/+page.svelte index 2af2d2a9..eb8aebe2 100644 --- a/src/routes/pricing/+page.svelte +++ b/src/routes/pricing/+page.svelte @@ -1,4 +1,4 @@ -