@forklaunch/interfaces-billing 0.1.0 → 0.1.1

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 (73) hide show
  1. package/{interfaces → lib/eject/interfaces}/billingPortal.service.interface.ts +1 -19
  2. package/lib/eject/interfaces/checkoutSession.service.interface.ts +19 -0
  3. package/lib/eject/interfaces/index.ts +5 -0
  4. package/lib/eject/interfaces/interfaces/billingPortal.service.interface.ts +18 -0
  5. package/lib/eject/interfaces/interfaces/checkoutSession.service.interface.ts +19 -0
  6. package/lib/eject/interfaces/interfaces/index.ts +5 -0
  7. package/{interfaces → lib/eject/interfaces/interfaces}/paymentLink.service.interface.ts +1 -23
  8. package/lib/eject/interfaces/interfaces/plan.service.interface.ts +29 -0
  9. package/{interfaces → lib/eject/interfaces/interfaces}/subscription.service.interface.ts +1 -28
  10. package/lib/eject/interfaces/paymentLink.service.interface.ts +27 -0
  11. package/lib/eject/interfaces/plan.service.interface.ts +29 -0
  12. package/lib/eject/interfaces/subscription.service.interface.ts +49 -0
  13. package/lib/eject/types/billingPortal.service.types.ts +19 -0
  14. package/{interfaces/checkoutSession.service.interface.ts → lib/eject/types/checkoutSession.service.types.ts} +0 -19
  15. package/lib/eject/types/index.ts +5 -0
  16. package/lib/eject/types/paymentLink.service.types.ts +23 -0
  17. package/{interfaces/plan.service.interface.ts → lib/eject/types/plan.service.types.ts} +0 -28
  18. package/lib/eject/types/subscription.service.types.ts +28 -0
  19. package/lib/eject/types/types/billingPortal.service.types.ts +19 -0
  20. package/lib/eject/types/types/checkoutSession.service.types.ts +21 -0
  21. package/lib/eject/types/types/index.ts +5 -0
  22. package/lib/eject/types/types/paymentLink.service.types.ts +23 -0
  23. package/lib/eject/types/types/plan.service.types.ts +26 -0
  24. package/lib/eject/types/types/subscription.service.types.ts +28 -0
  25. package/lib/index.d.ts +3 -0
  26. package/lib/index.d.ts.map +1 -0
  27. package/lib/index.js +2 -0
  28. package/lib/interfaces/billingPortal.service.interface.d.ts +8 -0
  29. package/lib/interfaces/billingPortal.service.interface.d.ts.map +1 -0
  30. package/lib/interfaces/billingPortal.service.interface.js +1 -0
  31. package/lib/interfaces/checkoutSession.service.interface.d.ts +9 -0
  32. package/lib/interfaces/checkoutSession.service.interface.d.ts.map +1 -0
  33. package/lib/interfaces/checkoutSession.service.interface.js +1 -0
  34. package/lib/interfaces/index.d.ts +6 -0
  35. package/lib/interfaces/index.d.ts.map +1 -0
  36. package/lib/interfaces/index.js +5 -0
  37. package/lib/interfaces/paymentLink.service.interface.d.ts +11 -0
  38. package/lib/interfaces/paymentLink.service.interface.d.ts.map +1 -0
  39. package/lib/interfaces/paymentLink.service.interface.js +1 -0
  40. package/lib/interfaces/plan.service.interface.d.ts +10 -0
  41. package/lib/interfaces/plan.service.interface.d.ts.map +1 -0
  42. package/lib/interfaces/plan.service.interface.js +1 -0
  43. package/lib/interfaces/subscription.service.interface.d.ts +14 -0
  44. package/lib/interfaces/subscription.service.interface.d.ts.map +1 -0
  45. package/lib/interfaces/subscription.service.interface.js +1 -0
  46. package/lib/jest.config.d.ts +4 -0
  47. package/lib/jest.config.d.ts.map +1 -0
  48. package/lib/jest.config.js +19 -0
  49. package/lib/tsconfig.tsbuildinfo +1 -0
  50. package/lib/types/billingPortal.service.types.d.ts +16 -0
  51. package/lib/types/billingPortal.service.types.d.ts.map +1 -0
  52. package/lib/types/billingPortal.service.types.js +1 -0
  53. package/lib/types/checkoutSession.service.types.d.ts +17 -0
  54. package/lib/types/checkoutSession.service.types.d.ts.map +1 -0
  55. package/lib/types/checkoutSession.service.types.js +1 -0
  56. package/lib/types/index.d.ts +6 -0
  57. package/lib/types/index.d.ts.map +1 -0
  58. package/lib/types/index.js +5 -0
  59. package/lib/types/paymentLink.service.types.d.ts +19 -0
  60. package/lib/types/paymentLink.service.types.d.ts.map +1 -0
  61. package/lib/types/paymentLink.service.types.js +1 -0
  62. package/lib/types/plan.service.types.d.ts +22 -0
  63. package/lib/types/plan.service.types.d.ts.map +1 -0
  64. package/lib/types/plan.service.types.js +1 -0
  65. package/lib/types/subscription.service.types.d.ts +24 -0
  66. package/lib/types/subscription.service.types.d.ts.map +1 -0
  67. package/lib/types/subscription.service.types.js +1 -0
  68. package/lib/vitest.config.d.ts +3 -0
  69. package/lib/vitest.config.d.ts.map +1 -0
  70. package/lib/vitest.config.js +7 -0
  71. package/package.json +7 -4
  72. package/index.ts +0 -5
  73. package/tsconfig.json +0 -7
