@forklaunch/implementation-billing-stripe 0.5.23 → 1.0.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.
Files changed (31) hide show
  1. package/lib/domain/enum/index.d.mts +6 -123
  2. package/lib/domain/enum/index.d.ts +6 -123
  3. package/lib/domain/enum/index.js +8 -0
  4. package/lib/domain/enum/index.mjs +7 -0
  5. package/lib/domain/schemas/index.d.mts +39 -39
  6. package/lib/domain/schemas/index.d.ts +39 -39
  7. package/lib/domain/schemas/index.js +8 -8
  8. package/lib/domain/schemas/index.mjs +8 -8
  9. package/lib/domain/types/index.d.mts +470 -66
  10. package/lib/domain/types/index.d.ts +470 -66
  11. package/lib/eject/domain/enum/index.ts +1 -0
  12. package/lib/eject/domain/enum/party.enum.ts +5 -0
  13. package/lib/eject/domain/schemas/plan.schema.ts +2 -2
  14. package/lib/eject/domain/schemas/subscription.schema.ts +2 -2
  15. package/lib/eject/domain/types/billingPortal.mapper.types.ts +7 -4
  16. package/lib/eject/domain/types/checkoutSession.mapper.types.ts +7 -4
  17. package/lib/eject/domain/types/paymentLink.mapper.types.ts +7 -4
  18. package/lib/eject/domain/types/plan.mapper.types.ts +9 -4
  19. package/lib/eject/domain/types/stripe.entity.types.ts +103 -63
  20. package/lib/eject/domain/types/stripeWebhookEvent.types.ts +16 -0
  21. package/lib/eject/domain/types/subscription.mapper.types.ts +10 -7
  22. package/lib/eject/services/checkoutSession.service.ts +5 -5
  23. package/lib/eject/services/paymentLink.service.ts +14 -12
  24. package/lib/eject/services/webhook.service.ts +4 -3
  25. package/lib/planCadence.enum-BKHaW1xa.d.mts +126 -0
  26. package/lib/planCadence.enum-BKHaW1xa.d.ts +126 -0
  27. package/lib/services/index.d.mts +19 -18
  28. package/lib/services/index.d.ts +19 -18
  29. package/lib/services/index.js +86 -14
  30. package/lib/services/index.mjs +86 -14
  31. package/package.json +10 -10
@@ -1,4 +1,5 @@
1
1
  export * from './billingProvider.enum';
2
2
  export * from './currency.enum';
3
+ export * from './party.enum';
3
4
  export * from './paymentMethod.enum';
4
5
  export * from './planCadence.enum';
@@ -0,0 +1,5 @@
1
+ export const PartyEnum = {
2
+ USER: 'user',
3
+ ORGANIZATION: 'organization'
4
+ } as const;
5
+ export type PartyEnum = (typeof PartyEnum)[keyof typeof PartyEnum];
@@ -27,7 +27,7 @@ export const CreatePlanSchema = {
27
27
  features: optional(array(string)),
28
28
  stripeFields: type<StripeCreatePlanDto['stripeFields']>(),
29
29
  externalId: string,
30
- billingProvider: optional(enum_(BillingProviderEnum)),
30
+ billingProvider: enum_(BillingProviderEnum),
31
31
  active: boolean
32
32
  };
33
33
 
@@ -55,7 +55,7 @@ export const PlanSchema = {
55
55
  features: optional(array(string)),
56
56
  stripeFields: type<StripePlanDto['stripeFields']>(),
57
57
  externalId: string,
58
- billingProvider: optional(enum_(BillingProviderEnum)),
58
+ billingProvider: enum_(BillingProviderEnum),
59
59
  active: boolean,
60
60
  createdAt: optional(date),
61
61
  updatedAt: optional(date)
@@ -29,7 +29,7 @@ export const CreateSubscriptionSchema = <
29
29
  startDate: date,
30
30
  endDate: optional(date),
31
31
  status: string,
32
- billingProvider: optional(enum_(BillingProviderEnum)),
32
+ billingProvider: enum_(BillingProviderEnum),
33
33
  stripeFields: type<StripeCreateSubscriptionDto<T>['stripeFields']>()
34
34
  });
