@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.
- package/lib/domain/enum/index.d.mts +6 -123
- package/lib/domain/enum/index.d.ts +6 -123
- package/lib/domain/enum/index.js +8 -0
- package/lib/domain/enum/index.mjs +7 -0
- package/lib/domain/schemas/index.d.mts +39 -39
- package/lib/domain/schemas/index.d.ts +39 -39
- package/lib/domain/schemas/index.js +8 -8
- package/lib/domain/schemas/index.mjs +8 -8
- package/lib/domain/types/index.d.mts +470 -66
- package/lib/domain/types/index.d.ts +470 -66
- package/lib/eject/domain/enum/index.ts +1 -0
- package/lib/eject/domain/enum/party.enum.ts +5 -0
- package/lib/eject/domain/schemas/plan.schema.ts +2 -2
- package/lib/eject/domain/schemas/subscription.schema.ts +2 -2
- package/lib/eject/domain/types/billingPortal.mapper.types.ts +7 -4
- package/lib/eject/domain/types/checkoutSession.mapper.types.ts +7 -4
- package/lib/eject/domain/types/paymentLink.mapper.types.ts +7 -4
- package/lib/eject/domain/types/plan.mapper.types.ts +9 -4
- package/lib/eject/domain/types/stripe.entity.types.ts +103 -63
- package/lib/eject/domain/types/stripeWebhookEvent.types.ts +16 -0
- package/lib/eject/domain/types/subscription.mapper.types.ts +10 -7
- package/lib/eject/services/checkoutSession.service.ts +5 -5
- package/lib/eject/services/paymentLink.service.ts +14 -12
- package/lib/eject/services/webhook.service.ts +4 -3
- package/lib/planCadence.enum-BKHaW1xa.d.mts +126 -0
- package/lib/planCadence.enum-BKHaW1xa.d.ts +126 -0
- package/lib/services/index.d.mts +19 -18
- package/lib/services/index.d.ts +19 -18
- package/lib/services/index.js +86 -14
- package/lib/services/index.mjs +86 -14
- package/package.json +10 -10
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
declare const BillingProviderEnum: {
|
|
2
|
+
readonly STRIPE: "stripe";
|
|
3
|
+
};
|
|
4
|
+
type BillingProviderEnum = (typeof BillingProviderEnum)[keyof typeof BillingProviderEnum];
|
|
5
|
+
|
|
6
|
+
declare const CurrencyEnum: {
|
|
7
|
+
readonly USD: "USD";
|
|
8
|
+
readonly EUR: "EUR";
|
|
9
|
+
readonly JPY: "JPY";
|
|
10
|
+
readonly GBP: "GBP";
|
|
11
|
+
readonly AUD: "AUD";
|
|
12
|
+
readonly CAD: "CAD";
|
|
13
|
+
readonly CHF: "CHF";
|
|
14
|
+
readonly CNY: "CNY";
|
|
15
|
+
readonly AED: "AED";
|
|
16
|
+
readonly ARS: "ARS";
|
|
17
|
+
readonly BAM: "BAM";
|
|
18
|
+
readonly BDT: "BDT";
|
|
19
|
+
readonly BGN: "BGN";
|
|
20
|
+
readonly BOB: "BOB";
|
|
21
|
+
readonly BRL: "BRL";
|
|
22
|
+
readonly CLP: "CLP";
|
|
23
|
+
readonly COP: "COP";
|
|
24
|
+
readonly CRC: "CRC";
|
|
25
|
+
readonly CZK: "CZK";
|
|
26
|
+
readonly DKK: "DKK";
|
|
27
|
+
readonly DZD: "DZD";
|
|
28
|
+
readonly EGP: "EGP";
|
|
29
|
+
readonly ETB: "ETB";
|
|
30
|
+
readonly GEL: "GEL";
|
|
31
|
+
readonly GTQ: "GTQ";
|
|
32
|
+
readonly HKD: "HKD";
|
|
33
|
+
readonly HUF: "HUF";
|
|
34
|
+
readonly IDR: "IDR";
|
|
35
|
+
readonly ILS: "ILS";
|
|
36
|
+
readonly INR: "INR";
|
|
37
|
+
readonly ISK: "ISK";
|
|
38
|
+
readonly JMD: "JMD";
|
|
39
|
+
readonly KES: "KES";
|
|
40
|
+
readonly KHR: "KHR";
|
|
41
|
+
readonly KRW: "KRW";
|
|
42
|
+
readonly KZT: "KZT";
|
|
43
|
+
readonly LAK: "LAK";
|
|
44
|
+
readonly LKR: "LKR";
|
|
45
|
+
readonly MAD: "MAD";
|
|
46
|
+
readonly MMK: "MMK";
|
|
47
|
+
readonly MXN: "MXN";
|
|
48
|
+
readonly MYR: "MYR";
|
|
49
|
+
readonly NGN: "NGN";
|
|
50
|
+
readonly NOK: "NOK";
|
|
51
|
+
readonly NPR: "NPR";
|
|
52
|
+
readonly NZD: "NZD";
|
|
53
|
+
readonly PEN: "PEN";
|
|
54
|
+
readonly PHP: "PHP";
|
|
55
|
+
readonly PKR: "PKR";
|
|
56
|
+
readonly PLN: "PLN";
|
|
57
|
+
readonly PYG: "PYG";
|
|
58
|
+
readonly QAR: "QAR";
|
|
59
|
+
readonly RON: "RON";
|
|
60
|
+
readonly RSD: "RSD";
|
|
61
|
+
readonly RUB: "RUB";
|
|
62
|
+
readonly SAR: "SAR";
|
|
63
|
+
readonly SEK: "SEK";
|
|
64
|
+
readonly SGD: "SGD";
|
|
65
|
+
readonly THB: "THB";
|
|
66
|
+
readonly TRY: "TRY";
|
|
67
|
+
readonly TWD: "TWD";
|
|
68
|
+
readonly TZS: "TZS";
|
|
69
|
+
readonly UAH: "UAH";
|
|
70
|
+
readonly UGX: "UGX";
|
|
71
|
+
readonly UYU: "UYU";
|
|
72
|
+
readonly VND: "VND";
|
|
73
|
+
readonly ZAR: "ZAR";
|
|
74
|
+
readonly ZMW: "ZMW";
|
|
75
|
+
};
|
|
76
|
+
type CurrencyEnum = (typeof CurrencyEnum)[keyof typeof CurrencyEnum];
|
|
77
|
+
|
|
78
|
+
declare const PaymentMethodEnum: {
|
|
79
|
+
readonly AFFIRM: "affirm";
|
|
80
|
+
readonly AFTERPAY_CLEARPAY: "afterpay_clearpay";
|
|
81
|
+
readonly ALIPAY: "alipay";
|
|
82
|
+
readonly ALMA: "alma";
|
|
83
|
+
readonly AU_BECS_DEBIT: "au_becs_debit";
|
|
84
|
+
readonly BACS_DEBIT: "bacs_debit";
|
|
85
|
+
readonly BANCONTACT: "bancontact";
|
|
86
|
+
readonly BILLIE: "billie";
|
|
87
|
+
readonly BLIK: "blik";
|
|
88
|
+
readonly BOLETO: "boleto";
|
|
89
|
+
readonly CARD: "card";
|
|
90
|
+
readonly CASHAPP: "cashapp";
|
|
91
|
+
readonly EPS: "eps";
|
|
92
|
+
readonly FPX: "fpx";
|
|
93
|
+
readonly GIROPAY: "giropay";
|
|
94
|
+
readonly GRABPAY: "grabpay";
|
|
95
|
+
readonly IDEAL: "ideal";
|
|
96
|
+
readonly KLARNA: "klarna";
|
|
97
|
+
readonly KONBINI: "konbini";
|
|
98
|
+
readonly LINK: "link";
|
|
99
|
+
readonly MOBILEPAY: "mobilepay";
|
|
100
|
+
readonly MULTIBANCO: "multibanco";
|
|
101
|
+
readonly OXXO: "oxxo";
|
|
102
|
+
readonly P24: "p24";
|
|
103
|
+
readonly PAY_BY_BANK: "pay_by_bank";
|
|
104
|
+
readonly PAYNOW: "paynow";
|
|
105
|
+
readonly PAYPAL: "paypal";
|
|
106
|
+
readonly PIX: "pix";
|
|
107
|
+
readonly PROMPTPAY: "promptpay";
|
|
108
|
+
readonly SATISPAY: "satispay";
|
|
109
|
+
readonly SEPA_DEBIT: "sepa_debit";
|
|
110
|
+
readonly SOFORT: "sofort";
|
|
111
|
+
readonly SWISH: "swish";
|
|
112
|
+
readonly TWINT: "twint";
|
|
113
|
+
readonly US_BANK_ACCOUNT: "us_bank_account";
|
|
114
|
+
readonly WECHAT_PAY: "wechat_pay";
|
|
115
|
+
readonly ZIP: "zip";
|
|
116
|
+
};
|
|
117
|
+
type PaymentMethodEnum = (typeof PaymentMethodEnum)[keyof typeof PaymentMethodEnum];
|
|
118
|
+
|
|
119
|
+
declare const PlanCadenceEnum: {
|
|
120
|
+
readonly WEEKLY: "week";
|
|
121
|
+
readonly MONTHLY: "month";
|
|
122
|
+
readonly ANNUALLY: "year";
|
|
123
|
+
};
|
|
124
|
+
type PlanCadenceEnum = (typeof PlanCadenceEnum)[keyof typeof PlanCadenceEnum];
|
|
125
|
+
|
|
126
|
+
export { BillingProviderEnum as B, CurrencyEnum as C, PaymentMethodEnum as P, PlanCadenceEnum as a };
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
declare const BillingProviderEnum: {
|
|
2
|
+
readonly STRIPE: "stripe";
|
|
3
|
+
};
|
|
4
|
+
type BillingProviderEnum = (typeof BillingProviderEnum)[keyof typeof BillingProviderEnum];
|
|
5
|
+
|
|
6
|
+
declare const CurrencyEnum: {
|
|
7
|
+
readonly USD: "USD";
|
|
8
|
+
readonly EUR: "EUR";
|
|
9
|
+
readonly JPY: "JPY";
|
|
10
|
+
readonly GBP: "GBP";
|
|
11
|
+
readonly AUD: "AUD";
|
|
12
|
+
readonly CAD: "CAD";
|
|
13
|
+
readonly CHF: "CHF";
|
|
14
|
+
readonly CNY: "CNY";
|
|
15
|
+
readonly AED: "AED";
|
|
16
|
+
readonly ARS: "ARS";
|
|
17
|
+
readonly BAM: "BAM";
|
|
18
|
+
readonly BDT: "BDT";
|
|
19
|
+
readonly BGN: "BGN";
|
|
20
|
+
readonly BOB: "BOB";
|
|
21
|
+
readonly BRL: "BRL";
|
|
22
|
+
readonly CLP: "CLP";
|
|
23
|
+
readonly COP: "COP";
|
|
24
|
+
readonly CRC: "CRC";
|
|
25
|
+
readonly CZK: "CZK";
|
|
26
|
+
readonly DKK: "DKK";
|
|
27
|
+
readonly DZD: "DZD";
|
|
28
|
+
readonly EGP: "EGP";
|
|
29
|
+
readonly ETB: "ETB";
|
|
30
|
+
readonly GEL: "GEL";
|
|
31
|
+
readonly GTQ: "GTQ";
|
|
32
|
+
readonly HKD: "HKD";
|
|
33
|
+
readonly HUF: "HUF";
|
|
34
|
+
readonly IDR: "IDR";
|
|
35
|
+
readonly ILS: "ILS";
|
|
36
|
+
readonly INR: "INR";
|
|
37
|
+
readonly ISK: "ISK";
|
|
38
|
+
readonly JMD: "JMD";
|
|
39
|
+
readonly KES: "KES";
|
|
40
|
+
readonly KHR: "KHR";
|
|
41
|
+
readonly KRW: "KRW";
|
|
42
|
+
readonly KZT: "KZT";
|
|
43
|
+
readonly LAK: "LAK";
|
|
44
|
+
readonly LKR: "LKR";
|
|
45
|
+
readonly MAD: "MAD";
|
|
46
|
+
readonly MMK: "MMK";
|
|
47
|
+
readonly MXN: "MXN";
|
|
48
|
+
readonly MYR: "MYR";
|
|
49
|
+
readonly NGN: "NGN";
|
|
50
|
+
readonly NOK: "NOK";
|
|
51
|
+
readonly NPR: "NPR";
|
|
52
|
+
readonly NZD: "NZD";
|
|
53
|
+
readonly PEN: "PEN";
|
|
54
|
+
readonly PHP: "PHP";
|
|
55
|
+
readonly PKR: "PKR";
|
|
56
|
+
readonly PLN: "PLN";
|
|
57
|
+
readonly PYG: "PYG";
|
|
58
|
+
readonly QAR: "QAR";
|
|
59
|
+
readonly RON: "RON";
|
|
60
|
+
readonly RSD: "RSD";
|
|
61
|
+
readonly RUB: "RUB";
|
|
62
|
+
readonly SAR: "SAR";
|
|
63
|
+
readonly SEK: "SEK";
|
|
64
|
+
readonly SGD: "SGD";
|
|
65
|
+
readonly THB: "THB";
|
|
66
|
+
readonly TRY: "TRY";
|
|
67
|
+
readonly TWD: "TWD";
|
|
68
|
+
readonly TZS: "TZS";
|
|
69
|
+
readonly UAH: "UAH";
|
|
70
|
+
readonly UGX: "UGX";
|
|
71
|
+
readonly UYU: "UYU";
|
|
72
|
+
readonly VND: "VND";
|
|
73
|
+
readonly ZAR: "ZAR";
|
|
74
|
+
readonly ZMW: "ZMW";
|
|
75
|
+
};
|
|
76
|
+
type CurrencyEnum = (typeof CurrencyEnum)[keyof typeof CurrencyEnum];
|
|
77
|
+
|
|
78
|
+
declare const PaymentMethodEnum: {
|
|
79
|
+
readonly AFFIRM: "affirm";
|
|
80
|
+
readonly AFTERPAY_CLEARPAY: "afterpay_clearpay";
|
|
81
|
+
readonly ALIPAY: "alipay";
|
|
82
|
+
readonly ALMA: "alma";
|
|
83
|
+
readonly AU_BECS_DEBIT: "au_becs_debit";
|
|
84
|
+
readonly BACS_DEBIT: "bacs_debit";
|
|
85
|
+
readonly BANCONTACT: "bancontact";
|
|
86
|
+
readonly BILLIE: "billie";
|
|
87
|
+
readonly BLIK: "blik";
|
|
88
|
+
readonly BOLETO: "boleto";
|
|
89
|
+
readonly CARD: "card";
|
|
90
|
+
readonly CASHAPP: "cashapp";
|
|
91
|
+
readonly EPS: "eps";
|
|
92
|
+
readonly FPX: "fpx";
|
|
93
|
+
readonly GIROPAY: "giropay";
|
|
94
|
+
readonly GRABPAY: "grabpay";
|
|
95
|
+
readonly IDEAL: "ideal";
|
|
96
|
+
readonly KLARNA: "klarna";
|
|
97
|
+
readonly KONBINI: "konbini";
|
|
98
|
+
readonly LINK: "link";
|
|
99
|
+
readonly MOBILEPAY: "mobilepay";
|
|
100
|
+
readonly MULTIBANCO: "multibanco";
|
|
101
|
+
readonly OXXO: "oxxo";
|
|
102
|
+
readonly P24: "p24";
|
|
103
|
+
readonly PAY_BY_BANK: "pay_by_bank";
|
|
104
|
+
readonly PAYNOW: "paynow";
|
|
105
|
+
readonly PAYPAL: "paypal";
|
|
106
|
+
readonly PIX: "pix";
|
|
107
|
+
readonly PROMPTPAY: "promptpay";
|
|
108
|
+
readonly SATISPAY: "satispay";
|
|
109
|
+
readonly SEPA_DEBIT: "sepa_debit";
|
|
110
|
+
readonly SOFORT: "sofort";
|
|
111
|
+
readonly SWISH: "swish";
|
|
112
|
+
readonly TWINT: "twint";
|
|
113
|
+
readonly US_BANK_ACCOUNT: "us_bank_account";
|
|
114
|
+
readonly WECHAT_PAY: "wechat_pay";
|
|
115
|
+
readonly ZIP: "zip";
|
|
116
|
+
};
|
|
117
|
+
type PaymentMethodEnum = (typeof PaymentMethodEnum)[keyof typeof PaymentMethodEnum];
|
|
118
|
+
|
|
119
|
+
declare const PlanCadenceEnum: {
|
|
120
|
+
readonly WEEKLY: "week";
|
|
121
|
+
readonly MONTHLY: "month";
|
|
122
|
+
readonly ANNUALLY: "year";
|
|
123
|
+
};
|
|
124
|
+
type PlanCadenceEnum = (typeof PlanCadenceEnum)[keyof typeof PlanCadenceEnum];
|
|
125
|
+
|
|
126
|
+
export { BillingProviderEnum as B, CurrencyEnum as C, PaymentMethodEnum as P, PlanCadenceEnum as a };
|
package/lib/services/index.d.mts
CHANGED
|
@@ -6,10 +6,11 @@ import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanS
|
|
|
6
6
|
export * from '@forklaunch/interfaces-billing/interfaces';
|
|
7
7
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
8
8
|
import { EntityManager } from '@mikro-orm/core';
|
|
9
|
-
import
|
|
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
|
-
import { PaymentMethodEnum, CurrencyEnum, PlanCadenceEnum, BillingProviderEnum } from '../
|
|
11
|
+
import { P as PaymentMethodEnum, C as CurrencyEnum, a as PlanCadenceEnum, B as BillingProviderEnum } from '../planCadence.enum-BKHaW1xa.mjs';
|
|
12
12
|
export * from '@forklaunch/interfaces-billing/types';
|
|
13
|
+
import '@forklaunch/core/persistence';
|
|
13
14
|
|
|
14
15
|
declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends StripeBillingPortalEntities, Dto extends StripeBillingPortalDtos = StripeBillingPortalDtos> implements BillingPortalService<{
|
|
15
16
|
CreateBillingPortalDto: Dto['CreateBillingPortalMapper'];
|
|
@@ -22,14 +23,14 @@ declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValida
|
|
|
22
23
|
telemetry?: TelemetryOptions;
|
|
23
24
|
} | undefined;
|
|
24
25
|
baseBillingPortalService: BaseBillingPortalService<SchemaValidator, Entities, Dto>;
|
|
25
|
-
protected readonly stripeClient:
|
|
26
|
+
protected readonly stripeClient: Stripe__default;
|
|
26
27
|
protected readonly em: EntityManager;
|
|
27
28
|
protected readonly cache: TtlCache;
|
|
28
29
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
29
30
|
protected readonly schemaValidator: SchemaValidator;
|
|
30
31
|
private readonly billingPortalSessionExpiryDurationMs;
|
|
31
32
|
protected readonly mappers: StripeBillingPortalMappers<Entities, Dto>;
|
|
32
|
-
constructor(stripeClient:
|
|
33
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripeBillingPortalMappers<Entities, Dto>, options?: {
|
|
33
34
|
enableDatabaseBackup?: boolean;
|
|
34
35
|
telemetry?: TelemetryOptions;
|
|
35
36
|
} | undefined);
|
|
@@ -39,7 +40,7 @@ declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValida
|
|
|
39
40
|
updateBillingPortalSession(billingPortalDto: StripeUpdateBillingPortalDto, ...args: unknown[]): Promise<Dto['BillingPortalMapper']>;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
declare class StripeCheckoutSessionService<SchemaValidator extends AnySchemaValidator, StatusEnum,
|
|
43
|
+
declare class StripeCheckoutSessionService<SchemaValidator extends AnySchemaValidator, StatusEnum, MapperEntities extends StripeCheckoutSessionEntities<StatusEnum>, Dto extends StripeCheckoutSessionDtos<StatusEnum> = StripeCheckoutSessionDtos<StatusEnum>> implements CheckoutSessionService<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum, {
|
|
43
44
|
CreateCheckoutSessionDto: Dto['CreateCheckoutSessionMapper'];
|
|
44
45
|
CheckoutSessionDto: Dto['CheckoutSessionMapper'];
|
|
45
46
|
IdDto: IdDto;
|
|
@@ -48,14 +49,14 @@ declare class StripeCheckoutSessionService<SchemaValidator extends AnySchemaVali
|
|
|
48
49
|
enableDatabaseBackup?: boolean;
|
|
49
50
|
telemetry?: TelemetryOptions;
|
|
50
51
|
} | undefined;
|
|
51
|
-
baseCheckoutSessionService: BaseCheckoutSessionService<SchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum,
|
|
52
|
-
protected readonly stripeClient:
|
|
52
|
+
baseCheckoutSessionService: BaseCheckoutSessionService<SchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities, Dto>;
|
|
53
|
+
protected readonly stripeClient: Stripe__default;
|
|
53
54
|
protected readonly em: EntityManager;
|
|
54
55
|
protected readonly cache: TtlCache;
|
|
55
56
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
56
57
|
protected readonly schemaValidator: SchemaValidator;
|
|
57
|
-
protected readonly mappers: StripeCheckoutSessionMappers<StatusEnum,
|
|
58
|
-
constructor(stripeClient:
|
|
58
|
+
protected readonly mappers: StripeCheckoutSessionMappers<StatusEnum, MapperEntities, Dto>;
|
|
59
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripeCheckoutSessionMappers<StatusEnum, MapperEntities, Dto>, options?: {
|
|
59
60
|
enableDatabaseBackup?: boolean;
|
|
60
61
|
telemetry?: TelemetryOptions;
|
|
61
62
|
} | undefined);
|
|
@@ -78,13 +79,13 @@ declare class StripePaymentLinkService<SchemaValidator extends AnySchemaValidato
|
|
|
78
79
|
telemetry?: TelemetryOptions;
|
|
79
80
|
} | undefined;
|
|
80
81
|
basePaymentLinkService: BasePaymentLinkService<SchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities, Dto>;
|
|
81
|
-
protected readonly stripeClient:
|
|
82
|
+
protected readonly stripeClient: Stripe__default;
|
|
82
83
|
protected readonly em: EntityManager;
|
|
83
84
|
protected readonly cache: TtlCache;
|
|
84
85
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
85
86
|
protected readonly schemaValidator: SchemaValidator;
|
|
86
87
|
protected readonly mappers: StripePaymentLinkMappers<StatusEnum, Entities, Dto>;
|
|
87
|
-
constructor(stripeClient:
|
|
88
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripePaymentLinkMappers<StatusEnum, Entities, Dto>, options?: {
|
|
88
89
|
enableDatabaseBackup?: boolean;
|
|
89
90
|
telemetry?: TelemetryOptions;
|
|
90
91
|
} | undefined);
|
|
@@ -109,12 +110,12 @@ declare class StripePlanService<SchemaValidator extends AnySchemaValidator, Enti
|
|
|
109
110
|
databaseTableName?: string;
|
|
110
111
|
} | undefined;
|
|
111
112
|
basePlanService: BasePlanService<SchemaValidator, PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Entities, Dto>;
|
|
112
|
-
protected readonly stripeClient:
|
|
113
|
+
protected readonly stripeClient: Stripe__default;
|
|
113
114
|
protected readonly em: EntityManager;
|
|
114
115
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
115
116
|
protected readonly schemaValidator: SchemaValidator;
|
|
116
117
|
protected readonly mappers: StripePlanMappers<Entities, Dto>;
|
|
117
|
-
constructor(stripeClient:
|
|
118
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripePlanMappers<Entities, Dto>, options?: {
|
|
118
119
|
telemetry?: TelemetryOptions;
|
|
119
120
|
databaseTableName?: string;
|
|
120
121
|
} | undefined);
|
|
@@ -137,12 +138,12 @@ declare class StripeSubscriptionService<SchemaValidator extends AnySchemaValidat
|
|
|
137
138
|
databaseTableName?: string;
|
|
138
139
|
} | undefined;
|
|
139
140
|
baseSubscriptionService: BaseSubscriptionService<SchemaValidator, PartyType, BillingProviderEnum, Entities, Dto>;
|
|
140
|
-
protected readonly stripeClient:
|
|
141
|
+
protected readonly stripeClient: Stripe__default;
|
|
141
142
|
protected readonly em: EntityManager;
|
|
142
143
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
143
144
|
protected readonly schemaValidator: SchemaValidator;
|
|
144
145
|
protected readonly mappers: StripeSubscriptionMappers<PartyType, Entities, Dto>;
|
|
145
|
-
constructor(stripeClient:
|
|
146
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripeSubscriptionMappers<PartyType, Entities, Dto>, options?: {
|
|
146
147
|
telemetry?: TelemetryOptions;
|
|
147
148
|
databaseTableName?: string;
|
|
148
149
|
} | undefined);
|
|
@@ -158,7 +159,7 @@ declare class StripeSubscriptionService<SchemaValidator extends AnySchemaValidat
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
declare class StripeWebhookService<SchemaValidator extends AnySchemaValidator, StatusEnum, PartyEnum, BillingPortalEntities extends StripeBillingPortalEntities = StripeBillingPortalEntities, CheckoutSessionEntities extends StripeCheckoutSessionEntities<StatusEnum> = StripeCheckoutSessionEntities<StatusEnum>, PaymentLinkEntities extends StripePaymentLinkEntities<StatusEnum> = StripePaymentLinkEntities<StatusEnum>, PlanEntities extends StripePlanEntities = StripePlanEntities, SubscriptionEntities extends StripeSubscriptionEntities<PartyEnum> = StripeSubscriptionEntities<PartyEnum>> {
|
|
161
|
-
protected readonly stripeClient:
|
|
162
|
+
protected readonly stripeClient: Stripe__default;
|
|
162
163
|
protected readonly em: EntityManager;
|
|
163
164
|
protected readonly schemaValidator: SchemaValidator;
|
|
164
165
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
@@ -167,7 +168,7 @@ declare class StripeWebhookService<SchemaValidator extends AnySchemaValidator, S
|
|
|
167
168
|
protected readonly paymentLinkService: StripePaymentLinkService<SchemaValidator, StatusEnum, PaymentLinkEntities>;
|
|
168
169
|
protected readonly planService: StripePlanService<SchemaValidator, PlanEntities>;
|
|
169
170
|
protected readonly subscriptionService: StripeSubscriptionService<SchemaValidator, PartyEnum, SubscriptionEntities>;
|
|
170
|
-
constructor(stripeClient:
|
|
171
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, schemaValidator: SchemaValidator, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, billingPortalService: StripeBillingPortalService<SchemaValidator, BillingPortalEntities>, checkoutSessionService: StripeCheckoutSessionService<SchemaValidator, StatusEnum, CheckoutSessionEntities>, paymentLinkService: StripePaymentLinkService<SchemaValidator, StatusEnum, PaymentLinkEntities>, planService: StripePlanService<SchemaValidator, PlanEntities>, subscriptionService: StripeSubscriptionService<SchemaValidator, PartyEnum, SubscriptionEntities>);
|
|
171
172
|
/**
|
|
172
173
|
* Extract features from Stripe product metadata.
|
|
173
174
|
* Features can be stored as:
|
|
@@ -175,7 +176,7 @@ declare class StripeWebhookService<SchemaValidator extends AnySchemaValidator, S
|
|
|
175
176
|
* - metadata.features: JSON array string (e.g., '["feature1","feature2"]')
|
|
176
177
|
*/
|
|
177
178
|
private extractFeaturesFromProduct;
|
|
178
|
-
handleWebhookEvent(event:
|
|
179
|
+
handleWebhookEvent(event: Stripe__default.Event): Promise<void>;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
export { StripeBillingPortalService, StripeCheckoutSessionService, StripePaymentLinkService, StripePlanService, StripeSubscriptionService, StripeWebhookService };
|
package/lib/services/index.d.ts
CHANGED
|
@@ -6,10 +6,11 @@ import { BillingPortalService, CheckoutSessionService, PaymentLinkService, PlanS
|
|
|
6
6
|
export * from '@forklaunch/interfaces-billing/interfaces';
|
|
7
7
|
import { AnySchemaValidator } from '@forklaunch/validator';
|
|
8
8
|
import { EntityManager } from '@mikro-orm/core';
|
|
9
|
-
import
|
|
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
|
-
import { PaymentMethodEnum, CurrencyEnum, PlanCadenceEnum, BillingProviderEnum } from '../
|
|
11
|
+
import { P as PaymentMethodEnum, C as CurrencyEnum, a as PlanCadenceEnum, B as BillingProviderEnum } from '../planCadence.enum-BKHaW1xa.js';
|
|
12
12
|
export * from '@forklaunch/interfaces-billing/types';
|
|
13
|
+
import '@forklaunch/core/persistence';
|
|
13
14
|
|
|
14
15
|
declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValidator, Entities extends StripeBillingPortalEntities, Dto extends StripeBillingPortalDtos = StripeBillingPortalDtos> implements BillingPortalService<{
|
|
15
16
|
CreateBillingPortalDto: Dto['CreateBillingPortalMapper'];
|
|
@@ -22,14 +23,14 @@ declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValida
|
|
|
22
23
|
telemetry?: TelemetryOptions;
|
|
23
24
|
} | undefined;
|
|
24
25
|
baseBillingPortalService: BaseBillingPortalService<SchemaValidator, Entities, Dto>;
|
|
25
|
-
protected readonly stripeClient:
|
|
26
|
+
protected readonly stripeClient: Stripe__default;
|
|
26
27
|
protected readonly em: EntityManager;
|
|
27
28
|
protected readonly cache: TtlCache;
|
|
28
29
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
29
30
|
protected readonly schemaValidator: SchemaValidator;
|
|
30
31
|
private readonly billingPortalSessionExpiryDurationMs;
|
|
31
32
|
protected readonly mappers: StripeBillingPortalMappers<Entities, Dto>;
|
|
32
|
-
constructor(stripeClient:
|
|
33
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripeBillingPortalMappers<Entities, Dto>, options?: {
|
|
33
34
|
enableDatabaseBackup?: boolean;
|
|
34
35
|
telemetry?: TelemetryOptions;
|
|
35
36
|
} | undefined);
|
|
@@ -39,7 +40,7 @@ declare class StripeBillingPortalService<SchemaValidator extends AnySchemaValida
|
|
|
39
40
|
updateBillingPortalSession(billingPortalDto: StripeUpdateBillingPortalDto, ...args: unknown[]): Promise<Dto['BillingPortalMapper']>;
|
|
40
41
|
}
|
|
41
42
|
|
|
42
|
-
declare class StripeCheckoutSessionService<SchemaValidator extends AnySchemaValidator, StatusEnum,
|
|
43
|
+
declare class StripeCheckoutSessionService<SchemaValidator extends AnySchemaValidator, StatusEnum, MapperEntities extends StripeCheckoutSessionEntities<StatusEnum>, Dto extends StripeCheckoutSessionDtos<StatusEnum> = StripeCheckoutSessionDtos<StatusEnum>> implements CheckoutSessionService<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum, {
|
|
43
44
|
CreateCheckoutSessionDto: Dto['CreateCheckoutSessionMapper'];
|
|
44
45
|
CheckoutSessionDto: Dto['CheckoutSessionMapper'];
|
|
45
46
|
IdDto: IdDto;
|
|
@@ -48,14 +49,14 @@ declare class StripeCheckoutSessionService<SchemaValidator extends AnySchemaVali
|
|
|
48
49
|
enableDatabaseBackup?: boolean;
|
|
49
50
|
telemetry?: TelemetryOptions;
|
|
50
51
|
} | undefined;
|
|
51
|
-
baseCheckoutSessionService: BaseCheckoutSessionService<SchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum,
|
|
52
|
-
protected readonly stripeClient:
|
|
52
|
+
baseCheckoutSessionService: BaseCheckoutSessionService<SchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, MapperEntities, Dto>;
|
|
53
|
+
protected readonly stripeClient: Stripe__default;
|
|
53
54
|
protected readonly em: EntityManager;
|
|
54
55
|
protected readonly cache: TtlCache;
|
|
55
56
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
56
57
|
protected readonly schemaValidator: SchemaValidator;
|
|
57
|
-
protected readonly mappers: StripeCheckoutSessionMappers<StatusEnum,
|
|
58
|
-
constructor(stripeClient:
|
|
58
|
+
protected readonly mappers: StripeCheckoutSessionMappers<StatusEnum, MapperEntities, Dto>;
|
|
59
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripeCheckoutSessionMappers<StatusEnum, MapperEntities, Dto>, options?: {
|
|
59
60
|
enableDatabaseBackup?: boolean;
|
|
60
61
|
telemetry?: TelemetryOptions;
|
|
61
62
|
} | undefined);
|
|
@@ -78,13 +79,13 @@ declare class StripePaymentLinkService<SchemaValidator extends AnySchemaValidato
|
|
|
78
79
|
telemetry?: TelemetryOptions;
|
|
79
80
|
} | undefined;
|
|
80
81
|
basePaymentLinkService: BasePaymentLinkService<SchemaValidator, PaymentMethodEnum, CurrencyEnum, StatusEnum, Entities, Dto>;
|
|
81
|
-
protected readonly stripeClient:
|
|
82
|
+
protected readonly stripeClient: Stripe__default;
|
|
82
83
|
protected readonly em: EntityManager;
|
|
83
84
|
protected readonly cache: TtlCache;
|
|
84
85
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
85
86
|
protected readonly schemaValidator: SchemaValidator;
|
|
86
87
|
protected readonly mappers: StripePaymentLinkMappers<StatusEnum, Entities, Dto>;
|
|
87
|
-
constructor(stripeClient:
|
|
88
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, cache: TtlCache, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripePaymentLinkMappers<StatusEnum, Entities, Dto>, options?: {
|
|
88
89
|
enableDatabaseBackup?: boolean;
|
|
89
90
|
telemetry?: TelemetryOptions;
|
|
90
91
|
} | undefined);
|
|
@@ -109,12 +110,12 @@ declare class StripePlanService<SchemaValidator extends AnySchemaValidator, Enti
|
|
|
109
110
|
databaseTableName?: string;
|
|
110
111
|
} | undefined;
|
|
111
112
|
basePlanService: BasePlanService<SchemaValidator, PlanCadenceEnum, CurrencyEnum, BillingProviderEnum, Entities, Dto>;
|
|
112
|
-
protected readonly stripeClient:
|
|
113
|
+
protected readonly stripeClient: Stripe__default;
|
|
113
114
|
protected readonly em: EntityManager;
|
|
114
115
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
115
116
|
protected readonly schemaValidator: SchemaValidator;
|
|
116
117
|
protected readonly mappers: StripePlanMappers<Entities, Dto>;
|
|
117
|
-
constructor(stripeClient:
|
|
118
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripePlanMappers<Entities, Dto>, options?: {
|
|
118
119
|
telemetry?: TelemetryOptions;
|
|
119
120
|
databaseTableName?: string;
|
|
120
121
|
} | undefined);
|
|
@@ -137,12 +138,12 @@ declare class StripeSubscriptionService<SchemaValidator extends AnySchemaValidat
|
|
|
137
138
|
databaseTableName?: string;
|
|
138
139
|
} | undefined;
|
|
139
140
|
baseSubscriptionService: BaseSubscriptionService<SchemaValidator, PartyType, BillingProviderEnum, Entities, Dto>;
|
|
140
|
-
protected readonly stripeClient:
|
|
141
|
+
protected readonly stripeClient: Stripe__default;
|
|
141
142
|
protected readonly em: EntityManager;
|
|
142
143
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
143
144
|
protected readonly schemaValidator: SchemaValidator;
|
|
144
145
|
protected readonly mappers: StripeSubscriptionMappers<PartyType, Entities, Dto>;
|
|
145
|
-
constructor(stripeClient:
|
|
146
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, schemaValidator: SchemaValidator, mappers: StripeSubscriptionMappers<PartyType, Entities, Dto>, options?: {
|
|
146
147
|
telemetry?: TelemetryOptions;
|
|
147
148
|
databaseTableName?: string;
|
|
148
149
|
} | undefined);
|
|
@@ -158,7 +159,7 @@ declare class StripeSubscriptionService<SchemaValidator extends AnySchemaValidat
|
|
|
158
159
|
}
|
|
159
160
|
|
|
160
161
|
declare class StripeWebhookService<SchemaValidator extends AnySchemaValidator, StatusEnum, PartyEnum, BillingPortalEntities extends StripeBillingPortalEntities = StripeBillingPortalEntities, CheckoutSessionEntities extends StripeCheckoutSessionEntities<StatusEnum> = StripeCheckoutSessionEntities<StatusEnum>, PaymentLinkEntities extends StripePaymentLinkEntities<StatusEnum> = StripePaymentLinkEntities<StatusEnum>, PlanEntities extends StripePlanEntities = StripePlanEntities, SubscriptionEntities extends StripeSubscriptionEntities<PartyEnum> = StripeSubscriptionEntities<PartyEnum>> {
|
|
161
|
-
protected readonly stripeClient:
|
|
162
|
+
protected readonly stripeClient: Stripe__default;
|
|
162
163
|
protected readonly em: EntityManager;
|
|
163
164
|
protected readonly schemaValidator: SchemaValidator;
|
|
164
165
|
protected readonly openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>;
|
|
@@ -167,7 +168,7 @@ declare class StripeWebhookService<SchemaValidator extends AnySchemaValidator, S
|
|
|
167
168
|
protected readonly paymentLinkService: StripePaymentLinkService<SchemaValidator, StatusEnum, PaymentLinkEntities>;
|
|
168
169
|
protected readonly planService: StripePlanService<SchemaValidator, PlanEntities>;
|
|
169
170
|
protected readonly subscriptionService: StripeSubscriptionService<SchemaValidator, PartyEnum, SubscriptionEntities>;
|
|
170
|
-
constructor(stripeClient:
|
|
171
|
+
constructor(stripeClient: Stripe__default, em: EntityManager, schemaValidator: SchemaValidator, openTelemetryCollector: OpenTelemetryCollector<MetricsDefinition>, billingPortalService: StripeBillingPortalService<SchemaValidator, BillingPortalEntities>, checkoutSessionService: StripeCheckoutSessionService<SchemaValidator, StatusEnum, CheckoutSessionEntities>, paymentLinkService: StripePaymentLinkService<SchemaValidator, StatusEnum, PaymentLinkEntities>, planService: StripePlanService<SchemaValidator, PlanEntities>, subscriptionService: StripeSubscriptionService<SchemaValidator, PartyEnum, SubscriptionEntities>);
|
|
171
172
|
/**
|
|
172
173
|
* Extract features from Stripe product metadata.
|
|
173
174
|
* Features can be stored as:
|
|
@@ -175,7 +176,7 @@ declare class StripeWebhookService<SchemaValidator extends AnySchemaValidator, S
|
|
|
175
176
|
* - metadata.features: JSON array string (e.g., '["feature1","feature2"]')
|
|
176
177
|
*/
|
|
177
178
|
private extractFeaturesFromProduct;
|
|
178
|
-
handleWebhookEvent(event:
|
|
179
|
+
handleWebhookEvent(event: Stripe__default.Event): Promise<void>;
|
|
179
180
|
}
|
|
180
181
|
|
|
181
182
|
export { StripeBillingPortalService, StripeCheckoutSessionService, StripePaymentLinkService, StripePlanService, StripeSubscriptionService, StripeWebhookService };
|
package/lib/services/index.js
CHANGED
|
@@ -245,17 +245,19 @@ var StripePaymentLinkService = class {
|
|
|
245
245
|
}
|
|
246
246
|
);
|
|
247
247
|
const paymentLink = await this.basePaymentLinkService.updatePaymentLink(
|
|
248
|
-
await this.mappers.
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
248
|
+
await this.mappers.PaymentLinkMapper.toDto(
|
|
249
|
+
await this.mappers.UpdatePaymentLinkMapper.toEntity(
|
|
250
|
+
{
|
|
251
|
+
...paymentLinkDto,
|
|
252
|
+
id: session.id,
|
|
253
|
+
amount: session.line_items?.data.reduce(
|
|
254
|
+
(total, item) => total + item.amount_total,
|
|
255
|
+
0
|
|
256
|
+
) ?? 0
|
|
257
|
+
},
|
|
258
|
+
this.em,
|
|
259
|
+
session
|
|
260
|
+
)
|
|
259
261
|
),
|
|
260
262
|
...args
|
|
261
263
|
);
|
|
@@ -613,12 +615,82 @@ var StripeSubscriptionService = class {
|
|
|
613
615
|
}
|
|
614
616
|
};
|
|
615
617
|
|
|
616
|
-
//
|
|
618
|
+
// domain/enum/party.enum.ts
|
|
617
619
|
var PartyEnum = {
|
|
618
620
|
USER: "user",
|
|
619
621
|
ORGANIZATION: "organization"
|
|
620
622
|
};
|
|
621
623
|
|
|
624
|
+
// persistence/entities/index.ts
|
|
625
|
+
var import_persistence = require("@forklaunch/core/persistence");
|
|
626
|
+
var BillingPortal = (0, import_persistence.defineComplianceEntity)({
|
|
627
|
+
name: "BillingPortal",
|
|
628
|
+
properties: {
|
|
629
|
+
id: import_persistence.fp.string().primary().compliance("none"),
|
|
630
|
+
customerId: import_persistence.fp.string().compliance("none"),
|
|
631
|
+
providerFields: import_persistence.fp.json().compliance("none")
|
|
632
|
+
}
|
|
633
|
+
});
|
|
634
|
+
var CheckoutSession = (0, import_persistence.defineComplianceEntity)({
|
|
635
|
+
name: "CheckoutSession",
|
|
636
|
+
properties: {
|
|
637
|
+
id: import_persistence.fp.string().primary().compliance("none"),
|
|
638
|
+
customerId: import_persistence.fp.string().compliance("none"),
|
|
639
|
+
paymentMethods: import_persistence.fp.enum().array().compliance("none"),
|
|
640
|
+
currency: import_persistence.fp.enum().compliance("none"),
|
|
641
|
+
status: import_persistence.fp.enum().compliance("none"),
|
|
642
|
+
providerFields: import_persistence.fp.json().compliance("none")
|
|
643
|
+
}
|
|
644
|
+
});
|
|
645
|
+
var PaymentLink = (0, import_persistence.defineComplianceEntity)({
|
|
646
|
+
name: "PaymentLink",
|
|
647
|
+
properties: {
|
|
648
|
+
id: import_persistence.fp.string().primary().compliance("none"),
|
|
649
|
+
amount: import_persistence.fp.double().compliance("none"),
|
|
650
|
+
paymentMethods: import_persistence.fp.enum().array().compliance("none"),
|
|
651
|
+
currency: import_persistence.fp.enum().compliance("none"),
|
|
652
|
+
status: import_persistence.fp.enum().compliance("none"),
|
|
653
|
+
providerFields: import_persistence.fp.json().compliance("none")
|
|
654
|
+
}
|
|
655
|
+
});
|
|
656
|
+
var Plan = (0, import_persistence.defineComplianceEntity)({
|
|
657
|
+
name: "Plan",
|
|
658
|
+
properties: {
|
|
659
|
+
id: import_persistence.fp.string().primary().compliance("none"),
|
|
660
|
+
name: import_persistence.fp.string().compliance("none"),
|
|
661
|
+
price: import_persistence.fp.double().compliance("none"),
|
|
662
|
+
externalId: import_persistence.fp.string().compliance("none"),
|
|
663
|
+
cadence: import_persistence.fp.enum().compliance("none"),
|
|
664
|
+
currency: import_persistence.fp.enum().compliance("none"),
|
|
665
|
+
billingProvider: import_persistence.fp.enum().compliance("none"),
|
|
666
|
+
providerFields: import_persistence.fp.json().compliance("none")
|
|
667
|
+
}
|
|
668
|
+
});
|
|
669
|
+
var Subscription = (0, import_persistence.defineComplianceEntity)({
|
|
670
|
+
name: "Subscription",
|
|
671
|
+
properties: {
|
|
672
|
+
id: import_persistence.fp.string().primary().compliance("none"),
|
|
673
|
+
partyId: import_persistence.fp.string().compliance("none"),
|
|
674
|
+
externalId: import_persistence.fp.string().compliance("none"),
|
|
675
|
+
partyType: import_persistence.fp.enum().compliance("none"),
|
|
676
|
+
billingProvider: import_persistence.fp.enum().compliance("none"),
|
|
677
|
+
active: import_persistence.fp.boolean().compliance("none"),
|
|
678
|
+
providerFields: import_persistence.fp.json().compliance("none")
|
|
679
|
+
}
|
|
680
|
+
});
|
|
681
|
+
var StripeWebhookEvent = (0, import_persistence.defineComplianceEntity)({
|
|
682
|
+
name: "StripeWebhookEvent",
|
|
683
|
+
properties: {
|
|
684
|
+
id: import_persistence.fp.uuid().primary().compliance("none"),
|
|
685
|
+
createdAt: import_persistence.fp.datetime().onCreate(() => /* @__PURE__ */ new Date()).compliance("none"),
|
|
686
|
+
updatedAt: import_persistence.fp.datetime().onCreate(() => /* @__PURE__ */ new Date()).onUpdate(() => /* @__PURE__ */ new Date()).compliance("none"),
|
|
687
|
+
stripeId: import_persistence.fp.string().compliance("none"),
|
|
688
|
+
idempotencyKey: import_persistence.fp.string().nullable().compliance("none"),
|
|
689
|
+
eventType: import_persistence.fp.string().compliance("none"),
|
|
690
|
+
eventData: import_persistence.fp.json().compliance("none")
|
|
691
|
+
}
|
|
692
|
+
});
|
|
693
|
+
|
|
622
694
|
// domain/enum/billingProvider.enum.ts
|
|
623
695
|
var BillingProviderEnum = {
|
|
624
696
|
STRIPE: "stripe"
|
|
@@ -670,7 +742,7 @@ var StripeWebhookService = class {
|
|
|
670
742
|
if (this.openTelemetryCollector) {
|
|
671
743
|
this.openTelemetryCollector.info("Handling webhook event", event);
|
|
672
744
|
}
|
|
673
|
-
if (await this.em.findOne(
|
|
745
|
+
if (await this.em.findOne(StripeWebhookEvent, {
|
|
674
746
|
idempotencyKey: event.request?.idempotency_key
|
|
675
747
|
})) {
|
|
676
748
|
this.openTelemetryCollector.info(
|
|
@@ -915,7 +987,7 @@ var StripeWebhookService = class {
|
|
|
915
987
|
);
|
|
916
988
|
break;
|
|
917
989
|
}
|
|
918
|
-
await this.em.insert(
|
|
990
|
+
await this.em.insert(StripeWebhookEvent, {
|
|
919
991
|
stripeId: event.id,
|
|
920
992
|
idempotencyKey: event.request?.idempotency_key,
|
|
921
993
|
eventType: event.type,
|