@forklaunch/implementation-billing-stripe 0.3.5 → 0.4.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 +112 -119
- package/lib/domain/enum/index.d.ts +112 -119
- package/lib/domain/enum/index.js +119 -124
- package/lib/domain/enum/index.mjs +109 -109
- package/lib/domain/schemas/index.d.mts +323 -2914
- package/lib/domain/schemas/index.d.ts +323 -2914
- package/lib/domain/schemas/index.js +181 -257
- package/lib/domain/schemas/index.mjs +130 -131
- package/lib/domain/types/index.d.mts +135 -375
- package/lib/domain/types/index.d.ts +135 -375
- package/lib/domain/types/index.js +4 -8
- package/lib/eject/services/webhook.service.ts +21 -0
- package/lib/services/index.d.mts +148 -461
- package/lib/services/index.d.ts +148 -461
- package/lib/services/index.js +147 -229
- package/lib/services/index.mjs +119 -194
- package/package.json +11 -11
|
@@ -1,424 +1,184 @@
|
|
|
1
1
|
import { EntityManager } from '@mikro-orm/core';
|
|
2
2
|
import stripe__default from 'stripe';
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
CreateBillingPortalDto,
|
|
6
|
-
UpdateBillingPortalDto,
|
|
7
|
-
CheckoutSessionDto,
|
|
8
|
-
CreateCheckoutSessionDto,
|
|
9
|
-
UpdateCheckoutSessionDto,
|
|
10
|
-
PaymentLinkDto,
|
|
11
|
-
CreatePaymentLinkDto,
|
|
12
|
-
UpdatePaymentLinkDto,
|
|
13
|
-
PlanDto,
|
|
14
|
-
CreatePlanDto,
|
|
15
|
-
UpdatePlanDto,
|
|
16
|
-
SubscriptionDto,
|
|
17
|
-
CreateSubscriptionDto,
|
|
18
|
-
UpdateSubscriptionDto
|
|
19
|
-
} from '@forklaunch/interfaces-billing/types';
|
|
20
|
-
import {
|
|
21
|
-
PaymentMethodEnum,
|
|
22
|
-
CurrencyEnum,
|
|
23
|
-
PlanCadenceEnum,
|
|
24
|
-
BillingProviderEnum
|
|
25
|
-
} from '../enum/index.js';
|
|
3
|
+
import { BillingPortalDto, CreateBillingPortalDto, UpdateBillingPortalDto, CheckoutSessionDto, CreateCheckoutSessionDto, UpdateCheckoutSessionDto, PaymentLinkDto, CreatePaymentLinkDto, UpdatePaymentLinkDto, PlanDto, CreatePlanDto, UpdatePlanDto, SubscriptionDto, CreateSubscriptionDto, UpdateSubscriptionDto } from '@forklaunch/interfaces-billing/types';
|
|
4
|
+
import { PaymentMethodEnum, CurrencyEnum, PlanCadenceEnum, BillingProviderEnum } from '../enum/index.js';
|
|
26
5
|
|
|
27
6
|
type BillingPortalOmissions = 'customer';
|
|
28
|
-
type StripeCreateBillingPortalDto = Omit<
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
> & {
|
|
32
|
-
|
|
33
|
-
stripe__default.BillingPortal.SessionCreateParams,
|
|
34
|
-
BillingPortalOmissions
|
|
35
|
-
>;
|
|
36
|
-
};
|
|
37
|
-
type StripeUpdateBillingPortalDto = Omit<
|
|
38
|
-
UpdateBillingPortalDto,
|
|
39
|
-
'providerFields'
|
|
40
|
-
> & {
|
|
41
|
-
stripeFields?: Omit<
|
|
42
|
-
stripe__default.BillingPortal.SessionCreateParams,
|
|
43
|
-
BillingPortalOmissions
|
|
44
|
-
>;
|
|
7
|
+
type StripeCreateBillingPortalDto = Omit<CreateBillingPortalDto, 'providerFields'> & {
|
|
8
|
+
stripeFields: Omit<stripe__default.BillingPortal.SessionCreateParams, BillingPortalOmissions>;
|
|
9
|
+
};
|
|
10
|
+
type StripeUpdateBillingPortalDto = Omit<UpdateBillingPortalDto, 'providerFields'> & {
|
|
11
|
+
stripeFields?: Omit<stripe__default.BillingPortal.SessionCreateParams, BillingPortalOmissions>;
|
|
45
12
|
};
|
|
46
13
|
type StripeBillingPortalDto = Omit<BillingPortalDto, 'providerFields'> & {
|
|
47
|
-
|
|
14
|
+
stripeFields: stripe__default.BillingPortal.Session;
|
|
48
15
|
};
|
|
49
16
|
type StripeBillingPortalDtos = {
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
};
|
|
54
|
-
type CheckoutSessionOmissions =
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
type
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
'providerFields' | 'uri'
|
|
66
|
-
> & {
|
|
67
|
-
uri: string;
|
|
68
|
-
stripeFields: Omit<
|
|
69
|
-
stripe__default.Checkout.SessionCreateParams,
|
|
70
|
-
CheckoutSessionOmissions
|
|
71
|
-
>;
|
|
72
|
-
};
|
|
73
|
-
type StripeUpdateCheckoutSessionDto<StatusEnum> = Omit<
|
|
74
|
-
UpdateCheckoutSessionDto<
|
|
75
|
-
typeof PaymentMethodEnum,
|
|
76
|
-
typeof CurrencyEnum,
|
|
77
|
-
StatusEnum
|
|
78
|
-
>,
|
|
79
|
-
'providerFields'
|
|
80
|
-
> & {
|
|
81
|
-
stripeFields?: Omit<
|
|
82
|
-
stripe__default.Checkout.SessionCreateParams,
|
|
83
|
-
CheckoutSessionOmissions
|
|
84
|
-
>;
|
|
85
|
-
};
|
|
86
|
-
type StripeCheckoutSessionDto<StatusEnum> = Omit<
|
|
87
|
-
CheckoutSessionDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>,
|
|
88
|
-
'providerFields' | 'uri'
|
|
89
|
-
> & {
|
|
90
|
-
uri: string;
|
|
91
|
-
stripeFields: stripe__default.Checkout.Session;
|
|
17
|
+
BillingPortalMapper: StripeBillingPortalDto;
|
|
18
|
+
CreateBillingPortalMapper: StripeCreateBillingPortalDto;
|
|
19
|
+
UpdateBillingPortalMapper: StripeUpdateBillingPortalDto;
|
|
20
|
+
};
|
|
21
|
+
type CheckoutSessionOmissions = 'payment_method_types' | 'currency' | 'success_url' | 'cancel_url';
|
|
22
|
+
type StripeCreateCheckoutSessionDto<StatusEnum> = Omit<CreateCheckoutSessionDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>, 'providerFields' | 'uri'> & {
|
|
23
|
+
uri: string;
|
|
24
|
+
stripeFields: Omit<stripe__default.Checkout.SessionCreateParams, CheckoutSessionOmissions>;
|
|
25
|
+
};
|
|
26
|
+
type StripeUpdateCheckoutSessionDto<StatusEnum> = Omit<UpdateCheckoutSessionDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>, 'providerFields'> & {
|
|
27
|
+
stripeFields?: Omit<stripe__default.Checkout.SessionCreateParams, CheckoutSessionOmissions>;
|
|
28
|
+
};
|
|
29
|
+
type StripeCheckoutSessionDto<StatusEnum> = Omit<CheckoutSessionDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>, 'providerFields' | 'uri'> & {
|
|
30
|
+
uri: string;
|
|
31
|
+
stripeFields: stripe__default.Checkout.Session;
|
|
92
32
|
};
|
|
93
33
|
type StripeCheckoutSessionDtos<StatusEnum> = {
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
};
|
|
98
|
-
type StripeCreatePaymentLinkDto<StatusEnum> = Omit<
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
stripeFields: stripe__default.PaymentLinkCreateParams;
|
|
107
|
-
};
|
|
108
|
-
type StripeUpdatePaymentLinkDto<StatusEnum> = Omit<
|
|
109
|
-
UpdatePaymentLinkDto<
|
|
110
|
-
typeof PaymentMethodEnum,
|
|
111
|
-
typeof CurrencyEnum,
|
|
112
|
-
StatusEnum
|
|
113
|
-
>,
|
|
114
|
-
'providerFields'
|
|
115
|
-
> & {
|
|
116
|
-
stripeFields?: stripe__default.PaymentLinkUpdateParams;
|
|
117
|
-
};
|
|
118
|
-
type StripePaymentLinkDto<StatusEnum> = Omit<
|
|
119
|
-
PaymentLinkDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>,
|
|
120
|
-
'providerFields'
|
|
121
|
-
> & {
|
|
122
|
-
stripeFields: stripe__default.PaymentLink;
|
|
34
|
+
CheckoutSessionMapper: StripeCheckoutSessionDto<StatusEnum>;
|
|
35
|
+
CreateCheckoutSessionMapper: StripeCreateCheckoutSessionDto<StatusEnum>;
|
|
36
|
+
UpdateCheckoutSessionMapper: StripeUpdateCheckoutSessionDto<StatusEnum>;
|
|
37
|
+
};
|
|
38
|
+
type StripeCreatePaymentLinkDto<StatusEnum> = Omit<CreatePaymentLinkDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>, 'providerFields'> & {
|
|
39
|
+
stripeFields: stripe__default.PaymentLinkCreateParams;
|
|
40
|
+
};
|
|
41
|
+
type StripeUpdatePaymentLinkDto<StatusEnum> = Omit<UpdatePaymentLinkDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>, 'providerFields'> & {
|
|
42
|
+
stripeFields?: stripe__default.PaymentLinkUpdateParams;
|
|
43
|
+
};
|
|
44
|
+
type StripePaymentLinkDto<StatusEnum> = Omit<PaymentLinkDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum>, 'providerFields'> & {
|
|
45
|
+
stripeFields: stripe__default.PaymentLink;
|
|
123
46
|
};
|
|
124
47
|
type StripePaymentLinkDtos<StatusEnum> = {
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
48
|
+
PaymentLinkMapper: StripePaymentLinkDto<StatusEnum>;
|
|
49
|
+
CreatePaymentLinkMapper: StripeCreatePaymentLinkDto<StatusEnum>;
|
|
50
|
+
UpdatePaymentLinkMapper: StripeUpdatePaymentLinkDto<StatusEnum>;
|
|
128
51
|
};
|
|
129
52
|
type PlanOmissions = 'product' | 'interval' | 'currency';
|
|
130
|
-
type StripeCreatePlanDto = Omit<
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
stripeFields: Omit<stripe__default.PlanCreateParams, PlanOmissions>;
|
|
139
|
-
};
|
|
140
|
-
type StripeUpdatePlanDto = Omit<
|
|
141
|
-
UpdatePlanDto<
|
|
142
|
-
typeof PlanCadenceEnum,
|
|
143
|
-
typeof CurrencyEnum,
|
|
144
|
-
typeof BillingProviderEnum
|
|
145
|
-
>,
|
|
146
|
-
'providerFields'
|
|
147
|
-
> & {
|
|
148
|
-
stripeFields?: Omit<stripe__default.PlanUpdateParams, PlanOmissions>;
|
|
149
|
-
};
|
|
150
|
-
type StripePlanDto = Omit<
|
|
151
|
-
PlanDto<
|
|
152
|
-
typeof PlanCadenceEnum,
|
|
153
|
-
typeof CurrencyEnum,
|
|
154
|
-
typeof BillingProviderEnum
|
|
155
|
-
>,
|
|
156
|
-
'providerFields'
|
|
157
|
-
> & {
|
|
158
|
-
stripeFields: stripe__default.Plan;
|
|
53
|
+
type StripeCreatePlanDto = Omit<CreatePlanDto<typeof PlanCadenceEnum, typeof CurrencyEnum, typeof BillingProviderEnum>, 'providerFields'> & {
|
|
54
|
+
stripeFields: Omit<stripe__default.PlanCreateParams, PlanOmissions>;
|
|
55
|
+
};
|
|
56
|
+
type StripeUpdatePlanDto = Omit<UpdatePlanDto<typeof PlanCadenceEnum, typeof CurrencyEnum, typeof BillingProviderEnum>, 'providerFields'> & {
|
|
57
|
+
stripeFields?: Omit<stripe__default.PlanUpdateParams, PlanOmissions>;
|
|
58
|
+
};
|
|
59
|
+
type StripePlanDto = Omit<PlanDto<typeof PlanCadenceEnum, typeof CurrencyEnum, typeof BillingProviderEnum>, 'providerFields'> & {
|
|
60
|
+
stripeFields: stripe__default.Plan;
|
|
159
61
|
};
|
|
160
62
|
type StripePlanDtos = {
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
63
|
+
PlanMapper: StripePlanDto;
|
|
64
|
+
CreatePlanMapper: StripeCreatePlanDto;
|
|
65
|
+
UpdatePlanMapper: StripeUpdatePlanDto;
|
|
164
66
|
};
|
|
165
67
|
type SubscriptionOmissions = 'items' | 'customer';
|
|
166
|
-
type StripeCreateSubscriptionDto<PartyType> = Omit<
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
> & {
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
};
|
|
175
|
-
type StripeUpdateSubscriptionDto<PartyType> = Omit<
|
|
176
|
-
UpdateSubscriptionDto<PartyType, typeof BillingProviderEnum>,
|
|
177
|
-
'providerFields'
|
|
178
|
-
> & {
|
|
179
|
-
stripeFields?: Omit<
|
|
180
|
-
stripe__default.SubscriptionUpdateParams,
|
|
181
|
-
SubscriptionOmissions
|
|
182
|
-
>;
|
|
183
|
-
};
|
|
184
|
-
type StripeSubscriptionDto<PartyType> = Omit<
|
|
185
|
-
SubscriptionDto<PartyType, typeof BillingProviderEnum>,
|
|
186
|
-
'providerFields'
|
|
187
|
-
> & {
|
|
188
|
-
stripeFields: stripe__default.Subscription;
|
|
68
|
+
type StripeCreateSubscriptionDto<PartyType> = Omit<CreateSubscriptionDto<PartyType, typeof BillingProviderEnum>, 'providerFields'> & {
|
|
69
|
+
stripeFields: Omit<stripe__default.SubscriptionCreateParams, SubscriptionOmissions>;
|
|
70
|
+
};
|
|
71
|
+
type StripeUpdateSubscriptionDto<PartyType> = Omit<UpdateSubscriptionDto<PartyType, typeof BillingProviderEnum>, 'providerFields'> & {
|
|
72
|
+
stripeFields?: Omit<stripe__default.SubscriptionUpdateParams, SubscriptionOmissions>;
|
|
73
|
+
};
|
|
74
|
+
type StripeSubscriptionDto<PartyType> = Omit<SubscriptionDto<PartyType, typeof BillingProviderEnum>, 'providerFields'> & {
|
|
75
|
+
stripeFields: stripe__default.Subscription;
|
|
189
76
|
};
|
|
190
77
|
type StripeSubscriptionDtos<PartyType> = {
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
78
|
+
SubscriptionMapper: StripeSubscriptionDto<PartyType>;
|
|
79
|
+
CreateSubscriptionMapper: StripeCreateSubscriptionDto<PartyType>;
|
|
80
|
+
UpdateSubscriptionMapper: StripeUpdateSubscriptionDto<PartyType>;
|
|
194
81
|
};
|
|
195
82
|
|
|
196
83
|
type StripeBillingPortalEntity = BillingPortalDto & {
|
|
197
|
-
|
|
84
|
+
providerFields: stripe__default.BillingPortal.Session;
|
|
198
85
|
};
|
|
199
86
|
type StripeBillingPortalEntities = {
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
87
|
+
BillingPortalMapper: StripeBillingPortalEntity;
|
|
88
|
+
CreateBillingPortalMapper: StripeBillingPortalEntity;
|
|
89
|
+
UpdateBillingPortalMapper: StripeBillingPortalEntity;
|
|
203
90
|
};
|
|
204
|
-
type StripeCheckoutSessionEntity<StatusEnum> = CheckoutSessionDto<
|
|
205
|
-
|
|
206
|
-
typeof CurrencyEnum,
|
|
207
|
-
StatusEnum
|
|
208
|
-
> & {
|
|
209
|
-
providerFields: stripe__default.Checkout.Session;
|
|
91
|
+
type StripeCheckoutSessionEntity<StatusEnum> = CheckoutSessionDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum> & {
|
|
92
|
+
providerFields: stripe__default.Checkout.Session;
|
|
210
93
|
};
|
|
211
94
|
type StripeCheckoutSessionEntities<StatusEnum> = {
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
95
|
+
CheckoutSessionMapper: StripeCheckoutSessionEntity<StatusEnum>;
|
|
96
|
+
CreateCheckoutSessionMapper: StripeCheckoutSessionEntity<StatusEnum>;
|
|
97
|
+
UpdateCheckoutSessionMapper: StripeCheckoutSessionEntity<StatusEnum>;
|
|
215
98
|
};
|
|
216
|
-
type StripePaymentLinkEntity<StatusEnum> = PaymentLinkDto<
|
|
217
|
-
|
|
218
|
-
typeof CurrencyEnum,
|
|
219
|
-
StatusEnum
|
|
220
|
-
> & {
|
|
221
|
-
providerFields: stripe__default.PaymentLink;
|
|
99
|
+
type StripePaymentLinkEntity<StatusEnum> = PaymentLinkDto<typeof PaymentMethodEnum, typeof CurrencyEnum, StatusEnum> & {
|
|
100
|
+
providerFields: stripe__default.PaymentLink;
|
|
222
101
|
};
|
|
223
102
|
type StripePaymentLinkEntities<StatusEnum> = {
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
103
|
+
PaymentLinkMapper: StripePaymentLinkEntity<StatusEnum>;
|
|
104
|
+
CreatePaymentLinkMapper: StripePaymentLinkEntity<StatusEnum>;
|
|
105
|
+
UpdatePaymentLinkMapper: StripePaymentLinkEntity<StatusEnum>;
|
|
227
106
|
};
|
|
228
|
-
type StripePlanEntity = PlanDto<
|
|
229
|
-
|
|
230
|
-
typeof CurrencyEnum,
|
|
231
|
-
typeof BillingProviderEnum
|
|
232
|
-
> & {
|
|
233
|
-
providerFields: stripe__default.Plan;
|
|
107
|
+
type StripePlanEntity = PlanDto<typeof PlanCadenceEnum, typeof CurrencyEnum, typeof BillingProviderEnum> & {
|
|
108
|
+
providerFields: stripe__default.Plan;
|
|
234
109
|
};
|
|
235
110
|
type StripePlanEntities = {
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
111
|
+
PlanMapper: StripePlanEntity;
|
|
112
|
+
CreatePlanMapper: StripePlanEntity;
|
|
113
|
+
UpdatePlanMapper: StripePlanEntity;
|
|
239
114
|
};
|
|
240
|
-
type StripeSubscriptionEntity<PartyType> = SubscriptionDto<
|
|
241
|
-
|
|
242
|
-
typeof BillingProviderEnum
|
|
243
|
-
> & {
|
|
244
|
-
providerFields: stripe__default.Subscription;
|
|
115
|
+
type StripeSubscriptionEntity<PartyType> = SubscriptionDto<PartyType, typeof BillingProviderEnum> & {
|
|
116
|
+
providerFields: stripe__default.Subscription;
|
|
245
117
|
};
|
|
246
118
|
type StripeSubscriptionEntities<PartyType> = {
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
119
|
+
SubscriptionMapper: StripeSubscriptionEntity<PartyType>;
|
|
120
|
+
CreateSubscriptionMapper: StripeSubscriptionEntity<PartyType>;
|
|
121
|
+
UpdateSubscriptionMapper: StripeSubscriptionEntity<PartyType>;
|
|
250
122
|
};
|
|
251
123
|
|
|
252
|
-
type StripeBillingPortalMappers<
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
toEntity: (
|
|
263
|
-
dto: Dto['CreateBillingPortalMapper'],
|
|
264
|
-
em: EntityManager,
|
|
265
|
-
stripeSession: stripe__default.BillingPortal.Session,
|
|
266
|
-
...args: unknown[]
|
|
267
|
-
) => Promise<Entities['CreateBillingPortalMapper']>;
|
|
268
|
-
};
|
|
269
|
-
UpdateBillingPortalMapper: {
|
|
270
|
-
toEntity: (
|
|
271
|
-
dto: Dto['UpdateBillingPortalMapper'],
|
|
272
|
-
em: EntityManager,
|
|
273
|
-
stripeSession: stripe__default.BillingPortal.Session,
|
|
274
|
-
...args: unknown[]
|
|
275
|
-
) => Promise<Entities['UpdateBillingPortalMapper']>;
|
|
276
|
-
};
|
|
124
|
+
type StripeBillingPortalMappers<Entities extends StripeBillingPortalEntities, Dto extends StripeBillingPortalDtos> = {
|
|
125
|
+
BillingPortalMapper: {
|
|
126
|
+
toDto: (entity: Entities['BillingPortalMapper']) => Promise<Dto['BillingPortalMapper']>;
|
|
127
|
+
};
|
|
128
|
+
CreateBillingPortalMapper: {
|
|
129
|
+
toEntity: (dto: Dto['CreateBillingPortalMapper'], em: EntityManager, stripeSession: stripe__default.BillingPortal.Session, ...args: unknown[]) => Promise<Entities['CreateBillingPortalMapper']>;
|
|
130
|
+
};
|
|
131
|
+
UpdateBillingPortalMapper: {
|
|
132
|
+
toEntity: (dto: Dto['UpdateBillingPortalMapper'], em: EntityManager, stripeSession: stripe__default.BillingPortal.Session, ...args: unknown[]) => Promise<Entities['UpdateBillingPortalMapper']>;
|
|
133
|
+
};
|
|
277
134
|
};
|
|
278
135
|
|
|
279
|
-
type StripeCheckoutSessionMappers<
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
CreateCheckoutSessionMapper: {
|
|
290
|
-
toEntity: (
|
|
291
|
-
dto: Dto['CreateCheckoutSessionMapper'],
|
|
292
|
-
em: EntityManager,
|
|
293
|
-
stripeSession: stripe__default.Checkout.Session,
|
|
294
|
-
...args: unknown[]
|
|
295
|
-
) => Promise<Entities['CreateCheckoutSessionMapper']>;
|
|
296
|
-
};
|
|
297
|
-
UpdateCheckoutSessionMapper: {
|
|
298
|
-
toEntity: (
|
|
299
|
-
dto: Dto['UpdateCheckoutSessionMapper'],
|
|
300
|
-
em: EntityManager,
|
|
301
|
-
stripeSession: stripe__default.Checkout.Session,
|
|
302
|
-
...args: unknown[]
|
|
303
|
-
) => Promise<Entities['UpdateCheckoutSessionMapper']>;
|
|
304
|
-
};
|
|
136
|
+
type StripeCheckoutSessionMappers<StatusEnum, Entities extends StripeCheckoutSessionEntities<StatusEnum>, Dto extends StripeCheckoutSessionDtos<StatusEnum>> = {
|
|
137
|
+
CheckoutSessionMapper: {
|
|
138
|
+
toDto: (entity: Entities['CheckoutSessionMapper']) => Promise<Dto['CheckoutSessionMapper']>;
|
|
139
|
+
};
|
|
140
|
+
CreateCheckoutSessionMapper: {
|
|
141
|
+
toEntity: (dto: Dto['CreateCheckoutSessionMapper'], em: EntityManager, stripeSession: stripe__default.Checkout.Session, ...args: unknown[]) => Promise<Entities['CreateCheckoutSessionMapper']>;
|
|
142
|
+
};
|
|
143
|
+
UpdateCheckoutSessionMapper: {
|
|
144
|
+
toEntity: (dto: Dto['UpdateCheckoutSessionMapper'], em: EntityManager, stripeSession: stripe__default.Checkout.Session, ...args: unknown[]) => Promise<Entities['UpdateCheckoutSessionMapper']>;
|
|
145
|
+
};
|
|
305
146
|
};
|
|
306
147
|
|
|
307
|
-
type StripePaymentLinkMappers<
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
CreatePaymentLinkMapper: {
|
|
318
|
-
toEntity: (
|
|
319
|
-
dto: Dto['CreatePaymentLinkMapper'],
|
|
320
|
-
em: EntityManager,
|
|
321
|
-
stripePaymentLink: stripe__default.PaymentLink,
|
|
322
|
-
...args: unknown[]
|
|
323
|
-
) => Promise<Entities['CreatePaymentLinkMapper']>;
|
|
324
|
-
};
|
|
325
|
-
UpdatePaymentLinkMapper: {
|
|
326
|
-
toEntity: (
|
|
327
|
-
dto: Dto['UpdatePaymentLinkMapper'],
|
|
328
|
-
em: EntityManager,
|
|
329
|
-
stripePaymentLink: stripe__default.PaymentLink,
|
|
330
|
-
...args: unknown[]
|
|
331
|
-
) => Promise<Entities['UpdatePaymentLinkMapper']>;
|
|
332
|
-
};
|
|
148
|
+
type StripePaymentLinkMappers<StatusEnum, Entities extends StripePaymentLinkEntities<StatusEnum>, Dto extends StripePaymentLinkDtos<StatusEnum>> = {
|
|
149
|
+
PaymentLinkMapper: {
|
|
150
|
+
toDto: (entity: Entities['PaymentLinkMapper']) => Promise<Dto['PaymentLinkMapper']>;
|
|
151
|
+
};
|
|
152
|
+
CreatePaymentLinkMapper: {
|
|
153
|
+
toEntity: (dto: Dto['CreatePaymentLinkMapper'], em: EntityManager, stripePaymentLink: stripe__default.PaymentLink, ...args: unknown[]) => Promise<Entities['CreatePaymentLinkMapper']>;
|
|
154
|
+
};
|
|
155
|
+
UpdatePaymentLinkMapper: {
|
|
156
|
+
toEntity: (dto: Dto['UpdatePaymentLinkMapper'], em: EntityManager, stripePaymentLink: stripe__default.PaymentLink, ...args: unknown[]) => Promise<Entities['UpdatePaymentLinkMapper']>;
|
|
157
|
+
};
|
|
333
158
|
};
|
|
334
159
|
|
|
335
|
-
type StripePlanMappers<
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
em: EntityManager,
|
|
346
|
-
stripePlan: stripe__default.Plan,
|
|
347
|
-
...args: unknown[]
|
|
348
|
-
) => Promise<Entities['CreatePlanMapper']>;
|
|
349
|
-
};
|
|
350
|
-
UpdatePlanMapper: {
|
|
351
|
-
toEntity: (
|
|
352
|
-
dto: Dto['UpdatePlanMapper'],
|
|
353
|
-
em: EntityManager,
|
|
354
|
-
stripePlan: stripe__default.Plan,
|
|
355
|
-
...args: unknown[]
|
|
356
|
-
) => Promise<Entities['UpdatePlanMapper']>;
|
|
357
|
-
};
|
|
160
|
+
type StripePlanMappers<Entities extends StripePlanEntities, Dto extends StripePlanDtos> = {
|
|
161
|
+
PlanMapper: {
|
|
162
|
+
toDto: (entity: Entities['PlanMapper']) => Promise<Dto['PlanMapper']>;
|
|
163
|
+
};
|
|
164
|
+
CreatePlanMapper: {
|
|
165
|
+
toEntity: (dto: Dto['CreatePlanMapper'], em: EntityManager, stripePlan: stripe__default.Plan, ...args: unknown[]) => Promise<Entities['CreatePlanMapper']>;
|
|
166
|
+
};
|
|
167
|
+
UpdatePlanMapper: {
|
|
168
|
+
toEntity: (dto: Dto['UpdatePlanMapper'], em: EntityManager, stripePlan: stripe__default.Plan, ...args: unknown[]) => Promise<Entities['UpdatePlanMapper']>;
|
|
169
|
+
};
|
|
358
170
|
};
|
|
359
171
|
|
|
360
|
-
type StripeSubscriptionMappers<
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
CreateSubscriptionMapper: {
|
|
371
|
-
toEntity: (
|
|
372
|
-
dto: Dto['CreateSubscriptionMapper'],
|
|
373
|
-
em: EntityManager,
|
|
374
|
-
stripeSubscription: stripe__default.Subscription,
|
|
375
|
-
...args: unknown[]
|
|
376
|
-
) => Promise<Entities['CreateSubscriptionMapper']>;
|
|
377
|
-
};
|
|
378
|
-
UpdateSubscriptionMapper: {
|
|
379
|
-
toEntity: (
|
|
380
|
-
dto: Dto['UpdateSubscriptionMapper'],
|
|
381
|
-
em: EntityManager,
|
|
382
|
-
stripeSubscription: stripe__default.Subscription,
|
|
383
|
-
...args: unknown[]
|
|
384
|
-
) => Promise<Entities['UpdateSubscriptionMapper']>;
|
|
385
|
-
};
|
|
172
|
+
type StripeSubscriptionMappers<PartyType, Entities extends StripeSubscriptionEntities<PartyType>, Dto extends StripeSubscriptionDtos<PartyType>> = {
|
|
173
|
+
SubscriptionMapper: {
|
|
174
|
+
toDto: (entity: Entities['SubscriptionMapper']) => Promise<Dto['SubscriptionMapper']>;
|
|
175
|
+
};
|
|
176
|
+
CreateSubscriptionMapper: {
|
|
177
|
+
toEntity: (dto: Dto['CreateSubscriptionMapper'], em: EntityManager, stripeSubscription: stripe__default.Subscription, ...args: unknown[]) => Promise<Entities['CreateSubscriptionMapper']>;
|
|
178
|
+
};
|
|
179
|
+
UpdateSubscriptionMapper: {
|
|
180
|
+
toEntity: (dto: Dto['UpdateSubscriptionMapper'], em: EntityManager, stripeSubscription: stripe__default.Subscription, ...args: unknown[]) => Promise<Entities['UpdateSubscriptionMapper']>;
|
|
181
|
+
};
|
|
386
182
|
};
|
|
387
183
|
|
|
388
|
-
export type {
|
|
389
|
-
StripeBillingPortalDto,
|
|
390
|
-
StripeBillingPortalDtos,
|
|
391
|
-
StripeBillingPortalEntities,
|
|
392
|
-
StripeBillingPortalEntity,
|
|
393
|
-
StripeBillingPortalMappers,
|
|
394
|
-
StripeCheckoutSessionDto,
|
|
395
|
-
StripeCheckoutSessionDtos,
|
|
396
|
-
StripeCheckoutSessionEntities,
|
|
397
|
-
StripeCheckoutSessionEntity,
|
|
398
|
-
StripeCheckoutSessionMappers,
|
|
399
|
-
StripeCreateBillingPortalDto,
|
|
400
|
-
StripeCreateCheckoutSessionDto,
|
|
401
|
-
StripeCreatePaymentLinkDto,
|
|
402
|
-
StripeCreatePlanDto,
|
|
403
|
-
StripeCreateSubscriptionDto,
|
|
404
|
-
StripePaymentLinkDto,
|
|
405
|
-
StripePaymentLinkDtos,
|
|
406
|
-
StripePaymentLinkEntities,
|
|
407
|
-
StripePaymentLinkEntity,
|
|
408
|
-
StripePaymentLinkMappers,
|
|
409
|
-
StripePlanDto,
|
|
410
|
-
StripePlanDtos,
|
|
411
|
-
StripePlanEntities,
|
|
412
|
-
StripePlanEntity,
|
|
413
|
-
StripePlanMappers,
|
|
414
|
-
StripeSubscriptionDto,
|
|
415
|
-
StripeSubscriptionDtos,
|
|
416
|
-
StripeSubscriptionEntities,
|
|
417
|
-
StripeSubscriptionEntity,
|
|
418
|
-
StripeSubscriptionMappers,
|
|
419
|
-
StripeUpdateBillingPortalDto,
|
|
420
|
-
StripeUpdateCheckoutSessionDto,
|
|
421
|
-
StripeUpdatePaymentLinkDto,
|
|
422
|
-
StripeUpdatePlanDto,
|
|
423
|
-
StripeUpdateSubscriptionDto
|
|
424
|
-
};
|
|
184
|
+
export type { StripeBillingPortalDto, StripeBillingPortalDtos, StripeBillingPortalEntities, StripeBillingPortalEntity, StripeBillingPortalMappers, StripeCheckoutSessionDto, StripeCheckoutSessionDtos, StripeCheckoutSessionEntities, StripeCheckoutSessionEntity, StripeCheckoutSessionMappers, StripeCreateBillingPortalDto, StripeCreateCheckoutSessionDto, StripeCreatePaymentLinkDto, StripeCreatePlanDto, StripeCreateSubscriptionDto, StripePaymentLinkDto, StripePaymentLinkDtos, StripePaymentLinkEntities, StripePaymentLinkEntity, StripePaymentLinkMappers, StripePlanDto, StripePlanDtos, StripePlanEntities, StripePlanEntity, StripePlanMappers, StripeSubscriptionDto, StripeSubscriptionDtos, StripeSubscriptionEntities, StripeSubscriptionEntity, StripeSubscriptionMappers, StripeUpdateBillingPortalDto, StripeUpdateCheckoutSessionDto, StripeUpdatePaymentLinkDto, StripeUpdatePlanDto, StripeUpdateSubscriptionDto };
|
|
@@ -1,21 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
5
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
6
|
var __copyProps = (to, from, except, desc) => {
|
|
7
|
-
if (
|
|
7
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
8
8
|
for (let key of __getOwnPropNames(from))
|
|
9
9
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
10
|
-
__defProp(to, key, {
|
|
11
|
-
get: () => from[key],
|
|
12
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
13
|
-
});
|
|
10
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
11
|
}
|
|
15
12
|
return to;
|
|
16
13
|
};
|
|
17
|
-
var __toCommonJS = (mod) =>
|
|
18
|
-
__copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
14
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
15
|
|
|
20
16
|
// domain/types/index.ts
|
|
21
17
|
var types_exports = {};
|
|
@@ -105,6 +105,19 @@ export class StripeWebhookService<
|
|
|
105
105
|
if (this.openTelemetryCollector) {
|
|
106
106
|
this.openTelemetryCollector.info('Handling webhook event', event);
|
|
107
107
|
}
|
|
108
|
+
|
|
109
|
+
if (
|
|
110
|
+
await this.em.findOne('StripeWebhookEvent', {
|
|
111
|
+
idempotencyKey: event.request?.idempotency_key
|
|
112
|
+
})
|
|
113
|
+
) {
|
|
114
|
+
this.openTelemetryCollector.info(
|
|
115
|
+
'Webhook event already processed',
|
|
116
|
+
event
|
|
117
|
+
);
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
|
|
108
121
|
const eventType = event.type;
|
|
109
122
|
|
|
110
123
|
switch (eventType) {
|
|
@@ -296,5 +309,13 @@ export class StripeWebhookService<
|
|
|
296
309
|
);
|
|
297
310
|
break;
|
|
298
311
|
}
|
|
312
|
+
|
|
313
|
+
await this.em.insert('StripeWebhookEvent', {
|
|
314
|
+
stripeId: event.id,
|
|
315
|
+
idempotencyKey: event.request?.idempotency_key,
|
|
316
|
+
eventType: event.type,
|
|
317
|
+
eventData: event.data
|
|
318
|
+
});
|
|
319
|
+
await this.em.flush();
|
|
299
320
|
}
|
|
300
321
|
}
|