Skip to content

Open source alternatives to paid SaaS apps: Notion, Slack, Auth0, Vercel and more. Curated list with licenses and GitHub stars.

Remove unrelated code files

Anil Chandra Naidu Matcha130179b3aff3
diff --git a/src/lib/services/billing.js b/src/lib/services/billing.js
deleted file mode 100644
index 4ca83a9..0000000
--- a/src/lib/services/billing.js
+++ /dev/null
@@ -1,48 +0,0 @@
-import { stripe } from "../stripe";
-import config from "../config";
-import { UserService } from "./user";
-
-export const BillingService = {
- async createCheckoutSession(userId, planId) {
- const plan = config.stripe.plans[planId];
- if (!plan) throw new Error("Invalid plan selected");
-
- const session = await stripe.checkout.sessions.create({
- payment_method_types: ["card"],
- line_items: [
- {
- price_data: {
- currency: "usd",
- product_data: {
- name: `${config.stripe.plans[planId].name}`,
- description: `Purchase ${plan.credits} credits to perform AI generations.`,
- },
- unit_amount: plan.price,
- },
- quantity: 1,
- },
- ],
- mode: "payment",
- success_url: `${config.auth.url}/pricing?success=true`,
- cancel_url: `${config.auth.url}/pricing?canceled=true`,
- metadata: { userId, credits: plan.credits.toString() },
- });
-
- return session.url;
- },
-
- async handleWebhook(body, signature) {
- const event = stripe.webhooks.constructEvent(body, signature, config.stripe.webhookSecret);
- if (event.type === "checkout.session.completed") {
- const session = event.data.object;
- const userId = session.metadata.userId;
- const credits = parseInt(session.metadata.credits || "0", 10);
-
- if (userId && credits > 0) {
- await UserService.addCredits(userId, credits);
- return { success: true, userId, credits };
- }
- }
- return { success: false };
- }
-};