@intlayer/backend 3.2.2 → 3.3.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (58) hide show
  1. package/dist/cjs/controllers/stripe.controller.cjs +110 -5
  2. package/dist/cjs/controllers/stripe.controller.cjs.map +1 -1
  3. package/dist/cjs/index.cjs +9 -2
  4. package/dist/cjs/index.cjs.map +1 -1
  5. package/dist/cjs/middlewares/request.middleware.cjs +0 -4
  6. package/dist/cjs/middlewares/request.middleware.cjs.map +1 -1
  7. package/dist/cjs/routes/stripe.routes.cjs +8 -2
  8. package/dist/cjs/routes/stripe.routes.cjs.map +1 -1
  9. package/dist/cjs/schemas/plans.schema.cjs +27 -5
  10. package/dist/cjs/schemas/plans.schema.cjs.map +1 -1
  11. package/dist/cjs/services/organization.service.cjs +5 -27
  12. package/dist/cjs/services/organization.service.cjs.map +1 -1
  13. package/dist/cjs/services/subscription.service.cjs +110 -116
  14. package/dist/cjs/services/subscription.service.cjs.map +1 -1
  15. package/dist/cjs/types/plan.types.cjs.map +1 -1
  16. package/dist/cjs/utils/errors/errorCodes.cjs +107 -3
  17. package/dist/cjs/utils/errors/errorCodes.cjs.map +1 -1
  18. package/dist/cjs/utils/plan.cjs +3 -3
  19. package/dist/cjs/utils/plan.cjs.map +1 -1
  20. package/dist/cjs/webhooks/stripe.webhook.cjs +102 -89
  21. package/dist/cjs/webhooks/stripe.webhook.cjs.map +1 -1
  22. package/dist/esm/controllers/stripe.controller.mjs +99 -5
  23. package/dist/esm/controllers/stripe.controller.mjs.map +1 -1
  24. package/dist/esm/index.mjs +10 -3
  25. package/dist/esm/index.mjs.map +1 -1
  26. package/dist/esm/middlewares/request.middleware.mjs +0 -4
  27. package/dist/esm/middlewares/request.middleware.mjs.map +1 -1
  28. package/dist/esm/routes/stripe.routes.mjs +12 -3
  29. package/dist/esm/routes/stripe.routes.mjs.map +1 -1
  30. package/dist/esm/schemas/plans.schema.mjs +27 -5
  31. package/dist/esm/schemas/plans.schema.mjs.map +1 -1
  32. package/dist/esm/services/organization.service.mjs +5 -25
  33. package/dist/esm/services/organization.service.mjs.map +1 -1
  34. package/dist/esm/services/subscription.service.mjs +101 -120
  35. package/dist/esm/services/subscription.service.mjs.map +1 -1
  36. package/dist/esm/utils/errors/errorCodes.mjs +107 -3
  37. package/dist/esm/utils/errors/errorCodes.mjs.map +1 -1
  38. package/dist/esm/utils/plan.mjs +3 -3
  39. package/dist/esm/utils/plan.mjs.map +1 -1
  40. package/dist/esm/webhooks/stripe.webhook.mjs +103 -90
  41. package/dist/esm/webhooks/stripe.webhook.mjs.map +1 -1
  42. package/dist/types/controllers/stripe.controller.d.ts +14 -0
  43. package/dist/types/controllers/stripe.controller.d.ts.map +1 -1
  44. package/dist/types/index.d.ts.map +1 -1
  45. package/dist/types/routes/stripe.routes.d.ts +6 -1
  46. package/dist/types/routes/stripe.routes.d.ts.map +1 -1
  47. package/dist/types/schemas/plans.schema.d.ts.map +1 -1
  48. package/dist/types/services/organization.service.d.ts +1 -8
  49. package/dist/types/services/organization.service.d.ts.map +1 -1
  50. package/dist/types/services/subscription.service.d.ts +5 -21
  51. package/dist/types/services/subscription.service.d.ts.map +1 -1
  52. package/dist/types/types/plan.types.d.ts +2 -1
  53. package/dist/types/types/plan.types.d.ts.map +1 -1
  54. package/dist/types/utils/errors/errorCodes.d.ts +104 -0
  55. package/dist/types/utils/errors/errorCodes.d.ts.map +1 -1
  56. package/dist/types/webhooks/stripe.webhook.d.ts +7 -2
  57. package/dist/types/webhooks/stripe.webhook.d.ts.map +1 -1
  58. package/package.json +10 -10
@@ -1,7 +1,9 @@
1
1
  "use strict";
2
+ var __create = Object.create;
2
3
  var __defProp = Object.defineProperty;
3
4
  var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
5
  var __getOwnPropNames = Object.getOwnPropertyNames;
6
+ var __getProtoOf = Object.getPrototypeOf;
5
7
  var __hasOwnProp = Object.prototype.hasOwnProperty;
6
8
  var __export = (target, all) => {
7
9
  for (var name in all)
@@ -15,10 +17,18 @@ var __copyProps = (to, from, except, desc) => {
15
17
  }
16
18
  return to;
17
19
  };