35
35
 
@@ -65,7 +65,7 @@ export const SubscriptionSchema = <T extends Record<string, LiteralSchema>>(
65
65
  startDate: date,
66
66
  endDate: optional(date),
67
67
  status: string,
68
- billingProvider: optional(enum_(BillingProviderEnum)),
68
+ billingProvider: enum_(BillingProviderEnum),
69
69
  stripeFields: type<StripeSubscriptionDto<T>['stripeFields']>(),
70
70
  createdAt: optional(date),
71
71
  updatedAt: optional(date)
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import Stripe from 'stripe';
3
3
  import { StripeBillingPortalDtos } from './stripe.dto.types';
4
4
  import { StripeBillingPortalEntities } from './stripe.entity.types';
@@ -8,24 +8,27 @@ export type StripeBillingPortalMappers<
8
8
  Dto extends StripeBillingPortalDtos
9
9
  > = {
10
10
  BillingPortalMapper: {
11
+ entity: Entities['BillingPortalMapper'];
11
12
  toDto: (
12
- entity: Entities['BillingPortalMapper']
13
+ entity: InferEntity<Entities['BillingPortalMapper']>
13
14
  ) => Promise<Dto['BillingPortalMapper']>;
14
15
  };
15
16
  CreateBillingPortalMapper: {
17
+ entity: Entities['CreateBillingPortalMapper'];
16
18
  toEntity: (
17
19
  dto: Dto['CreateBillingPortalMapper'],
18
20
  em: EntityManager,
19
21
  stripeSession: Stripe.BillingPortal.Session,
20
22
  ...args: unknown[]
21
- ) => Promise<Entities['CreateBillingPortalMapper']>;
23
+ ) => Promise<InferEntity<Entities['CreateBillingPortalMapper']>>;
22
24
  };
23
25
  UpdateBillingPortalMapper: {
26
+ entity: Entities['UpdateBillingPortalMapper'];
24
27
  toEntity: (
25
28
  dto: Dto['UpdateBillingPortalMapper'],
26
29
  em: EntityManager,
27
30
  stripeSession: Stripe.BillingPortal.Session,
28
31
  ...args: unknown[]
29
- ) => Promise<Entities['UpdateBillingPortalMapper']>;
32
+ ) => Promise<InferEntity<Entities['UpdateBillingPortalMapper']>>;
30
33
  };
31
34
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import Stripe from 'stripe';
3
3
  import { StripeCheckoutSessionDtos } from './stripe.dto.types';
4
4
  import { StripeCheckoutSessionEntities } from './stripe.entity.types';
@@ -9,24 +9,27 @@ export type StripeCheckoutSessionMappers<
9
9
  Dto extends StripeCheckoutSessionDtos<StatusEnum>
10
10
  > = {
11
11
  CheckoutSessionMapper: {
12
+ entity: Entities['CheckoutSessionMapper'];
12
13
  toDto: (
13
- entity: Entities['CheckoutSessionMapper']
14
+ entity: InferEntity<Entities['CheckoutSessionMapper']>
14
15
  ) => Promise<Dto['CheckoutSessionMapper']>;
15
16
  };
16
17
  CreateCheckoutSessionMapper: {
18
+ entity: Entities['CreateCheckoutSessionMapper'];
17
19
  toEntity: (
18
20
  dto: Dto['CreateCheckoutSessionMapper'],
19
21
  em: EntityManager,
20
22
  stripeSession: Stripe.Checkout.Session,
21
23
  ...args: unknown[]
22
- ) => Promise<Entities['CreateCheckoutSessionMapper']>;
24
+ ) => Promise<InferEntity<Entities['CreateCheckoutSessionMapper']>>;
23
25
  };
