@forklaunch/implementation-billing-stripe 0.0.3 → 0.0.4
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 +177 -182
- package/lib/domain/enum/index.d.ts +177 -182
- package/lib/domain/enum/index.js +186 -191
- package/lib/domain/enum/index.mjs +176 -176
- package/lib/domain/schemas/index.d.mts +318 -4084
- package/lib/domain/schemas/index.d.ts +318 -4084
- package/lib/domain/schemas/index.js +248 -324
- package/lib/domain/schemas/index.mjs +197 -198
- package/lib/domain/types/index.d.mts +72 -231
- package/lib/domain/types/index.d.ts +72 -231
- package/lib/domain/types/index.js +4 -8
- package/lib/eject/domain/schemas/billingPortal.schema.ts +2 -2
- package/lib/eject/domain/schemas/checkoutSession.schema.ts +4 -4
- package/lib/eject/domain/schemas/paymentLink.schema.ts +4 -4
- package/lib/eject/domain/schemas/plan.schema.ts +5 -5
- package/lib/eject/domain/schemas/subscription.schema.ts +3 -3
- package/lib/services/index.d.mts +194 -709
- package/lib/services/index.d.ts +194 -709
- package/lib/services/index.js +244 -359
- package/lib/services/index.mjs +205 -298
- package/package.json +2 -2
package/lib/services/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
var __defProp = Object.defineProperty;
|
|
3
3
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
4
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -8,18 +8,14 @@ var __export = (target, all) => {
|
|
|
8
8
|
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
9
|
};
|
|
10
10
|
var __copyProps = (to, from, except, desc) => {
|
|
11
|
-
if (
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
12
|
for (let key of __getOwnPropNames(from))
|
|
13
13
|
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
-
__defProp(to, key, {
|
|
15
|
-
get: () => from[key],
|
|
16
|
-
enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable
|
|
17
|
-
});
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
18
15
|
}
|
|
19
16
|
return to;
|
|
20
17
|
};
|
|
21
|
-
var __toCommonJS = (mod) =>
|
|
22
|
-
__copyProps(__defProp({}, '__esModule', { value: true }), mod);
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
19
|
|
|
24
20
|
// services/index.ts
|
|
25
21
|
var services_exports = {};
|
|
@@ -34,18 +30,10 @@ __export(services_exports, {
|
|
|
34
30
|
module.exports = __toCommonJS(services_exports);
|
|
35
31
|
|
|
36
32
|
// services/billingPortal.service.ts
|
|
37
|
-
var import_services = require(
|
|
38
|
-
var import_internal = require(
|
|
33
|
+
var import_services = require("@forklaunch/implementation-billing-base/services");
|
|
34
|
+
var import_internal = require("@forklaunch/internal");
|
|
39
35
|
var StripeBillingPortalService = class {
|
|
40
|
-
constructor(
|
|
41
|
-
stripeClient,
|
|
42
|
-
em,
|
|
43
|
-
cache,
|
|
44
|
-
openTelemetryCollector,
|
|
45
|
-
schemaValidator,
|
|
46
|
-
mappers,
|
|
47
|
-
options
|
|
48
|
-
) {
|
|
36
|
+
constructor(stripeClient, em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
49
37
|
this.stripeClient = stripeClient;
|
|
50
38
|
this.em = em;
|
|
51
39
|
this.cache = cache;
|
|
@@ -53,23 +41,19 @@ var StripeBillingPortalService = class {
|
|
|
53
41
|
this.schemaValidator = schemaValidator;
|
|
54
42
|
this.mappers = mappers;
|
|
55
43
|
this.options = options;
|
|
56
|
-
this._mappers = (0, import_internal.transformIntoInternalMapper)(
|
|
57
|
-
|
|
58
|
-
|
|
44
|
+
this._mappers = (0, import_internal.transformIntoInternalMapper)(mappers, schemaValidator);
|
|
45
|
+
this.baseBillingPortalService = new import_services.BaseBillingPortalService(
|
|
46
|
+
em,
|
|
47
|
+
cache,
|
|
48
|
+
openTelemetryCollector,
|
|
49
|
+
schemaValidator,
|
|
50
|
+
{
|
|
51
|
+
BillingPortalMapper: import_internal.IdentityResponseMapper,
|
|
52
|
+
CreateBillingPortalMapper: import_internal.IdentityRequestMapper,
|
|
53
|
+
UpdateBillingPortalMapper: import_internal.IdentityRequestMapper
|
|
54
|
+
},
|
|
55
|
+
options
|
|
59
56
|
);
|
|
60
|
-
this.baseBillingPortalService =
|
|
61
|
-
new import_services.BaseBillingPortalService(
|
|
62
|
-
em,
|
|
63
|
-
cache,
|
|
64
|
-
openTelemetryCollector,
|
|
65
|
-
schemaValidator,
|
|
66
|
-
{
|
|
67
|
-
BillingPortalMapper: import_internal.IdentityResponseMapper,
|
|
68
|
-
CreateBillingPortalMapper: import_internal.IdentityRequestMapper,
|
|
69
|
-
UpdateBillingPortalMapper: import_internal.IdentityRequestMapper
|
|
70
|
-
},
|
|
71
|
-
options
|
|
72
|
-
);
|
|
73
57
|
}
|
|
74
58
|
billingPortalSessionExpiryDurationMs = 5 * 60 * 1e3;
|
|
75
59
|
baseBillingPortalService;
|
|
@@ -79,28 +63,26 @@ var StripeBillingPortalService = class {
|
|
|
79
63
|
...billingPortalDto.stripeFields,
|
|
80
64
|
customer: billingPortalDto.customerId
|
|
81
65
|
});
|
|
82
|
-
const billingPortalEntity =
|
|
83
|
-
await this.
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
);
|
|
66
|
+
const billingPortalEntity = await this.baseBillingPortalService.createBillingPortalSession(
|
|
67
|
+
await this._mappers.CreateBillingPortalMapper.deserializeDtoToEntity(
|
|
68
|
+
{
|
|
69
|
+
...billingPortalDto,
|
|
70
|
+
id: session.id,
|
|
71
|
+
uri: session.url,
|
|
72
|
+
expiresAt: new Date(
|
|
73
|
+
Date.now() + this.billingPortalSessionExpiryDurationMs
|
|
74
|
+
)
|
|
75
|
+
},
|
|
76
|
+
this.em,
|
|
77
|
+
session
|
|
78
|
+
)
|
|
79
|
+
);
|
|
97
80
|
return this._mappers.BillingPortalMapper.serializeEntityToDto(
|
|
98
81
|
billingPortalEntity
|
|
99
82
|
);
|
|
100
83
|
}
|
|
101
84
|
async getBillingPortalSession(idDto) {
|
|
102
|
-
const billingPortalEntity =
|
|
103
|
-
await this.baseBillingPortalService.getBillingPortalSession(idDto);
|
|
85
|
+
const billingPortalEntity = await this.baseBillingPortalService.getBillingPortalSession(idDto);
|
|
104
86
|
return this._mappers.BillingPortalMapper.serializeEntityToDto(
|
|
105
87
|
billingPortalEntity
|
|
106
88
|
);
|
|
@@ -109,29 +91,27 @@ var StripeBillingPortalService = class {
|
|
|
109
91
|
return this.baseBillingPortalService.expireBillingPortalSession(idDto);
|
|
110
92
|
}
|
|
111
93
|
async updateBillingPortalSession(billingPortalDto) {
|
|
112
|
-
const existingSession =
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
});
|
|
94
|
+
const existingSession = await this.baseBillingPortalService.getBillingPortalSession({
|
|
95
|
+
id: billingPortalDto.id
|
|
96
|
+
});
|
|
116
97
|
const session = await this.stripeClient.billingPortal.sessions.create({
|
|
117
98
|
...billingPortalDto.stripeFields,
|
|
118
99
|
customer: existingSession.customerId
|
|
119
100
|
});
|
|
120
|
-
const baseBillingPortalDto =
|
|
121
|
-
await this.
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
);
|
|
101
|
+
const baseBillingPortalDto = await this.baseBillingPortalService.updateBillingPortalSession(
|
|
102
|
+
await this._mappers.UpdateBillingPortalMapper.deserializeDtoToEntity(
|
|
103
|
+
{
|
|
104
|
+
...billingPortalDto,
|
|
105
|
+
id: session.id,
|
|
106
|
+
uri: session.url,
|
|
107
|
+
expiresAt: new Date(
|
|
108
|
+
Date.now() + this.billingPortalSessionExpiryDurationMs
|
|
109
|
+
)
|
|
110
|
+
},
|
|
111
|
+
this.em,
|
|
112
|
+
session
|
|
113
|
+
)
|
|
114
|
+
);
|
|
135
115
|
return this._mappers.BillingPortalMapper.serializeEntityToDto(
|
|
136
116
|
baseBillingPortalDto
|
|
137
117
|
);
|
|
@@ -139,18 +119,10 @@ var StripeBillingPortalService = class {
|
|
|
139
119
|
};
|
|
140
120
|
|
|
141
121
|
// services/checkoutSession.service.ts
|
|
142
|
-
var import_services2 = require(
|
|
143
|
-
var import_internal2 = require(
|
|
122
|
+
var import_services2 = require("@forklaunch/implementation-billing-base/services");
|
|
123
|
+
var import_internal2 = require("@forklaunch/internal");
|
|
144
124
|
var StripeCheckoutSessionService = class {
|
|
145
|
-
constructor(
|
|
146
|
-
stripeClient,
|
|
147
|
-
em,
|
|
148
|
-
cache,
|
|
149
|
-
openTelemetryCollector,
|
|
150
|
-
schemaValidator,
|
|
151
|
-
mappers,
|
|
152
|
-
options
|
|
153
|
-
) {
|
|
125
|
+
constructor(stripeClient, em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
154
126
|
this.stripeClient = stripeClient;
|
|
155
127
|
this.em = em;
|
|
156
128
|
this.cache = cache;
|
|
@@ -158,23 +130,19 @@ var StripeCheckoutSessionService = class {
|
|
|
158
130
|
this.schemaValidator = schemaValidator;
|
|
159
131
|
this.mappers = mappers;
|
|
160
132
|
this.options = options;
|
|
161
|
-
this._mappers = (0, import_internal2.transformIntoInternalMapper)(
|
|
162
|
-
|
|
163
|
-
|
|
133
|
+
this._mappers = (0, import_internal2.transformIntoInternalMapper)(mappers, schemaValidator);
|
|
134
|
+
this.baseCheckoutSessionService = new import_services2.BaseCheckoutSessionService(
|
|
135
|
+
em,
|
|
136
|
+
cache,
|
|
137
|
+
openTelemetryCollector,
|
|
138
|
+
schemaValidator,
|
|
139
|
+
{
|
|
140
|
+
CheckoutSessionMapper: import_internal2.IdentityResponseMapper,
|
|
141
|
+
CreateCheckoutSessionMapper: import_internal2.IdentityRequestMapper,
|
|
142
|
+
UpdateCheckoutSessionMapper: import_internal2.IdentityRequestMapper
|
|
143
|
+
},
|
|
144
|
+
options
|
|
164
145
|
);
|
|
165
|
-
this.baseCheckoutSessionService =
|
|
166
|
-
new import_services2.BaseCheckoutSessionService(
|
|
167
|
-
em,
|
|
168
|
-
cache,
|
|
169
|
-
openTelemetryCollector,
|
|
170
|
-
schemaValidator,
|
|
171
|
-
{
|
|
172
|
-
CheckoutSessionMapper: import_internal2.IdentityResponseMapper,
|
|
173
|
-
CreateCheckoutSessionMapper: import_internal2.IdentityRequestMapper,
|
|
174
|
-
UpdateCheckoutSessionMapper: import_internal2.IdentityRequestMapper
|
|
175
|
-
},
|
|
176
|
-
options
|
|
177
|
-
);
|
|
178
146
|
}
|
|
179
147
|
baseCheckoutSessionService;
|
|
180
148
|
_mappers;
|
|
@@ -186,27 +154,27 @@ var StripeCheckoutSessionService = class {
|
|
|
186
154
|
success_url: checkoutSessionDto.successRedirectUri,
|
|
187
155
|
cancel_url: checkoutSessionDto.cancelRedirectUri
|
|
188
156
|
});
|
|
189
|
-
const checkoutSessionEntity =
|
|
190
|
-
await this.
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
);
|
|
157
|
+
const checkoutSessionEntity = await this.baseCheckoutSessionService.createCheckoutSession(
|
|
158
|
+
await this._mappers.CreateCheckoutSessionMapper.deserializeDtoToEntity(
|
|
159
|
+
{
|
|
160
|
+
...checkoutSessionDto,
|
|
161
|
+
id: session.id,
|
|
162
|
+
uri: session.url,
|
|
163
|
+
expiresAt: new Date(Date.now() + 5 * 60 * 1e3),
|
|
164
|
+
providerFields: session
|
|
165
|
+
},
|
|
166
|
+
this.em,
|
|
167
|
+
session
|
|
168
|
+
)
|
|
169
|
+
);
|
|
203
170
|
return this._mappers.CheckoutSessionMapper.serializeEntityToDto(
|
|
204
171
|
checkoutSessionEntity
|
|
205
172
|
);
|
|
206
173
|
}
|
|
207
|
-
async getCheckoutSession({
|
|
208
|
-
|
|
209
|
-
|
|
174
|
+
async getCheckoutSession({
|
|
175
|
+
id
|
|
176
|
+
}) {
|
|
177
|
+
const databaseCheckoutSession = await this.baseCheckoutSessionService.getCheckoutSession({ id });
|
|
210
178
|
return {
|
|
211
179
|
...this._mappers.CheckoutSessionMapper.serializeEntityToDto(
|
|
212
180
|
databaseCheckoutSession
|
|
@@ -221,7 +189,7 @@ var StripeCheckoutSessionService = class {
|
|
|
221
189
|
async handleCheckoutSuccess({ id }) {
|
|
222
190
|
await this.stripeClient.checkout.sessions.update(id, {
|
|
223
191
|
metadata: {
|
|
224
|
-
status:
|
|
192
|
+
status: "SUCCESS"
|
|
225
193
|
}
|
|
226
194
|
});
|
|
227
195
|
await this.baseCheckoutSessionService.handleCheckoutSuccess({ id });
|
|
@@ -229,7 +197,7 @@ var StripeCheckoutSessionService = class {
|
|
|
229
197
|
async handleCheckoutFailure({ id }) {
|
|
230
198
|
await this.stripeClient.checkout.sessions.update(id, {
|
|
231
199
|
metadata: {
|
|
232
|
-
status:
|
|
200
|
+
status: "FAILED"
|
|
233
201
|
}
|
|
234
202
|
});
|
|
235
203
|
await this.baseCheckoutSessionService.handleCheckoutFailure({ id });
|
|
@@ -237,18 +205,10 @@ var StripeCheckoutSessionService = class {
|
|
|
237
205
|
};
|
|
238
206
|
|
|
239
207
|
// services/paymentLink.service.ts
|
|
240
|
-
var import_services3 = require(
|
|
241
|
-
var import_internal3 = require(
|
|
208
|
+
var import_services3 = require("@forklaunch/implementation-billing-base/services");
|
|
209
|
+
var import_internal3 = require("@forklaunch/internal");
|
|
242
210
|
var StripePaymentLinkService = class {
|
|
243
|
-
constructor(
|
|
244
|
-
stripeClient,
|
|
245
|
-
em,
|
|
246
|
-
cache,
|
|
247
|
-
openTelemetryCollector,
|
|
248
|
-
schemaValidator,
|
|
249
|
-
mappers,
|
|
250
|
-
options
|
|
251
|
-
) {
|
|
211
|
+
constructor(stripeClient, em, cache, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
252
212
|
this.stripeClient = stripeClient;
|
|
253
213
|
this.em = em;
|
|
254
214
|
this.cache = cache;
|
|
@@ -256,10 +216,7 @@ var StripePaymentLinkService = class {
|
|
|
256
216
|
this.schemaValidator = schemaValidator;
|
|
257
217
|
this.mappers = mappers;
|
|
258
218
|
this.options = options;
|
|
259
|
-
this._mappers = (0, import_internal3.transformIntoInternalMapper)(
|
|
260
|
-
mappers,
|
|
261
|
-
schemaValidator
|
|
262
|
-
);
|
|
219
|
+
this._mappers = (0, import_internal3.transformIntoInternalMapper)(mappers, schemaValidator);
|
|
263
220
|
this.basePaymentLinkService = new import_services3.BasePaymentLinkService(
|
|
264
221
|
em,
|
|
265
222
|
cache,
|
|
@@ -281,22 +238,20 @@ var StripePaymentLinkService = class {
|
|
|
281
238
|
payment_method_types: paymentLinkDto.paymentMethods,
|
|
282
239
|
currency: paymentLinkDto.currency
|
|
283
240
|
});
|
|
284
|
-
const paymentLinkEntity =
|
|
285
|
-
await this.
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
)
|
|
299
|
-
);
|
|
241
|
+
const paymentLinkEntity = await this.basePaymentLinkService.createPaymentLink(
|
|
242
|
+
await this._mappers.CreatePaymentLinkMapper.deserializeDtoToEntity(
|
|
243
|
+
{
|
|
244
|
+
...paymentLinkDto,
|
|
245
|
+
id: session.id,
|
|
246
|
+
amount: session.line_items?.data.reduce(
|
|
247
|
+
(total, item) => total + item.amount_total,
|
|
248
|
+
0
|
|
249
|
+
) ?? 0
|
|
250
|
+
},
|
|
251
|
+
this.em,
|
|
252
|
+
session
|
|
253
|
+
)
|
|
254
|
+
);
|
|
300
255
|
return this._mappers.PaymentLinkMapper.serializeEntityToDto(
|
|
301
256
|
paymentLinkEntity
|
|
302
257
|
);
|
|
@@ -309,29 +264,26 @@ var StripePaymentLinkService = class {
|
|
|
309
264
|
payment_method_types: paymentLinkDto.paymentMethods
|
|
310
265
|
}
|
|
311
266
|
);
|
|
312
|
-
const paymentLinkEntity =
|
|
313
|
-
await this.
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
)
|
|
327
|
-
);
|
|
267
|
+
const paymentLinkEntity = await this.basePaymentLinkService.updatePaymentLink(
|
|
268
|
+
await this._mappers.UpdatePaymentLinkMapper.deserializeDtoToEntity(
|
|
269
|
+
{
|
|
270
|
+
...paymentLinkDto,
|
|
271
|
+
id: session.id,
|
|
272
|
+
amount: session.line_items?.data.reduce(
|
|
273
|
+
(total, item) => total + item.amount_total,
|
|
274
|
+
0
|
|
275
|
+
) ?? 0
|
|
276
|
+
},
|
|
277
|
+
this.em,
|
|
278
|
+
session
|
|
279
|
+
)
|
|
280
|
+
);
|
|
328
281
|
return this._mappers.PaymentLinkMapper.serializeEntityToDto(
|
|
329
282
|
paymentLinkEntity
|
|
330
283
|
);
|
|
331
284
|
}
|
|
332
285
|
async getPaymentLink({ id }) {
|
|
333
|
-
const databasePaymentLink =
|
|
334
|
-
await this.basePaymentLinkService.getPaymentLink({ id });
|
|
286
|
+
const databasePaymentLink = await this.basePaymentLinkService.getPaymentLink({ id });
|
|
335
287
|
return {
|
|
336
288
|
...this._mappers.PaymentLinkMapper.serializeEntityToDto(
|
|
337
289
|
databasePaymentLink
|
|
@@ -342,7 +294,7 @@ var StripePaymentLinkService = class {
|
|
|
342
294
|
async expirePaymentLink({ id }) {
|
|
343
295
|
await this.stripeClient.paymentLinks.update(id, {
|
|
344
296
|
metadata: {
|
|
345
|
-
status:
|
|
297
|
+
status: "EXPIRED"
|
|
346
298
|
}
|
|
347
299
|
});
|
|
348
300
|
await this.basePaymentLinkService.expirePaymentLink({ id });
|
|
@@ -350,7 +302,7 @@ var StripePaymentLinkService = class {
|
|
|
350
302
|
async handlePaymentSuccess({ id }) {
|
|
351
303
|
await this.stripeClient.paymentLinks.update(id, {
|
|
352
304
|
metadata: {
|
|
353
|
-
status:
|
|
305
|
+
status: "COMPLETED"
|
|
354
306
|
}
|
|
355
307
|
});
|
|
356
308
|
await this.basePaymentLinkService.handlePaymentSuccess({ id });
|
|
@@ -358,7 +310,7 @@ var StripePaymentLinkService = class {
|
|
|
358
310
|
async handlePaymentFailure({ id }) {
|
|
359
311
|
await this.stripeClient.paymentLinks.update(id, {
|
|
360
312
|
metadata: {
|
|
361
|
-
status:
|
|
313
|
+
status: "FAILED"
|
|
362
314
|
}
|
|
363
315
|
});
|
|
364
316
|
await this.basePaymentLinkService.handlePaymentFailure({ id });
|
|
@@ -370,9 +322,9 @@ var StripePaymentLinkService = class {
|
|
|
370
322
|
return await Promise.all(
|
|
371
323
|
(await this.basePaymentLinkService.listPaymentLinks(idsDto)).map(
|
|
372
324
|
async (paymentLink) => ({
|
|
373
|
-
...
|
|
325
|
+
...await this._mappers.PaymentLinkMapper.serializeEntityToDto(
|
|
374
326
|
paymentLink
|
|
375
|
-
)
|
|
327
|
+
),
|
|
376
328
|
stripeFields: paymentLinks.data.find(
|
|
377
329
|
(paymentLink2) => paymentLink2.id === paymentLink2.id
|
|
378
330
|
)
|
|
@@ -383,27 +335,17 @@ var StripePaymentLinkService = class {
|
|
|
383
335
|
};
|
|
384
336
|
|
|
385
337
|
// services/plan.service.ts
|
|
386
|
-
var import_services4 = require(
|
|
387
|
-
var import_internal4 = require(
|
|
338
|
+
var import_services4 = require("@forklaunch/implementation-billing-base/services");
|
|
339
|
+
var import_internal4 = require("@forklaunch/internal");
|
|
388
340
|
var StripePlanService = class {
|
|
389
|
-
constructor(
|
|
390
|
-
stripeClient,
|
|
391
|
-
em,
|
|
392
|
-
openTelemetryCollector,
|
|
393
|
-
schemaValidator,
|
|
394
|
-
mappers,
|
|
395
|
-
options
|
|
396
|
-
) {
|
|
341
|
+
constructor(stripeClient, em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
397
342
|
this.stripeClient = stripeClient;
|
|
398
343
|
this.em = em;
|
|
399
344
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
400
345
|
this.schemaValidator = schemaValidator;
|
|
401
346
|
this.mappers = mappers;
|
|
402
347
|
this.options = options;
|
|
403
|
-
this._mappers = (0, import_internal4.transformIntoInternalMapper)(
|
|
404
|
-
mappers,
|
|
405
|
-
schemaValidator
|
|
406
|
-
);
|
|
348
|
+
this._mappers = (0, import_internal4.transformIntoInternalMapper)(mappers, schemaValidator);
|
|
407
349
|
this.basePlanService = new import_services4.BasePlanService(
|
|
408
350
|
em,
|
|
409
351
|
openTelemetryCollector,
|
|
@@ -430,7 +372,7 @@ var StripePlanService = class {
|
|
|
430
372
|
{
|
|
431
373
|
...planDto,
|
|
432
374
|
externalId: plan.id,
|
|
433
|
-
billingProvider:
|
|
375
|
+
billingProvider: "stripe"
|
|
434
376
|
},
|
|
435
377
|
em ?? this.em,
|
|
436
378
|
plan
|
|
@@ -441,25 +383,24 @@ var StripePlanService = class {
|
|
|
441
383
|
}
|
|
442
384
|
async getPlan(idDto, em) {
|
|
443
385
|
const plan = await this.stripeClient.plans.retrieve(idDto.id);
|
|
444
|
-
const id = (
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
)?.id;
|
|
386
|
+
const id = (await em?.findOne(
|
|
387
|
+
this.options?.databaseTableName ?? "plan",
|
|
388
|
+
{ externalId: idDto.id }
|
|
389
|
+
))?.id;
|
|
449
390
|
if (!id) {
|
|
450
|
-
throw new Error(
|
|
391
|
+
throw new Error("Plan not found");
|
|
451
392
|
}
|
|
452
393
|
return {
|
|
453
|
-
...
|
|
394
|
+
...await this._mappers.PlanMapper.serializeEntityToDto(
|
|
454
395
|
await this.basePlanService.getPlan({ id }, em)
|
|
455
|
-
)
|
|
396
|
+
),
|
|
456
397
|
stripeFields: plan
|
|
457
398
|
};
|
|
458
399
|
}
|
|
459
400
|
async updatePlan(planDto, em) {
|
|
460
401
|
const existingPlan = await this.stripeClient.plans.retrieve(planDto.id);
|
|
461
|
-
const plan = await this.stripeClient.plans.del(planDto.id).then(
|
|
462
|
-
this.stripeClient.plans.create({
|
|
402
|
+
const plan = await this.stripeClient.plans.del(planDto.id).then(
|
|
403
|
+
() => this.stripeClient.plans.create({
|
|
463
404
|
...planDto.stripeFields,
|
|
464
405
|
interval: planDto.cadence ?? existingPlan.interval,
|
|
465
406
|
product: planDto.name,
|
|
@@ -471,7 +412,7 @@ var StripePlanService = class {
|
|
|
471
412
|
{
|
|
472
413
|
...planDto,
|
|
473
414
|
externalId: plan.id,
|
|
474
|
-
billingProvider:
|
|
415
|
+
billingProvider: "stripe"
|
|
475
416
|
},
|
|
476
417
|
em ?? this.em,
|
|
477
418
|
plan
|
|
@@ -488,19 +429,16 @@ var StripePlanService = class {
|
|
|
488
429
|
const plans = await this.stripeClient.plans.list({
|
|
489
430
|
active: true
|
|
490
431
|
});
|
|
491
|
-
const ids = (
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
)
|
|
496
|
-
?.filter((s) => idsDto?.ids?.includes(s.id))
|
|
497
|
-
?.map((s) => s.id);
|
|
432
|
+
const ids = (await em?.findAll(
|
|
433
|
+
this.options?.databaseTableName ?? "plan",
|
|
434
|
+
{ where: { externalId: { $in: plans.data.map((plan) => plan.id) } } }
|
|
435
|
+
))?.filter((s) => idsDto?.ids?.includes(s.id))?.map((s) => s.id);
|
|
498
436
|
if (!ids) {
|
|
499
|
-
throw new Error(
|
|
437
|
+
throw new Error("Plans not found");
|
|
500
438
|
}
|
|
501
439
|
return await Promise.all(
|
|
502
440
|
(await this.basePlanService.listPlans({ ids }, em)).map(async (plan) => ({
|
|
503
|
-
...
|
|
441
|
+
...await this._mappers.PlanMapper.serializeEntityToDto(plan),
|
|
504
442
|
stripeFields: plans.data.find(
|
|
505
443
|
(stripePlan) => stripePlan.id === plan.externalId
|
|
506
444
|
)
|
|
@@ -510,27 +448,17 @@ var StripePlanService = class {
|
|
|
510
448
|
};
|
|
511
449
|
|
|
512
450
|
// services/subscription.service.ts
|
|
513
|
-
var import_services5 = require(
|
|
514
|
-
var import_internal5 = require(
|
|
451
|
+
var import_services5 = require("@forklaunch/implementation-billing-base/services");
|
|
452
|
+
var import_internal5 = require("@forklaunch/internal");
|
|
515
453
|
var StripeSubscriptionService = class {
|
|
516
|
-
constructor(
|
|
517
|
-
stripe,
|
|
518
|
-
em,
|
|
519
|
-
openTelemetryCollector,
|
|
520
|
-
schemaValidator,
|
|
521
|
-
mappers,
|
|
522
|
-
options
|
|
523
|
-
) {
|
|
454
|
+
constructor(stripe, em, openTelemetryCollector, schemaValidator, mappers, options) {
|
|
524
455
|
this.stripe = stripe;
|
|
525
456
|
this.em = em;
|
|
526
457
|
this.openTelemetryCollector = openTelemetryCollector;
|
|
527
458
|
this.schemaValidator = schemaValidator;
|
|
528
459
|
this.mappers = mappers;
|
|
529
460
|
this.options = options;
|
|
530
|
-
this._mappers = (0, import_internal5.transformIntoInternalMapper)(
|
|
531
|
-
mappers,
|
|
532
|
-
schemaValidator
|
|
533
|
-
);
|
|
461
|
+
this._mappers = (0, import_internal5.transformIntoInternalMapper)(mappers, schemaValidator);
|
|
534
462
|
this.baseSubscriptionService = new import_services5.BaseSubscriptionService(
|
|
535
463
|
em,
|
|
536
464
|
openTelemetryCollector,
|
|
@@ -555,55 +483,53 @@ var StripeSubscriptionService = class {
|
|
|
555
483
|
}
|
|
556
484
|
]
|
|
557
485
|
});
|
|
558
|
-
const subscriptionEntity =
|
|
559
|
-
await this.
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
);
|
|
486
|
+
const subscriptionEntity = await this.baseSubscriptionService.createSubscription(
|
|
487
|
+
await this._mappers.CreateSubscriptionMapper.deserializeDtoToEntity(
|
|
488
|
+
{
|
|
489
|
+
...subscriptionDto,
|
|
490
|
+
externalId: subscription.id,
|
|
491
|
+
billingProvider: "stripe"
|
|
492
|
+
},
|
|
493
|
+
em ?? this.em,
|
|
494
|
+
subscription
|
|
495
|
+
),
|
|
496
|
+
em
|
|
497
|
+
);
|
|
571
498
|
return this._mappers.SubscriptionMapper.serializeEntityToDto(
|
|
572
499
|
subscriptionEntity
|
|
573
500
|
);
|
|
574
501
|
}
|
|
575
502
|
async getSubscription(idDto, em) {
|
|
576
503
|
return {
|
|
577
|
-
...
|
|
504
|
+
...await this._mappers.SubscriptionMapper.serializeEntityToDto(
|
|
578
505
|
await this.baseSubscriptionService.getSubscription(idDto, em)
|
|
579
|
-
)
|
|
506
|
+
),
|
|
580
507
|
stripeFields: await this.stripe.subscriptions.retrieve(idDto.id)
|
|
581
508
|
};
|
|
582
509
|
}
|
|
583
510
|
async getUserSubscription(idDto, em) {
|
|
584
511
|
return {
|
|
585
|
-
...
|
|
512
|
+
...await this._mappers.SubscriptionMapper.serializeEntityToDto(
|
|
586
513
|
await this.baseSubscriptionService.getUserSubscription(idDto, em)
|
|
587
|
-
)
|
|
514
|
+
),
|
|
588
515
|
stripeFields: await this.stripe.subscriptions.retrieve(idDto.id)
|
|
589
516
|
};
|
|
590
517
|
}
|
|
591
518
|
async getOrganizationSubscription(idDto, em) {
|
|
592
|
-
const id = (
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
)?.id;
|
|
519
|
+
const id = (await em?.findOne(
|
|
520
|
+
this.options?.databaseTableName ?? "subscription",
|
|
521
|
+
{ externalId: idDto.id }
|
|
522
|
+
))?.id;
|
|
597
523
|
if (!id) {
|
|
598
|
-
throw new Error(
|
|
524
|
+
throw new Error("Subscription not found");
|
|
599
525
|
}
|
|
600
526
|
return {
|
|
601
|
-
...
|
|
527
|
+
...await this._mappers.SubscriptionMapper.serializeEntityToDto(
|
|
602
528
|
await this.baseSubscriptionService.getOrganizationSubscription(
|
|
603
529
|
{ id },
|
|
604
530
|
em
|
|
605
531
|
)
|
|
606
|
-
)
|
|
532
|
+
),
|
|
607
533
|
stripeFields: await this.stripe.subscriptions.retrieve(idDto.id)
|
|
608
534
|
};
|
|
609
535
|
}
|
|
@@ -619,20 +545,19 @@ var StripeSubscriptionService = class {
|
|
|
619
545
|
]
|
|
620
546
|
}
|
|
621
547
|
);
|
|
622
|
-
const subscriptionEntity =
|
|
623
|
-
await this.
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
);
|
|
548
|
+
const subscriptionEntity = await this.baseSubscriptionService.updateSubscription(
|
|
549
|
+
await this._mappers.UpdateSubscriptionMapper.deserializeDtoToEntity(
|
|
550
|
+
{
|
|
551
|
+
...subscriptionDto,
|
|
552
|
+
externalId: subscription.id,
|
|
553
|
+
billingProvider: "stripe",
|
|
554
|
+
providerFields: subscription
|
|
555
|
+
},
|
|
556
|
+
em ?? this.em,
|
|
557
|
+
subscription
|
|
558
|
+
),
|
|
559
|
+
em
|
|
560
|
+
);
|
|
636
561
|
return this._mappers.SubscriptionMapper.serializeEntityToDto(
|
|
637
562
|
subscriptionEntity
|
|
638
563
|
);
|
|
@@ -642,26 +567,23 @@ var StripeSubscriptionService = class {
|
|
|
642
567
|
await this.baseSubscriptionService.deleteSubscription(idDto, em);
|
|
643
568
|
}
|
|
644
569
|
async listSubscriptions(idsDto, em) {
|
|
645
|
-
const subscriptions = (
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
where: { externalId: { $in: subscriptions.map((s) => s.id) } }
|
|
653
|
-
})
|
|
654
|
-
)?.map((s) => s.id);
|
|
570
|
+
const subscriptions = (await this.stripe.subscriptions.list({
|
|
571
|
+
status: "active"
|
|
572
|
+
})).data.filter((s) => idsDto.ids?.includes(s.id));
|
|
573
|
+
const ids = (await em?.findAll(
|
|
574
|
+
this.options?.databaseTableName ?? "subscription",
|
|
575
|
+
{ where: { externalId: { $in: subscriptions.map((s) => s.id) } } }
|
|
576
|
+
))?.map((s) => s.id);
|
|
655
577
|
if (!ids) {
|
|
656
|
-
throw new Error(
|
|
578
|
+
throw new Error("Subscriptions not found");
|
|
657
579
|
}
|
|
658
580
|
return await Promise.all(
|
|
659
581
|
(await this.baseSubscriptionService.listSubscriptions({ ids }, em)).map(
|
|
660
582
|
async (subscription) => {
|
|
661
583
|
return {
|
|
662
|
-
...
|
|
584
|
+
...await this._mappers.SubscriptionMapper.serializeEntityToDto(
|
|
663
585
|
subscription
|
|
664
|
-
)
|
|
586
|
+
),
|
|
665
587
|
stripeFields: subscriptions.find(
|
|
666
588
|
(s) => s.id === subscription.externalId
|
|
667
589
|
)
|
|
@@ -682,17 +604,7 @@ var StripeSubscriptionService = class {
|
|
|
682
604
|
|
|
683
605
|
// services/webhook.service.ts
|
|
684
606
|
var StripeWebhookService = class {
|
|
685
|
-
constructor(
|
|
686
|
-
stripeClient,
|
|
687
|
-
em,
|
|
688
|
-
schemaValidator,
|
|
689
|
-
openTelemetryCollector,
|
|
690
|
-
billingPortalService,
|
|
691
|
-
checkoutSessionService,
|
|
692
|
-
paymentLinkService,
|
|
693
|
-
planService,
|
|
694
|
-
subscriptionService
|
|
695
|
-
) {
|
|
607
|
+
constructor(stripeClient, em, schemaValidator, openTelemetryCollector, billingPortalService, checkoutSessionService, paymentLinkService, planService, subscriptionService) {
|
|
696
608
|
this.stripeClient = stripeClient;
|
|
697
609
|
this.em = em;
|
|
698
610
|
this.schemaValidator = schemaValidator;
|
|
@@ -705,11 +617,11 @@ var StripeWebhookService = class {
|
|
|
705
617
|
}
|
|
706
618
|
async handleWebhookEvent(event) {
|
|
707
619
|
if (this.openTelemetryCollector) {
|
|
708
|
-
this.openTelemetryCollector.info(
|
|
620
|
+
this.openTelemetryCollector.info("Handling webhook event", event);
|
|
709
621
|
}
|
|
710
622
|
const eventType = event.type;
|
|
711
623
|
switch (eventType) {
|
|
712
|
-
case
|
|
624
|
+
case "billing_portal.session.created": {
|
|
713
625
|
this.billingPortalService.baseBillingPortalService.createBillingPortalSession(
|
|
714
626
|
{
|
|
715
627
|
id: event.data.object.id,
|
|
@@ -721,162 +633,136 @@ var StripeWebhookService = class {
|
|
|
721
633
|
);
|
|
722
634
|
break;
|
|
723
635
|
}
|
|
724
|
-
case
|
|
636
|
+
case "checkout.session.expired": {
|
|
725
637
|
this.checkoutSessionService.handleCheckoutFailure({
|
|
726
638
|
id: event.data.object.id
|
|
727
639
|
});
|
|
728
640
|
break;
|
|
729
641
|
}
|
|
730
|
-
case
|
|
642
|
+
case "checkout.session.completed": {
|
|
731
643
|
this.checkoutSessionService.handleCheckoutSuccess({
|
|
732
644
|
id: event.data.object.id
|
|
733
645
|
});
|
|
734
646
|
break;
|
|
735
647
|
}
|
|
736
|
-
case
|
|
648
|
+
case "payment_link.created":
|
|
737
649
|
{
|
|
738
650
|
this.paymentLinkService.basePaymentLinkService.createPaymentLink({
|
|
739
651
|
id: event.data.object.id,
|
|
740
|
-
amount:
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
) ?? 0,
|
|
652
|
+
amount: event.data.object.line_items?.data.reduce(
|
|
653
|
+
(total, item) => total + item.amount_total,
|
|
654
|
+
0
|
|
655
|
+
) ?? 0,
|
|
745
656
|
paymentMethods: event.data.object.payment_method_types,
|
|
746
|
-
status:
|
|
657
|
+
status: "CREATED",
|
|
747
658
|
currency: event.data.object.currency,
|
|
748
659
|
providerFields: event.data.object
|
|
749
660
|
});
|
|
750
661
|
}
|
|
751
662
|
break;
|
|
752
|
-
case
|
|
663
|
+
case "payment_link.updated": {
|
|
753
664
|
this.paymentLinkService.basePaymentLinkService.updatePaymentLink({
|
|
754
665
|
id: event.data.object.id,
|
|
755
|
-
amount:
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
) ?? 0,
|
|
666
|
+
amount: event.data.object.line_items?.data.reduce(
|
|
667
|
+
(total, item) => total + item.amount_total,
|
|
668
|
+
0
|
|
669
|
+
) ?? 0,
|
|
760
670
|
paymentMethods: event.data.object.payment_method_types,
|
|
761
|
-
status:
|
|
671
|
+
status: "UPDATED",
|
|
762
672
|
currency: event.data.object.currency,
|
|
763
673
|
providerFields: event.data.object
|
|
764
674
|
});
|
|
765
675
|
break;
|
|
766
676
|
}
|
|
767
|
-
case
|
|
768
|
-
if (
|
|
769
|
-
typeof event.data.object.product === 'object' &&
|
|
770
|
-
event.data.object.product != null &&
|
|
771
|
-
event.data.object.amount != null
|
|
772
|
-
) {
|
|
677
|
+
case "plan.created": {
|
|
678
|
+
if (typeof event.data.object.product === "object" && event.data.object.product != null && event.data.object.amount != null) {
|
|
773
679
|
this.planService.basePlanService.createPlan({
|
|
774
680
|
id: event.data.object.id,
|
|
775
|
-
billingProvider:
|
|
681
|
+
billingProvider: "stripe" /* STRIPE */,
|
|
776
682
|
cadence: event.data.object.interval,
|
|
777
683
|
currency: event.data.object.currency,
|
|
778
684
|
active: true,
|
|
779
|
-
name:
|
|
780
|
-
typeof event.data.object.product === 'string'
|
|
781
|
-
? event.data.object.product
|
|
782
|
-
: event.data.object.product?.id,
|
|
685
|
+
name: typeof event.data.object.product === "string" ? event.data.object.product : event.data.object.product?.id,
|
|
783
686
|
price: event.data.object.amount,
|
|
784
687
|
externalId: event.data.object.id,
|
|
785
688
|
providerFields: event.data.object
|
|
786
689
|
});
|
|
787
690
|
} else {
|
|
788
|
-
throw new Error(
|
|
691
|
+
throw new Error("Invalid plan");
|
|
789
692
|
}
|
|
790
693
|
break;
|
|
791
694
|
}
|
|
792
|
-
case
|
|
793
|
-
if (
|
|
794
|
-
typeof event.data.object.product === 'object' &&
|
|
795
|
-
event.data.object.product != null &&
|
|
796
|
-
event.data.object.amount != null
|
|
797
|
-
) {
|
|
695
|
+
case "plan.updated": {
|
|
696
|
+
if (typeof event.data.object.product === "object" && event.data.object.product != null && event.data.object.amount != null) {
|
|
798
697
|
this.planService.basePlanService.updatePlan({
|
|
799
698
|
id: event.data.object.id,
|
|
800
|
-
billingProvider:
|
|
699
|
+
billingProvider: "stripe" /* STRIPE */,
|
|
801
700
|
cadence: event.data.object.interval,
|
|
802
701
|
currency: event.data.object.currency,
|
|
803
702
|
active: true,
|
|
804
|
-
name:
|
|
805
|
-
typeof event.data.object.product === 'string'
|
|
806
|
-
? event.data.object.product
|
|
807
|
-
: event.data.object.product?.id,
|
|
703
|
+
name: typeof event.data.object.product === "string" ? event.data.object.product : event.data.object.product?.id,
|
|
808
704
|
price: event.data.object.amount,
|
|
809
705
|
externalId: event.data.object.id,
|
|
810
706
|
providerFields: event.data.object
|
|
811
707
|
});
|
|
812
708
|
} else {
|
|
813
|
-
throw new Error(
|
|
709
|
+
throw new Error("Invalid plan");
|
|
814
710
|
}
|
|
815
711
|
break;
|
|
816
712
|
}
|
|
817
|
-
case
|
|
713
|
+
case "plan.deleted": {
|
|
818
714
|
this.planService.deletePlan({
|
|
819
715
|
id: event.data.object.id
|
|
820
716
|
});
|
|
821
717
|
break;
|
|
822
718
|
}
|
|
823
|
-
case
|
|
719
|
+
case "customer.subscription.created": {
|
|
824
720
|
this.subscriptionService.baseSubscriptionService.createSubscription({
|
|
825
721
|
id: event.data.object.id,
|
|
826
|
-
partyId:
|
|
827
|
-
|
|
828
|
-
? event.data.object.customer
|
|
829
|
-
: event.data.object.customer.id,
|
|
830
|
-
partyType: 'USER',
|
|
722
|
+
partyId: typeof event.data.object.customer === "string" ? event.data.object.customer : event.data.object.customer.id,
|
|
723
|
+
partyType: "USER",
|
|
831
724
|
description: event.data.object.description ?? void 0,
|
|
832
725
|
active: true,
|
|
833
726
|
productId: event.data.object.items.data[0].plan.id,
|
|
834
727
|
providerFields: event.data.object,
|
|
835
728
|
externalId: event.data.object.id,
|
|
836
|
-
billingProvider:
|
|
729
|
+
billingProvider: "stripe" /* STRIPE */,
|
|
837
730
|
startDate: new Date(event.data.object.created),
|
|
838
|
-
endDate: event.data.object.cancel_at
|
|
839
|
-
? new Date(event.data.object.cancel_at)
|
|
840
|
-
: /* @__PURE__ */ new Date(Infinity),
|
|
731
|
+
endDate: event.data.object.cancel_at ? new Date(event.data.object.cancel_at) : /* @__PURE__ */ new Date(Infinity),
|
|
841
732
|
status: event.data.object.status
|
|
842
733
|
});
|
|
843
734
|
break;
|
|
844
735
|
}
|
|
845
|
-
case
|
|
736
|
+
case "customer.subscription.updated": {
|
|
846
737
|
this.subscriptionService.baseSubscriptionService.updateSubscription({
|
|
847
738
|
id: event.data.object.id,
|
|
848
|
-
partyId:
|
|
849
|
-
|
|
850
|
-
? event.data.object.customer
|
|
851
|
-
: event.data.object.customer.id,
|
|
852
|
-
partyType: 'USER',
|
|
739
|
+
partyId: typeof event.data.object.customer === "string" ? event.data.object.customer : event.data.object.customer.id,
|
|
740
|
+
partyType: "USER",
|
|
853
741
|
description: event.data.object.description ?? void 0,
|
|
854
742
|
active: true,
|
|
855
743
|
providerFields: event.data.object,
|
|
856
744
|
externalId: event.data.object.id,
|
|
857
|
-
billingProvider:
|
|
745
|
+
billingProvider: "stripe" /* STRIPE */,
|
|
858
746
|
startDate: new Date(event.data.object.created),
|
|
859
|
-
endDate: event.data.object.cancel_at
|
|
860
|
-
? new Date(event.data.object.cancel_at)
|
|
861
|
-
: /* @__PURE__ */ new Date(Infinity),
|
|
747
|
+
endDate: event.data.object.cancel_at ? new Date(event.data.object.cancel_at) : /* @__PURE__ */ new Date(Infinity),
|
|
862
748
|
productId: event.data.object.items.data[0].plan.id,
|
|
863
749
|
status: event.data.object.status
|
|
864
750
|
});
|
|
865
751
|
break;
|
|
866
752
|
}
|
|
867
|
-
case
|
|
753
|
+
case "customer.subscription.deleted": {
|
|
868
754
|
this.subscriptionService.deleteSubscription({
|
|
869
755
|
id: event.data.object.id
|
|
870
756
|
});
|
|
871
757
|
break;
|
|
872
758
|
}
|
|
873
|
-
case
|
|
759
|
+
case "customer.subscription.paused": {
|
|
874
760
|
this.subscriptionService.cancelSubscription({
|
|
875
761
|
id: event.data.object.id
|
|
876
762
|
});
|
|
877
763
|
break;
|
|
878
764
|
}
|
|
879
|
-
case
|
|
765
|
+
case "customer.subscription.resumed": {
|
|
880
766
|
this.subscriptionService.resumeSubscription({
|
|
881
767
|
id: event.data.object.id
|
|
882
768
|
});
|
|
@@ -884,7 +770,7 @@ var StripeWebhookService = class {
|
|
|
884
770
|
}
|
|
885
771
|
default:
|
|
886
772
|
this.openTelemetryCollector.info(
|
|
887
|
-
|
|
773
|
+
"Unprocessed stripe event type",
|
|
888
774
|
eventType
|
|
889
775
|
);
|
|
890
776
|
break;
|
|
@@ -892,12 +778,11 @@ var StripeWebhookService = class {
|
|
|
892
778
|
}
|
|
893
779
|
};
|
|
894
780
|
// Annotate the CommonJS export names for ESM import in node:
|
|
895
|
-
0 &&
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
});
|
|
781
|
+
0 && (module.exports = {
|
|
782
|
+
StripeBillingPortalService,
|
|
783
|
+
StripeCheckoutSessionService,
|
|
784
|
+
StripePaymentLinkService,
|
|
785
|
+
StripePlanService,
|
|
786
|
+
StripeSubscriptionService,
|
|
787
|
+
StripeWebhookService
|
|
788
|
+
});
|