20
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
+ // If the importer is in node compatibility mode or this is not an ESM
22
+ // file that has been converted to a CommonJS file using a Babel-
23
+ // compatible transform (i.e. "__esModule" has not been set), then set
24
+ // "default" to the CommonJS "module.exports" for node compatibility.
25
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
+ mod
27
+ ));
18
28
  var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
29
  var subscription_service_exports = {};
20
30
  __export(subscription_service_exports, {
21
- addSubscription: () => addSubscription,
31
+ addOrUpdateSubscription: () => addOrUpdateSubscription,
22
32
  cancelSubscription: () => cancelSubscription,
23
33
  changeSubscriptionStatus: () => changeSubscriptionStatus
24
34
  });
@@ -26,175 +36,159 @@ module.exports = __toCommonJS(subscription_service_exports);
26
36
  var import_logger = require('./../logger/index.cjs');
27
37
  var import_errors = require('./../utils/errors/index.cjs');
28
38
  var import_plan = require('./../utils/plan.cjs');
29
- var import_intlayer = require("intlayer");
30
- var import_stripe = require("stripe");
39
+ var import_stripe = __toESM(require("stripe"), 1);
31
40
  var import_email = require('./email.service.cjs');
32
41
  var import_organization = require('./organization.service.cjs');
33
42
  var import_user = require('./user.service.cjs');
