@forklaunch/implementation-billing-stripe 0.4.3 → 0.5.0
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.
- package/lib/eject/services/billingPortal.service.ts +2 -2
- package/lib/eject/services/checkoutSession.service.ts +1 -0
- package/lib/eject/services/index.ts +1 -0
- package/lib/eject/services/paymentLink.service.ts +7 -7
- package/lib/eject/services/plan.service.ts +70 -55
- package/lib/eject/services/subscription.service.ts +96 -64
- package/lib/services/index.d.mts +5 -9
- package/lib/services/index.d.ts +5 -9
- package/lib/services/index.js +153 -110
- package/lib/services/index.mjs +151 -109
- package/package.json +11 -11
|
@@ -120,13 +120,13 @@ export class StripeBillingPortalService<
|
|
|
120
120
|
});
|
|
121
121
|
const session = await this.stripeClient.billingPortal.sessions.create({
|
|
122
122
|
...billingPortalDto.stripeFields,
|
|
123
|
-
customer: existingSession.customerId
|
|
123
|
+
customer: billingPortalDto.customerId || existingSession.customerId
|
|
124
124
|
});
|
|
125
125
|
|
|
126
126
|
return await this.baseBillingPortalService.updateBillingPortalSession(
|
|
127
127
|
{
|
|
128
128
|
...billingPortalDto,
|
|
129
|
-
id:
|
|
129
|
+
id: existingSession.id, // Use the original database ID, not the new Stripe session ID
|
|
130
130
|
uri: session.url,
|
|
131
131
|
expiresAt: new Date(
|
|
132
132
|
Date.now() + this.billingPortalSessionExpiryDurationMs
|
|
@@ -97,6 +97,7 @@ export class StripeCheckoutSessionService<
|
|
|
97
97
|
): Promise<Dto['CheckoutSessionMapper']> {
|
|
98
98
|
const session = await this.stripeClient.checkout.sessions.create({
|
|
99
99
|
...checkoutSessionDto.stripeFields,
|
|
100
|
+
mode: 'subscription',
|
|
100
101
|
payment_method_types: checkoutSessionDto.paymentMethods,
|
|
101
102
|
currency: checkoutSessionDto.currency as string,
|
|
102
103
|
success_url: checkoutSessionDto.successRedirectUri,
|
|
@@ -109,10 +109,11 @@ export class StripePaymentLinkService<
|
|
|
109
109
|
...paymentLinkDto,
|
|
110
110
|
id: session.id,
|
|
111
111
|
amount:
|
|
112
|
+
paymentLinkDto.amount ??
|
|
112
113
|
session.line_items?.data.reduce<number>(
|
|
113
114
|
(total, item) => total + item.amount_total,
|
|
114
115
|
0
|
|
115
|
-
)
|
|
116
|
+
)
|
|
116
117
|
},
|
|
117
118
|
this.em,
|
|
118
119
|
session,
|
|
@@ -197,6 +198,7 @@ export class StripePaymentLinkService<
|
|
|
197
198
|
}
|
|
198
199
|
|
|
199
200
|
async listPaymentLinks(idsDto?: IdsDto): Promise<Dto['PaymentLinkMapper'][]> {
|
|
201
|
+
this.openTelemetryCollector.log('info', idsDto ?? 'idsDto is undefined');
|
|
200
202
|
const stripePaymentLinks = await this.stripeClient.paymentLinks.list({
|
|
201
203
|
active: true
|
|
202
204
|
});
|
|
@@ -204,19 +206,17 @@ export class StripePaymentLinkService<
|
|
|
204
206
|
const databasePaymentLinks =
|
|
205
207
|
await this.basePaymentLinkService.listPaymentLinks(idsDto);
|
|
206
208
|
|
|
207
|
-
return
|
|
208
|
-
|
|
209
|
+
return databasePaymentLinks
|
|
210
|
+
.map((paymentLink) => {
|
|
209
211
|
const stripePaymentLink = stripePaymentLinks.data.find(
|
|
210
212
|
(sp) => sp.id === paymentLink.id
|
|
211
213
|
);
|
|
212
214
|
if (!stripePaymentLink) {
|
|
213
|
-
|
|
214
|
-
`Stripe payment link not found for id: ${paymentLink.id}`
|
|
215
|
-
);
|
|
215
|
+
return null;
|
|
216
216
|
}
|
|
217
217
|
paymentLink.stripeFields = stripePaymentLink;
|
|
218
218
|
return paymentLink;
|
|
219
219
|
})
|
|
220
|
-
|
|
220
|
+
.filter((paymentLink) => paymentLink !== null);
|
|
221
221
|
}
|
|
222
222
|
}
|
|
@@ -91,6 +91,7 @@ export class StripePlanService<
|
|
|
91
91
|
): Promise<Dto['PlanMapper']> {
|
|
92
92
|
const stripePlan = await this.stripeClient.plans.create({
|
|
93
93
|
...planDto.stripeFields,
|
|
94
|
+
amount: planDto.price,
|
|
94
95
|
interval: planDto.cadence,
|
|
95
96
|
product: planDto.name,
|
|
96
97
|
currency: planDto.currency as string
|
|
@@ -110,17 +111,11 @@ export class StripePlanService<
|
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
async getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanMapper']> {
|
|
113
|
-
const
|
|
114
|
-
|
|
115
|
-
await em?.findOne<{ id: string; externalId: string }>(
|
|
116
|
-
this.options?.databaseTableName ?? 'plan',
|
|
117
|
-
{ externalId: idDto.id }
|
|
118
|
-
)
|
|
119
|
-
)?.id;
|
|
120
|
-
if (!id) {
|
|
114
|
+
const planEntity = await this.basePlanService.getPlan(idDto, em);
|
|
115
|
+
if (!planEntity.externalId) {
|
|
121
116
|
throw new Error('Plan not found');
|
|
122
117
|
}
|
|
123
|
-
const
|
|
118
|
+
const plan = await this.stripeClient.plans.retrieve(planEntity.externalId);
|
|
124
119
|
planEntity.stripeFields = plan;
|
|
125
120
|
return planEntity;
|
|
126
121
|
}
|
|
@@ -129,35 +124,58 @@ export class StripePlanService<
|
|
|
129
124
|
planDto: StripeUpdatePlanDto,
|
|
130
125
|
em?: EntityManager
|
|
131
126
|
): Promise<Dto['PlanMapper']> {
|
|
132
|
-
const
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
product: planDto.name,
|
|
138
|
-
currency: planDto.currency ?? existingPlan.currency
|
|
139
|
-
})
|
|
127
|
+
const planEntity = await this.basePlanService.getPlan(
|
|
128
|
+
{
|
|
129
|
+
id: planDto.id
|
|
130
|
+
},
|
|
131
|
+
em
|
|
140
132
|
);
|
|
141
133
|
|
|
142
|
-
const
|
|
143
|
-
|
|
144
|
-
{
|
|
145
|
-
...planDto,
|
|
146
|
-
externalId: plan.id,
|
|
147
|
-
billingProvider: 'stripe'
|
|
148
|
-
},
|
|
149
|
-
em ?? this.em,
|
|
150
|
-
plan
|
|
151
|
-
),
|
|
152
|
-
em
|
|
134
|
+
const existingPlan = await this.stripeClient.plans.retrieve(
|
|
135
|
+
planEntity.externalId
|
|
153
136
|
);
|
|
154
|
-
planEntity.stripeFields = plan;
|
|
155
137
|
|
|
156
|
-
|
|
138
|
+
const existingProduct = existingPlan.product;
|
|
139
|
+
if (!existingProduct) {
|
|
140
|
+
throw new Error('Plan product not found');
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
const productId =
|
|
144
|
+
typeof existingProduct === 'string'
|
|
145
|
+
? existingProduct
|
|
146
|
+
: existingProduct.id;
|
|
147
|
+
|
|
148
|
+
await this.stripeClient.plans.del(planEntity.externalId);
|
|
149
|
+
const updatedPlan = await this.stripeClient.plans.create({
|
|
150
|
+
...planDto.stripeFields,
|
|
151
|
+
interval: planDto.cadence ?? existingPlan.interval,
|
|
152
|
+
currency: planDto.currency ?? existingPlan.currency,
|
|
153
|
+
amount: planDto.price ?? existingPlan.amount ?? undefined,
|
|
154
|
+
product: productId
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
const updatedPlanEntity = await this.basePlanService.updatePlan(
|
|
158
|
+
{
|
|
159
|
+
...planDto,
|
|
160
|
+
externalId: updatedPlan.id,
|
|
161
|
+
name: planDto.name,
|
|
162
|
+
billingProvider: 'stripe'
|
|
163
|
+
},
|
|
164
|
+
em,
|
|
165
|
+
updatedPlan
|
|
166
|
+
);
|
|
167
|
+
|
|
168
|
+
updatedPlanEntity.stripeFields = updatedPlan;
|
|
169
|
+
|
|
170
|
+
return updatedPlanEntity;
|
|
157
171
|
}
|
|
158
172
|
|
|
159
|
-
async deletePlan(idDto:
|
|
160
|
-
await this.
|
|
173
|
+
async deletePlan(idDto: IdDto, em?: EntityManager): Promise<void> {
|
|
174
|
+
const plan = await this.basePlanService.getPlan(idDto, em);
|
|
175
|
+
if (!plan.externalId) {
|
|
176
|
+
throw new Error('Plan not found');
|
|
177
|
+
}
|
|
178
|
+
await this.stripeClient.plans.del(plan.externalId);
|
|
161
179
|
await this.basePlanService.deletePlan(idDto, em);
|
|
162
180
|
}
|
|
163
181
|
|
|
@@ -165,30 +183,27 @@ export class StripePlanService<
|
|
|
165
183
|
idsDto?: IdsDto,
|
|
166
184
|
em?: EntityManager
|
|
167
185
|
): Promise<Dto['PlanMapper'][]> {
|
|
168
|
-
const plans = await this.
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
await em?.findAll<{ id: string; externalId: string }>(
|
|
173
|
-
this.options?.databaseTableName ?? 'plan',
|
|
174
|
-
{ where: { externalId: { $in: plans.data.map((plan) => plan.id) } } }
|
|
175
|
-
)
|
|
176
|
-
)
|
|
177
|
-
?.filter((s) => idsDto?.ids?.includes(s.id))
|
|
178
|
-
?.map((s) => s.id);
|
|
179
|
-
|
|
180
|
-
if (!planIds) {
|
|
181
|
-
throw new Error('Plans not found');
|
|
186
|
+
const plans = await this.basePlanService.listPlans(idsDto, em);
|
|
187
|
+
|
|
188
|
+
if (!plans || plans.length === 0) {
|
|
189
|
+
return [];
|
|
182
190
|
}
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
}
|
|
191
|
-
)
|
|
191
|
+
|
|
192
|
+
const stripePlans = await Promise.all(
|
|
193
|
+
plans.map(async (plan) => {
|
|
194
|
+
try {
|
|
195
|
+
return await this.stripeClient.plans.retrieve(plan.externalId);
|
|
196
|
+
} catch {
|
|
197
|
+
return null;
|
|
198
|
+
}
|
|
199
|
+
})
|
|
192
200
|
);
|
|
201
|
+
|
|
202
|
+
return plans
|
|
203
|
+
.map((plan, index) => ({
|
|
204
|
+
...plan,
|
|
205
|
+
stripeFields: stripePlans[index]
|
|
206
|
+
}))
|
|
207
|
+
.filter((plan) => plan.stripeFields !== null);
|
|
193
208
|
}
|
|
194
209
|
}
|
|
@@ -117,8 +117,11 @@ export class StripeSubscriptionService<
|
|
|
117
117
|
): Promise<Dto['SubscriptionMapper']> {
|
|
118
118
|
const subscriptionEntity =
|
|
119
119
|
await this.baseSubscriptionService.getSubscription(idDto, em);
|
|
120
|
+
if (!subscriptionEntity.externalId) {
|
|
121
|
+
throw new Error('Subscription not found');
|
|
122
|
+
}
|
|
120
123
|
const stripeSubscription = await this.stripeClient.subscriptions.retrieve(
|
|
121
|
-
|
|
124
|
+
subscriptionEntity.externalId
|
|
122
125
|
);
|
|
123
126
|
subscriptionEntity.stripeFields = stripeSubscription;
|
|
124
127
|
return subscriptionEntity;
|
|
@@ -130,8 +133,11 @@ export class StripeSubscriptionService<
|
|
|
130
133
|
): Promise<Dto['SubscriptionMapper']> {
|
|
131
134
|
const subscriptionEntity =
|
|
132
135
|
await this.baseSubscriptionService.getUserSubscription(idDto, em);
|
|
136
|
+
if (!subscriptionEntity.externalId) {
|
|
137
|
+
throw new Error('Subscription not found');
|
|
138
|
+
}
|
|
133
139
|
const stripeSubscription = await this.stripeClient.subscriptions.retrieve(
|
|
134
|
-
|
|
140
|
+
subscriptionEntity.externalId
|
|
135
141
|
);
|
|
136
142
|
subscriptionEntity.stripeFields = stripeSubscription;
|
|
137
143
|
return subscriptionEntity;
|
|
@@ -141,104 +147,130 @@ export class StripeSubscriptionService<
|
|
|
141
147
|
idDto: IdDto,
|
|
142
148
|
em?: EntityManager
|
|
143
149
|
): Promise<Dto['SubscriptionMapper']> {
|
|
144
|
-
const
|
|
145
|
-
await em
|
|
146
|
-
|
|
147
|
-
{ externalId: idDto.id }
|
|
148
|
-
)
|
|
149
|
-
)?.id;
|
|
150
|
-
if (!id) {
|
|
150
|
+
const subscriptionEntity =
|
|
151
|
+
await this.baseSubscriptionService.getOrganizationSubscription(idDto, em);
|
|
152
|
+
if (!subscriptionEntity.externalId) {
|
|
151
153
|
throw new Error('Subscription not found');
|
|
152
154
|
}
|
|
153
|
-
const subscriptionEntity =
|
|
154
|
-
await this.baseSubscriptionService.getOrganizationSubscription(
|
|
155
|
-
{ id },
|
|
156
|
-
em
|
|
157
|
-
);
|
|
158
155
|
const stripeSubscription = await this.stripeClient.subscriptions.retrieve(
|
|
159
|
-
|
|
156
|
+
subscriptionEntity.externalId
|
|
160
157
|
);
|
|
161
158
|
subscriptionEntity.stripeFields = stripeSubscription;
|
|
162
159
|
return subscriptionEntity;
|
|
163
160
|
}
|
|
164
161
|
|
|
165
162
|
async updateSubscription(
|
|
166
|
-
subscriptionDto: StripeUpdateSubscriptionDto<PartyType
|
|
163
|
+
subscriptionDto: StripeUpdateSubscriptionDto<PartyType> & IdDto,
|
|
167
164
|
em?: EntityManager
|
|
168
165
|
): Promise<Dto['SubscriptionMapper']> {
|
|
169
|
-
const
|
|
170
|
-
|
|
166
|
+
const subscriptionEntity =
|
|
167
|
+
await this.baseSubscriptionService.getSubscription(
|
|
168
|
+
{
|
|
169
|
+
id: subscriptionDto.id
|
|
170
|
+
},
|
|
171
|
+
em
|
|
172
|
+
);
|
|
173
|
+
if (!subscriptionEntity.externalId) {
|
|
174
|
+
throw new Error('Subscription not found');
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
const existingStripeSubscription =
|
|
178
|
+
await this.stripeClient.subscriptions.retrieve(
|
|
179
|
+
subscriptionEntity.externalId
|
|
180
|
+
);
|
|
181
|
+
|
|
182
|
+
const updatedSubscription = await this.stripeClient.subscriptions.update(
|
|
183
|
+
subscriptionEntity.externalId,
|
|
171
184
|
{
|
|
172
185
|
...subscriptionDto.stripeFields,
|
|
173
|
-
items:
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
]
|
|
186
|
+
items: existingStripeSubscription.items.data.map((item) => ({
|
|
187
|
+
id: item.id,
|
|
188
|
+
plan: subscriptionDto.productId || item.plan?.id
|
|
189
|
+
}))
|
|
178
190
|
}
|
|
179
191
|
);
|
|
180
192
|
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
193
|
+
const updatedSubscriptionEntity =
|
|
194
|
+
await this.baseSubscriptionService.updateSubscription(
|
|
195
|
+
{
|
|
196
|
+
...subscriptionDto,
|
|
197
|
+
externalId: updatedSubscription.id,
|
|
198
|
+
billingProvider: 'stripe'
|
|
199
|
+
},
|
|
200
|
+
em ?? this.em,
|
|
201
|
+
updatedSubscription
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
updatedSubscriptionEntity.stripeFields = updatedSubscription;
|
|
205
|
+
return updatedSubscriptionEntity;
|
|
191
206
|
}
|
|
192
207
|
|
|
193
|
-
async deleteSubscription(
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
208
|
+
async deleteSubscription(idDto: IdDto, em?: EntityManager): Promise<void> {
|
|
209
|
+
const subscription = await this.baseSubscriptionService.getSubscription(
|
|
210
|
+
idDto,
|
|
211
|
+
em
|
|
212
|
+
);
|
|
213
|
+
if (!subscription.externalId) {
|
|
214
|
+
throw new Error('Subscription not found');
|
|
215
|
+
}
|
|
216
|
+
await this.stripeClient.subscriptions.cancel(subscription.externalId);
|
|
198
217
|
await this.baseSubscriptionService.deleteSubscription(idDto, em);
|
|
199
218
|
}
|
|
200
219
|
|
|
201
220
|
async listSubscriptions(
|
|
202
|
-
idsDto
|
|
221
|
+
idsDto?: IdsDto,
|
|
203
222
|
em?: EntityManager
|
|
204
223
|
): Promise<Dto['SubscriptionMapper'][]> {
|
|
205
|
-
const subscriptions = (
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
).data.filter((s) => idsDto.ids?.includes(s.id));
|
|
210
|
-
|
|
211
|
-
const ids = (
|
|
212
|
-
await em?.findAll<{ id: string; externalId: string }>(
|
|
213
|
-
this.options?.databaseTableName ?? 'subscription',
|
|
214
|
-
{ where: { externalId: { $in: subscriptions.map((s) => s.id) } } }
|
|
215
|
-
)
|
|
216
|
-
)?.map((s) => s.id);
|
|
224
|
+
const subscriptions = await this.baseSubscriptionService.listSubscriptions(
|
|
225
|
+
idsDto,
|
|
226
|
+
em
|
|
227
|
+
);
|
|
217
228
|
|
|
218
|
-
if (!
|
|
219
|
-
|
|
229
|
+
if (!subscriptions || subscriptions.length === 0) {
|
|
230
|
+
return [];
|
|
220
231
|
}
|
|
221
232
|
|
|
222
|
-
|
|
223
|
-
(
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
)
|
|
228
|
-
|
|
229
|
-
return
|
|
233
|
+
const stripeSubscriptions = await Promise.all(
|
|
234
|
+
subscriptions.map(async (subscription) => {
|
|
235
|
+
try {
|
|
236
|
+
return await this.stripeClient.subscriptions.retrieve(
|
|
237
|
+
subscription.externalId
|
|
238
|
+
);
|
|
239
|
+
} catch {
|
|
240
|
+
return null;
|
|
230
241
|
}
|
|
231
|
-
)
|
|
242
|
+
})
|
|
232
243
|
);
|
|
244
|
+
|
|
245
|
+
return subscriptions
|
|
246
|
+
.map((subscription, index) => ({
|
|
247
|
+
...subscription,
|
|
248
|
+
stripeFields: stripeSubscriptions[index]
|
|
249
|
+
}))
|
|
250
|
+
.filter((subscription) => subscription.stripeFields !== null);
|
|
233
251
|
}
|
|
234
252
|
|
|
235
253
|
async cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void> {
|
|
236
|
-
await this.
|
|
254
|
+
const subscription = await this.baseSubscriptionService.getSubscription(
|
|
255
|
+
idDto,
|
|
256
|
+
em
|
|
257
|
+
);
|
|
258
|
+
if (!subscription.externalId) {
|
|
259
|
+
throw new Error('Subscription not found');
|
|
260
|
+
}
|
|
261
|
+
await this.stripeClient.subscriptions.cancel(subscription.externalId);
|
|
237
262
|
await this.baseSubscriptionService.cancelSubscription(idDto, em);
|
|
238
263
|
}
|
|
239
264
|
|
|
240
265
|
async resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void> {
|
|
241
|
-
await this.
|
|
266
|
+
const subscription = await this.baseSubscriptionService.getSubscription(
|
|
267
|
+
idDto,
|
|
268
|
+
em
|
|
269
|
+
);
|
|
270
|
+
if (!subscription.externalId) {
|
|
271
|
+
throw new Error('Subscription not found');
|
|
272
|
+
}
|
|
273
|
+
await this.stripeClient.subscriptions.resume(subscription.externalId);
|
|
242
274
|
await this.baseSubscriptionService.resumeSubscription(idDto, em);
|
|
243
275
|
}
|
|
244
276
|
}
|
package/lib/services/index.d.mts
CHANGED
|
@@ -9,7 +9,7 @@ import { EntityManager } from '@mikro-orm/core';
|
|
|
9
9
|
import stripe__default from 'stripe';
|
|
10
10
|
import { StripeBillingPortalEntities, StripeBillingPortalDtos, StripeBillingPortalMappers, StripeCreateBillingPortalDto, StripeUpdateBillingPortalDto, StripeCheckoutSessionEntities, StripeCheckoutSessionDtos, StripeCheckoutSessionMappers, StripeCreateCheckoutSessionDto, StripePaymentLinkEntities, StripePaymentLinkDtos, StripeCreatePaymentLinkDto, StripeUpdatePaymentLinkDto, StripePaymentLinkDto, StripePaymentLinkMappers, StripePlanEntities, StripePlanDtos, StripeCreatePlanDto, StripeUpdatePlanDto, StripePlanDto, StripePlanMappers, StripeSubscriptionEntities, StripeSubscriptionDtos, StripeCreateSubscriptionDto, StripeUpdateSubscriptionDto, StripeSubscriptionDto, StripeSubscriptionMappers } from '../domain/types/index.mjs';
|
|
11
11
|
import { PaymentMethodEnum, CurrencyEnum, PlanCadenceEnum, BillingProviderEnum } from '../domain/enum/index.mjs';
|
|
12
|
-
|
|
12
|
+
export * from '@forklaunch/interfaces-billing/types';
|
|
13
13
|
|
|
14
14
|
declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends StripeBillingPortalEntities, Dto extends StripeBillingPortalDtos = StripeBillingPortalDtos> implements BillingPortalService<{
|
|
15
15
|
CreateBillingPortalDto: Dto['CreateBillingPortalMapper'];
|
|
@@ -121,9 +121,7 @@ declare class StripePlanService<SchemaValidator extends AnySchemaValidator, Enti
|
|
|
121
121
|
createPlan(planDto: StripeCreatePlanDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
|
|
122
122
|
getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
|
|
123
123
|
updatePlan(planDto: StripeUpdatePlanDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
|
|
124
|
-
deletePlan(idDto:
|
|
125
|
-
id: string;
|
|
126
|
-
}, em?: EntityManager): Promise<void>;
|
|
124
|
+
deletePlan(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
127
125
|
listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['PlanMapper'][]>;
|
|
128
126
|
}
|
|
129
127
|
|
|
@@ -152,11 +150,9 @@ declare class StripeSubscriptionService<SchemaValidator extends AnySchemaValidat
|
|
|
152
150
|
getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
153
151
|
getUserSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
154
152
|
getOrganizationSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
155
|
-
updateSubscription(subscriptionDto: StripeUpdateSubscriptionDto<PartyType
|
|
156
|
-
deleteSubscription(idDto:
|
|
157
|
-
|
|
158
|
-
}, em?: EntityManager): Promise<void>;
|
|
159
|
-
listSubscriptions(idsDto: IdsDto, em?: EntityManager): Promise<Dto['SubscriptionMapper'][]>;
|
|
153
|
+
updateSubscription(subscriptionDto: StripeUpdateSubscriptionDto<PartyType> & IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
154
|
+
deleteSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
155
|
+
listSubscriptions(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['SubscriptionMapper'][]>;
|
|
160
156
|
cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
161
157
|
resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
162
158
|
}
|
package/lib/services/index.d.ts
CHANGED
|
@@ -9,7 +9,7 @@ import { EntityManager } from '@mikro-orm/core';
|
|
|
9
9
|
import stripe__default from 'stripe';
|
|
10
10
|
import { StripeBillingPortalEntities, StripeBillingPortalDtos, StripeBillingPortalMappers, StripeCreateBillingPortalDto, StripeUpdateBillingPortalDto, StripeCheckoutSessionEntities, StripeCheckoutSessionDtos, StripeCheckoutSessionMappers, StripeCreateCheckoutSessionDto, StripePaymentLinkEntities, StripePaymentLinkDtos, StripeCreatePaymentLinkDto, StripeUpdatePaymentLinkDto, StripePaymentLinkDto, StripePaymentLinkMappers, StripePlanEntities, StripePlanDtos, StripeCreatePlanDto, StripeUpdatePlanDto, StripePlanDto, StripePlanMappers, StripeSubscriptionEntities, StripeSubscriptionDtos, StripeCreateSubscriptionDto, StripeUpdateSubscriptionDto, StripeSubscriptionDto, StripeSubscriptionMappers } from '../domain/types/index.js';
|
|
11
11
|
import { PaymentMethodEnum, CurrencyEnum, PlanCadenceEnum, BillingProviderEnum } from '../domain/enum/index.js';
|
|
12
|
-
|
|
12
|
+
export * from '@forklaunch/interfaces-billing/types';
|
|
13
13
|
|
|
14
14
|
declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends StripeBillingPortalEntities, Dto extends StripeBillingPortalDtos = StripeBillingPortalDtos> implements BillingPortalService<{
|
|
15
15
|
CreateBillingPortalDto: Dto['CreateBillingPortalMapper'];
|
|
@@ -121,9 +121,7 @@ declare class StripePlanService<SchemaValidator extends AnySchemaValidator, Enti
|
|
|
121
121
|
createPlan(planDto: StripeCreatePlanDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
|
|
122
122
|
getPlan(idDto: IdDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
|
|
123
123
|
updatePlan(planDto: StripeUpdatePlanDto, em?: EntityManager): Promise<Dto['PlanMapper']>;
|
|
124
|
-
deletePlan(idDto:
|
|
125
|
-
id: string;
|
|
126
|
-
}, em?: EntityManager): Promise<void>;
|
|
124
|
+
deletePlan(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
127
125
|
listPlans(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['PlanMapper'][]>;
|
|
128
126
|
}
|
|
129
127
|
|
|
@@ -152,11 +150,9 @@ declare class StripeSubscriptionService<SchemaValidator extends AnySchemaValidat
|
|
|
152
150
|
getSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
153
151
|
getUserSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
154
152
|
getOrganizationSubscription(idDto: IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
155
|
-
updateSubscription(subscriptionDto: StripeUpdateSubscriptionDto<PartyType
|
|
156
|
-
deleteSubscription(idDto:
|
|
157
|
-
|
|
158
|
-
}, em?: EntityManager): Promise<void>;
|
|
159
|
-
listSubscriptions(idsDto: IdsDto, em?: EntityManager): Promise<Dto['SubscriptionMapper'][]>;
|
|
153
|
+
updateSubscription(subscriptionDto: StripeUpdateSubscriptionDto<PartyType> & IdDto, em?: EntityManager): Promise<Dto['SubscriptionMapper']>;
|
|
154
|
+
deleteSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
155
|
+
listSubscriptions(idsDto?: IdsDto, em?: EntityManager): Promise<Dto['SubscriptionMapper'][]>;
|
|
160
156
|
cancelSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
161
157
|
resumeSubscription(idDto: IdDto, em?: EntityManager): Promise<void>;
|
|
162
158
|
}
|