@darraghor/nest-backend-libs 5.7.5 → 6.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/README.md +87 -36
- package/dist/exports/authorization.d.ts +14 -0
- package/dist/exports/authorization.js +12 -0
- package/dist/exports/authorization.js.map +1 -0
- package/dist/exports/core.d.ts +11 -0
- package/dist/exports/core.js +10 -0
- package/dist/exports/core.js.map +1 -0
- package/dist/exports/database.d.ts +5 -0
- package/dist/exports/database.js +6 -0
- package/dist/exports/database.js.map +1 -0
- package/dist/exports/email.d.ts +4 -0
- package/dist/exports/email.js +4 -0
- package/dist/exports/email.js.map +1 -0
- package/dist/exports/invitations.d.ts +6 -0
- package/dist/exports/invitations.js +6 -0
- package/dist/exports/invitations.js.map +1 -0
- package/dist/exports/organisations.d.ts +11 -0
- package/dist/exports/organisations.js +12 -0
- package/dist/exports/organisations.js.map +1 -0
- package/dist/exports/stripe-legacy.d.ts +6 -0
- package/dist/exports/stripe-legacy.js +7 -0
- package/dist/exports/stripe-legacy.js.map +1 -0
- package/dist/exports/stripe.d.ts +11 -0
- package/dist/exports/stripe.js +9 -0
- package/dist/exports/stripe.js.map +1 -0
- package/dist/exports/twitter.d.ts +5 -0
- package/dist/exports/twitter.js +5 -0
- package/dist/exports/twitter.js.map +1 -0
- package/dist/exports/users.d.ts +10 -0
- package/dist/exports/users.js +11 -0
- package/dist/exports/users.js.map +1 -0
- package/dist/index.d.ts +11 -0
- package/dist/index.js +11 -0
- package/dist/index.js.map +1 -1
- package/dist/organisation-subscriptions/entities/organisation-subscription.entity.js +2 -1
- package/dist/organisation-subscriptions/entities/organisation-subscription.entity.js.map +1 -1
- package/dist/stripe-client/StripeClientConfigurationService.js +1 -0
- package/dist/stripe-client/StripeClientConfigurationService.js.map +1 -1
- package/dist/stripe-client/controllers/stripe-checkout-controller.d.ts +1 -0
- package/dist/stripe-client/controllers/stripe-checkout-controller.js +1 -0
- package/dist/stripe-client/controllers/stripe-checkout-controller.js.map +1 -1
- package/dist/stripe-client/controllers/stripe-events-controller.js +1 -0
- package/dist/stripe-client/controllers/stripe-events-controller.js.map +1 -1
- package/dist/stripe-client/controllers/stripe-unauthenticated-checkout-controller.js +1 -0
- package/dist/stripe-client/controllers/stripe-unauthenticated-checkout-controller.js.map +1 -1
- package/dist/stripe-client/services/auth-stripe-checkout.service.js +1 -0
- package/dist/stripe-client/services/auth-stripe-checkout.service.js.map +1 -1
- package/dist/stripe-client/services/queued-payment-event.handler.d.ts +1 -0
- package/dist/stripe-client/services/queued-payment-event.handler.js +2 -0
- package/dist/stripe-client/services/queued-payment-event.handler.js.map +1 -1
- package/dist/stripe-client/services/stripe-checkout.service.d.ts +1 -0
- package/dist/stripe-client/services/stripe-checkout.service.js +2 -0
- package/dist/stripe-client/services/stripe-checkout.service.js.map +1 -1
- package/dist/stripe-client/stripe-account.module.d.ts +1 -0
- package/dist/stripe-client/stripe-account.module.js +2 -0
- package/dist/stripe-client/stripe-account.module.js.map +1 -1
- package/dist/stripe-client/stripe-account.options.d.ts +2 -0
- package/dist/stripe-client/stripe-account.options.js.map +1 -1
- package/dist/stripe-payments/controllers/secure-stripe-checkout.controller.d.ts +10 -0
- package/dist/stripe-payments/controllers/secure-stripe-checkout.controller.js +65 -0
- package/dist/stripe-payments/controllers/secure-stripe-checkout.controller.js.map +1 -0
- package/dist/stripe-payments/controllers/secure-stripe-events.controller.d.ts +9 -0
- package/dist/stripe-payments/controllers/secure-stripe-events.controller.js +65 -0
- package/dist/stripe-payments/controllers/secure-stripe-events.controller.js.map +1 -0
- package/dist/stripe-payments/controllers/secure-stripe-webhook.controller.d.ts +14 -0
- package/dist/stripe-payments/controllers/secure-stripe-webhook.controller.js +112 -0
- package/dist/stripe-payments/controllers/secure-stripe-webhook.controller.js.map +1 -0
- package/dist/stripe-payments/entities/stripe-checkout-attempt.entity.d.ts +15 -0
- package/dist/stripe-payments/entities/stripe-checkout-attempt.entity.js +88 -0
- package/dist/stripe-payments/entities/stripe-checkout-attempt.entity.js.map +1 -0
- package/dist/stripe-payments/entities/stripe-payment-event.entity.d.ts +16 -0
- package/dist/stripe-payments/entities/stripe-payment-event.entity.js +101 -0
- package/dist/stripe-payments/entities/stripe-payment-event.entity.js.map +1 -0
- package/dist/stripe-payments/entities/stripe-payment-state.entity.d.ts +9 -0
- package/dist/stripe-payments/entities/stripe-payment-state.entity.js +53 -0
- package/dist/stripe-payments/entities/stripe-payment-state.entity.js.map +1 -0
- package/dist/stripe-payments/models/secure-checkout.dto.d.ts +14 -0
- package/dist/stripe-payments/models/secure-checkout.dto.js +105 -0
- package/dist/stripe-payments/models/secure-checkout.dto.js.map +1 -0
- package/dist/stripe-payments/models/secure-payment-response.dto.d.ts +7 -0
- package/dist/stripe-payments/models/secure-payment-response.dto.js +30 -0
- package/dist/stripe-payments/models/secure-payment-response.dto.js.map +1 -0
- package/dist/stripe-payments/services/default-stripe-payments-entitlement-store.d.ts +12 -0
- package/dist/stripe-payments/services/default-stripe-payments-entitlement-store.js +49 -0
- package/dist/stripe-payments/services/default-stripe-payments-entitlement-store.js.map +1 -0
- package/dist/stripe-payments/services/secure-stripe-checkout.service.d.ts +24 -0
- package/dist/stripe-payments/services/secure-stripe-checkout.service.js +213 -0
- package/dist/stripe-payments/services/secure-stripe-checkout.service.js.map +1 -0
- package/dist/stripe-payments/services/secure-stripe-client.provider.d.ts +2 -0
- package/dist/stripe-payments/services/secure-stripe-client.provider.js +15 -0
- package/dist/stripe-payments/services/secure-stripe-client.provider.js.map +1 -0
- package/dist/stripe-payments/services/secure-stripe-product.service.d.ts +9 -0
- package/dist/stripe-payments/services/secure-stripe-product.service.js +54 -0
- package/dist/stripe-payments/services/secure-stripe-product.service.js.map +1 -0
- package/dist/stripe-payments/services/secure-stripe-webhook.service.d.ts +14 -0
- package/dist/stripe-payments/services/secure-stripe-webhook.service.js +58 -0
- package/dist/stripe-payments/services/secure-stripe-webhook.service.js.map +1 -0
- package/dist/stripe-payments/services/secure-subscription.service.d.ts +18 -0
- package/dist/stripe-payments/services/secure-subscription.service.js +217 -0
- package/dist/stripe-payments/services/secure-subscription.service.js.map +1 -0
- package/dist/stripe-payments/services/stripe-payment-event.processor.d.ts +15 -0
- package/dist/stripe-payments/services/stripe-payment-event.processor.js +78 -0
- package/dist/stripe-payments/services/stripe-payment-event.processor.js.map +1 -0
- package/dist/stripe-payments/services/stripe-payment-event.service.d.ts +20 -0
- package/dist/stripe-payments/services/stripe-payment-event.service.js +178 -0
- package/dist/stripe-payments/services/stripe-payment-event.service.js.map +1 -0
- package/dist/stripe-payments/services/stripe-payment-fulfillment.service.d.ts +31 -0
- package/dist/stripe-payments/services/stripe-payment-fulfillment.service.js +331 -0
- package/dist/stripe-payments/services/stripe-payment-fulfillment.service.js.map +1 -0
- package/dist/stripe-payments/services/stripe-payments-operations.service.d.ts +25 -0
- package/dist/stripe-payments/services/stripe-payments-operations.service.js +59 -0
- package/dist/stripe-payments/services/stripe-payments-operations.service.js.map +1 -0
- package/dist/stripe-payments/services/stripe-payments-telemetry.service.d.ts +7 -0
- package/dist/stripe-payments/services/stripe-payments-telemetry.service.js +40 -0
- package/dist/stripe-payments/services/stripe-payments-telemetry.service.js.map +1 -0
- package/dist/stripe-payments/stripe-payment.config.d.ts +19 -0
- package/dist/stripe-payments/stripe-payment.config.js +98 -0
- package/dist/stripe-payments/stripe-payment.config.js.map +1 -0
- package/dist/stripe-payments/stripe-payment.config.test.d.ts +1 -0
- package/dist/stripe-payments/stripe-payment.config.test.js +59 -0
- package/dist/stripe-payments/stripe-payment.config.test.js.map +1 -0
- package/dist/stripe-payments/stripe-payments.extensions.d.ts +69 -0
- package/dist/stripe-payments/stripe-payments.extensions.js +30 -0
- package/dist/stripe-payments/stripe-payments.extensions.js.map +1 -0
- package/dist/stripe-payments/stripe-payments.module.d.ts +12 -0
- package/dist/stripe-payments/stripe-payments.module.js +118 -0
- package/dist/stripe-payments/stripe-payments.module.js.map +1 -0
- package/dist/stripe-payments/stripe-payments.options.d.ts +21 -0
- package/dist/stripe-payments/stripe-payments.options.js +2 -0
- package/dist/stripe-payments/stripe-payments.options.js.map +1 -0
- package/dist/typeorm/entities.d.ts +15 -0
- package/dist/typeorm/entities.js +32 -0
- package/dist/typeorm/entities.js.map +1 -0
- package/package.json +41 -1
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
11
|
+
import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from "typeorm";
|
|
12
|
+
let StripeCheckoutEvent = class StripeCheckoutEvent {
|
|
13
|
+
id;
|
|
14
|
+
stripeEventId;
|
|
15
|
+
stripeObjectId;
|
|
16
|
+
eventType;
|
|
17
|
+
clientReferenceId;
|
|
18
|
+
status;
|
|
19
|
+
stripeData;
|
|
20
|
+
errorMessage;
|
|
21
|
+
processingStartedAt;
|
|
22
|
+
processedAt;
|
|
23
|
+
processingAttempts;
|
|
24
|
+
createdDate;
|
|
25
|
+
updatedDate;
|
|
26
|
+
get stripeDataAsString() {
|
|
27
|
+
return JSON.stringify(this.stripeData, undefined, 4);
|
|
28
|
+
}
|
|
29
|
+
};
|
|
30
|
+
__decorate([
|
|
31
|
+
PrimaryGeneratedColumn(),
|
|
32
|
+
ApiProperty(),
|
|
33
|
+
__metadata("design:type", Number)
|
|
34
|
+
], StripeCheckoutEvent.prototype, "id", void 0);
|
|
35
|
+
__decorate([
|
|
36
|
+
Column({ length: 255 }),
|
|
37
|
+
ApiProperty(),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], StripeCheckoutEvent.prototype, "stripeEventId", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
Column({ length: 255 }),
|
|
42
|
+
ApiProperty(),
|
|
43
|
+
__metadata("design:type", String)
|
|
44
|
+
], StripeCheckoutEvent.prototype, "stripeObjectId", void 0);
|
|
45
|
+
__decorate([
|
|
46
|
+
Column({ length: 128 }),
|
|
47
|
+
ApiProperty(),
|
|
48
|
+
__metadata("design:type", String)
|
|
49
|
+
], StripeCheckoutEvent.prototype, "eventType", void 0);
|
|
50
|
+
__decorate([
|
|
51
|
+
Column({ nullable: true, length: 255 }),
|
|
52
|
+
ApiPropertyOptional(),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], StripeCheckoutEvent.prototype, "clientReferenceId", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
Column({ length: 32, default: "received" }),
|
|
57
|
+
ApiProperty(),
|
|
58
|
+
__metadata("design:type", String)
|
|
59
|
+
], StripeCheckoutEvent.prototype, "status", void 0);
|
|
60
|
+
__decorate([
|
|
61
|
+
Column({ type: "jsonb" }),
|
|
62
|
+
__metadata("design:type", Object)
|
|
63
|
+
], StripeCheckoutEvent.prototype, "stripeData", void 0);
|
|
64
|
+
__decorate([
|
|
65
|
+
Column({ nullable: true, type: "text" }),
|
|
66
|
+
__metadata("design:type", String)
|
|
67
|
+
], StripeCheckoutEvent.prototype, "errorMessage", void 0);
|
|
68
|
+
__decorate([
|
|
69
|
+
Column({ nullable: true, type: "timestamptz" }),
|
|
70
|
+
__metadata("design:type", Date)
|
|
71
|
+
], StripeCheckoutEvent.prototype, "processingStartedAt", void 0);
|
|
72
|
+
__decorate([
|
|
73
|
+
Column({ nullable: true, type: "timestamptz" }),
|
|
74
|
+
__metadata("design:type", Date)
|
|
75
|
+
], StripeCheckoutEvent.prototype, "processedAt", void 0);
|
|
76
|
+
__decorate([
|
|
77
|
+
Column({ default: 0 }),
|
|
78
|
+
__metadata("design:type", Number)
|
|
79
|
+
], StripeCheckoutEvent.prototype, "processingAttempts", void 0);
|
|
80
|
+
__decorate([
|
|
81
|
+
CreateDateColumn(),
|
|
82
|
+
ApiProperty({ format: "date-time" }),
|
|
83
|
+
__metadata("design:type", Date)
|
|
84
|
+
], StripeCheckoutEvent.prototype, "createdDate", void 0);
|
|
85
|
+
__decorate([
|
|
86
|
+
UpdateDateColumn(),
|
|
87
|
+
__metadata("design:type", Date)
|
|
88
|
+
], StripeCheckoutEvent.prototype, "updatedDate", void 0);
|
|
89
|
+
__decorate([
|
|
90
|
+
ApiProperty({ type: String, name: "stripeDataAsString" }),
|
|
91
|
+
__metadata("design:type", String),
|
|
92
|
+
__metadata("design:paramtypes", [])
|
|
93
|
+
], StripeCheckoutEvent.prototype, "stripeDataAsString", null);
|
|
94
|
+
StripeCheckoutEvent = __decorate([
|
|
95
|
+
Entity("stripe_payment_event"),
|
|
96
|
+
Index(["stripeEventId"], { unique: true }),
|
|
97
|
+
Index(["stripeObjectId", "eventType"]),
|
|
98
|
+
Index(["status", "processingStartedAt"])
|
|
99
|
+
], StripeCheckoutEvent);
|
|
100
|
+
export { StripeCheckoutEvent };
|
|
101
|
+
//# sourceMappingURL=stripe-payment-event.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-payment-event.entity.js","sourceRoot":"","sources":["../../../src/stripe-payments/entities/stripe-payment-event.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACjE,OAAO,EACH,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAMV,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;IAG5B,EAAE,CAAU;IAIZ,aAAa,CAAU;IAIvB,cAAc,CAAU;IAIxB,SAAS,CAAU;IAInB,iBAAiB,CAAU;IAI3B,MAAM,CAAsD;IAG5D,UAAU,CAAW;IAGrB,YAAY,CAAU;IAGtB,mBAAmB,CAAQ;IAG3B,WAAW,CAAQ;IAGnB,kBAAkB,CAAU;IAI5B,WAAW,CAAQ;IAGnB,WAAW,CAAQ;IAEnB,IACI,kBAAkB;QAClB,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,UAAU,EAAE,SAAS,EAAE,CAAC,CAAC,CAAC;IACzD,CAAC;CACJ,CAAA;AAhDG;IAFC,sBAAsB,EAAE;IACxB,WAAW,EAAE;;+CACF;AAIZ;IAFC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;IACrB,WAAW,EAAE;;0DACS;AAIvB;IAFC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;IACrB,WAAW,EAAE;;2DACU;AAIxB;IAFC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;IACrB,WAAW,EAAE;;sDACK;AAInB;IAFC,MAAM,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,MAAM,EAAE,GAAG,EAAC,CAAC;IACrC,mBAAmB,EAAE;;8DACK;AAI3B;IAFC,MAAM,CAAC,EAAC,MAAM,EAAE,EAAE,EAAE,OAAO,EAAE,UAAU,EAAC,CAAC;IACzC,WAAW,EAAE;;mDAC8C;AAG5D;IADC,MAAM,CAAC,EAAC,IAAI,EAAE,OAAO,EAAC,CAAC;;uDACH;AAGrB;IADC,MAAM,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,MAAM,EAAC,CAAC;;yDACjB;AAGtB;IADC,MAAM,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC;8BACxB,IAAI;gEAAC;AAG3B;IADC,MAAM,CAAC,EAAC,QAAQ,EAAE,IAAI,EAAE,IAAI,EAAE,aAAa,EAAC,CAAC;8BAChC,IAAI;wDAAC;AAGnB;IADC,MAAM,CAAC,EAAC,OAAO,EAAE,CAAC,EAAC,CAAC;;+DACO;AAI5B;IAFC,gBAAgB,EAAE;IAClB,WAAW,CAAC,EAAC,MAAM,EAAE,WAAW,EAAC,CAAC;8BACrB,IAAI;wDAAC;AAGnB;IADC,gBAAgB,EAAE;8BACL,IAAI;wDAAC;AAEnB;IAAC,WAAW,CAAC,EAAC,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,oBAAoB,EAAC,CAAC;;;6DAGvD;AAlDQ,mBAAmB;IAJ/B,MAAM,CAAC,sBAAsB,CAAC;IAC9B,KAAK,CAAC,CAAC,eAAe,CAAC,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;IACxC,KAAK,CAAC,CAAC,gBAAgB,EAAE,WAAW,CAAC,CAAC;IACtC,KAAK,CAAC,CAAC,QAAQ,EAAE,qBAAqB,CAAC,CAAC;GAC5B,mBAAmB,CAmD/B"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Column, CreateDateColumn, Entity, Index, PrimaryGeneratedColumn, UpdateDateColumn, } from "typeorm";
|
|
11
|
+
let StripePaymentState = class StripePaymentState {
|
|
12
|
+
id;
|
|
13
|
+
paymentSystemTransactionId;
|
|
14
|
+
lastStripeEventId;
|
|
15
|
+
lastStripeEventCreatedAt;
|
|
16
|
+
status;
|
|
17
|
+
createdDate;
|
|
18
|
+
updatedDate;
|
|
19
|
+
};
|
|
20
|
+
__decorate([
|
|
21
|
+
PrimaryGeneratedColumn(),
|
|
22
|
+
__metadata("design:type", Number)
|
|
23
|
+
], StripePaymentState.prototype, "id", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
Column({ length: 255 }),
|
|
26
|
+
__metadata("design:type", String)
|
|
27
|
+
], StripePaymentState.prototype, "paymentSystemTransactionId", void 0);
|
|
28
|
+
__decorate([
|
|
29
|
+
Column({ length: 255 }),
|
|
30
|
+
__metadata("design:type", String)
|
|
31
|
+
], StripePaymentState.prototype, "lastStripeEventId", void 0);
|
|
32
|
+
__decorate([
|
|
33
|
+
Column({ type: "timestamptz" }),
|
|
34
|
+
__metadata("design:type", Date)
|
|
35
|
+
], StripePaymentState.prototype, "lastStripeEventCreatedAt", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
Column({ length: 64 }),
|
|
38
|
+
__metadata("design:type", String)
|
|
39
|
+
], StripePaymentState.prototype, "status", void 0);
|
|
40
|
+
__decorate([
|
|
41
|
+
CreateDateColumn(),
|
|
42
|
+
__metadata("design:type", Date)
|
|
43
|
+
], StripePaymentState.prototype, "createdDate", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
UpdateDateColumn(),
|
|
46
|
+
__metadata("design:type", Date)
|
|
47
|
+
], StripePaymentState.prototype, "updatedDate", void 0);
|
|
48
|
+
StripePaymentState = __decorate([
|
|
49
|
+
Entity("stripe_payment_state"),
|
|
50
|
+
Index(["paymentSystemTransactionId"], { unique: true })
|
|
51
|
+
], StripePaymentState);
|
|
52
|
+
export { StripePaymentState };
|
|
53
|
+
//# sourceMappingURL=stripe-payment-state.entity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-payment-state.entity.js","sourceRoot":"","sources":["../../../src/stripe-payments/entities/stripe-payment-state.entity.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EACH,MAAM,EACN,gBAAgB,EAChB,MAAM,EACN,KAAK,EACL,sBAAsB,EACtB,gBAAgB,GACnB,MAAM,SAAS,CAAC;AAIV,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAE3B,EAAE,CAAU;IAGZ,0BAA0B,CAAU;IAGpC,iBAAiB,CAAU;IAG3B,wBAAwB,CAAQ;IAGhC,MAAM,CAAU;IAGhB,WAAW,CAAQ;IAGnB,WAAW,CAAQ;CACtB,CAAA;AAnBG;IADC,sBAAsB,EAAE;;8CACb;AAGZ;IADC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;;sEACc;AAGpC;IADC,MAAM,CAAC,EAAC,MAAM,EAAE,GAAG,EAAC,CAAC;;6DACK;AAG3B;IADC,MAAM,CAAC,EAAC,IAAI,EAAE,aAAa,EAAC,CAAC;8BACH,IAAI;oEAAC;AAGhC;IADC,MAAM,CAAC,EAAC,MAAM,EAAE,EAAE,EAAC,CAAC;;kDACL;AAGhB;IADC,gBAAgB,EAAE;8BACL,IAAI;uDAAC;AAGnB;IADC,gBAAgB,EAAE;8BACL,IAAI;uDAAC;AApBV,kBAAkB;IAF9B,MAAM,CAAC,sBAAsB,CAAC;IAC9B,KAAK,CAAC,CAAC,4BAA4B,CAAC,EAAE,EAAC,MAAM,EAAE,IAAI,EAAC,CAAC;GACzC,kBAAkB,CAqB9B"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class StripeCheckoutSessionRequestDto {
|
|
2
|
+
organisationUuid: string;
|
|
3
|
+
productKey: string;
|
|
4
|
+
successFrontendPath: string;
|
|
5
|
+
cancelFrontendPath?: string;
|
|
6
|
+
}
|
|
7
|
+
export declare class StripeCustomerPortalRequestDto {
|
|
8
|
+
subscriptionRecordUuid: string;
|
|
9
|
+
returnUrl: string;
|
|
10
|
+
}
|
|
11
|
+
export declare class StripeEventsQueryDto {
|
|
12
|
+
skip: number;
|
|
13
|
+
take: number;
|
|
14
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty, ApiPropertyOptional } from "@nestjs/swagger";
|
|
11
|
+
import { Type } from "class-transformer";
|
|
12
|
+
import { IsInt, IsNotEmpty, IsOptional, IsString, IsUUID, Matches, Max, MaxLength, Min, } from "class-validator";
|
|
13
|
+
const relativePathPattern = /^\/(?!\/)[^\s]*$/;
|
|
14
|
+
export class StripeCheckoutSessionRequestDto {
|
|
15
|
+
organisationUuid;
|
|
16
|
+
productKey;
|
|
17
|
+
successFrontendPath;
|
|
18
|
+
cancelFrontendPath;
|
|
19
|
+
}
|
|
20
|
+
__decorate([
|
|
21
|
+
ApiProperty(),
|
|
22
|
+
IsUUID("4"),
|
|
23
|
+
__metadata("design:type", String)
|
|
24
|
+
], StripeCheckoutSessionRequestDto.prototype, "organisationUuid", void 0);
|
|
25
|
+
__decorate([
|
|
26
|
+
ApiProperty({
|
|
27
|
+
description: "A product key from the server-side Stripe product catalog",
|
|
28
|
+
}),
|
|
29
|
+
IsString(),
|
|
30
|
+
IsNotEmpty(),
|
|
31
|
+
Matches(/^[a-z0-9][a-z0-9_-]{0,63}$/),
|
|
32
|
+
__metadata("design:type", String)
|
|
33
|
+
], StripeCheckoutSessionRequestDto.prototype, "productKey", void 0);
|
|
34
|
+
__decorate([
|
|
35
|
+
ApiProperty({
|
|
36
|
+
description: "A relative frontend path on the configured application origin",
|
|
37
|
+
}),
|
|
38
|
+
IsString(),
|
|
39
|
+
IsNotEmpty(),
|
|
40
|
+
MaxLength(200),
|
|
41
|
+
Matches(relativePathPattern),
|
|
42
|
+
__metadata("design:type", String)
|
|
43
|
+
], StripeCheckoutSessionRequestDto.prototype, "successFrontendPath", void 0);
|
|
44
|
+
__decorate([
|
|
45
|
+
ApiPropertyOptional({
|
|
46
|
+
description: "A relative frontend path on the configured application origin",
|
|
47
|
+
}),
|
|
48
|
+
IsOptional(),
|
|
49
|
+
IsString(),
|
|
50
|
+
MaxLength(200),
|
|
51
|
+
Matches(relativePathPattern),
|
|
52
|
+
__metadata("design:type", String)
|
|
53
|
+
], StripeCheckoutSessionRequestDto.prototype, "cancelFrontendPath", void 0);
|
|
54
|
+
export class StripeCustomerPortalRequestDto {
|
|
55
|
+
subscriptionRecordUuid;
|
|
56
|
+
returnUrl;
|
|
57
|
+
}
|
|
58
|
+
__decorate([
|
|
59
|
+
ApiProperty(),
|
|
60
|
+
IsUUID("4"),
|
|
61
|
+
__metadata("design:type", String)
|
|
62
|
+
], StripeCustomerPortalRequestDto.prototype, "subscriptionRecordUuid", void 0);
|
|
63
|
+
__decorate([
|
|
64
|
+
ApiProperty({
|
|
65
|
+
description: "A relative frontend path on the configured application origin",
|
|
66
|
+
}),
|
|
67
|
+
IsString(),
|
|
68
|
+
IsNotEmpty(),
|
|
69
|
+
MaxLength(200),
|
|
70
|
+
Matches(relativePathPattern),
|
|
71
|
+
__metadata("design:type", String)
|
|
72
|
+
], StripeCustomerPortalRequestDto.prototype, "returnUrl", void 0);
|
|
73
|
+
export class StripeEventsQueryDto {
|
|
74
|
+
skip = 0;
|
|
75
|
+
take = 50;
|
|
76
|
+
}
|
|
77
|
+
__decorate([
|
|
78
|
+
ApiPropertyOptional({
|
|
79
|
+
type: Number,
|
|
80
|
+
default: 0,
|
|
81
|
+
minimum: 0,
|
|
82
|
+
maximum: 1000,
|
|
83
|
+
}),
|
|
84
|
+
IsOptional(),
|
|
85
|
+
Type(() => Number),
|
|
86
|
+
IsInt(),
|
|
87
|
+
Min(0),
|
|
88
|
+
Max(1000),
|
|
89
|
+
__metadata("design:type", Object)
|
|
90
|
+
], StripeEventsQueryDto.prototype, "skip", void 0);
|
|
91
|
+
__decorate([
|
|
92
|
+
ApiPropertyOptional({
|
|
93
|
+
type: Number,
|
|
94
|
+
default: 50,
|
|
95
|
+
minimum: 1,
|
|
96
|
+
maximum: 1000,
|
|
97
|
+
}),
|
|
98
|
+
IsOptional(),
|
|
99
|
+
Type(() => Number),
|
|
100
|
+
IsInt(),
|
|
101
|
+
Min(1),
|
|
102
|
+
Max(1000),
|
|
103
|
+
__metadata("design:type", Object)
|
|
104
|
+
], StripeEventsQueryDto.prototype, "take", void 0);
|
|
105
|
+
//# sourceMappingURL=secure-checkout.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-checkout.dto.js","sourceRoot":"","sources":["../../../src/stripe-payments/models/secure-checkout.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAE,mBAAmB,EAAC,MAAM,iBAAiB,CAAC;AACjE,OAAO,EAAC,IAAI,EAAC,MAAM,mBAAmB,CAAC;AACvC,OAAO,EACH,KAAK,EACL,UAAU,EACV,UAAU,EACV,QAAQ,EACR,MAAM,EACN,OAAO,EACP,GAAG,EACH,SAAS,EACT,GAAG,GACN,MAAM,iBAAiB,CAAC;AAEzB,MAAM,mBAAmB,GAAG,kBAAkB,CAAC;AAE/C,MAAM,OAAO,+BAA+B;IAGxC,gBAAgB,CAAU;IAS1B,UAAU,CAAU;IAUpB,mBAAmB,CAAU;IAU7B,kBAAkB,CAAU;CAC/B;AA9BG;IAFC,WAAW,EAAE;IACb,MAAM,CAAC,GAAG,CAAC;;yEACc;AAS1B;IAPC,WAAW,CAAC;QACT,WAAW,EACP,2DAA2D;KAClE,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;IACZ,OAAO,CAAC,4BAA4B,CAAC;;mEAClB;AAUpB;IARC,WAAW,CAAC;QACT,WAAW,EACP,+DAA+D;KACtE,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;IACZ,SAAS,CAAC,GAAG,CAAC;IACd,OAAO,CAAC,mBAAmB,CAAC;;4EACA;AAU7B;IARC,mBAAmB,CAAC;QACjB,WAAW,EACP,+DAA+D;KACtE,CAAC;IACD,UAAU,EAAE;IACZ,QAAQ,EAAE;IACV,SAAS,CAAC,GAAG,CAAC;IACd,OAAO,CAAC,mBAAmB,CAAC;;2EACD;AAGhC,MAAM,OAAO,8BAA8B;IAGvC,sBAAsB,CAAU;IAUhC,SAAS,CAAU;CACtB;AAXG;IAFC,WAAW,EAAE;IACb,MAAM,CAAC,GAAG,CAAC;;8EACoB;AAUhC;IARC,WAAW,CAAC;QACT,WAAW,EACP,+DAA+D;KACtE,CAAC;IACD,QAAQ,EAAE;IACV,UAAU,EAAE;IACZ,SAAS,CAAC,GAAG,CAAC;IACd,OAAO,CAAC,mBAAmB,CAAC;;iEACV;AAGvB,MAAM,OAAO,oBAAoB;IAY7B,IAAI,GAAG,CAAC,CAAC;IAaT,IAAI,GAAG,EAAE,CAAC;CACb;AAdG;IAXC,mBAAmB,CAAC;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,IAAI;KAChB,CAAC;IACD,UAAU,EAAE;IACZ,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,GAAG,CAAC,CAAC,CAAC;IACN,GAAG,CAAC,IAAI,CAAC;;kDACD;AAaT;IAXC,mBAAmB,CAAC;QACjB,IAAI,EAAE,MAAM;QACZ,OAAO,EAAE,EAAE;QACX,OAAO,EAAE,CAAC;QACV,OAAO,EAAE,IAAI;KAChB,CAAC;IACD,UAAU,EAAE;IACZ,IAAI,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC;IAClB,KAAK,EAAE;IACP,GAAG,CAAC,CAAC,CAAC;IACN,GAAG,CAAC,IAAI,CAAC;;kDACA"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { ApiProperty } from "@nestjs/swagger";
|
|
11
|
+
export class StripeCheckoutSessionResponseDto {
|
|
12
|
+
stripeSessionId;
|
|
13
|
+
stripeSessionUrl;
|
|
14
|
+
}
|
|
15
|
+
__decorate([
|
|
16
|
+
ApiProperty(),
|
|
17
|
+
__metadata("design:type", String)
|
|
18
|
+
], StripeCheckoutSessionResponseDto.prototype, "stripeSessionId", void 0);
|
|
19
|
+
__decorate([
|
|
20
|
+
ApiProperty(),
|
|
21
|
+
__metadata("design:type", String)
|
|
22
|
+
], StripeCheckoutSessionResponseDto.prototype, "stripeSessionUrl", void 0);
|
|
23
|
+
export class StripeCustomerPortalResponseDto {
|
|
24
|
+
sessionUrl;
|
|
25
|
+
}
|
|
26
|
+
__decorate([
|
|
27
|
+
ApiProperty(),
|
|
28
|
+
__metadata("design:type", String)
|
|
29
|
+
], StripeCustomerPortalResponseDto.prototype, "sessionUrl", void 0);
|
|
30
|
+
//# sourceMappingURL=secure-payment-response.dto.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"secure-payment-response.dto.js","sourceRoot":"","sources":["../../../src/stripe-payments/models/secure-payment-response.dto.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,WAAW,EAAC,MAAM,iBAAiB,CAAC;AAE5C,MAAM,OAAO,gCAAgC;IAEzC,eAAe,CAAU;IAGzB,gBAAgB,CAAU;CAC7B;AAJG;IADC,WAAW,EAAE;;yEACW;AAGzB;IADC,WAAW,EAAE;;0EACY;AAG9B,MAAM,OAAO,+BAA+B;IAExC,UAAU,CAAU;CACvB;AADG;IADC,WAAW,EAAE;;mEACM"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { StripePaymentsEntitlement, StripePaymentsEntitlementInput, StripePaymentsEntitlementStore, StripePaymentsRevocationInput } from "../stripe-payments.extensions.js";
|
|
2
|
+
import { SecureSubscriptionService } from "./secure-subscription.service.js";
|
|
3
|
+
export declare class DefaultStripePaymentsEntitlementStore implements StripePaymentsEntitlementStore {
|
|
4
|
+
private readonly subscriptionService;
|
|
5
|
+
constructor(subscriptionService: SecureSubscriptionService);
|
|
6
|
+
findByUuid(uuid: string): Promise<StripePaymentsEntitlement>;
|
|
7
|
+
findByTransactionId(paymentSystemTransactionId: string): Promise<StripePaymentsEntitlement | null>;
|
|
8
|
+
save(input: StripePaymentsEntitlementInput): Promise<void>;
|
|
9
|
+
revokeCustomerPayments(customerId: string, input: StripePaymentsRevocationInput): Promise<void>;
|
|
10
|
+
revokePayment(paymentSystemTransactionId: string, input: StripePaymentsRevocationInput): Promise<boolean>;
|
|
11
|
+
private map;
|
|
12
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { Injectable } from "@nestjs/common";
|
|
11
|
+
import { SecureSubscriptionService } from "./secure-subscription.service.js";
|
|
12
|
+
let DefaultStripePaymentsEntitlementStore = class DefaultStripePaymentsEntitlementStore {
|
|
13
|
+
subscriptionService;
|
|
14
|
+
constructor(subscriptionService) {
|
|
15
|
+
this.subscriptionService = subscriptionService;
|
|
16
|
+
}
|
|
17
|
+
async findByUuid(uuid) {
|
|
18
|
+
const record = await this.subscriptionService.findByUuid(uuid);
|
|
19
|
+
return this.map(record);
|
|
20
|
+
}
|
|
21
|
+
async findByTransactionId(paymentSystemTransactionId) {
|
|
22
|
+
const record = await this.subscriptionService.findByTransactionId(paymentSystemTransactionId);
|
|
23
|
+
return record ? this.map(record) : null;
|
|
24
|
+
}
|
|
25
|
+
async save(input) {
|
|
26
|
+
await this.subscriptionService.save(input);
|
|
27
|
+
}
|
|
28
|
+
revokeCustomerPayments(customerId, input) {
|
|
29
|
+
return this.subscriptionService.revokeCustomerPayments(customerId, input);
|
|
30
|
+
}
|
|
31
|
+
revokePayment(paymentSystemTransactionId, input) {
|
|
32
|
+
return this.subscriptionService.revokePayment(paymentSystemTransactionId, input);
|
|
33
|
+
}
|
|
34
|
+
map(record) {
|
|
35
|
+
return {
|
|
36
|
+
uuid: record.uuid,
|
|
37
|
+
organisationUuid: record.organisation.uuid,
|
|
38
|
+
paymentSystemTransactionId: record.paymentSystemTransactionId,
|
|
39
|
+
paymentSystemCustomerId: record.paymentSystemCustomerId,
|
|
40
|
+
paymentSystemMode: record.paymentSystemMode,
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
};
|
|
44
|
+
DefaultStripePaymentsEntitlementStore = __decorate([
|
|
45
|
+
Injectable(),
|
|
46
|
+
__metadata("design:paramtypes", [SecureSubscriptionService])
|
|
47
|
+
], DefaultStripePaymentsEntitlementStore);
|
|
48
|
+
export { DefaultStripePaymentsEntitlementStore };
|
|
49
|
+
//# sourceMappingURL=default-stripe-payments-entitlement-store.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"default-stripe-payments-entitlement-store.js","sourceRoot":"","sources":["../../../src/stripe-payments/services/default-stripe-payments-entitlement-store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAC,UAAU,EAAC,MAAM,gBAAgB,CAAC;AAO1C,OAAO,EAAC,yBAAyB,EAAC,MAAM,kCAAkC,CAAC;AAGpE,IAAM,qCAAqC,GAA3C,MAAM,qCAAqC;IAEzB;IADrB,YACqB,mBAA8C;QAA9C,wBAAmB,GAAnB,mBAAmB,CAA2B;IAChE,CAAC;IAEJ,KAAK,CAAC,UAAU,CAAC,IAAY;QACzB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC;QAC/D,OAAO,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;IAC5B,CAAC;IAED,KAAK,CAAC,mBAAmB,CACrB,0BAAkC;QAElC,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,mBAAmB,CAAC,mBAAmB,CAC7D,0BAA0B,CAC7B,CAAC;QACF,OAAO,MAAM,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC;IAC5C,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,KAAqC;QAC5C,MAAM,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;IAC/C,CAAC;IAED,sBAAsB,CAClB,UAAkB,EAClB,KAAoC;QAEpC,OAAO,IAAI,CAAC,mBAAmB,CAAC,sBAAsB,CAClD,UAAU,EACV,KAAK,CACR,CAAC;IACN,CAAC;IAED,aAAa,CACT,0BAAkC,EAClC,KAAoC;QAEpC,OAAO,IAAI,CAAC,mBAAmB,CAAC,aAAa,CACzC,0BAA0B,EAC1B,KAAK,CACR,CAAC;IACN,CAAC;IAEO,GAAG,CAAC,MAMX;QACG,OAAO;YACH,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,gBAAgB,EAAE,MAAM,CAAC,YAAY,CAAC,IAAI;YAC1C,0BAA0B,EAAE,MAAM,CAAC,0BAA0B;YAC7D,uBAAuB,EAAE,MAAM,CAAC,uBAAuB;YACvD,iBAAiB,EAAE,MAAM,CAAC,iBAAiB;SAC9C,CAAC;IACN,CAAC;CACJ,CAAA;AA1DY,qCAAqC;IADjD,UAAU,EAAE;qCAGiC,yBAAyB;GAF1D,qCAAqC,CA0DjD"}
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import { RequestUser } from "../../authorization/models/RequestWithUser.js";
|
|
2
|
+
import Stripe from "stripe";
|
|
3
|
+
import { Repository } from "typeorm";
|
|
4
|
+
import { StripeCheckoutSessionRequestDto, StripeCustomerPortalRequestDto } from "../models/secure-checkout.dto.js";
|
|
5
|
+
import { StripeCheckoutSessionResponseDto, StripeCustomerPortalResponseDto } from "../models/secure-payment-response.dto.js";
|
|
6
|
+
import { StripeCheckoutAttempt } from "../entities/stripe-checkout-attempt.entity.js";
|
|
7
|
+
import { SecureStripeProductService } from "./secure-stripe-product.service.js";
|
|
8
|
+
import { StripePaymentsAccessPolicy, StripePaymentsEntitlementStore } from "../stripe-payments.extensions.js";
|
|
9
|
+
import { StripePaymentsTelemetryService } from "./stripe-payments-telemetry.service.js";
|
|
10
|
+
export declare class SecureStripeCheckoutService {
|
|
11
|
+
private readonly stripe;
|
|
12
|
+
private readonly attemptRepository;
|
|
13
|
+
private readonly productService;
|
|
14
|
+
private readonly entitlementStore;
|
|
15
|
+
private readonly accessPolicy;
|
|
16
|
+
private readonly telemetry;
|
|
17
|
+
private readonly logger;
|
|
18
|
+
constructor(stripe: Stripe, attemptRepository: Repository<StripeCheckoutAttempt>, productService: SecureStripeProductService, entitlementStore: StripePaymentsEntitlementStore, accessPolicy: StripePaymentsAccessPolicy, telemetry: StripePaymentsTelemetryService);
|
|
19
|
+
createCheckoutSession(request: StripeCheckoutSessionRequestDto, user: RequestUser, idempotencyKey: string | undefined): Promise<StripeCheckoutSessionResponseDto>;
|
|
20
|
+
createCustomerPortalSession(request: StripeCustomerPortalRequestDto, user: RequestUser, idempotencyKey: string | undefined): Promise<StripeCustomerPortalResponseDto>;
|
|
21
|
+
private requireIdempotencyKey;
|
|
22
|
+
private assertMatchingAttempt;
|
|
23
|
+
private isUniqueViolation;
|
|
24
|
+
}
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
|
+
};
|
|
13
|
+
var SecureStripeCheckoutService_1;
|
|
14
|
+
import { ConflictException, Inject, Injectable, Logger, ServiceUnavailableException, } from "@nestjs/common";
|
|
15
|
+
import Stripe from "stripe";
|
|
16
|
+
import { InjectRepository } from "@nestjs/typeorm";
|
|
17
|
+
import { QueryFailedError, Repository } from "typeorm";
|
|
18
|
+
import { StripeCheckoutAttempt } from "../entities/stripe-checkout-attempt.entity.js";
|
|
19
|
+
import { SecureStripeProductService } from "./secure-stripe-product.service.js";
|
|
20
|
+
import { STRIPE_PAYMENTS_ACCESS_POLICY, STRIPE_PAYMENTS_ENTITLEMENT_STORE, } from "../stripe-payments.extensions.js";
|
|
21
|
+
import { StripePaymentsTelemetryService } from "./stripe-payments-telemetry.service.js";
|
|
22
|
+
const idempotencyKeyPattern = /^[A-Za-z0-9._-]{8,255}$/;
|
|
23
|
+
let SecureStripeCheckoutService = SecureStripeCheckoutService_1 = class SecureStripeCheckoutService {
|
|
24
|
+
stripe;
|
|
25
|
+
attemptRepository;
|
|
26
|
+
productService;
|
|
27
|
+
entitlementStore;
|
|
28
|
+
accessPolicy;
|
|
29
|
+
telemetry;
|
|
30
|
+
logger = new Logger(SecureStripeCheckoutService_1.name);
|
|
31
|
+
constructor(stripe, attemptRepository, productService, entitlementStore, accessPolicy, telemetry) {
|
|
32
|
+
this.stripe = stripe;
|
|
33
|
+
this.attemptRepository = attemptRepository;
|
|
34
|
+
this.productService = productService;
|
|
35
|
+
this.entitlementStore = entitlementStore;
|
|
36
|
+
this.accessPolicy = accessPolicy;
|
|
37
|
+
this.telemetry = telemetry;
|
|
38
|
+
}
|
|
39
|
+
async createCheckoutSession(request, user, idempotencyKey) {
|
|
40
|
+
const key = this.requireIdempotencyKey(idempotencyKey);
|
|
41
|
+
await this.accessPolicy.assertCanManageOrganisation({
|
|
42
|
+
organisationUuid: request.organisationUuid,
|
|
43
|
+
user,
|
|
44
|
+
operation: "checkout",
|
|
45
|
+
});
|
|
46
|
+
const product = this.productService.getByKey(request.productKey);
|
|
47
|
+
const successUrl = this.productService.buildRedirectUrl(request.successFrontendPath);
|
|
48
|
+
const cancelUrl = request.cancelFrontendPath
|
|
49
|
+
? this.productService.buildRedirectUrl(request.cancelFrontendPath)
|
|
50
|
+
: undefined;
|
|
51
|
+
const existingAttempt = await this.attemptRepository.findOne({
|
|
52
|
+
where: { idempotencyKey: key },
|
|
53
|
+
});
|
|
54
|
+
if (existingAttempt) {
|
|
55
|
+
this.assertMatchingAttempt(existingAttempt, request, user, product.priceId);
|
|
56
|
+
if (existingAttempt.status === "created" &&
|
|
57
|
+
existingAttempt.stripeSessionId &&
|
|
58
|
+
existingAttempt.stripeSessionUrl) {
|
|
59
|
+
return {
|
|
60
|
+
stripeSessionId: existingAttempt.stripeSessionId,
|
|
61
|
+
stripeSessionUrl: existingAttempt.stripeSessionUrl,
|
|
62
|
+
};
|
|
63
|
+
}
|
|
64
|
+
if (existingAttempt.updatedDate.getTime() >
|
|
65
|
+
Date.now() - 10 * 60 * 1000) {
|
|
66
|
+
throw new ConflictException("Checkout attempt is already in progress");
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
const attempt = existingAttempt ??
|
|
70
|
+
this.attemptRepository.create({
|
|
71
|
+
idempotencyKey: key,
|
|
72
|
+
organisationUuid: request.organisationUuid,
|
|
73
|
+
userUuid: user.uuid,
|
|
74
|
+
productKey: product.key,
|
|
75
|
+
priceId: product.priceId,
|
|
76
|
+
mode: product.mode,
|
|
77
|
+
status: "creating",
|
|
78
|
+
});
|
|
79
|
+
attempt.status = "creating";
|
|
80
|
+
attempt.errorMessage = undefined;
|
|
81
|
+
try {
|
|
82
|
+
await this.attemptRepository.save(attempt);
|
|
83
|
+
}
|
|
84
|
+
catch (error) {
|
|
85
|
+
if (!this.isUniqueViolation(error)) {
|
|
86
|
+
throw error;
|
|
87
|
+
}
|
|
88
|
+
const concurrentAttempt = await this.attemptRepository.findOne({
|
|
89
|
+
where: { idempotencyKey: key },
|
|
90
|
+
});
|
|
91
|
+
if (!concurrentAttempt) {
|
|
92
|
+
throw error;
|
|
93
|
+
}
|
|
94
|
+
this.assertMatchingAttempt(concurrentAttempt, request, user, product.priceId);
|
|
95
|
+
if (concurrentAttempt.status === "created" &&
|
|
96
|
+
concurrentAttempt.stripeSessionId &&
|
|
97
|
+
concurrentAttempt.stripeSessionUrl) {
|
|
98
|
+
return {
|
|
99
|
+
stripeSessionId: concurrentAttempt.stripeSessionId,
|
|
100
|
+
stripeSessionUrl: concurrentAttempt.stripeSessionUrl,
|
|
101
|
+
};
|
|
102
|
+
}
|
|
103
|
+
throw new ConflictException("Checkout attempt is already in progress");
|
|
104
|
+
}
|
|
105
|
+
try {
|
|
106
|
+
const metadata = {
|
|
107
|
+
organisationUuid: request.organisationUuid,
|
|
108
|
+
userUuid: user.uuid,
|
|
109
|
+
productKey: product.key,
|
|
110
|
+
internalSku: product.internalSku,
|
|
111
|
+
checkoutAttemptId: String(attempt.id),
|
|
112
|
+
};
|
|
113
|
+
const session = await this.stripe.checkout.sessions.create({
|
|
114
|
+
mode: product.mode,
|
|
115
|
+
client_reference_id: String(attempt.id),
|
|
116
|
+
line_items: [{ price: product.priceId, quantity: 1 }],
|
|
117
|
+
success_url: successUrl,
|
|
118
|
+
cancel_url: cancelUrl,
|
|
119
|
+
metadata,
|
|
120
|
+
...(product.mode === "subscription"
|
|
121
|
+
? { subscription_data: { metadata } }
|
|
122
|
+
: { payment_intent_data: { metadata } }),
|
|
123
|
+
}, { idempotencyKey: key });
|
|
124
|
+
if (!session.url) {
|
|
125
|
+
throw new Error("Stripe did not return a Checkout URL");
|
|
126
|
+
}
|
|
127
|
+
attempt.status = "created";
|
|
128
|
+
attempt.stripeSessionId = session.id;
|
|
129
|
+
attempt.stripeSessionUrl = session.url;
|
|
130
|
+
await this.attemptRepository.save(attempt);
|
|
131
|
+
await this.telemetry.record({
|
|
132
|
+
name: "checkout.created",
|
|
133
|
+
attemptId: attempt.id,
|
|
134
|
+
organisationUuid: attempt.organisationUuid,
|
|
135
|
+
productKey: attempt.productKey,
|
|
136
|
+
stripeSessionId: session.id,
|
|
137
|
+
});
|
|
138
|
+
return {
|
|
139
|
+
stripeSessionId: session.id,
|
|
140
|
+
stripeSessionUrl: session.url,
|
|
141
|
+
};
|
|
142
|
+
}
|
|
143
|
+
catch (error) {
|
|
144
|
+
attempt.status = "failed";
|
|
145
|
+
const errorMessage = error instanceof Error
|
|
146
|
+
? error.message.slice(0, 500)
|
|
147
|
+
: "Stripe error";
|
|
148
|
+
attempt.errorMessage = errorMessage;
|
|
149
|
+
await this.attemptRepository.save(attempt);
|
|
150
|
+
await this.telemetry.record({
|
|
151
|
+
name: "checkout.failed",
|
|
152
|
+
attemptId: attempt.id,
|
|
153
|
+
organisationUuid: attempt.organisationUuid,
|
|
154
|
+
productKey: attempt.productKey,
|
|
155
|
+
error: errorMessage,
|
|
156
|
+
});
|
|
157
|
+
this.logger.error("Stripe Checkout session creation failed", {
|
|
158
|
+
attemptId: attempt.id,
|
|
159
|
+
productKey: product.key,
|
|
160
|
+
error: error instanceof Error ? error.message : String(error),
|
|
161
|
+
});
|
|
162
|
+
throw new ServiceUnavailableException("Unable to start checkout right now. Please try again.");
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
async createCustomerPortalSession(request, user, idempotencyKey) {
|
|
166
|
+
const key = this.requireIdempotencyKey(idempotencyKey);
|
|
167
|
+
const subscription = await this.entitlementStore.findByUuid(request.subscriptionRecordUuid);
|
|
168
|
+
await this.accessPolicy.assertCanManageOrganisation({
|
|
169
|
+
organisationUuid: subscription.organisationUuid,
|
|
170
|
+
user,
|
|
171
|
+
operation: "customer-portal",
|
|
172
|
+
});
|
|
173
|
+
if (!/^cus_[A-Za-z0-9]+$/.test(subscription.paymentSystemCustomerId)) {
|
|
174
|
+
throw new ConflictException("This subscription has no valid Stripe customer");
|
|
175
|
+
}
|
|
176
|
+
const session = await this.stripe.billingPortal.sessions.create({
|
|
177
|
+
customer: subscription.paymentSystemCustomerId,
|
|
178
|
+
return_url: this.productService.buildRedirectUrl(request.returnUrl),
|
|
179
|
+
}, { idempotencyKey: key });
|
|
180
|
+
return { sessionUrl: session.url };
|
|
181
|
+
}
|
|
182
|
+
requireIdempotencyKey(idempotencyKey) {
|
|
183
|
+
if (!idempotencyKey || !idempotencyKeyPattern.test(idempotencyKey)) {
|
|
184
|
+
throw new ConflictException("An Idempotency-Key header is required for payment requests");
|
|
185
|
+
}
|
|
186
|
+
return idempotencyKey;
|
|
187
|
+
}
|
|
188
|
+
assertMatchingAttempt(attempt, request, user, priceId) {
|
|
189
|
+
if (attempt.organisationUuid !== request.organisationUuid ||
|
|
190
|
+
attempt.userUuid !== user.uuid ||
|
|
191
|
+
attempt.productKey !== request.productKey ||
|
|
192
|
+
attempt.priceId !== priceId) {
|
|
193
|
+
throw new ConflictException("The Idempotency-Key was already used for another checkout");
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
isUniqueViolation(error) {
|
|
197
|
+
return (error instanceof QueryFailedError &&
|
|
198
|
+
error
|
|
199
|
+
.driverError.code === "23505");
|
|
200
|
+
}
|
|
201
|
+
};
|
|
202
|
+
SecureStripeCheckoutService = SecureStripeCheckoutService_1 = __decorate([
|
|
203
|
+
Injectable(),
|
|
204
|
+
__param(0, Inject("SecureStripeClient")),
|
|
205
|
+
__param(1, InjectRepository(StripeCheckoutAttempt)),
|
|
206
|
+
__param(3, Inject(STRIPE_PAYMENTS_ENTITLEMENT_STORE)),
|
|
207
|
+
__param(4, Inject(STRIPE_PAYMENTS_ACCESS_POLICY)),
|
|
208
|
+
__metadata("design:paramtypes", [Stripe,
|
|
209
|
+
Repository,
|
|
210
|
+
SecureStripeProductService, Object, Object, StripePaymentsTelemetryService])
|
|
211
|
+
], SecureStripeCheckoutService);
|
|
212
|
+
export { SecureStripeCheckoutService };
|
|
213
|
+
//# sourceMappingURL=secure-stripe-checkout.service.js.map
|