34
- const addSubscription = async (priceId, customerId, email, locale = import_intlayer.Locales.ENGLISH) => {
35
- let user = await (0, import_user.getUserByEmail)(email);
36
- const organization = await (0, import_organization.getOrganizationByCustomerId)(customerId);
37
- if (!organization) {
38
- throw new import_errors.GenericError("ORGANIZATION_NOT_FOUND", {
39
- customerId
40
- });
41
- }
42
- if (!user) {
43
- user = await (0, import_user.createUser)({
44
- email
45
- });
46
- }
43
+ const stripe = new import_stripe.default(process.env.STRIPE_SECRET_KEY);
44
+ const addOrUpdateSubscription = async (subscriptionId, priceId, customerId, userId, organization, status) => {
45
+ const user = await (0, import_user.getUserById)(userId);
47
46
  if (!user) {
48
47
  throw new import_errors.GenericError("USER_NOT_FOUND", {
49
- email
48
+ userId
50
49
  });
51
50
  }
52
51
  if (user.customerId !== customerId) {
53
52
  user.customerId = customerId;
54
53
  await user.save();
55
54
  }
56
- const planType = (0, import_plan.retrievePlanInformation)(priceId);
57
- if (organization.plan) {
58
- await cancelSubscription(organization.plan.customerId);
59
- const editedOrganization2 = await (0, import_organization.updatePlan)(organization, {
60
- ...organization.plan,
61
- creatorId: user._id,
62
- priceId,
63
- type: planType.type,
64
- period: planType.period,
65
- status: "ACTIVE"
66
- });
67
- if (!editedOrganization2) {
68
- throw new import_errors.GenericError("ORGANIZATION_UPDATE_FAILED", {
69
- organizationId: organization._id
70
- });
71
- }
72
- import_logger.logger.info(
73
- `Updated plan for organization ${organization._id} - ${planType.type} - ${planType.period}`
55
+ const planInfo = (0, import_plan.retrievePlanInformation)(priceId);
56
+ const subscriptions = await stripe.subscriptions.list({
57
+ customer: customerId,
58
+ status: "active",
59
+ limit: 1
60
+ });
61
+ if (subscriptions.data.length >= 1) {
62
+ const otherSubscriptionArray = subscriptions.data.filter(
63
+ (subscription) => subscription.id !== subscriptionId
74
64
  );
75
- return editedOrganization2.plan;
65
+ for (const subscription of otherSubscriptionArray) {
66
+ await stripe.subscriptions.cancel(subscription.id);
67
+ }
76
68
  }
77
- const editedOrganization = await (0, import_organization.updatePlan)(organization, {
69
+ const updatedOrganization = await (0, import_organization.updatePlan)(organization, {
78
70
  creatorId: user._id,
79
71
  priceId,
80
- type: planType.type,
81
- period: planType.period,
82
- status: "ACTIVE"
72
+ customerId,
73
+ subscriptionId,
74
+ type: planInfo.type,
75
+ period: planInfo.period,
76
+ status
83
77
  });
84
- if (!editedOrganization) {
78
+ if (!updatedOrganization) {
85
79
  throw new import_errors.GenericError("ORGANIZATION_UPDATE_FAILED", {
86
80
  organizationId: organization._id
87
81
  });
88
82
  }
89
- const { type } = (0, import_plan.retrievePlanInformation)(priceId);
90
- await (0, import_email.sendEmail)({
91
- type: "subscriptionPaymentSuccess",
92
- to: user.email,
93
- username: user.name,
94
- planName: type,
95
- subscriptionStartDate: (/* @__PURE__ */ new Date()).toLocaleDateString(),
96
- email,
97
- manageSubscriptionLink: `${process.env.CLIENT_URL}/dashboard`,
98
- locale
99
- });
100
83
  import_logger.logger.info(
101
- `Created plan for organization ${organization._id} - ${planType.type} - ${planType.period}`
84
+ `Plan updated for organization ${organization._id} - ${planInfo.type} - ${planInfo.period}`
102
85
  );
103
- return editedOrganization.plan;
104
- };
105
- const getActiveSubscriptions = async (customerId) => {
106
- const stripe = new import_stripe.Stripe(process.env.STRIPE_SECRET_KEY);
107
- const subscriptions = await stripe.subscriptions.list({
108
- customer: customerId,
109
- status: "active"
110
- });
111
- return subscriptions.data;
86
+ return updatedOrganization.plan;
112
87
  };
113
- const cancelSubscription = async (customerId) => {
114
- const stripe = new import_stripe.Stripe(process.env.STRIPE_SECRET_KEY);
115
- const organization = await (0, import_organization.getOrganizationByCustomerId)(customerId);
88
+ const cancelSubscription = async (subscriptionId, organizationId) => {
89
+ const organization = await (0, import_organization.getOrganizationById)(organizationId);
116
90
  if (!organization) {
117
91
  throw new import_errors.GenericError("ORGANIZATION_NOT_FOUND", {
118
- customerId
92
+ subscriptionId
119
93
  });
120
94
  }
95
+ if (!subscriptionId) {
96
+ throw new import_errors.GenericError("NO_SUBSCRIPTION_ID_PROVIDED");
97
+ }
121
98
  if (!organization.plan) {
122
99
  throw new import_errors.GenericError("ORGANIZATION_PLAN_NOT_FOUND", {
123
- customerId
100
+ subscriptionId,
101
+ organizationId: organization._id
124
102
  });
125
103
  }
126
- const activeSubscriptions = await getActiveSubscriptions(customerId);
127
- for (const sub of activeSubscriptions) {
128
- await stripe.subscriptions.cancel(sub.id);
104
+ const updatedOrganization = await (0, import_organization.updatePlan)(organization, {
105
+ status: "canceled"
106
+ });
107
+ if (!updatedOrganization) {
108
+ throw new import_errors.GenericError("ORGANIZATION_UPDATE_FAILED", {
109
+ organizationId: organization._id
110
+ });
129
111
  }
130
112
  import_logger.logger.info(
131
- `Cancelled plan for organization ${organization._id} - ${organization.plan.type} - ${organization.plan.period}`
113
+ `Cancelled plan for organization ${updatedOrganization._id} - ${updatedOrganization.plan.type} - ${updatedOrganization.plan.period}`
132
114
  );
133
- return organization.plan;
115
+ return updatedOrganization.plan;
134
116
  };
135
- const changeSubscriptionStatus = async (customerId, status, locale = import_intlayer.Locales.ENGLISH) => {
136
- const organization = await (0, import_organization.getOrganizationByCustomerId)(customerId);
117
+ const changeSubscriptionStatus = async (subscriptionId, status, userId, organizationId) => {
118
+ const organization = await (0, import_organization.getOrganizationById)(organizationId);
137
119
  if (!organization) {
138
120
  throw new import_errors.GenericError("ORGANIZATION_NOT_FOUND", {
139
- customerId
121
+ userId,
122
+ subscriptionId
140
123
  });
141
124
  }
142
125
  if (!organization.plan) {
143
126
  throw new import_errors.GenericError("ORGANIZATION_PLAN_NOT_FOUND", {
144
- customerId
127
+ userId,
128
+ subscriptionId,
129
+ organizationId: organization._id
145
130
  });
146
131
  }
147
- const editedOrganization = await (0, import_organization.updatePlan)(organization, {
148
- status
132
+ const updatedOrganization = await (0, import_organization.updatePlan)(organization, {
133
+ status,
134
+ subscriptionId
149
135
  });
150
- if (!editedOrganization) {
136
+ if (!updatedOrganization) {
151
137
  throw new import_errors.GenericError("ORGANIZATION_UPDATE_FAILED", {
152
138
  organizationId: organization._id
153
139
  });
154
140
  }
155
- const user = await (0, import_user.getUserById)(organization.plan.creatorId);
141
+ const user = await (0, import_user.getUserById)(userId);
142
+ if (!user) {
143
+ throw new import_errors.GenericError("USER_NOT_FOUND", {
144
+ userId,
145
+ subscriptionId
146
+ });
147
+ }
156
148
  import_logger.logger.info(
157
- `Updated plan for organization ${organization._id} - ${organization.plan.type} - ${organization.plan.period} - ${status}`
149
+ `Updated plan status for organization ${organization._id} - Status: ${status}`
158
150
  );
159
- if (status === "ACTIVE") {
160
- await (0, import_email.sendEmail)({
161
- type: "subscriptionPaymentSuccess",
162
- to: user.email,
163
- username: user.name,
164
- email: user.email,
165
- planName: organization.plan.type,
166
- subscriptionStartDate: (/* @__PURE__ */ new Date()).toLocaleDateString(),
167
- manageSubscriptionLink: `${process.env.CLIENT_URL}/dashboard`,
168
- locale
169
- });
170
- } else if (status === "CANCELLED") {
171
- await (0, import_email.sendEmail)({
172
- type: "subscriptionPaymentCancellation",
173
- to: user.email,
174
- username: user.name,
175
- email: user.email,
176
- planName: organization.plan.type,
177
- cancellationDate: (/* @__PURE__ */ new Date()).toLocaleDateString(),
178
- reactivateLink: `${process.env.CLIENT_URL}/dashboard`,
179
- locale
180
- });
181
- } else if (status === "ERROR") {
182
- await (0, import_email.sendEmail)({
183
- type: "subscriptionPaymentError",
184
- to: user.email,
185
- username: user.name,
186
- email: user.email,
187
- planName: organization.plan.type,
188
- errorDate: (/* @__PURE__ */ new Date()).toLocaleDateString(),
189
- retryPaymentLink: `${process.env.CLIENT_URL}/dashboard`,
190
- locale
191
- });
151
+ const emailData = {
152
+ to: user.email,
153
+ username: user.name,
154
+ email: user.email,
155
+ planName: organization.plan.type,
156
+ date: (/* @__PURE__ */ new Date()).toLocaleDateString(),
157
+ link: `${process.env.CLIENT_URL}/dashboard`
158
+ };
159
+ switch (status) {
160
+ case "active":
161
+ await (0, import_email.sendEmail)({
162
+ ...emailData,
163
+ type: "subscriptionPaymentSuccess",
164
+ subscriptionStartDate: emailData.date,
165
+ manageSubscriptionLink: emailData.link
166
+ });
167
+ break;
168
+ case "canceled":
169
+ await (0, import_email.sendEmail)({
170
+ ...emailData,
171
+ type: "subscriptionPaymentCancellation",
172
+ cancellationDate: emailData.date,
173
+ reactivateLink: emailData.link
174
+ });
175
+ break;
176
+ case "incomplete":
177
+ await (0, import_email.sendEmail)({
178
+ ...emailData,
179
+ type: "subscriptionPaymentError",
180
+ errorDate: emailData.date,
181
+ retryPaymentLink: emailData.link
182
+ });
183
+ break;
184
+ default:
185
+ import_logger.logger.warn(`Unhandled subscription status: ${status}`);
192
186
  }
193
- return editedOrganization.plan;
187
+ return updatedOrganization.plan;
194
188
  };
195
189
  // Annotate the CommonJS export names for ESM import in node:
196
190
  0 && (module.exports = {
197
- addSubscription,
191
+ addOrUpdateSubscription,
198
192
  cancelSubscription,
199
193
  changeSubscriptionStatus
200
194
  });
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/services/subscription.service.ts"],"sourcesContent":["import { logger } from '@logger';\nimport { GenericError } from '@utils/errors';\nimport { retrievePlanInformation } from '@utils/plan';\nimport { Locales } from 'intlayer';\nimport { Stripe } from 'stripe';\nimport { sendEmail } from './email.service';\nimport {\n getOrganizationByCustomerId,\n updatePlan,\n} from './organization.service';\nimport { getUserByEmail, createUser, getUserById } from './user.service';\nimport { Plan } from '@/types/plan.types';\n\n/**\n * Adds a subscription to an organization.\n * @param priceId - The ID of the price to add.\n * @param customerId - The ID of the customer to add.\n * @param email - The email of the user to add.\n * @param locale - The locale of the user to add.\n * @returns The added plan.\n */\nexport const addSubscription = async (\n priceId: string,\n customerId: string,\n email: string,\n locale: Locales = Locales.ENGLISH\n): Promise<Plan | null> => {\n let user = await getUserByEmail(email);\n const organization = await getOrganizationByCustomerId(customerId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', {\n customerId,\n });\n }\n\n if (!user) {\n user = await createUser({\n email,\n });\n }\n\n if (!user) {\n throw new GenericError('USER_NOT_FOUND', {\n email,\n });\n }\n\n if (user.customerId !== customerId) {\n user.customerId = customerId as string;\n await user.save();\n }\n const planType = retrievePlanInformation(priceId!);\n\n if (organization.plan) {\n // Cancel the current plan\n await cancelSubscription(organization.plan.customerId!);\n\n const editedOrganization = await updatePlan(organization, {\n ...organization.plan,\n creatorId: user._id,\n priceId: priceId!,\n type: planType.type,\n period: planType.period,\n status: 'ACTIVE',\n });\n\n if (!editedOrganization) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization._id,\n });\n }\n\n logger.info(\n `Updated plan for organization ${organization._id} - ${planType.type} - ${planType.period}`\n );\n\n return editedOrganization.plan;\n }\n\n const editedOrganization = await updatePlan(organization, {\n creatorId: user._id,\n priceId: priceId!,\n type: planType.type,\n period: planType.period,\n status: 'ACTIVE',\n });\n\n if (!editedOrganization) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization._id,\n });\n }\n\n const { type } = retrievePlanInformation(priceId!);\n\n await sendEmail({\n type: 'subscriptionPaymentSuccess',\n to: user.email,\n username: user.name,\n planName: type,\n subscriptionStartDate: new Date().toLocaleDateString(),\n email,\n manageSubscriptionLink: `${process.env.CLIENT_URL}/dashboard`!,\n locale,\n });\n\n logger.info(\n `Created plan for organization ${organization._id} - ${planType.type} - ${planType.period}`\n );\n\n return editedOrganization.plan;\n};\n\n/* Function to retrieve active subscriptions for a customer\n * Returns an array of Stripe.Subscription objects\n */\nconst getActiveSubscriptions = async (\n customerId: string\n): Promise<Stripe.Subscription[]> => {\n const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);\n\n const subscriptions = await stripe.subscriptions.list({\n customer: customerId,\n status: 'active',\n });\n return subscriptions.data;\n};\n\nexport const cancelSubscription = async (customerId: string) => {\n const stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);\n const organization = await getOrganizationByCustomerId(customerId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', {\n customerId,\n });\n }\n\n if (!organization.plan) {\n throw new GenericError('ORGANIZATION_PLAN_NOT_FOUND', {\n customerId,\n });\n }\n\n // Retrieve and cancel existing subscriptions\n const activeSubscriptions = await getActiveSubscriptions(customerId);\n for (const sub of activeSubscriptions) {\n await stripe.subscriptions.cancel(sub.id);\n }\n\n logger.info(\n `Cancelled plan for organization ${organization._id} - ${organization.plan.type} - ${organization.plan.period}`\n );\n\n return organization.plan;\n};\n\n/**\n * Changes the subscription status of an organization.\n *\n * @param customerId - The ID of the customer to change the subscription status for.\n * @param status - The new status of the subscription.\n * @param locale - The locale of the user to change the subscription status for.\n * @returns The updated plan.\n */\nexport const changeSubscriptionStatus = async (\n customerId: string,\n status: Plan['status'],\n locale: Locales = Locales.ENGLISH\n) => {\n const organization = await getOrganizationByCustomerId(customerId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', {\n customerId,\n });\n }\n\n if (!organization.plan) {\n throw new GenericError('ORGANIZATION_PLAN_NOT_FOUND', {\n customerId,\n });\n }\n\n const editedOrganization = await updatePlan(organization, {\n status,\n });\n\n if (!editedOrganization) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization._id,\n });\n }\n\n const user = await getUserById(organization.plan.creatorId!);\n\n logger.info(\n `Updated plan for organization ${organization._id} - ${organization.plan.type} - ${organization.plan.period} - ${status}`\n );\n\n if (status === 'ACTIVE') {\n await sendEmail({\n type: 'subscriptionPaymentSuccess',\n to: user!.email,\n username: user!.name,\n email: user!.email,\n planName: organization.plan.type,\n subscriptionStartDate: new Date().toLocaleDateString(),\n manageSubscriptionLink: `${process.env.CLIENT_URL}/dashboard`!,\n locale,\n });\n } else if (status === 'CANCELLED') {\n await sendEmail({\n type: 'subscriptionPaymentCancellation',\n to: user!.email,\n username: user!.name,\n email: user!.email,\n planName: organization.plan.type,\n cancellationDate: new Date().toLocaleDateString(),\n reactivateLink: `${process.env.CLIENT_URL}/dashboard`!,\n locale,\n });\n } else if (status === 'ERROR') {\n await sendEmail({\n type: 'subscriptionPaymentError',\n to: user!.email,\n username: user!.name,\n email: user!.email,\n planName: organization.plan.type,\n errorDate: new Date().toLocaleDateString(),\n retryPaymentLink: `${process.env.CLIENT_URL}/dashboard`!,\n locale,\n });\n }\n\n return editedOrganization.plan;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,oBAA6B;AAC7B,kBAAwC;AACxC,sBAAw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mB;AAAA,MAChD,gBAAgB,GAAG,QAAQ,IAAI,UAAU;AAAA,MACzC;AAAA,IACF,CAAC;AAAA,EACH,WAAW,WAAW,SAAS;AAC7B,cAAM,wBAAU;AAAA,MACd,MAAM;AAAA,MACN,IAAI,KAAM;AAAA,MACV,UAAU,KAAM;AAAA,MAChB,OAAO,KAAM;AAAA,MACb,UAAU,aAAa,KAAK;AAAA,MAC5B,YAAW,oBAAI,KAAK,GAAE,mBAAmB;AAAA,MACzC,kBAAkB,GAAG,QAAQ,IAAI,UAAU;AAAA,MAC3C;AAAA,IACF,CAAC;AAAA,EACH;AAEA,SAAO,mBAAmB;AAC5B;","names":["editedOrganization"]}
1
+ {"version":3,"sources":["../../../src/services/subscription.service.ts"],"sourcesContent":["import { logger } from '@logger';\nimport { GenericError } from '@utils/errors';\nimport { retrievePlanInformation } from '@utils/plan';\nimport Stripe from 'stripe';\nimport { sendEmail } from './email.service';\nimport { getOrganizationById, updatePlan } from './organization.service';\nimport { getUserById } from './user.service';\nimport type { Organization } from '@/types/organization.types';\nimport type { Plan } from '@/types/plan.types';\n\nconst stripe = new Stripe(process.env.STRIPE_SECRET_KEY!);\n\nexport const addOrUpdateSubscription = async (\n subscriptionId: string,\n priceId: string,\n customerId: string,\n userId: string,\n organization: Organization,\n status: Plan['status']\n): Promise<Plan | null> => {\n const user = await getUserById(userId);\n\n if (!user) {\n throw new GenericError('USER_NOT_FOUND', {\n userId,\n });\n }\n\n if (user.customerId !== customerId) {\n user.customerId = customerId;\n await user.save();\n }\n\n const planInfo = retrievePlanInformation(priceId);\n\n const subscriptions = await stripe.subscriptions.list({\n customer: customerId,\n status: 'active',\n limit: 1,\n });\n\n if (subscriptions.data.length >= 1) {\n // Active subscription exists; update it to the new plan\n const otherSubscriptionArray = subscriptions.data.filter(\n (subscription) => subscription.id !== subscriptionId\n );\n\n for (const subscription of otherSubscriptionArray) {\n await stripe.subscriptions.cancel(subscription.id);\n }\n }\n\n const updatedOrganization = await updatePlan(organization, {\n creatorId: user._id,\n priceId,\n customerId,\n subscriptionId,\n type: planInfo.type,\n period: planInfo.period,\n status,\n });\n\n if (!updatedOrganization) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization._id,\n });\n }\n\n logger.info(\n `Plan updated for organization ${organization._id} - ${planInfo.type} - ${planInfo.period}`\n );\n\n return updatedOrganization.plan;\n};\n\nexport const cancelSubscription = async (\n subscriptionId: string | Organization['_id'],\n organizationId: Organization['_id'] | string\n): Promise<Plan | null> => {\n const organization = await getOrganizationById(organizationId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', {\n subscriptionId,\n });\n }\n\n if (!subscriptionId) {\n throw new GenericError('NO_SUBSCRIPTION_ID_PROVIDED');\n }\n\n if (!organization.plan) {\n throw new GenericError('ORGANIZATION_PLAN_NOT_FOUND', {\n subscriptionId,\n organizationId: organization._id,\n });\n }\n\n const updatedOrganization = await updatePlan(organization, {\n status: 'canceled',\n });\n\n if (!updatedOrganization) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization._id,\n });\n }\n\n logger.info(\n `Cancelled plan for organization ${updatedOrganization._id} - ${updatedOrganization.plan.type} - ${updatedOrganization.plan.period}`\n );\n\n return updatedOrganization.plan;\n};\n\nexport const changeSubscriptionStatus = async (\n subscriptionId: string,\n status: Plan['status'],\n userId: string,\n organizationId: string\n): Promise<Plan | null> => {\n const organization = await getOrganizationById(organizationId);\n\n if (!organization) {\n throw new GenericError('ORGANIZATION_NOT_FOUND', {\n userId,\n subscriptionId,\n });\n }\n\n if (!organization.plan) {\n throw new GenericError('ORGANIZATION_PLAN_NOT_FOUND', {\n userId,\n subscriptionId,\n organizationId: organization._id,\n });\n }\n\n const updatedOrganization = await updatePlan(organization, {\n status,\n subscriptionId,\n });\n\n if (!updatedOrganization) {\n throw new GenericError('ORGANIZATION_UPDATE_FAILED', {\n organizationId: organization._id,\n });\n }\n\n const user = await getUserById(userId);\n\n if (!user) {\n throw new GenericError('USER_NOT_FOUND', {\n userId,\n subscriptionId,\n });\n }\n\n logger.info(\n `Updated plan status for organization ${organization._id} - Status: ${status}`\n );\n\n const emailData = {\n to: user.email,\n username: user.name,\n email: user.email,\n planName: organization.plan.type,\n date: new Date().toLocaleDateString(),\n link: `${process.env.CLIENT_URL}/dashboard`,\n };\n\n switch (status) {\n case 'active':\n await sendEmail({\n ...emailData,\n type: 'subscriptionPaymentSuccess',\n subscriptionStartDate: emailData.date,\n manageSubscriptionLink: emailData.link,\n });\n break;\n case 'canceled':\n await sendEmail({\n ...emailData,\n type: 'subscriptionPaymentCancellation',\n cancellationDate: emailData.date,\n reactivateLink: emailData.link,\n });\n break;\n case 'incomplete':\n await sendEmail({\n ...emailData,\n type: 'subscriptionPaymentError',\n errorDate: emailData.date,\n retryPaymentLink: emailData.link,\n });\n break;\n default:\n logger.warn(`Unhandled subscription status: ${status}`);\n }\n\n return updatedOrganization.plan;\n};\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,oBAAuB;AACvB,oBAA6B;AAC7B,kBAAwC;AACxC,oBAAmB;AACnB,mBAA0B;AAC1B,0BAAgD;AAChD,kBAA4B;AAI5B,MAAM,SAAS,IAAI,cAAAA,QAAO,QAAQ,IAAI,iBAAkB;AAEjD,MAAM,0BAA0B,OACrC,gBACA,SACA,YACA,QACA,cACA,WACyB;AACzB,QAAM,OAAO,UAAM,yBAAY,MAAM;AAErC,MAAI,CAAC,MAAM;AACT,UAAM,IAAI,2BAAa,kBAAkB;AAAA,MACvC;AAAA,IACF,CAAC;AAAA,EACH;AAEA,MAAI,KAAK,eAAe,YAAY;AAClC,SAAK,aAAa;AAClB,UAAM,KAAK,KAAK;AAAA,EAClB;AAEA,QAAM,eAAW,qCAAwB,OAAO;AAEhD,QAAM,gBAAgB,MAAM,OAAO,cAAc,KAAK;AAAA,IACpD,UAAU;AAAA,IACV,QAAQ;AAAA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AwB,UAAU;AAAA,MACpC,CAAC;AACD;AAAA,IACF,KAAK;AACH,gBAAM,wBAAU;AAAA,QACd,GAAG;AAAA,QACH,MAAM;AAAA,QACN,kBAAkB,UAAU;AAAA,QAC5B,gBAAgB,UAAU;AAAA,MAC5B,CAAC;AACD;AAAA,IACF,KAAK;AACH,gBAAM,wBAAU;AAAA,QACd,GAAG;AAAA,QACH,MAAM;AAAA,QACN,WAAW,UAAU;AAAA,QACrB,kBAAkB,UAAU;AAAA,MAC9B,CAAC;AACD;AAAA,IACF;AACE,2BAAO,KAAK,kCAAkC,MAAM,EAAE;AAAA,EAC1D;AAEA,SAAO,oBAAoB;AAC7B;","names":["Stripe"]}
@@ -1 +1 @@
1
- {"version":3,"sources":["../../../src/types/plan.types.ts"],"sourcesContent":["import { Document, ObjectId } from 'mongoose';\nimport { User } from './user.types';\n\nexport type PlanType = 'FREE' | 'PREMIUM' | 'ENTERPRISE';\n\nexport type PlanData = {\n type: PlanType;\n creatorId?: User['_id'];\n customerId?: string;\n priceId?: string;\n status?: 'INACTIVE' | 'ACTIVE' | 'ERROR' | 'CANCELLED';\n period?: 'MONTHLY' | 'YEARLY';\n};\n\nexport type Plan = PlanData & {\n _id: ObjectId;\n createdAt: number;\n updatedAt: number;\n};\n\nexport type PlanDocument = Document<unknown, {}, Plan> & Plan;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
1
+ {"version":3,"sources":["../../../src/types/plan.types.ts"],"sourcesContent":["import { Document, ObjectId } from 'mongoose';\nimport { User } from './user.types';\n\nexport type PlanType = 'FREE' | 'PREMIUM' | 'ENTERPRISE';\n\nexport type PlanData = {\n type: PlanType;\n creatorId?: User['_id'];\n subscriptionId?: string;\n customerId?: string;\n priceId?: string;\n status?:\n | 'active'\n | 'canceled'\n | 'past_due'\n | 'unpaid'\n | 'incomplete'\n | 'incomplete_expired'\n | 'paused'\n | 'trialing';\n period?: 'MONTHLY' | 'YEARLY';\n};\n\nexport type Plan = PlanData & {\n _id: ObjectId;\n createdAt: number;\n updatedAt: number;\n};\n\nexport type PlanDocument = Document<unknown, {}, Plan> & Plan;\n"],"mappings":";;;;;;;;;;;;;;AAAA;AAAA;","names":[]}
@@ -257,6 +257,32 @@ const errorData = {
257
257
  },
258
258
  statusCode: import_httpStatusCodes.HttpStatusCodes.NOT_FOUND_404
259
259
  },
260
+ USER_NOT_ORGANIZATION_MEMBER: {
261
+ title: {
262
+ en: "User Not Organization Member",
263
+ fr: "Utilisateur non membre de l'organisation",
264
+ es: "Usuario no miembro de la organizaci\xF3n"
265
+ },
266
+ message: {
267
+ en: "The user is not a member of the organization.",
268
+ fr: "L'utilisateur n'est pas membre de l'organisation.",
269
+ es: "El usuario no es miembro de la organizaci\xF3n."
270
+ },
271
+ statusCode: import_httpStatusCodes.HttpStatusCodes.FORBIDDEN_403
272
+ },
273
+ USER_NOT_ORGANIZATION_ADMIN: {
274
+ title: {
275
+ en: "User Not Organization Admin",
276
+ fr: "Utilisateur non administrateur de l'organisation",
277
+ es: "Usuario no administrador de la organizaci\xF3n"
278
+ },
279
+ message: {
280
+ en: "The user is not an admin of the organization.",
281
+ fr: "L'utilisateur n'est pas administrateur de l'organisation.",
282
+ es: "El usuario no es administrador de la organizaci\xF3n."
283
+ },
284
+ statusCode: import_httpStatusCodes.HttpStatusCodes.FORBIDDEN_403
285
+ },
260
286
  JWT_TOKEN_CREATION_FAILED_USER: {
261
287
  title: {
262
288
  en: "JWT Token Creation Failed",
@@ -316,9 +342,9 @@ const errorData = {
316
342
  es: "Organizaci\xF3n no encontrada"
317
343
  },
318
344
  message: {
319
- en: "Organization not found for the project.",
320
- fr: "Organisation non trouv\xE9e pour le projet.",
321
- es: "Organizaci\xF3n no encontrada para el proyecto."
345
+ en: "Organization not found.",
346
+ fr: "Organisation non trouv\xE9e.",
347
+ es: "Organizaci\xF3n no encontrada."
322
348
  },
323
349
  statusCode: import_httpStatusCodes.HttpStatusCodes.NOT_FOUND_404
324
350
  },
@@ -1140,6 +1166,84 @@ const errorData = {
1140
1166
  es: "La URL de devoluci\xF3n no es v\xE1lida."
1141
1167
  },
1142
1168
  statusCode: import_httpStatusCodes.HttpStatusCodes.BAD_REQUEST_400
1169
+ },
1170
+ STRIPE_SUBSCRIPTION_NO_CUSTOMER: {
1171
+ title: {
1172
+ en: "No customer found",
1173
+ fr: "Aucun client trouv\xE9",
1174
+ es: "No se encontr\xF3 el cliente"
1175
+ },
1176
+ message: {
1177
+ en: "No customer found for the provided subscription.",
1178
+ fr: "Aucun client n'a \xE9t\xE9 trouv\xE9 pour l'abonnement fourni.",
1179
+ es: "No se encontr\xF3 ning\xFAn cliente para el suscripci\xF3n proporcionada."
1180
+ },
1181
+ statusCode: import_httpStatusCodes.HttpStatusCodes.INTERNAL_SERVER_ERROR_500
1182
+ },
1183
+ NO_SUBSCRIPTION_ID_PROVIDED: {
1184
+ title: {
1185
+ en: "No subscription ID provided",
1186
+ fr: "Aucun ID d'abonnement fourni",
1187
+ es: "No se proporcion\xF3 ning\xFAn ID de suscripci\xF3n"
1188
+ },
1189
+ message: {
1190
+ en: "No subscription ID provided.",
1191
+ fr: "Aucun ID d'abonnement n'a \xE9t\xE9 fourni.",
1192
+ es: "No se proporcion\xF3 ning\xFAn ID de suscripci\xF3n."
1193
+ },
1194
+ statusCode: import_httpStatusCodes.HttpStatusCodes.BAD_REQUEST_400
1195
+ },
1196
+ CANNOT_CANCEL_SUBSCRIPTION: {
1197
+ title: {
1198
+ en: "Cannot cancel subscription",
1199
+ fr: "Impossible d'annuler l'abonnement",
1200
+ es: "No se puede cancelar la suscripci\xF3n"
1201
+ },
1202
+ message: {
1203
+ en: "Cannot cancel subscription.",
1204
+ fr: "Impossible d'annuler l'abonnement.",
1205
+ es: "No se puede cancelar la suscripci\xF3n."
1206
+ },
1207
+ statusCode: import_httpStatusCodes.HttpStatusCodes.INTERNAL_SERVER_ERROR_500
1208
+ },
1209
+ ALREADY_SUBSCRIBED: {
1210
+ title: {
1211
+ en: "Already Subscribed",
1212
+ fr: "D\xE9j\xE0 abonn\xE9",
1213
+ es: "Ya suscrito"
1214
+ },
1215
+ message: {
1216
+ en: "You are already subscribed to this plan.",
1217
+ fr: "Vous \xEAtes d\xE9j\xE0 abonn\xE9 \xE0 ce plan.",
1218
+ es: "Ya est\xE1s suscrito a este plan."
1219
+ },
1220
+ statusCode: import_httpStatusCodes.HttpStatusCodes.BAD_REQUEST_400
1221
+ },
1222
+ SESSION_CREATION_FAILED: {
1223
+ title: {
1224
+ en: "Session Creation Failed",
1225
+ fr: "\xC9chec de la cr\xE9ation de la session",
1226
+ es: "Error al crear la sesi\xF3n"
1227
+ },
1228
+ message: {
1229
+ en: "Failed to create the specified session.",
1230
+ fr: "La cr\xE9ation de la session a \xE9chou\xE9.",
1231
+ es: "No se pudo crear la sesi\xF3n especificada."
1232
+ },
1233
+ statusCode: import_httpStatusCodes.HttpStatusCodes.INTERNAL_SERVER_ERROR_500
1234
+ },
1235
+ SETUP_INTENT_CREATION_FAILED: {
1236
+ title: {
1237
+ en: "Setup Intent Creation Failed",
1238
+ fr: "\xC9chec de la cr\xE9ation de l'intention de configuration",
1239
+ es: "Error al crear la intenci\xF3n de configuraci\xF3n"
1240
+ },
1241
+ message: {
1242
+ en: "Failed to create the setup intent.",
1243
+ fr: "\xC9chec de la cr\xE9ation de l'intention de configuration.",
1244
+ es: "Error al crear la intenci\xF3n de configuraci\xF3n."
1245
+ },
1246
+ statusCode: import_httpStatusCodes.HttpStatusCodes.INTERNAL_SERVER_ERROR_500
1143
1247
  }
1144
1248
  };
1145
1249
  // Annotate the CommonJS export names for ESM import in node: