Chat / backend /src /modules /subscription /subscription.service.ts
kishankrish19's picture
Deploy Stillwave fullstack clean
b0798af
Raw History Blame Contribute Delete
1.73 kB
import { Injectable } from '@nestjs/common';
@Injectable()
export class SubscriptionService {
getPlans() {
return [
{
id: 'free',
name: 'Free',
price: '$0.00/mo',
description: 'Shuffle-only playback with periodic ads.',
},
{
id: 'premium_individual',
name: 'Premium Individual',
price: '$10.99/mo',
description: 'On-demand, ad-free, 320kbps Hi-Fi audio.',
},
{
id: 'premium_duo',
name: 'Premium Duo',
price: '$14.99/mo',
description: '2 Premium accounts under one roof.',
},
{
id: 'premium_family',
name: 'Premium Family',
price: '$16.99/mo',
description: 'Up to 6 accounts with parental controls.',
},
{
id: 'premium_student',
name: 'Premium Student',
price: '$5.99/mo',
description: 'Discounted rate for eligible students.',
},
];
}
getSubscription(userId: string) {
return {
user_id: userId,
plan: 'free',
status: 'active',
stripe_customer_id: 'cus_xyz123',
current_period_end: new Date(
Date.now() + 30 * 24 * 60 * 60 * 1000,
).toISOString(),
};
}
createCheckoutSession(userId: string, planId: string) {
return {
url: `https://checkout.stripe.com/c/pay/cs_test_${Date.now()}?plan=${planId}`,
session_id: `cs_test_${Date.now()}`,
};
}
cancelSubscription(userId: string) {
return {
success: true,
message: 'Subscription set to cancel at current period end.',
};
}
handleStripeWebhook(event: any) {
return { received: true, type: event?.type || 'payment_intent.succeeded' };
}
}