@@ -1,22 +1,4 @@
1
- import { IdDto, RecordTimingDto } from '@forklaunch/common';
2
-
3
- export type CreateBillingPortalDto = {
4
- customerId: string;
5
- uri: string;
6
- expiresAt: Date;
7
- extraFields?: unknown;
8
- };
9
- export type UpdateBillingPortalDto = IdDto & Partial<CreateBillingPortalDto>;
10
- export type BillingPortalDto = IdDto &
11
- CreateBillingPortalDto &
12
- Partial<RecordTimingDto>;
13
-
14
- export type BillingPortalServiceParameters = {
15
- CreateBillingPortalDto: CreateBillingPortalDto;
16
- UpdateBillingPortalDto: UpdateBillingPortalDto;
17
- BillingPortalDto: BillingPortalDto;
18
- IdDto: IdDto;
19
- };
1
+ import { BillingPortalServiceParameters } from '../types/billingPortal.service.types';
20
2
 
21
3
  export interface BillingPortalService<
22
4
  Params extends BillingPortalServiceParameters = BillingPortalServiceParameters
@@ -0,0 +1,19 @@
1
+ import { CheckoutSessionServiceParameters } from '../types/checkoutSession.service.types';
2
+ export interface CheckoutSessionService<
3
+ PaymentMethodEnum,
4
+ Params extends
5
+ CheckoutSessionServiceParameters<PaymentMethodEnum> = CheckoutSessionServiceParameters<PaymentMethodEnum>
6
+ > {
7
+ // for generating external links
8
+ // store in cache, for permissions
9
+ createCheckoutSession: (
10
+ checkoutSessionDto: Params['CreateCheckoutSessionDto']
11
+ ) => Promise<Params['CheckoutSessionDto']>;
12
+ getCheckoutSession: (
13
+ idDto: Params['IdDto']
14
+ ) => Promise<Params['CheckoutSessionDto']>;
15
+ expireCheckoutSession: (idDto: Params['IdDto']) => Promise<void>;
16
+
17
+ handleCheckoutSuccess: (idDto: Params['IdDto']) => Promise<void>;
18
+ handleCheckoutFailure: (idDto: Params['IdDto']) => Promise<void>;
19
+ }
@@ -0,0 +1,5 @@
1
+ export * from './billingPortal.service.interface';
2
+ export * from './checkoutSession.service.interface';
3
+ export * from './paymentLink.service.interface';
4
+ export * from './plan.service.interface';
5
+ export * from './subscription.service.interface';
@@ -0,0 +1,18 @@
1
+ import { BillingPortalServiceParameters } from '../types/billingPortal.service.types';
2
+
3
+ export interface BillingPortalService<
4
+ Params extends BillingPortalServiceParameters = BillingPortalServiceParameters
5
+ > {
6
+ // for generating external links
7
+ // store in cache, for permissions
8
+ createBillingPortalSession: (
9
+ billingPortalDto: Params['CreateBillingPortalDto']
10
+ ) => Promise<Params['BillingPortalDto']>;
11
+ getBillingPortalSession: (
12
+ idDto: Params['IdDto']
13
+ ) => Promise<Params['BillingPortalDto']>;
14
+ updateBillingPortalSession: (
15
+ billingPortalDto: Params['UpdateBillingPortalDto']
16
+ ) => Promise<Params['BillingPortalDto']>;
17
+ expireBillingPortalSession: (idDto: Params['IdDto']) => Promise<void>;
18
+ }
@@ -0,0 +1,19 @@
1
+ import { CheckoutSessionServiceParameters } from '../types/checkoutSession.service.types';
2
+ export interface CheckoutSessionService<
3
+ PaymentMethodEnum,
4
+ Params extends
5
+ CheckoutSessionServiceParameters<PaymentMethodEnum> = CheckoutSessionServiceParameters<PaymentMethodEnum>
6
+ > {
7
+ // for generating external links
8
+ // store in cache, for permissions
9
+ createCheckoutSession: (
10
+ checkoutSessionDto: Params['CreateCheckoutSessionDto']
11
+ ) => Promise<Params['CheckoutSessionDto']>;
12
+ getCheckoutSession: (
13
+ idDto: Params['IdDto']
14
+ ) => Promise<Params['CheckoutSessionDto']>;
15
+ expireCheckoutSession: (idDto: Params['IdDto']) => Promise<void>;
16
+
17
+ handleCheckoutSuccess: (idDto: Params['IdDto']) => Promise<void>;
18
+ handleCheckoutFailure: (idDto: Params['IdDto']) => Promise<void>;
19
+ }
@@ -0,0 +1,5 @@
1
+ export * from './billingPortal.service.interface';
2
+ export * from './checkoutSession.service.interface';
3
+ export * from './paymentLink.service.interface';
4
+ export * from './plan.service.interface';
5
+ export * from './subscription.service.interface';
@@ -1,26 +1,4 @@
1
- import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
-
3
- export type CreatePaymentLinkDto<CurrencyEnum> = {
4
- amount: number;
5
- currency: CurrencyEnum[keyof CurrencyEnum];
6
- metadata?: unknown;
7
- successRedirectUri: string;
8
- cancelRedirectUri: string;
9
- extraFields?: unknown;
10
- };
11
- export type UpdatePaymentLinkDto<CurrencyEnum> = IdDto &
12
- Partial<CreatePaymentLinkDto<CurrencyEnum>>;
13
- export type PaymentLinkDto<CurrencyEnum> = IdDto &
14
- CreatePaymentLinkDto<CurrencyEnum> &
15
- Partial<RecordTimingDto>;
16
-
17
- export type PaymentLinkServiceParameters<CurrencyEnum> = {
18
- CreatePaymentLinkDto: CreatePaymentLinkDto<CurrencyEnum>;
19
- UpdatePaymentLinkDto: UpdatePaymentLinkDto<CurrencyEnum>;
20
- PaymentLinkDto: PaymentLinkDto<CurrencyEnum>;
21
- IdDto: IdDto;
22
- IdsDto: IdsDto;
23
- };
1
+ import { PaymentLinkServiceParameters } from '../types/paymentLink.service.types';
24
2
 
