diff --git a/src/lib/components/CookieConsent.svelte b/src/lib/components/CookieConsent.svelte index 09984b7..760cc72 100644 --- a/src/lib/components/CookieConsent.svelte +++ b/src/lib/components/CookieConsent.svelte @@ -21,7 +21,9 @@

We use cookies to ensure you get the best experience on our website. By continuing, you agree - to our use of cookies. + to our use of cookies. For details, please see our Privacy Policy.

{ return product as Product; }; +const getUserSubscriptions = async (userId: string) => { + try { + // Step 1: Retrieve subscription data + const { data: subscriptions, error } = await supabaseAdmin + .from('subscriptions') + .select('*') + .eq('user_id', userId); + + if (error) { + console.error('Error retrieving subscriptions:', error.message); + throw new Error('Failed to fetch subscriptions'); + } + + // Step 2: Map through each subscription and fetch product and price details + const subscriptionDetails = await Promise.all( + subscriptions.map(async (sub) => { + // Fetch product and price details from Stripe + const product = await stripeClient.products.retrieve(sub.product_id); + const price = await stripeClient.prices.retrieve(sub.price_id); + + const expiryDate = new Date(sub.current_period_end); + + // Format output data + return { + productName: product.name, + amount: (price.unit_amount / 100).toFixed(2), + currency: price.currency.toUpperCase(), + interval: price.recurring?.interval || 'one-time', + expiryDate: expiryDate.toLocaleDateString('en-GB', { + day: '2-digit', + month: '2-digit', + year: 'numeric' + }), + status: sub.status + }; + }) + ); + + return subscriptionDetails; + } catch (error) { + console.error('An error occurred while retrieving subscription details:', error); + throw new Error('Could not retrieve subscription details'); + } +}; + +const getUserTransactions = async (userId: string) => { + try { + // Step 1: Retrieve the customer ID associated with the user + const { data, error } = await supabaseAdmin + .from('customers') + .select('stripe_customer_id') + .eq('id', userId) + .single(); + + if (error) { + console.error('Error retrieving user data:', error.message); + throw new Error('Failed to fetch user data'); + } + + const customerId = data?.stripe_customer_id; + if (!customerId) { + throw new Error('No Stripe customer ID found for this user'); + } + + // Step 2: Fetch charge transactions from Stripe + const charges = await stripeClient.charges.list({ customer: customerId }); + + // Step 3: Format transaction data + const transactions = charges.data.map((charge) => ({ + amount: (charge.amount / 100).toFixed(2), + currency: charge.currency.toUpperCase(), + description: charge.description ?? 'No description provided', + status: charge.status, + created: new Date(charge.created * 1000).toLocaleDateString('en-GB', { + day: '2-digit', + month: '2-digit', + year: 'numeric' + }), + receipt_url: charge.receipt_url + })); + + return transactions; + } catch (error) { + console.error('An error occurred while retrieving transactions:', error); + throw new Error('Could not retrieve transactions'); + } +}; + export { upsertProductRecord, upsertPriceRecord, @@ -496,5 +584,7 @@ export { getActiveProductsWithPrices, getProductById, upsertCustomerToSupabase, - getStripeCustomerId + getStripeCustomerId, + getUserSubscriptions, + getUserTransactions }; diff --git a/src/routes/(policies)/cookies/+page.svelte b/src/routes/(policies)/cookies/+page.svelte new file mode 100644 index 0000000..511b4e0 --- /dev/null +++ b/src/routes/(policies)/cookies/+page.svelte @@ -0,0 +1,85 @@ +
+

Cookie Policy

+

Effective Date: [Insert Date]

+ +
+

1. Introduction

+

+ This Cookie Policy explains how [Your Company/Website Name] ("we", "us", or "our") uses + cookies and similar technologies to collect and store information when you visit our website. +

+
+ +
+

2. What Are Cookies?

+

+ Cookies are small text files stored on your device (computer, tablet, smartphone) by your web + browser when you visit a website. They help us remember your preferences and improve your + experience on our website. +

+
+ +
+

3. Types of Cookies We Use

+
    +
  • + Essential Cookies: These cookies are necessary for the + website to function properly and cannot be disabled in our systems. They include login + authentication and session management cookies. +
  • +
  • + Performance Cookies: These cookies help us understand how + visitors interact with our website by collecting information on usage patterns, such as + pages visited and links clicked. +
  • +
  • + Functional Cookies: These cookies allow us to remember + choices you make (such as your language preference) to provide a more personalised + experience. +
  • +
  • + Targeting/Advertising Cookies: These cookies are used to + deliver relevant advertisements and track the effectiveness of our marketing campaigns. +
  • +
+
+ +
+

4. How We Use Cookies

+

+ We use cookies to improve the functionality and performance of our website, analyse visitor + usage, and provide personalised content and advertisements. This helps us improve our website + and better understand our audience. +

+
+ +
+

5. Managing Your Cookie Preferences

+

+ You have the right to accept or reject cookies. You can manage your cookie preferences by + adjusting your browser settings. However, disabling certain cookies may affect your experience + on our website. For specific instructions on managing cookies, please consult your browser's + help documentation. +

+
+ +
+

6. Changes to Our Cookie Policy

+

+ We may update this Cookie Policy from time to time. Significant changes will be posted on this + page. We encourage you to review this policy periodically to stay informed about our use of + cookies. +

+
+ +
+

Contact Us

+

+ For questions about our Cookie Policy, please contact us at [Your Contact Email] + or visit our Contact Page. +

+
+
diff --git a/src/routes/(policies)/privacy/+page.svelte b/src/routes/(policies)/privacy/+page.svelte new file mode 100644 index 0000000..6901837 --- /dev/null +++ b/src/routes/(policies)/privacy/+page.svelte @@ -0,0 +1,125 @@ +
+

Privacy Policy

+

Effective Date: [Insert Date]

+ +
+

1. Introduction

+

+ This Privacy Policy explains how we at [Your Company/Website Name] collect, use, and protect + your personal information when you visit our website. We are committed to safeguarding your + data and complying with relevant data protection laws, including the General Data Protection + Regulation (GDPR). +

+
+ +
+

2. Information We Collect

+

+ We collect personal and non-personal information to provide our services and enhance your + experience. +

+
    +
  • + Personal Information: Details like your name, email + address, and payment information collected when you make a purchase or create an account. +
  • +
  • + Usage Data: Information such as IP address, browser type, + and browsing history for analytics and functionality. +
  • +
+
+ +
+

3. How We Use Your Information

+
    +
  • To process orders and manage customer support.
  • +
  • To improve website functionality and provide a better user experience.
  • +
  • To send marketing emails, if you opt in (you may unsubscribe at any time).
  • +
+
+ +
+

4. Sharing Information with Third Parties

+

+ We work with trusted third-party providers to offer secure services, such as payment + processing and authentication. +

+
+

Stripe

+

+ For payment processing, we use Stripe. Please refer to their + Privacy Policy for details. +

+
+
+

Supabase

+

+ For database and authentication, we use Supabase. See their + Privacy Policy for more information. +

+
+
+ +
+

5. Cookies and Tracking

+

+ We use cookies to provide essential site functionality, analytics, and improved user + experience. By continuing to use our site, you consent to our use of cookies. You can manage + your cookie preferences in your browser settings. For more details, please refer to our Cookie Policy. +

+
+ +
+

6. Your Data Rights

+

+ Under GDPR, you have the right to access, correct, delete, and restrict the processing of your + personal data. To make a request, please contact us at [Your Contact Email]. +

+
+ +
+

7. Data Security

+

+ We take reasonable steps to protect your information through encryption and secure access + protocols. However, no online service can be 100% secure. +

+
+ +
+

8. Policy Updates

+

+ We may update this policy periodically. Significant changes will be posted on this page, so + please review it regularly. +

+
+ +
+

Contact Us

+

+ If you have questions about this Privacy Policy, please contact us at [Your Contact Email] + or visit our Contact Page. +

+
+
diff --git a/src/routes/+layout.svelte b/src/routes/+layout.svelte index 9e50d24..7dfb5cd 100644 --- a/src/routes/+layout.svelte +++ b/src/routes/+layout.svelte @@ -195,8 +195,12 @@ d="M22.672 15.226l-2.432.811.841 2.515c.33 1.019-.209 2.127-1.23 2.456-1.15.325-2.148-.321-2.463-1.226l-.84-2.518-5.013 1.677.84 2.517c.391 1.203-.434 2.542-1.831 2.542-.88 0-1.601-.564-1.86-1.314l-.842-2.516-2.431.809c-1.135.328-2.145-.317-2.463-1.229-.329-1.018.211-2.127 1.231-2.456l2.432-.809-1.621-4.823-2.432.808c-1.355.384-2.558-.59-2.558-1.839 0-.817.509-1.582 1.327-1.846l2.433-.809-.842-2.515c-.33-1.02.211-2.129 1.232-2.458 1.02-.329 2.13.209 2.461 1.229l.842 2.515 5.011-1.677-.839-2.517c-.403-1.238.484-2.553 1.843-2.553.819 0 1.585.509 1.85 1.326l.841 2.517 2.431-.81c1.02-.33 2.131.211 2.461 1.229.332 1.018-.21 2.126-1.23 2.456l-2.433.809 1.622 4.823 2.433-.809c1.242-.401 2.557.484 2.557 1.838 0 .819-.51 1.583-1.328 1.847m-8.992-6.428l-5.01 1.675 1.619 4.828 5.011-1.674-1.62-4.829z" > -

Copyright © 2024 - All right reserved

+

Copyright © 2024 - All rights reserved

+
+ Privacy Policy + Cookie Policy +