@forklaunch/implementation-billing-stripe 0.3.3 → 0.3.5

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.
@@ -1,7 +1,15 @@
1
1
  // services/billingPortal.service.ts
2
- import { BaseBillingPortalService } from "@forklaunch/implementation-billing-base/services";
2
+ import { BaseBillingPortalService } from '@forklaunch/implementation-billing-base/services';
3
3
  var StripeBillingPortalService = class {
4
- constructor(stripeClient, em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
4
+ constructor(
5
+ stripeClient,
6
+ em,
7
+ cache,
8
+ openTelemetryCollector,
9
+ schemaValidator,
10
+ mappers,
11
+ options
12
+ ) {
5
13
  this.options = options;
6
14
  this.stripeClient = stripeClient;
7
15
  this.em = em;
@@ -52,9 +60,10 @@ var StripeBillingPortalService = class {
52
60
  return this.baseBillingPortalService.expireBillingPortalSession(idDto);
53
61
  }
54
62
  async updateBillingPortalSession(billingPortalDto, ...args) {
55
- const existingSession = await this.baseBillingPortalService.getBillingPortalSession({
56
- id: billingPortalDto.id
57
- });
63
+ const existingSession =
64
+ await this.baseBillingPortalService.getBillingPortalSession({
65
+ id: billingPortalDto.id
66
+ });
58
67
  const session = await this.stripeClient.billingPortal.sessions.create({
59
68
  ...billingPortalDto.stripeFields,
60
69
  customer: existingSession.customerId
@@ -76,9 +85,17 @@ var StripeBillingPortalService = class {
76
85
  };
77
86
 
78
87
  // services/checkoutSession.service.ts
79
- import { BaseCheckoutSessionService } from "@forklaunch/implementation-billing-base/services";
88
+ import { BaseCheckoutSessionService } from '@forklaunch/implementation-billing-base/services';
80
89
  var StripeCheckoutSessionService = class {
81
- constructor(stripeClient, em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
90
+ constructor(
91
+ stripeClient,
92
+ em,
93
+ cache,
94
+ openTelemetryCollector,
95
+ schemaValidator,
96
+ mappers,
97
+ options
98
+ ) {
82
99
  this.options = options;
83
100
  this.stripeClient = stripeClient;
84
101
  this.em = em;
@@ -127,7 +144,8 @@ var StripeCheckoutSessionService = class {
127
144
  const session = await this.stripeClient.checkout.sessions.retrieve(
128
145
  idDto.id
129
146
  );
130
- const databaseCheckoutSession = await this.baseCheckoutSessionService.getCheckoutSession(idDto);
147
+ const databaseCheckoutSession =
148
+ await this.baseCheckoutSessionService.getCheckoutSession(idDto);
131
149
  databaseCheckoutSession.stripeFields = session;
132
150
  return databaseCheckoutSession;
133
151
  }
@@ -138,7 +156,7 @@ var StripeCheckoutSessionService = class {
138
156
  async handleCheckoutSuccess({ id }) {
139
157
  await this.stripeClient.checkout.sessions.update(id, {
140
158
  metadata: {
141
- status: "SUCCESS"
159
+ status: 'SUCCESS'
142
160
  }
143
161
  });
144
162
  await this.baseCheckoutSessionService.handleCheckoutSuccess({ id });
@@ -146,7 +164,7 @@ var StripeCheckoutSessionService = class {
146
164
  async handleCheckoutFailure({ id }) {
147
165
  await this.stripeClient.checkout.sessions.update(id, {
148
166
  metadata: {
149
- status: "FAILED"
167
+ status: 'FAILED'
150
168
  }
151
169
  });
152
170
  await this.baseCheckoutSessionService.handleCheckoutFailure({ id });
@@ -154,9 +172,17 @@ var StripeCheckoutSessionService = class {
154
172
  };
155
173
 
156
174
  // services/paymentLink.service.ts
157
- import { BasePaymentLinkService } from "@forklaunch/implementation-billing-base/services";
175
+ import { BasePaymentLinkService } from '@forklaunch/implementation-billing-base/services';
158
176
  var StripePaymentLinkService = class {
159
- constructor(stripeClient, em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
177
+ constructor(
178
+ stripeClient,
179
+ em,
180
+ cache,
181
+ openTelemetryCollector,
182
+ schemaValidator,
183
+ mappers,
184
+ options
185
+ ) {
160
186
  this.options = options;
161
187
  this.stripeClient = stripeClient;
162
188
  this.em = em;
@@ -190,10 +216,11 @@ var StripePaymentLinkService = class {
190
216
  {
191
217
  ...paymentLinkDto,
192
218
  id: session.id,
193
- amount: session.line_items?.data.reduce(
194
- (total, item) => total + item.amount_total,
195
- 0
196
- ) ?? 0
219
+ amount:
220
+ session.line_items?.data.reduce(
221
+ (total, item) => total + item.amount_total,
222
+ 0
223
+ ) ?? 0
197
224
  },
198
225
  this.em,
199
226
  session,
@@ -215,10 +242,11 @@ var StripePaymentLinkService = class {
215
242
  {
216
243
  ...paymentLinkDto,
217
244
  id: session.id,
218
- amount: session.line_items?.data.reduce(
219
- (total, item) => total + item.amount_total,
220
- 0
221
- ) ?? 0
245
+ amount:
246
+ session.line_items?.data.reduce(
247
+ (total, item) => total + item.amount_total,
248
+ 0
249
+ ) ?? 0
222
250
  },
223
251
  this.em,
224
252
  session
@@ -230,14 +258,15 @@ var StripePaymentLinkService = class {
230
258
  }
231
259
  async getPaymentLink({ id }) {
232
260
  const stripePaymentLink = await this.stripeClient.paymentLinks.retrieve(id);
233
- const databasePaymentLink = await this.basePaymentLinkService.getPaymentLink({ id });
261
+ const databasePaymentLink =
262
+ await this.basePaymentLinkService.getPaymentLink({ id });
234
263
  databasePaymentLink.stripeFields = stripePaymentLink;
235
264
  return databasePaymentLink;
236
265
  }
237
266
  async expirePaymentLink({ id }) {
238
267
  await this.stripeClient.paymentLinks.update(id, {
239
268
  metadata: {
240
- status: "EXPIRED"
269
+ status: 'EXPIRED'
241
270
  }
242
271
  });
243
272
  await this.basePaymentLinkService.expirePaymentLink({ id });
@@ -245,7 +274,7 @@ var StripePaymentLinkService = class {
245
274
  async handlePaymentSuccess({ id }) {
246
275
  await this.stripeClient.paymentLinks.update(id, {
247
276
  metadata: {
248
- status: "COMPLETED"
277
+ status: 'COMPLETED'
249
278
  }
250
279
  });
251
280
  await this.basePaymentLinkService.handlePaymentSuccess({ id });
@@ -253,7 +282,7 @@ var StripePaymentLinkService = class {
253
282
  async handlePaymentFailure({ id }) {
254
283
  await this.stripeClient.paymentLinks.update(id, {
255
284
  metadata: {
256
- status: "FAILED"
285
+ status: 'FAILED'
257
286
  }
258
287
  });
259
288
  await this.basePaymentLinkService.handlePaymentFailure({ id });
@@ -262,7 +291,8 @@ var StripePaymentLinkService = class {
262
291
  const stripePaymentLinks = await this.stripeClient.paymentLinks.list({
263
292
  active: true
264
293
  });
265
- const databasePaymentLinks = await this.basePaymentLinkService.listPaymentLinks(idsDto);
294
+ const databasePaymentLinks =
295
+ await this.basePaymentLinkService.listPaymentLinks(idsDto);
266
296
  return await Promise.all(
267
297
  databasePaymentLinks.map(async (paymentLink) => {
268
298
  const stripePaymentLink = stripePaymentLinks.data.find(
@@ -281,9 +311,16 @@ var StripePaymentLinkService = class {
281
311
  };
282
312
 
283
313
  // services/plan.service.ts
284
- import { BasePlanService } from "@forklaunch/implementation-billing-base/services";
314
+ import { BasePlanService } from '@forklaunch/implementation-billing-base/services';
285
315
  var StripePlanService = class {
286
- constructor(stripeClient, em, openTelemetryCollector, schemaValidator, mappers, options) {
316
+ constructor(
317
+ stripeClient,
318
+ em,
319
+ openTelemetryCollector,
320
+ schemaValidator,
321
+ mappers,
322
+ options
323
+ ) {
287
324
  this.options = options;
288
325
  this.stripeClient = stripeClient;
289
326
  this.em = em;
@@ -315,7 +352,7 @@ var StripePlanService = class {
315
352
  {
316
353
  ...planDto,
317
354
  externalId: stripePlan.id,
318
- billingProvider: "stripe"
355
+ billingProvider: 'stripe'
319
356
  },
320
357
  em ?? this.em,
321
358
  stripePlan
@@ -324,12 +361,13 @@ var StripePlanService = class {
324
361
  }
325
362
  async getPlan(idDto, em) {
326
363
  const plan = await this.stripeClient.plans.retrieve(idDto.id);
327
- const id = (await em?.findOne(
328
- this.options?.databaseTableName ?? "plan",
329
- { externalId: idDto.id }
330
- ))?.id;
364
+ const id = (
365
+ await em?.findOne(this.options?.databaseTableName ?? 'plan', {
366
+ externalId: idDto.id
367
+ })
368
+ )?.id;
331
369
  if (!id) {
332
- throw new Error("Plan not found");
370
+ throw new Error('Plan not found');
333
371
  }
334
372
  const planEntity = await this.basePlanService.getPlan({ id }, em);
335
373
  planEntity.stripeFields = plan;
@@ -337,8 +375,8 @@ var StripePlanService = class {
337
375
  }
338
376
  async updatePlan(planDto, em) {
339
377
  const existingPlan = await this.stripeClient.plans.retrieve(planDto.id);
340
- const plan = await this.stripeClient.plans.del(planDto.id).then(
341
- () => this.stripeClient.plans.create({
378
+ const plan = await this.stripeClient.plans.del(planDto.id).then(() =>
379
+ this.stripeClient.plans.create({
342
380
  ...planDto.stripeFields,
343
381
  interval: planDto.cadence ?? existingPlan.interval,
344
382
  product: planDto.name,
@@ -350,7 +388,7 @@ var StripePlanService = class {
350
388
  {
351
389
  ...planDto,
352
390
  externalId: plan.id,
353
- billingProvider: "stripe"
391
+ billingProvider: 'stripe'
354
392
  },
355
393
  em ?? this.em,
356
394
  plan
@@ -368,12 +406,15 @@ var StripePlanService = class {
368
406
  const plans = await this.stripeClient.plans.list({
369
407
  active: true
370
408
  });
371
- const planIds = (await em?.findAll(
372
- this.options?.databaseTableName ?? "plan",
373
- { where: { externalId: { $in: plans.data.map((plan) => plan.id) } } }
374
- ))?.filter((s) => idsDto?.ids?.includes(s.id))?.map((s) => s.id);
409
+ const planIds = (
410
+ await em?.findAll(this.options?.databaseTableName ?? 'plan', {
411
+ where: { externalId: { $in: plans.data.map((plan) => plan.id) } }
412
+ })
413
+ )
414
+ ?.filter((s) => idsDto?.ids?.includes(s.id))
415
+ ?.map((s) => s.id);
375
416
  if (!planIds) {
376
- throw new Error("Plans not found");
417
+ throw new Error('Plans not found');
377
418
  }
378
419
  return await Promise.all(
379
420
  (await this.basePlanService.listPlans({ ids: planIds }, em)).map(
@@ -389,9 +430,16 @@ var StripePlanService = class {
389
430
  };
390
431
 
391
432
  // services/subscription.service.ts
392
- import { BaseSubscriptionService } from "@forklaunch/implementation-billing-base/services";
433
+ import { BaseSubscriptionService } from '@forklaunch/implementation-billing-base/services';
393
434
  var StripeSubscriptionService = class {
394
- constructor(stripeClient, em, openTelemetryCollector, schemaValidator, mappers, options) {
435
+ constructor(
436
+ stripeClient,
437
+ em,
438
+ openTelemetryCollector,
439
+ schemaValidator,
440
+ mappers,
441
+ options
442
+ ) {
395
443
  this.options = options;
396
444
  this.stripeClient = stripeClient;
397
445
  this.em = em;
@@ -426,14 +474,15 @@ var StripeSubscriptionService = class {
426
474
  {
427
475
  ...subscriptionDto,
428
476
  externalId: subscription.id,
429
- billingProvider: "stripe"
477
+ billingProvider: 'stripe'
430
478
  },
431
479
  em ?? this.em,
432
480
  subscription
433
481
  );
434
482
  }
435
483
  async getSubscription(idDto, em) {
436
- const subscriptionEntity = await this.baseSubscriptionService.getSubscription(idDto, em);
484
+ const subscriptionEntity =
485
+ await this.baseSubscriptionService.getSubscription(idDto, em);
437
486
  const stripeSubscription = await this.stripeClient.subscriptions.retrieve(
438
487
  idDto.id
439
488
  );
@@ -441,7 +490,8 @@ var StripeSubscriptionService = class {
441
490
  return subscriptionEntity;
442
491
  }
443
492
  async getUserSubscription(idDto, em) {
444
- const subscriptionEntity = await this.baseSubscriptionService.getUserSubscription(idDto, em);
493
+ const subscriptionEntity =
494
+ await this.baseSubscriptionService.getUserSubscription(idDto, em);
445
495
  const stripeSubscription = await this.stripeClient.subscriptions.retrieve(
446
496
  idDto.id
447
497
  );
@@ -449,17 +499,19 @@ var StripeSubscriptionService = class {
449
499
  return subscriptionEntity;
450
500
  }
451
501
  async getOrganizationSubscription(idDto, em) {
452
- const id = (await em?.findOne(
453
- this.options?.databaseTableName ?? "subscription",
454
- { externalId: idDto.id }
455
- ))?.id;
502
+ const id = (
503
+ await em?.findOne(this.options?.databaseTableName ?? 'subscription', {
504
+ externalId: idDto.id
505
+ })
506
+ )?.id;
456
507
  if (!id) {
457
- throw new Error("Subscription not found");
508
+ throw new Error('Subscription not found');
458
509
  }
459
- const subscriptionEntity = await this.baseSubscriptionService.getOrganizationSubscription(
460
- { id },
461
- em
462
- );
510
+ const subscriptionEntity =
511
+ await this.baseSubscriptionService.getOrganizationSubscription(
512
+ { id },
513
+ em
514
+ );
463
515
  const stripeSubscription = await this.stripeClient.subscriptions.retrieve(
464
516
  idDto.id
465
517
  );
@@ -482,7 +534,7 @@ var StripeSubscriptionService = class {
482
534
  {
483
535
  ...subscriptionDto,
484
536
  externalId: subscription.id,
485
- billingProvider: "stripe",
537
+ billingProvider: 'stripe',
486
538
  providerFields: subscription
487
539
  },
488
540
  em ?? this.em,
@@ -494,15 +546,18 @@ var StripeSubscriptionService = class {
494
546
  await this.baseSubscriptionService.deleteSubscription(idDto, em);
495
547
  }
496
548
  async listSubscriptions(idsDto, em) {
497
- const subscriptions = (await this.stripeClient.subscriptions.list({
498
- status: "active"
499
- })).data.filter((s) => idsDto.ids?.includes(s.id));
500
- const ids = (await em?.findAll(
501
- this.options?.databaseTableName ?? "subscription",
502
- { where: { externalId: { $in: subscriptions.map((s) => s.id) } } }
503
- ))?.map((s) => s.id);
549
+ const subscriptions = (
550
+ await this.stripeClient.subscriptions.list({
551
+ status: 'active'
552
+ })
553
+ ).data.filter((s) => idsDto.ids?.includes(s.id));
554
+ const ids = (
555
+ await em?.findAll(this.options?.databaseTableName ?? 'subscription', {
556
+ where: { externalId: { $in: subscriptions.map((s) => s.id) } }
557
+ })
558
+ )?.map((s) => s.id);
504
559
  if (!ids) {
505
- throw new Error("Subscriptions not found");
560
+ throw new Error('Subscriptions not found');
506
561
  }
507
562
  return await Promise.all(
508
563
  (await this.baseSubscriptionService.listSubscriptions({ ids }, em)).map(
@@ -528,7 +583,7 @@ var StripeSubscriptionService = class {
528
583
 
529
584
  // domain/enum/billingProvider.enum.ts
530
585
  var BillingProviderEnum = {
531
- STRIPE: "stripe"
586
+ STRIPE: 'stripe'
532
587
  };
533
588
 
534
589
  // services/webhook.service.ts
@@ -542,7 +597,17 @@ var StripeWebhookService = class {
542
597
  paymentLinkService;
543
598
  planService;
544
599
  subscriptionService;
545
- constructor(stripeClient, em, schemaValidator, openTelemetryCollector, billingPortalService, checkoutSessionService, paymentLinkService, planService, subscriptionService) {
600
+ constructor(
601
+ stripeClient,
602
+ em,
603
+ schemaValidator,
604
+ openTelemetryCollector,
605
+ billingPortalService,
606
+ checkoutSessionService,
607
+ paymentLinkService,
608
+ planService,
609
+ subscriptionService
610
+ ) {
546
611
  this.stripeClient = stripeClient;
547
612
  this.em = em;
548
613
  this.schemaValidator = schemaValidator;
@@ -555,11 +620,11 @@ var StripeWebhookService = class {
555
620
  }
556
621
  async handleWebhookEvent(event) {
557
622
  if (this.openTelemetryCollector) {
558
- this.openTelemetryCollector.info("Handling webhook event", event);
623
+ this.openTelemetryCollector.info('Handling webhook event', event);
559
624
  }
560
625
  const eventType = event.type;
561
626
  switch (eventType) {
562
- case "billing_portal.session.created": {
627
+ case 'billing_portal.session.created': {
563
628
  this.billingPortalService.baseBillingPortalService.createBillingPortalSession(
564
629
  {
565
630
  id: event.data.object.id,
@@ -570,130 +635,156 @@ var StripeWebhookService = class {
570
635
  );
571
636
  break;
572
637
  }
573
- case "checkout.session.expired": {
638
+ case 'checkout.session.expired': {
574
639
  this.checkoutSessionService.handleCheckoutFailure({
575
640
  id: event.data.object.id
576
641
  });
577
642
  break;
578
643
  }
579
- case "checkout.session.completed": {
644
+ case 'checkout.session.completed': {
580
645
  this.checkoutSessionService.handleCheckoutSuccess({
581
646
  id: event.data.object.id
582
647
  });
583
648
  break;
584
649
  }
585
- case "payment_link.created":
650
+ case 'payment_link.created':
586
651
  {
587
652
  this.paymentLinkService.basePaymentLinkService.createPaymentLink({
588
653
  id: event.data.object.id,
589
- amount: event.data.object.line_items?.data.reduce(
590
- (total, item) => total + item.amount_total,
591
- 0
592
- ) ?? 0,
654
+ amount:
655
+ event.data.object.line_items?.data.reduce(
656
+ (total, item) => total + item.amount_total,
657
+ 0
658
+ ) ?? 0,
593
659
  paymentMethods: event.data.object.payment_method_types,
594
- status: "CREATED",
660
+ status: 'CREATED',
595
661
  currency: event.data.object.currency
596
662
  });
597
663
  }
598
664
  break;
599
- case "payment_link.updated": {
665
+ case 'payment_link.updated': {
600
666
  this.paymentLinkService.basePaymentLinkService.updatePaymentLink({
601
667
  id: event.data.object.id,
602
- amount: event.data.object.line_items?.data.reduce(
603
- (total, item) => total + item.amount_total,
604
- 0
605
- ) ?? 0,
668
+ amount:
669
+ event.data.object.line_items?.data.reduce(
670
+ (total, item) => total + item.amount_total,
671
+ 0
672
+ ) ?? 0,
606
673
  paymentMethods: event.data.object.payment_method_types,
607
- status: "UPDATED",
674
+ status: 'UPDATED',
608
675
  currency: event.data.object.currency
609
676
  });
610
677
  break;
611
678
  }
612
- case "plan.created": {
613
- if (typeof event.data.object.product === "object" && event.data.object.product != null && event.data.object.amount != null) {
679
+ case 'plan.created': {
680
+ if (
681
+ typeof event.data.object.product === 'object' &&
682
+ event.data.object.product != null &&
683
+ event.data.object.amount != null
684
+ ) {
614
685
  this.planService.basePlanService.createPlan({
615
686
  id: event.data.object.id,
616
687
  billingProvider: BillingProviderEnum.STRIPE,
617
688
  cadence: event.data.object.interval,
618
689
  currency: event.data.object.currency,
619
690
  active: true,
620
- name: typeof event.data.object.product === "string" ? event.data.object.product : event.data.object.product?.id,
691
+ name:
692
+ typeof event.data.object.product === 'string'
693
+ ? event.data.object.product
694
+ : event.data.object.product?.id,
621
695
  price: event.data.object.amount,
622
696
  externalId: event.data.object.id
623
697
  });
624
698
  } else {
625
- throw new Error("Invalid plan");
699
+ throw new Error('Invalid plan');
626
700
  }
627
701
  break;
628
702
  }
629
- case "plan.updated": {
630
- if (typeof event.data.object.product === "object" && event.data.object.product != null && event.data.object.amount != null) {
703
+ case 'plan.updated': {
704
+ if (
705
+ typeof event.data.object.product === 'object' &&
706
+ event.data.object.product != null &&
707
+ event.data.object.amount != null
708
+ ) {
631
709
  this.planService.basePlanService.updatePlan({
632
710
  id: event.data.object.id,
633
711
  billingProvider: BillingProviderEnum.STRIPE,
634
712
  cadence: event.data.object.interval,
635
713
  currency: event.data.object.currency,
636
714
  active: true,
637
- name: typeof event.data.object.product === "string" ? event.data.object.product : event.data.object.product?.id,
715
+ name:
716
+ typeof event.data.object.product === 'string'
717
+ ? event.data.object.product
718
+ : event.data.object.product?.id,
638
719
  price: event.data.object.amount,
639
720
  externalId: event.data.object.id
640
721
  });
641
722
  } else {
642
- throw new Error("Invalid plan");
723
+ throw new Error('Invalid plan');
643
724
  }
644
725
  break;
645
726
  }
646
- case "plan.deleted": {
727
+ case 'plan.deleted': {
647
728
  this.planService.deletePlan({
648
729
  id: event.data.object.id
649
730
  });
650
731
  break;
651
732
  }
652
- case "customer.subscription.created": {
733
+ case 'customer.subscription.created': {
653
734
  this.subscriptionService.baseSubscriptionService.createSubscription({
654
735
  id: event.data.object.id,
655
- partyId: typeof event.data.object.customer === "string" ? event.data.object.customer : event.data.object.customer.id,
656
- partyType: "USER",
736
+ partyId:
737
+ typeof event.data.object.customer === 'string'
738
+ ? event.data.object.customer
739
+ : event.data.object.customer.id,
740
+ partyType: 'USER',
657
741
  description: event.data.object.description ?? void 0,
658
742
  active: true,
659
743
  productId: event.data.object.items.data[0].plan.id,
660
744
  externalId: event.data.object.id,
661
745
  billingProvider: BillingProviderEnum.STRIPE,
662
746
  startDate: new Date(event.data.object.created),
663
- endDate: event.data.object.cancel_at ? new Date(event.data.object.cancel_at) : /* @__PURE__ */ new Date(Infinity),
747
+ endDate: event.data.object.cancel_at
748
+ ? new Date(event.data.object.cancel_at)
749
+ : /* @__PURE__ */ new Date(Infinity),
664
750
  status: event.data.object.status
665
751
  });
666
752
  break;
667
753
  }
668
- case "customer.subscription.updated": {
754
+ case 'customer.subscription.updated': {
669
755
  this.subscriptionService.baseSubscriptionService.updateSubscription({
670
756
  id: event.data.object.id,
671
- partyId: typeof event.data.object.customer === "string" ? event.data.object.customer : event.data.object.customer.id,
672
- partyType: "USER",
757
+ partyId:
758
+ typeof event.data.object.customer === 'string'
759
+ ? event.data.object.customer
760
+ : event.data.object.customer.id,
761
+ partyType: 'USER',
673
762
  description: event.data.object.description ?? void 0,
674
763
  active: true,
675
764
  externalId: event.data.object.id,
676
765
  billingProvider: BillingProviderEnum.STRIPE,
677
766
  startDate: new Date(event.data.object.created),
678
- endDate: event.data.object.cancel_at ? new Date(event.data.object.cancel_at) : /* @__PURE__ */ new Date(Infinity),
767
+ endDate: event.data.object.cancel_at
768
+ ? new Date(event.data.object.cancel_at)
769
+ : /* @__PURE__ */ new Date(Infinity),
679
770
  productId: event.data.object.items.data[0].plan.id,
680
771
  status: event.data.object.status
681
772
  });
682
773
  break;
683
774
  }
684
- case "customer.subscription.deleted": {
775
+ case 'customer.subscription.deleted': {
685
776
  this.subscriptionService.deleteSubscription({
686
777
  id: event.data.object.id
687
778
  });
688
779
  break;
689
780
  }
690
- case "customer.subscription.paused": {
781
+ case 'customer.subscription.paused': {
691
782
  this.subscriptionService.cancelSubscription({
692
783
  id: event.data.object.id
693
784
  });
694
785
  break;
695
786
  }
696
- case "customer.subscription.resumed": {
787
+ case 'customer.subscription.resumed': {
697
788
  this.subscriptionService.resumeSubscription({
698
789
  id: event.data.object.id
699
790
  });
@@ -701,7 +792,7 @@ var StripeWebhookService = class {
701
792
  }
702
793
  default:
703
794
  this.openTelemetryCollector.info(
704
- "Unprocessed stripe event type",
795
+ 'Unprocessed stripe event type',
705
796
  eventType
706
797
  );
707
798
  break;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@forklaunch/implementation-billing-stripe",
3
- "version": "0.3.3",
3
+ "version": "0.3.5",
4
4
  "description": "Stripe implementation for forklaunch billing",
5
5
  "homepage": "https://github.com/forklaunch/forklaunch-js#readme",
6
6
  "bugs": {
@@ -42,23 +42,23 @@
42
42
  "lib/**"
43
43
  ],
44
44
  "dependencies": {
45
- "@forklaunch/common": "^0.6.5",
46
- "@forklaunch/core": "^0.14.6",
47
- "@forklaunch/internal": "^0.3.5",
48
- "@forklaunch/validator": "^0.10.5",
49
- "@mikro-orm/core": "^6.5.1",
45
+ "@forklaunch/common": "^0.6.7",
46
+ "@forklaunch/core": "^0.14.9",
47
+ "@forklaunch/internal": "^0.3.7",
48
+ "@forklaunch/validator": "^0.10.7",
49
+ "@mikro-orm/core": "^6.5.2",
50
50
  "@sinclair/typebox": "^0.34.41",
51
51
  "ajv": "^8.17.1",
52
52
  "stripe": "^18.5.0",
53
- "zod": "^4.1.5",
54
- "@forklaunch/implementation-billing-base": "0.6.3",
55
- "@forklaunch/interfaces-billing": "0.6.2"
53
+ "zod": "^4.1.8",
54
+ "@forklaunch/implementation-billing-base": "0.6.5",
55
+ "@forklaunch/interfaces-billing": "0.6.4"
56
56
  },
57
57
  "devDependencies": {
58
- "@typescript/native-preview": "7.0.0-dev.20250830.1",
58
+ "@typescript/native-preview": "7.0.0-dev.20250911.1",
59
59
  "depcheck": "^1.4.7",
60
60
  "prettier": "^3.6.2",
61
- "typedoc": "^0.28.11"
61
+ "typedoc": "^0.28.12"
62
62
  },
63
63
  "scripts": {
64
64
  "build": "tsc --noEmit && tsup domain/schemas/index.ts services/index.ts domain/enum/index.ts domain/types/index.ts --format cjs,esm --no-splitting --dts --tsconfig tsconfig.json --out-dir lib --clean && if [ -f eject-package.bash ]; then pnpm package:eject; fi",