24
26
  UpdateCheckoutSessionMapper: {
27
+ entity: Entities['UpdateCheckoutSessionMapper'];
25
28
  toEntity: (
26
29
  dto: Dto['UpdateCheckoutSessionMapper'],
27
30
  em: EntityManager,
28
31
  stripeSession: Stripe.Checkout.Session,
29
32
  ...args: unknown[]
30
- ) => Promise<Entities['UpdateCheckoutSessionMapper']>;
33
+ ) => Promise<InferEntity<Entities['UpdateCheckoutSessionMapper']>>;
31
34
  };
32
35
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import Stripe from 'stripe';
3
3
  import { StripePaymentLinkDtos } from './stripe.dto.types';
4
4
  import { StripePaymentLinkEntities } from './stripe.entity.types';
@@ -9,24 +9,27 @@ export type StripePaymentLinkMappers<
9
9
  Dto extends StripePaymentLinkDtos<StatusEnum>
10
10
  > = {
11
11
  PaymentLinkMapper: {
12
+ entity: Entities['PaymentLinkMapper'];
12
13
  toDto: (
13
- entity: Entities['PaymentLinkMapper']
14
+ entity: InferEntity<Entities['PaymentLinkMapper']>
14
15
  ) => Promise<Dto['PaymentLinkMapper']>;
15
16
  };
16
17
  CreatePaymentLinkMapper: {
18
+ entity: Entities['CreatePaymentLinkMapper'];
17
19
  toEntity: (
18
20
  dto: Dto['CreatePaymentLinkMapper'],
19
21
  em: EntityManager,
20
22
  stripePaymentLink: Stripe.PaymentLink,
21
23
  ...args: unknown[]
22
- ) => Promise<Entities['CreatePaymentLinkMapper']>;
24
+ ) => Promise<InferEntity<Entities['CreatePaymentLinkMapper']>>;
23
25
  };
24
26
  UpdatePaymentLinkMapper: {
27
+ entity: Entities['UpdatePaymentLinkMapper'];
25
28
  toEntity: (
26
29
  dto: Dto['UpdatePaymentLinkMapper'],
27
30
  em: EntityManager,
28
31
  stripePaymentLink: Stripe.PaymentLink,
29
32
  ...args: unknown[]
30
- ) => Promise<Entities['UpdatePaymentLinkMapper']>;
33
+ ) => Promise<InferEntity<Entities['UpdatePaymentLinkMapper']>>;
31
34
  };
32
35
  };
@@ -1,4 +1,4 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import Stripe from 'stripe';
3
3
  import { StripePlanDtos } from './stripe.dto.types';
4
4
  import { StripePlanEntities } from './stripe.entity.types';
@@ -8,22 +8,27 @@ export type StripePlanMappers<
8
8
  Dto extends StripePlanDtos
9
9
  > = {
10
10
  PlanMapper: {
11
- toDto: (entity: Entities['PlanMapper']) => Promise<Dto['PlanMapper']>;
11
+ entity: Entities['PlanMapper'];
12
+ toDto: (
13
+ entity: InferEntity<Entities['PlanMapper']>
14
+ ) => Promise<Dto['PlanMapper']>;
12
15
  };
13
16
  CreatePlanMapper: {
17
+ entity: Entities['CreatePlanMapper'];
14
18
  toEntity: (
15
19
  dto: Dto['CreatePlanMapper'],
16
20
  em: EntityManager,
17
21
  stripePlan: Stripe.Product,
18
22
  ...args: unknown[]
19
- ) => Promise<Entities['CreatePlanMapper']>;
23
+ ) => Promise<InferEntity<Entities['CreatePlanMapper']>>;
20
24
  };
21
25
  UpdatePlanMapper: {
26
+ entity: Entities['UpdatePlanMapper'];
22
27
  toEntity: (
23
28
  dto: Dto['UpdatePlanMapper'],
24
29
  em: EntityManager,
25
30
  stripePlan: Stripe.Product,
26
31
  ...args: unknown[]
27
- ) => Promise<Entities['UpdatePlanMapper']>;
32
+ ) => Promise<InferEntity<Entities['UpdatePlanMapper']>>;
28
33
  };
29
34
  };