25
3
  export interface PaymentLinkService<
26
4
  CurrencyEnum,
@@ -0,0 +1,29 @@
1
+ import { EntityManager } from '@mikro-orm/core';
2
+ import { PlanServiceParameters } from '../types/plan.service.types';
3
+
4
+ export interface PlanService<
5
+ PlanCadenceEnum,
6
+ BillingProviderEnum,
7
+ Params extends PlanServiceParameters<
8
+ PlanCadenceEnum,
9
+ BillingProviderEnum
10
+ > = PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum>
11
+ > {
12
+ createPlan: (
13
+ planDto: Params['CreatePlanDto'],
14
+ em?: EntityManager
15
+ ) => Promise<Params['PlanDto']>;
16
+ getPlan: (
17
+ idDto: Params['IdDto'],
18
+ em?: EntityManager
19
+ ) => Promise<Params['PlanDto']>;
20
+ updatePlan: (
21
+ planDto: Params['UpdatePlanDto'],
22
+ em?: EntityManager
23
+ ) => Promise<Params['PlanDto']>;
24
+ deletePlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
25
+ listPlans: (
26
+ idsDto?: Params['IdsDto'],
27
+ em?: EntityManager
28
+ ) => Promise<Params['PlanDto'][]>;
29
+ }
@@ -1,32 +1,5 @@
1
- import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
1
  import { EntityManager } from '@mikro-orm/core';
3
-
4
- export type CreateSubscriptionDto<PartyType, BillingProviderType> = {
5
- partyId: string;
6
- partyType: PartyType[keyof PartyType];
7
- description?: string;
8
- active: boolean;
9
- productId: string;
10
- extraFields?: unknown;
11
- externalId: string;
12
- billingProvider?: BillingProviderType[keyof BillingProviderType];
13
- startDate: Date;
14
- endDate: Date;
15
- status: string;
16
- };
17
- export type UpdateSubscriptionDto<PartyType, BillingProviderType> = IdDto &
18
- Partial<CreateSubscriptionDto<PartyType, BillingProviderType>>;
19
- export type SubscriptionDto<PartyType, BillingProviderType> = IdDto &
20
- CreateSubscriptionDto<PartyType, BillingProviderType> &
21
- Partial<RecordTimingDto>;
22
-
23
- export type SubscriptionServiceParameters<PartyType, BillingProviderType> = {
24
- CreateSubscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>;
25
- UpdateSubscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>;
26
- SubscriptionDto: SubscriptionDto<PartyType, BillingProviderType>;
27
- IdDto: IdDto;
28
- IdsDto: IdsDto;
29
- };
2
+ import { SubscriptionServiceParameters } from '../types/subscription.service.types';
30
3
 