@@ -1,83 +1,123 @@
1
1
  import {
2
- BillingPortalDto,
3
- CheckoutSessionDto,
4
- PaymentLinkDto,
5
- PlanDto,
6
- SubscriptionDto
7
- } from '@forklaunch/interfaces-billing/types';
8
- import Stripe from 'stripe';
9
- import { BillingProviderEnum } from '../enum/billingProvider.enum';
10
- import { CurrencyEnum } from '../enum/currency.enum';
11
- import { PaymentMethodEnum } from '../enum/paymentMethod.enum';
12
- import { PlanCadenceEnum } from '../enum/planCadence.enum';
2
+ BillingPortal,
3
+ CheckoutSession,
4
+ PaymentLink,
5
+ Plan,
6
+ Subscription
7
+ } from '../../persistence/entities';
8
+ import {
9
+ BillingProviderEnum,
10
+ CurrencyEnum,
11
+ PaymentMethodEnum,
12
+ PlanCadenceEnum
13
+ } from '../enum';
13
14
 
14
15
  // Billing Portal Types
15
- export type StripeBillingPortalEntity = BillingPortalDto & {
16
- providerFields: Stripe.BillingPortal.Session;
17
- };
18
-
19
16
  export type StripeBillingPortalEntities = {
20
- BillingPortalMapper: StripeBillingPortalEntity;
21
- CreateBillingPortalMapper: StripeBillingPortalEntity;
22
- UpdateBillingPortalMapper: StripeBillingPortalEntity;
17
+ BillingPortalMapper: {
18
+ '~entity': (typeof BillingPortal)['~entity'];
19
+ };
20
+ CreateBillingPortalMapper: {
21
+ '~entity': (typeof BillingPortal)['~entity'];
22
+ };
23
+ UpdateBillingPortalMapper: {
24
+ '~entity': (typeof BillingPortal)['~entity'];
25
+ };
23
26
  };
24
27
 
25
28
  // Checkout Session Types
26
-
27
- export type StripeCheckoutSessionEntity<StatusEnum> = CheckoutSessionDto<
28
- typeof PaymentMethodEnum,
29
- typeof CurrencyEnum,
30
- StatusEnum
31
- > & {
32
- providerFields: Stripe.Checkout.Session;
33
- };
34
-
35
29
  export type StripeCheckoutSessionEntities<StatusEnum> = {
36
- CheckoutSessionMapper: StripeCheckoutSessionEntity<StatusEnum>;
37
- CreateCheckoutSessionMapper: StripeCheckoutSessionEntity<StatusEnum>;
38
- UpdateCheckoutSessionMapper: StripeCheckoutSessionEntity<StatusEnum>;
30
+ CheckoutSessionMapper: {
31
+ '~entity': (typeof CheckoutSession)['~entity'] & {
32
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
33
+ currency: CurrencyEnum[keyof CurrencyEnum];
34
+ status: StatusEnum[keyof StatusEnum];
35
+ };
36
+ };
37
+ CreateCheckoutSessionMapper: {
38
+ '~entity': (typeof CheckoutSession)['~entity'] & {
39
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
40
+ currency: CurrencyEnum[keyof CurrencyEnum];
41
+ status: StatusEnum[keyof StatusEnum];
42
+ };
43
+ };
44
+ UpdateCheckoutSessionMapper: {
45
+ '~entity': (typeof CheckoutSession)['~entity'] & {
46
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
47
+ currency: CurrencyEnum[keyof CurrencyEnum];
48
+ status: StatusEnum[keyof StatusEnum];
49
+ };
50
+ };
39
51
  };
40
52
 
41
53
  // Payment Link Types
42
- export type StripePaymentLinkEntity<StatusEnum> = PaymentLinkDto<
43
- typeof PaymentMethodEnum,
44
- typeof CurrencyEnum,
45
- StatusEnum
46
- > & {
47
- providerFields: Stripe.PaymentLink;
48
- };
49
-
50
54
  export type StripePaymentLinkEntities<StatusEnum> = {
51
- PaymentLinkMapper: StripePaymentLinkEntity<StatusEnum>;
52
- CreatePaymentLinkMapper: StripePaymentLinkEntity<StatusEnum>;
53
- UpdatePaymentLinkMapper: StripePaymentLinkEntity<StatusEnum>;
55
+ PaymentLinkMapper: {
56
+ '~entity': (typeof PaymentLink)['~entity'] & {
57
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
58
+ currency: CurrencyEnum[keyof CurrencyEnum];
59
+ status: StatusEnum[keyof StatusEnum];
60
+ };
61
+ };
62
+ CreatePaymentLinkMapper: {
63
+ '~entity': (typeof PaymentLink)['~entity'] & {
64
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
65
+ currency: CurrencyEnum[keyof CurrencyEnum];
66
+ status: StatusEnum[keyof StatusEnum];
67
+ };
68
+ };
69
+ UpdatePaymentLinkMapper: {
70
+ '~entity': (typeof PaymentLink)['~entity'] & {
71
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
72
+ currency: CurrencyEnum[keyof CurrencyEnum];
73
+ status: StatusEnum[keyof StatusEnum];
74
+ };
75
+ };
54
76
  };
55
77
 
56
78
  // Plan Types
57
- export type StripePlanEntity = PlanDto<
58
- typeof PlanCadenceEnum,
59
- typeof CurrencyEnum,
60
- typeof BillingProviderEnum
61
- > & {
62
- providerFields: Stripe.Product;
63
- };
64
-
65
79
  export type StripePlanEntities = {
66
- PlanMapper: StripePlanEntity;
67
- CreatePlanMapper: StripePlanEntity;
68
- UpdatePlanMapper: StripePlanEntity;
80
+ PlanMapper: {
81
+ '~entity': (typeof Plan)['~entity'] & {
82
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
83
+ currency: CurrencyEnum[keyof CurrencyEnum];
84
+ billingProvider: BillingProviderEnum[keyof BillingProviderEnum];
85
+ };
86
+ };
87
+ CreatePlanMapper: {
88
+ '~entity': (typeof Plan)['~entity'] & {
89
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
90
+ currency: CurrencyEnum[keyof CurrencyEnum];
91
+ billingProvider: BillingProviderEnum[keyof BillingProviderEnum];
92
+ };
93
+ };
94
+ UpdatePlanMapper: {
95
+ '~entity': (typeof Plan)['~entity'] & {
96
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
97
+ currency: CurrencyEnum[keyof CurrencyEnum];
98
+ billingProvider: BillingProviderEnum[keyof BillingProviderEnum];
99
+ };
100
+ };
69
101
  };
70
102
 
71
103
  // Subscription Types