31
4
  export interface SubscriptionService<
32
5
  PartyType,
@@ -0,0 +1,27 @@
1
+ import { PaymentLinkServiceParameters } from '../types/paymentLink.service.types';
2
+
3
+ export interface PaymentLinkService<
4
+ CurrencyEnum,
5
+ Params extends
6
+ PaymentLinkServiceParameters<CurrencyEnum> = PaymentLinkServiceParameters<CurrencyEnum>
7
+ > {
8
+ // for one off products that are not part of a subscription
9
+ // think about how permissions work on payment links, but these should be ephemeral
10
+ // store in cache, for permissions
11
+ createPaymentLink: (
12
+ paymentLink: Params['CreatePaymentLinkDto']
13
+ ) => Promise<Params['PaymentLinkDto']>;
14
+ updatePaymentLink: (
15
+ paymentLink: Params['UpdatePaymentLinkDto']
16
+ ) => Promise<Params['PaymentLinkDto']>;
17
+ getPaymentLink: (idDto: Params['IdDto']) => Promise<Params['PaymentLinkDto']>;
18
+ expirePaymentLink: (idDto: Params['IdDto']) => Promise<void>;
19
+
20
+ handlePaymentSuccess: (idDto: Params['IdDto']) => Promise<void>;
21
+ handlePaymentFailure: (idDto: Params['IdDto']) => Promise<void>;
22
+
23
+ // admin API, make sure that permissions are correct here
24
+ listPaymentLinks: (
25
+ idsDto?: Params['IdsDto']
26
+ ) => Promise<Params['PaymentLinkDto'][]>;
27
+ }
@@ -0,0 +1,29 @@
1
+ import { EntityManager } from '@mikro-orm/core';
2
+ import { PlanServiceParameters } from '../types/plan.service.types';
3
+
4
+ export interface PlanService<
5
+ PlanCadenceEnum,
6
+ BillingProviderEnum,
7
+ Params extends PlanServiceParameters<
8
+ PlanCadenceEnum,
9
+ BillingProviderEnum
10
+ > = PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum>
11
+ > {
12
+ createPlan: (
13
+ planDto: Params['CreatePlanDto'],
14
+ em?: EntityManager
15
+ ) => Promise<Params['PlanDto']>;
16
+ getPlan: (
17
+ idDto: Params['IdDto'],
18
+ em?: EntityManager
19
+ ) => Promise<Params['PlanDto']>;
20
+ updatePlan: (
21
+ planDto: Params['UpdatePlanDto'],
22
+ em?: EntityManager
23
+ ) => Promise<Params['PlanDto']>;
24
+ deletePlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
25
+ listPlans: (
26
+ idsDto?: Params['IdsDto'],
27
+ em?: EntityManager
28
+ ) => Promise<Params['PlanDto'][]>;
29
+ }
@@ -0,0 +1,49 @@
1
+ import { EntityManager } from '@mikro-orm/core';
2
+ import { SubscriptionServiceParameters } from '../types/subscription.service.types';
3
+
4
+ export interface SubscriptionService<
5
+ PartyType,
6
+ BillingProviderType,
7
+ Params extends SubscriptionServiceParameters<
8
+ PartyType,
9
+ BillingProviderType
10
+ > = SubscriptionServiceParameters<PartyType, BillingProviderType>
11
+ > {
12
+ // store this in a table
13
+ createSubscription: (
14
+ subscriptionDto: Params['CreateSubscriptionDto'],
15
+ em?: EntityManager
16
+ ) => Promise<Params['SubscriptionDto']>;
17
+ getSubscription: (
18
+ idDto: Params['IdDto'],
19
+ em?: EntityManager
20
+ ) => Promise<Params['SubscriptionDto']>;
21
+ getUserSubscription: (
22
+ idDto: Params['IdDto'],
23
+ em?: EntityManager
24
+ ) => Promise<Params['SubscriptionDto']>;
25
+ getOrganizationSubscription: (
26
+ idDto: Params['IdDto'],
27
+ em?: EntityManager
28
+ ) => Promise<Params['SubscriptionDto']>;
29
+ updateSubscription: (
30
+ subscriptionDto: Params['UpdateSubscriptionDto'],
31
+ em?: EntityManager
32
+ ) => Promise<Params['SubscriptionDto']>;
33
+ deleteSubscription: (
34
+ id: Params['IdDto'],
35
+ em?: EntityManager
36
+ ) => Promise<void>;
37
+ listSubscriptions: (
38
+ idsDto: Params['IdsDto'],
39
+ em?: EntityManager
40
+ ) => Promise<Params['SubscriptionDto'][]>;
41
+ cancelSubscription: (
42
+ idDto: Params['IdDto'],
43
+ em?: EntityManager
44
+ ) => Promise<void>;
45
+ resumeSubscription: (
46
+ idDto: Params['IdDto'],
47
+ em?: EntityManager
48
+ ) => Promise<void>;
49
+ }
@@ -0,0 +1,19 @@
1
+ import { IdDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreateBillingPortalDto = {
4
+ customerId: string;
5
+ uri: string;
6
+ expiresAt: Date;
7
+ extraFields?: unknown;
8
+ };
9
+ export type UpdateBillingPortalDto = IdDto & Partial<CreateBillingPortalDto>;
10
+ export type BillingPortalDto = IdDto &
11
+ CreateBillingPortalDto &
12
+ Partial<RecordTimingDto>;
13
+
14
+ export type BillingPortalServiceParameters = {
15
+ CreateBillingPortalDto: CreateBillingPortalDto;
16
+ UpdateBillingPortalDto: UpdateBillingPortalDto;
17
+ BillingPortalDto: BillingPortalDto;
18
+ IdDto: IdDto;
19
+ };
@@ -19,22 +19,3 @@ export type CheckoutSessionServiceParameters<PaymentMethodEnum> = {
19
19
  CheckoutSessionDto: CheckoutSessionDto<PaymentMethodEnum>;
20
20
  IdDto: IdDto;
21
21
  };
22
-
23
- export interface CheckoutSessionService<
24
- PaymentMethodEnum,
25
- Params extends
26
- CheckoutSessionServiceParameters<PaymentMethodEnum> = CheckoutSessionServiceParameters<PaymentMethodEnum>
27
- > {
28
- // for generating external links
29
- // store in cache, for permissions
30
- createCheckoutSession: (
31
- checkoutSessionDto: Params['CreateCheckoutSessionDto']
32
- ) => Promise<Params['CheckoutSessionDto']>;
33
- getCheckoutSession: (
34
- idDto: Params['IdDto']
35
- ) => Promise<Params['CheckoutSessionDto']>;
36
- expireCheckoutSession: (idDto: Params['IdDto']) => Promise<void>;
37
-
38
- handleCheckoutSuccess: (idDto: Params['IdDto']) => Promise<void>;
39
- handleCheckoutFailure: (idDto: Params['IdDto']) => Promise<void>;
40
- }
@@ -0,0 +1,5 @@
1
+ export * from './billingPortal.service.types';
2
+ export * from './checkoutSession.service.types';
3
+ export * from './paymentLink.service.types';
4
+ export * from './plan.service.types';
5
+ export * from './subscription.service.types';
@@ -0,0 +1,23 @@
1
+ import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreatePaymentLinkDto<CurrencyEnum> = {
4
+ amount: number;
5
+ currency: CurrencyEnum[keyof CurrencyEnum];
6
+ metadata?: unknown;
7
+ successRedirectUri: string;
8
+ cancelRedirectUri: string;
9
+ extraFields?: unknown;
10
+ };
11
+ export type UpdatePaymentLinkDto<CurrencyEnum> = IdDto &
12
+ Partial<CreatePaymentLinkDto<CurrencyEnum>>;
13
+ export type PaymentLinkDto<CurrencyEnum> = IdDto &
14
+ CreatePaymentLinkDto<CurrencyEnum> &
15
+ Partial<RecordTimingDto>;
16
+
17
+ export type PaymentLinkServiceParameters<CurrencyEnum> = {
18
+ CreatePaymentLinkDto: CreatePaymentLinkDto<CurrencyEnum>;
19
+ UpdatePaymentLinkDto: UpdatePaymentLinkDto<CurrencyEnum>;
20
+ PaymentLinkDto: PaymentLinkDto<CurrencyEnum>;
21
+ IdDto: IdDto;
22
+ IdsDto: IdsDto;
23
+ };
@@ -1,5 +1,4 @@
1
1
  import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
- import { EntityManager } from '@mikro-orm/core';
3
2
 
4
3
  export type CreatePlanDto<PlanCadenceEnum, BillingProviderEnum> = {
5
4
  active: boolean;
@@ -25,30 +24,3 @@ export type PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum> = {
25
24
  IdDto: IdDto;
26
25
  IdsDto: IdsDto;
27
26
  };
28
-
29
- export interface PlanService<
30
- PlanCadenceEnum,
31
- BillingProviderEnum,
32
- Params extends PlanServiceParameters<
33
- PlanCadenceEnum,
34
- BillingProviderEnum
35
- > = PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum>
36
- > {
37
- createPlan: (
38
- planDto: Params['CreatePlanDto'],
39
- em?: EntityManager
40
- ) => Promise<Params['PlanDto']>;
41
- getPlan: (
42
- idDto: Params['IdDto'],
43
- em?: EntityManager
44
- ) => Promise<Params['PlanDto']>;
45
- updatePlan: (
46
- planDto: Params['UpdatePlanDto'],
47
- em?: EntityManager
48
- ) => Promise<Params['PlanDto']>;
49
- deletePlan: (idDto: Params['IdDto'], em?: EntityManager) => Promise<void>;
50
- listPlans: (
51
- idsDto?: Params['IdsDto'],
52
- em?: EntityManager
53
- ) => Promise<Params['PlanDto'][]>;
54
- }
@@ -0,0 +1,28 @@
1
+ import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreateSubscriptionDto<PartyType, BillingProviderType> = {
4
+ partyId: string;
5
+ partyType: PartyType[keyof PartyType];
6
+ description?: string;
7
+ active: boolean;
8
+ productId: string;
9
+ extraFields?: unknown;
10
+ externalId: string;
11
+ billingProvider?: BillingProviderType[keyof BillingProviderType];
12
+ startDate: Date;
13
+ endDate: Date;
14
+ status: string;
15
+ };
16
+ export type UpdateSubscriptionDto<PartyType, BillingProviderType> = IdDto &
17
+ Partial<CreateSubscriptionDto<PartyType, BillingProviderType>>;
18
+ export type SubscriptionDto<PartyType, BillingProviderType> = IdDto &
19
+ CreateSubscriptionDto<PartyType, BillingProviderType> &
20
+ Partial<RecordTimingDto>;
21
+
22
+ export type SubscriptionServiceParameters<PartyType, BillingProviderType> = {
23
+ CreateSubscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>;
24
+ UpdateSubscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>;
25
+ SubscriptionDto: SubscriptionDto<PartyType, BillingProviderType>;
26
+ IdDto: IdDto;
27
+ IdsDto: IdsDto;
28
+ };
@@ -0,0 +1,19 @@
1
+ import { IdDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreateBillingPortalDto = {
4
+ customerId: string;
5
+ uri: string;
6
+ expiresAt: Date;
7
+ extraFields?: unknown;
8
+ };
9
+ export type UpdateBillingPortalDto = IdDto & Partial<CreateBillingPortalDto>;
10
+ export type BillingPortalDto = IdDto &
11
+ CreateBillingPortalDto &
12
+ Partial<RecordTimingDto>;
13
+
14
+ export type BillingPortalServiceParameters = {
15
+ CreateBillingPortalDto: CreateBillingPortalDto;
16
+ UpdateBillingPortalDto: UpdateBillingPortalDto;
17
+ BillingPortalDto: BillingPortalDto;
18
+ IdDto: IdDto;
19
+ };
@@ -0,0 +1,21 @@
1
+ import { IdDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreateCheckoutSessionDto<PaymentMethodEnum> = {
4
+ customerId: string;
5
+ paymentMethods: PaymentMethodEnum[keyof PaymentMethodEnum][];
6
+ metadata?: unknown;
7
+ successRedirectUri: string;
8
+ cancelRedirectUri: string;
9
+ extraFields?: unknown;
10
+ };
11
+ export type UpdateCheckoutSessionDto<PaymentMethodEnum> = IdDto &
12
+ Partial<CreateCheckoutSessionDto<PaymentMethodEnum>>;
13
+ export type CheckoutSessionDto<PaymentMethodEnum> = IdDto &
14
+ CreateCheckoutSessionDto<PaymentMethodEnum> &
15
+ Partial<RecordTimingDto>;
16
+
17
+ export type CheckoutSessionServiceParameters<PaymentMethodEnum> = {
18
+ CreateCheckoutSessionDto: CreateCheckoutSessionDto<PaymentMethodEnum>;
19
+ CheckoutSessionDto: CheckoutSessionDto<PaymentMethodEnum>;
20
+ IdDto: IdDto;
21
+ };
@@ -0,0 +1,5 @@
1
+ export * from './billingPortal.service.types';
2
+ export * from './checkoutSession.service.types';
3
+ export * from './paymentLink.service.types';
4
+ export * from './plan.service.types';
5
+ export * from './subscription.service.types';
@@ -0,0 +1,23 @@
1
+ import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreatePaymentLinkDto<CurrencyEnum> = {
4
+ amount: number;
5
+ currency: CurrencyEnum[keyof CurrencyEnum];
6
+ metadata?: unknown;
7
+ successRedirectUri: string;
8
+ cancelRedirectUri: string;
9
+ extraFields?: unknown;
10
+ };
11
+ export type UpdatePaymentLinkDto<CurrencyEnum> = IdDto &
12
+ Partial<CreatePaymentLinkDto<CurrencyEnum>>;
13
+ export type PaymentLinkDto<CurrencyEnum> = IdDto &
14
+ CreatePaymentLinkDto<CurrencyEnum> &
15
+ Partial<RecordTimingDto>;
16
+
17
+ export type PaymentLinkServiceParameters<CurrencyEnum> = {
18
+ CreatePaymentLinkDto: CreatePaymentLinkDto<CurrencyEnum>;
19
+ UpdatePaymentLinkDto: UpdatePaymentLinkDto<CurrencyEnum>;
20
+ PaymentLinkDto: PaymentLinkDto<CurrencyEnum>;
21
+ IdDto: IdDto;
22
+ IdsDto: IdsDto;
23
+ };
@@ -0,0 +1,26 @@
1
+ import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreatePlanDto<PlanCadenceEnum, BillingProviderEnum> = {
4
+ active: boolean;
5
+ name: string;
6
+ description?: string;
7
+ price: number;
8
+ cadence: PlanCadenceEnum[keyof PlanCadenceEnum];
9
+ features?: string[];
10
+ extraFields?: unknown;
11
+ externalId: string;
12
+ billingProvider?: BillingProviderEnum[keyof BillingProviderEnum];
13
+ };
14
+ export type UpdatePlanDto<PlanCadenceEnum, BillingProviderEnum> = IdDto &
15
+ Partial<CreatePlanDto<PlanCadenceEnum, BillingProviderEnum>>;
16
+ export type PlanDto<PlanCadenceEnum, BillingProviderEnum> = IdDto &
17
+ CreatePlanDto<PlanCadenceEnum, BillingProviderEnum> &
18
+ Partial<RecordTimingDto>;
19
+
20
+ export type PlanServiceParameters<PlanCadenceEnum, BillingProviderEnum> = {
21
+ CreatePlanDto: CreatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
22
+ UpdatePlanDto: UpdatePlanDto<PlanCadenceEnum, BillingProviderEnum>;
23
+ PlanDto: PlanDto<PlanCadenceEnum, BillingProviderEnum>;
24
+ IdDto: IdDto;
25
+ IdsDto: IdsDto;
26
+ };
@@ -0,0 +1,28 @@
1
+ import { IdDto, IdsDto, RecordTimingDto } from '@forklaunch/common';
2
+
3
+ export type CreateSubscriptionDto<PartyType, BillingProviderType> = {
4
+ partyId: string;
5
+ partyType: PartyType[keyof PartyType];
6
+ description?: string;
7
+ active: boolean;
8
+ productId: string;
9
+ extraFields?: unknown;
10
+ externalId: string;
11
+ billingProvider?: BillingProviderType[keyof BillingProviderType];
12
+ startDate: Date;
13
+ endDate: Date;
14
+ status: string;
15
+ };
16
+ export type UpdateSubscriptionDto<PartyType, BillingProviderType> = IdDto &
17
+ Partial<CreateSubscriptionDto<PartyType, BillingProviderType>>;
18
+ export type SubscriptionDto<PartyType, BillingProviderType> = IdDto &
19
+ CreateSubscriptionDto<PartyType, BillingProviderType> &
20
+ Partial<RecordTimingDto>;
21
+
22
+ export type SubscriptionServiceParameters<PartyType, BillingProviderType> = {
23
+ CreateSubscriptionDto: CreateSubscriptionDto<PartyType, BillingProviderType>;
24
+ UpdateSubscriptionDto: UpdateSubscriptionDto<PartyType, BillingProviderType>;
25
+ SubscriptionDto: SubscriptionDto<PartyType, BillingProviderType>;
26
+ IdDto: IdDto;
27
+ IdsDto: IdsDto;
28
+ };
package/lib/index.d.ts ADDED
@@ -0,0 +1,3 @@
1
+ export * from './interfaces';
2
+ export * from './types';
3
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './interfaces';
2
+ export * from './types';
@@ -0,0 +1,8 @@
1
+ import { BillingPortalServiceParameters } from '../types/billingPortal.service.types';
2
+ export interface BillingPortalService<Params extends BillingPortalServiceParameters = BillingPortalServiceParameters> {
3
+ createBillingPortalSession: (billingPortalDto: Params['CreateBillingPortalDto']) => Promise<Params['BillingPortalDto']>;
4
+ getBillingPortalSession: (idDto: Params['IdDto']) => Promise<Params['BillingPortalDto']>;
5
+ updateBillingPortalSession: (billingPortalDto: Params['UpdateBillingPortalDto']) => Promise<Params['BillingPortalDto']>;
6
+ expireBillingPortalSession: (idDto: Params['IdDto']) => Promise<void>;
7
+ }
8
+ //# sourceMappingURL=billingPortal.service.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"billingPortal.service.interface.d.ts","sourceRoot":"","sources":["../../interfaces/billingPortal.service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,8BAA8B,EAAE,MAAM,sCAAsC,CAAC;AAEtF,MAAM,WAAW,oBAAoB,CACnC,MAAM,SAAS,8BAA8B,GAAG,8BAA8B;IAI9E,0BAA0B,EAAE,CAC1B,gBAAgB,EAAE,MAAM,CAAC,wBAAwB,CAAC,KAC/C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACzC,uBAAuB,EAAE,CACvB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KACnB,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACzC,0BAA0B,EAAE,CAC1B,gBAAgB,EAAE,MAAM,CAAC,wBAAwB,CAAC,KAC/C,OAAO,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC;IACzC,0BAA0B,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACvE"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,9 @@
1
+ import { CheckoutSessionServiceParameters } from '../types/checkoutSession.service.types';
2
+ export interface CheckoutSessionService<PaymentMethodEnum, Params extends CheckoutSessionServiceParameters<PaymentMethodEnum> = CheckoutSessionServiceParameters<PaymentMethodEnum>> {
3
+ createCheckoutSession: (checkoutSessionDto: Params['CreateCheckoutSessionDto']) => Promise<Params['CheckoutSessionDto']>;
4
+ getCheckoutSession: (idDto: Params['IdDto']) => Promise<Params['CheckoutSessionDto']>;
5
+ expireCheckoutSession: (idDto: Params['IdDto']) => Promise<void>;
6
+ handleCheckoutSuccess: (idDto: Params['IdDto']) => Promise<void>;
7
+ handleCheckoutFailure: (idDto: Params['IdDto']) => Promise<void>;
8
+ }
9
+ //# sourceMappingURL=checkoutSession.service.interface.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"checkoutSession.service.interface.d.ts","sourceRoot":"","sources":["../../interfaces/checkoutSession.service.interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,gCAAgC,EAAE,MAAM,wCAAwC,CAAC;AAC1F,MAAM,WAAW,sBAAsB,CACrC,iBAAiB,EACjB,MAAM,SACJ,gCAAgC,CAAC,iBAAiB,CAAC,GAAG,gCAAgC,CAAC,iBAAiB,CAAC;IAI3G,qBAAqB,EAAE,CACrB,kBAAkB,EAAE,MAAM,CAAC,0BAA0B,CAAC,KACnD,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC3C,kBAAkB,EAAE,CAClB,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KACnB,OAAO,CAAC,MAAM,CAAC,oBAAoB,CAAC,CAAC,CAAC;IAC3C,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAEjE,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IACjE,qBAAqB,EAAE,CAAC,KAAK,EAAE,MAAM,CAAC,OAAO,CAAC,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CAClE"}
@@ -0,0 +1,6 @@
1
+ export * from './billingPortal.service.interface';
2
+ export * from './checkoutSession.service.interface';
3
+ export * from './paymentLink.service.interface';
4
+ export * from './plan.service.interface';
5
+ export * from './subscription.service.interface';
6
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../interfaces/index.ts"],"names":[],"mappings":"AAAA,cAAc,mCAAmC,CAAC;AAClD,cAAc,qCAAqC,CAAC;AACpD,cAAc,iCAAiC,CAAC;AAChD,cAAc,0BAA0B,CAAC;AACzC,cAAc,kCAAkC,CAAC"}
@@ -0,0 +1,5 @@
1
+ export * from './billingPortal.service.interface';
2
+ export * from './checkoutSession.service.interface';
3
+ export * from './paymentLink.service.interface';
4
+ export * from './plan.service.interface';
5
+ export * from './subscription.service.interface';