72
- export type StripeSubscriptionEntity<PartyType> = SubscriptionDto<
73
- PartyType,
74
- typeof BillingProviderEnum
75
- > & {
76
- providerFields: Stripe.Subscription;
77
- };
78
-
79
- export type StripeSubscriptionEntities<PartyType> = {
80
- SubscriptionMapper: StripeSubscriptionEntity<PartyType>;
81
- CreateSubscriptionMapper: StripeSubscriptionEntity<PartyType>;
82
- UpdateSubscriptionMapper: StripeSubscriptionEntity<PartyType>;
104
+ export type StripeSubscriptionEntities<PartyTypeEnum> = {
105
+ SubscriptionMapper: {
106
+ '~entity': (typeof Subscription)['~entity'] & {
107
+ partyType: PartyTypeEnum[keyof PartyTypeEnum];
108
+ billingProvider: BillingProviderEnum[keyof BillingProviderEnum];
109
+ };
110
+ };
111
+ CreateSubscriptionMapper: {
112
+ '~entity': (typeof Subscription)['~entity'] & {
113
+ partyType: PartyTypeEnum[keyof PartyTypeEnum];
114
+ billingProvider: BillingProviderEnum[keyof BillingProviderEnum];
115
+ };
116
+ };
117
+ UpdateSubscriptionMapper: {
118
+ '~entity': (typeof Subscription)['~entity'] & {
119
+ partyType: PartyTypeEnum[keyof PartyTypeEnum];
120
+ billingProvider: BillingProviderEnum[keyof BillingProviderEnum];
121
+ };
122
+ };
83
123
  };
@@ -0,0 +1,16 @@
1
+ import { defineEntity, p, type InferEntity } from '@mikro-orm/core';
2
+
3
+ export const StripeWebhookEventEntity = defineEntity({
4
+ name: 'StripeWebhookEvent',
5
+ properties: {
6
+ id: p.uuid().primary(),
7
+ createdAt: p.datetime(),
8
+ updatedAt: p.datetime(),
9
+ stripeId: p.string(),
10
+ idempotencyKey: p.string().nullable(),
11
+ eventType: p.string(),
12
+ eventData: p.json<unknown>()
13
+ }
14
+ });
15
+
16
+ export type StripeWebhookEvent = InferEntity<typeof StripeWebhookEventEntity>;
@@ -1,32 +1,35 @@
1
- import { EntityManager } from '@mikro-orm/core';
1
+ import { EntityManager, InferEntity } from '@mikro-orm/core';
2
2
  import Stripe from 'stripe';
3
3
  import { StripeSubscriptionDtos } from './stripe.dto.types';
4
4
  import { StripeSubscriptionEntities } from './stripe.entity.types';
5
5
 
6
6
  export type StripeSubscriptionMappers<
7
- PartyType,
8
- Entities extends StripeSubscriptionEntities<PartyType>,
9
- Dto extends StripeSubscriptionDtos<PartyType>
7
+ PartyTypeEnum,
8
+ Entities extends StripeSubscriptionEntities<PartyTypeEnum>,
9
+ Dto extends StripeSubscriptionDtos<PartyTypeEnum>
10
10
  > = {
11
11
  SubscriptionMapper: {
12
+ entity: Entities['SubscriptionMapper'];
12
13
  toDto: (
13
- entity: Entities['SubscriptionMapper']
14
+ entity: InferEntity<Entities['SubscriptionMapper']>
14
15
  ) => Promise<Dto['SubscriptionMapper']>;
15
16
  };
16
17
  CreateSubscriptionMapper: {
18
+ entity: Entities['CreateSubscriptionMapper'];
17
19
  toEntity: (
18
20
  dto: Dto['CreateSubscriptionMapper'],
19
21
  em: EntityManager,
20
22
  stripeSubscription: Stripe.Subscription,
21
23
  ...args: unknown[]
22
- ) => Promise<Entities['CreateSubscriptionMapper']>;
24
+ ) => Promise<InferEntity<Entities['CreateSubscriptionMapper']>>;
23
25
  };
24
26
  UpdateSubscriptionMapper: {
27
+ entity: Entities['UpdateSubscriptionMapper'];
25
28
  toEntity: (
26
29
  dto: Dto['UpdateSubscriptionMapper'],
27
30
  em: EntityManager,
28
31
  stripeSubscription: Stripe.Subscription,
29
32
  ...args: unknown[]
30
- ) => Promise<Entities['UpdateSubscriptionMapper']>;
33
+ ) => Promise<InferEntity<Entities['UpdateSubscriptionMapper']>>;
31
34
  };
32
35
  };
@@ -23,7 +23,7 @@ import { StripeCheckoutSessionEntities } from '../domain/types/stripe.entity.typ
23
23
  export class StripeCheckoutSessionService<
24
24
  SchemaValidator extends AnySchemaValidator,
25
25
  StatusEnum,
26
- Entities extends StripeCheckoutSessionEntities<StatusEnum>,
26
+ MapperEntities extends StripeCheckoutSessionEntities<StatusEnum>,
27
27
  Dto extends
28
28
  StripeCheckoutSessionDtos<StatusEnum> = StripeCheckoutSessionDtos<StatusEnum>
29
29
  > implements
@@ -43,7 +43,7 @@ export class StripeCheckoutSessionService<
43
43
  PaymentMethodEnum,
44
44
  CurrencyEnum,
45
45
  StatusEnum,
46
- Entities,
46
+ MapperEntities,
47
47
  Dto
48
48
  >;
49
49
  protected readonly stripeClient: Stripe;
@@ -53,7 +53,7 @@ export class StripeCheckoutSessionService<
53
53
  protected readonly schemaValidator: SchemaValidator;
54
54
  protected readonly mappers: StripeCheckoutSessionMappers<
55
55
  StatusEnum,
56
- Entities,
56
+ MapperEntities,
57
57
  Dto
58
58
  >;
59
59
 
@@ -63,7 +63,7 @@ export class StripeCheckoutSessionService<
63
63
  cache: TtlCache,
64
64
  openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>,
65
65
  schemaValidator: SchemaValidator,
66
- mappers: StripeCheckoutSessionMappers<StatusEnum, Entities, Dto>,
66
+ mappers: StripeCheckoutSessionMappers<StatusEnum, MapperEntities, Dto>,
67
67
  readonly options?: {
68
68
  enableDatabaseBackup?: boolean;
69
69
  telemetry?: TelemetryOptions;
@@ -84,7 +84,7 @@ export class StripeCheckoutSessionService<
84
84
  PaymentMethodEnum,
85
85
  CurrencyEnum,
86
86
  StatusEnum,
87
- Entities,
87
+ MapperEntities,
88
88
  Dto
89
89
  >,
90
90
  options
@@ -138,18 +138,20 @@ export class StripePaymentLinkService<
138
138
  );
139
139
 
140
140
  const paymentLink = await this.basePaymentLinkService.updatePaymentLink(
141
- await this.mappers.UpdatePaymentLinkMapper.toEntity(
142
- {
143
- ...paymentLinkDto,
144
- id: session.id,
145
- amount:
146
- session.line_items?.data.reduce<number>(
147
- (total, item) => total + item.amount_total,
148
- 0
149
- ) ?? 0
150
- },
151
- this.em,
152
- session
141
+ await this.mappers.PaymentLinkMapper.toDto(
142
+ await this.mappers.UpdatePaymentLinkMapper.toEntity(
143
+ {
144
+ ...paymentLinkDto,
145
+ id: session.id,
146
+ amount:
147
+ session.line_items?.data.reduce<number>(
148
+ (total, item) => total + item.amount_total,
149
+ 0
150
+ ) ?? 0
151
+ },
152
+ this.em,
153
+ session
154
+ )
153
155
  ),
154
156
  ...args
155
157
  );
@@ -5,7 +5,8 @@ import {
5
5
  import { AnySchemaValidator } from '@forklaunch/validator';
6
6
  import { EntityManager } from '@mikro-orm/core';
7
7
  import Stripe from 'stripe';
8
- import { PartyEnum } from '../../../../billing-base/domain/enum/party.enum';
8
+ import { PartyEnum } from '../domain/enum/party.enum';
9
+ import { StripeWebhookEvent } from '../persistence/entities';
9
10
  import { BillingProviderEnum } from '../domain/enum/billingProvider.enum';
10
11
  import { CurrencyEnum } from '../domain/enum/currency.enum';
11
12
  import { PaymentMethodEnum } from '../domain/enum/paymentMethod.enum';
@@ -136,7 +137,7 @@ export class StripeWebhookService<
136
137
  }
137
138
 
138
139
  if (
139
- await this.em.findOne('StripeWebhookEvent', {
140
+ await this.em.findOne(StripeWebhookEvent, {
140
141
  idempotencyKey: event.request?.idempotency_key
141
142
  })
142
143
  ) {
@@ -454,7 +455,7 @@ export class StripeWebhookService<
454
455
  break;
455
456
  }
456
457
 
457
- await this.em.insert('StripeWebhookEvent', {
458
+ await this.em.insert(StripeWebhookEvent, {
458
459
  stripeId: event.id,
459
460
  idempotencyKey: event.request?.idempotency_key,
460
461
  eventType: event.type,