@darraghor/nest-backend-libs 1.49.1 → 2.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/dist/core-config/CoreConfigurationService.d.ts +1 -2
- package/dist/core-config/CoreConfigurationService.js +3 -12
- package/dist/core-config/CoreConfigurationService.js.map +1 -1
- package/dist/core-config/CoreConfigurationVariables.d.ts +2 -4
- package/dist/core-config/CoreConfigurationVariables.js +1 -2
- package/dist/core-config/CoreConfigurationVariables.js.map +1 -1
- package/dist/database-postgres/PostgresDatabaseConfigurationService.d.ts +0 -2
- package/dist/database-postgres/PostgresDatabaseConfigurationService.js +0 -2
- package/dist/database-postgres/PostgresDatabaseConfigurationService.js.map +1 -1
- package/dist/organisation/dto/RolesEnum.d.ts +4 -0
- package/dist/organisation/dto/RolesEnum.js +10 -0
- package/dist/organisation/dto/RolesEnum.js.map +1 -0
- package/dist/organisation/entities/member-role.entity.d.ts +10 -0
- package/dist/organisation/entities/member-role.entity.js +60 -0
- package/dist/organisation/entities/member-role.entity.js.map +1 -0
- package/dist/organisation/entities/organisation-membership.entity.d.ts +16 -0
- package/dist/organisation/entities/organisation-membership.entity.js +105 -0
- package/dist/organisation/entities/organisation-membership.entity.js.map +1 -0
- package/dist/organisation/entities/organisation.entity.d.ts +2 -4
- package/dist/organisation/entities/organisation.entity.js +7 -23
- package/dist/organisation/entities/organisation.entity.js.map +1 -1
- package/dist/organisation/organisation.service.js +73 -17
- package/dist/organisation/organisation.service.js.map +1 -1
- package/dist/person/entities/person.entity.d.ts +2 -3
- package/dist/person/entities/person.entity.js +6 -17
- package/dist/person/entities/person.entity.js.map +1 -1
- package/dist/person/person.service.js +33 -11
- package/dist/person/person.service.js.map +1 -1
- package/dist/root-app/core-app.module.js +4 -2
- package/dist/root-app/core-app.module.js.map +1 -1
- package/dist/smtp-email-client/EmailConfigurationService.d.ts +1 -1
- package/dist/smtp-email-client/EmailConfigurationService.js +3 -3
- package/dist/smtp-email-client/EmailConfigurationService.js.map +1 -1
- package/dist/smtp-email-client/EmailConfigurationVariables.d.ts +2 -2
- package/dist/smtp-email-client/EmailConfigurationVariables.js +1 -1
- package/dist/smtp-email-client/EmailConfigurationVariables.js.map +1 -1
- package/dist/smtp-email-client/email-client.service.d.ts +4 -2
- package/dist/smtp-email-client/email-client.service.js +20 -26
- package/dist/smtp-email-client/email-client.service.js.map +1 -1
- package/dist/smtp-email-client/email.entity.d.ts +3 -1
- package/dist/smtp-email-client/email.entity.js +12 -2
- package/dist/smtp-email-client/email.entity.js.map +1 -1
- package/dist/smtp-email-client/smtp-email-client.module.d.ts +1 -0
- package/dist/smtp-email-client/smtp-email-client.module.js +8 -1
- package/dist/smtp-email-client/smtp-email-client.module.js.map +1 -1
- package/dist/smtp-email-client/smtp-email-handler.d.ts +17 -0
- package/dist/smtp-email-client/smtp-email-handler.js +108 -0
- package/dist/smtp-email-client/smtp-email-handler.js.map +1 -0
- package/dist/stripe-client/StripeClientConfigurationService.d.ts +9 -0
- package/dist/stripe-client/StripeClientConfigurationService.js +56 -0
- package/dist/stripe-client/StripeClientConfigurationService.js.map +1 -0
- package/dist/stripe-client/StripeClientProvider.d.ts +7 -0
- package/dist/stripe-client/StripeClientProvider.js +22 -0
- package/dist/stripe-client/StripeClientProvider.js.map +1 -0
- package/dist/stripe-client/StripeConfigurationVariables.d.ts +10 -0
- package/dist/stripe-client/StripeConfigurationVariables.js +9 -0
- package/dist/stripe-client/StripeConfigurationVariables.js.map +1 -0
- package/dist/stripe-client/models/StripeCheckoutSessionParams.d.ts +11 -0
- package/dist/stripe-client/models/StripeCheckoutSessionParams.js +63 -0
- package/dist/stripe-client/models/StripeCheckoutSessionParams.js.map +1 -0
- package/dist/stripe-client/services/stripe-checkout.service.d.ts +15 -0
- package/dist/stripe-client/services/stripe-checkout.service.js +65 -0
- package/dist/stripe-client/services/stripe-checkout.service.js.map +1 -0
- package/dist/stripe-client/services/stripe-event-handler.d.ts +11 -0
- package/dist/stripe-client/services/stripe-event-handler.js +148 -0
- package/dist/stripe-client/services/stripe-event-handler.js.map +1 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.d.ts +14 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.js +56 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.js.map +1 -0
- package/dist/stripe-client/stripe-account.module.d.ts +4 -0
- package/dist/stripe-client/stripe-account.module.js +44 -0
- package/dist/stripe-client/stripe-account.module.js.map +1 -0
- package/dist/stripe-client/stripe-controller.d.ts +14 -0
- package/dist/stripe-client/stripe-controller.js +86 -0
- package/dist/stripe-client/stripe-controller.js.map +1 -0
- package/package.json +20 -17
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import { StripeClientConfigurationService } from "./StripeClientConfigurationService";
|
|
3
|
+
export declare const StripeClientProvider: {
|
|
4
|
+
provide: string;
|
|
5
|
+
useFactory: (config: StripeClientConfigurationService) => Stripe;
|
|
6
|
+
inject: (typeof StripeClientConfigurationService)[];
|
|
7
|
+
};
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.StripeClientProvider = void 0;
|
|
7
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
8
|
+
const StripeClientConfigurationService_1 = require("./StripeClientConfigurationService");
|
|
9
|
+
exports.StripeClientProvider = {
|
|
10
|
+
provide: "StripeClient",
|
|
11
|
+
useFactory: (config) => {
|
|
12
|
+
const apiVersion = "2022-11-15";
|
|
13
|
+
const appInfo = {
|
|
14
|
+
name: "NestBackendLibs",
|
|
15
|
+
url: "https://github.com/darraghoriordan/nest-backend-libs", // Optional
|
|
16
|
+
};
|
|
17
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-return, @typescript-eslint/no-unsafe-call
|
|
18
|
+
return new stripe_1.default(config.accessToken, { apiVersion, appInfo });
|
|
19
|
+
},
|
|
20
|
+
inject: [StripeClientConfigurationService_1.StripeClientConfigurationService],
|
|
21
|
+
};
|
|
22
|
+
//# sourceMappingURL=StripeClientProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeClientProvider.js","sourceRoot":"","sources":["../../src/stripe-client/StripeClientProvider.ts"],"names":[],"mappings":";;;;;;AAAA,oDAA4B;AAC5B,yFAAoF;AAEvE,QAAA,oBAAoB,GAAG;IAChC,OAAO,EAAE,cAAc;IACvB,UAAU,EAAE,CAAC,MAAwC,EAAU,EAAE;QAC7D,MAAM,UAAU,GAAG,YAAY,CAAC;QAChC,MAAM,OAAO,GAAG;YACZ,IAAI,EAAE,iBAAiB;YACvB,GAAG,EAAE,sDAAsD,EAAE,WAAW;SAC3E,CAAC;QACF,kGAAkG;QAClG,OAAO,IAAI,gBAAM,CAAC,MAAM,CAAC,WAAW,EAAE,EAAC,UAAU,EAAE,OAAO,EAAC,CAAC,CAAC;IACjE,CAAC;IACD,MAAM,EAAE,CAAC,mEAAgC,CAAC;CAC7C,CAAC"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
declare const _default: (() => {
|
|
2
|
+
accessToken: string | undefined;
|
|
3
|
+
webhookVerificationKey: string | undefined;
|
|
4
|
+
stripeRedirectsBaseUrl: string | undefined;
|
|
5
|
+
}) & import("@nestjs/config").ConfigFactoryKeyHost<{
|
|
6
|
+
accessToken: string | undefined;
|
|
7
|
+
webhookVerificationKey: string | undefined;
|
|
8
|
+
stripeRedirectsBaseUrl: string | undefined;
|
|
9
|
+
}>;
|
|
10
|
+
export default _default;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
const config_1 = require("@nestjs/config");
|
|
4
|
+
exports.default = (0, config_1.registerAs)("stripe-client", () => ({
|
|
5
|
+
accessToken: process.env.STRIPE_ACCESS_TOKEN,
|
|
6
|
+
webhookVerificationKey: process.env.STRIPE_WEBHOOK_VERIFICATION_KEY,
|
|
7
|
+
stripeRedirectsBaseUrl: process.env.STRIPE_REDIRECTS_BASE_URL,
|
|
8
|
+
}));
|
|
9
|
+
//# sourceMappingURL=StripeConfigurationVariables.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeConfigurationVariables.js","sourceRoot":"","sources":["../../src/stripe-client/StripeConfigurationVariables.ts"],"names":[],"mappings":";;AAAA,2CAA0C;AAE1C,kBAAe,IAAA,mBAAU,EAAC,eAAe,EAAE,GAAG,EAAE,CAAC,CAAC;IAC9C,WAAW,EAAE,OAAO,CAAC,GAAG,CAAC,mBAAmB;IAC5C,sBAAsB,EAAE,OAAO,CAAC,GAAG,CAAC,+BAA+B;IACnE,sBAAsB,EAAE,OAAO,CAAC,GAAG,CAAC,yBAAyB;CAChE,CAAC,CAAC,CAAC"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class StripeCheckoutLineItem {
|
|
2
|
+
price: string;
|
|
3
|
+
quantity: number;
|
|
4
|
+
}
|
|
5
|
+
export declare class StripeCheckoutSessionParameters {
|
|
6
|
+
clientReferenceId?: string;
|
|
7
|
+
lineItems: StripeCheckoutLineItem[];
|
|
8
|
+
mode: "subscription" | "payment" | "setup";
|
|
9
|
+
successFrontendPath: string;
|
|
10
|
+
cancelFrontendPath?: string;
|
|
11
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// this just exists to avoid having to import the stripe lib directly
|
|
3
|
+
// not sure if a great idea but let's see!
|
|
4
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
5
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
6
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
7
|
+
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;
|
|
8
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
9
|
+
};
|
|
10
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
11
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
12
|
+
};
|
|
13
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14
|
+
exports.StripeCheckoutSessionParameters = exports.StripeCheckoutLineItem = void 0;
|
|
15
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
16
|
+
const class_transformer_1 = require("class-transformer");
|
|
17
|
+
const class_validator_1 = require("class-validator");
|
|
18
|
+
class StripeCheckoutLineItem {
|
|
19
|
+
}
|
|
20
|
+
__decorate([
|
|
21
|
+
(0, swagger_1.ApiProperty)(),
|
|
22
|
+
__metadata("design:type", String)
|
|
23
|
+
], StripeCheckoutLineItem.prototype, "price", void 0);
|
|
24
|
+
__decorate([
|
|
25
|
+
(0, swagger_1.ApiProperty)(),
|
|
26
|
+
__metadata("design:type", Number)
|
|
27
|
+
], StripeCheckoutLineItem.prototype, "quantity", void 0);
|
|
28
|
+
exports.StripeCheckoutLineItem = StripeCheckoutLineItem;
|
|
29
|
+
class StripeCheckoutSessionParameters {
|
|
30
|
+
}
|
|
31
|
+
__decorate([
|
|
32
|
+
(0, swagger_1.ApiPropertyOptional)(),
|
|
33
|
+
(0, class_validator_1.IsOptional)(),
|
|
34
|
+
__metadata("design:type", String)
|
|
35
|
+
], StripeCheckoutSessionParameters.prototype, "clientReferenceId", void 0);
|
|
36
|
+
__decorate([
|
|
37
|
+
(0, swagger_1.ApiProperty)({ isArray: true, type: StripeCheckoutLineItem }),
|
|
38
|
+
(0, class_validator_1.IsArray)(),
|
|
39
|
+
(0, class_validator_1.ValidateNested)({ each: true }),
|
|
40
|
+
(0, class_transformer_1.Type)(() => StripeCheckoutLineItem),
|
|
41
|
+
__metadata("design:type", Array)
|
|
42
|
+
], StripeCheckoutSessionParameters.prototype, "lineItems", void 0);
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, swagger_1.ApiProperty)({ type: String }),
|
|
45
|
+
(0, class_validator_1.IsIn)(["subscription", "payment", "setup"]),
|
|
46
|
+
__metadata("design:type", String)
|
|
47
|
+
], StripeCheckoutSessionParameters.prototype, "mode", void 0);
|
|
48
|
+
__decorate([
|
|
49
|
+
(0, swagger_1.ApiProperty)({
|
|
50
|
+
description: "The URL to which Stripe should redirect the customer after payment. This is appended to the host configured in the StripeClientConfigurationService",
|
|
51
|
+
}),
|
|
52
|
+
(0, class_validator_1.IsString)(),
|
|
53
|
+
__metadata("design:type", String)
|
|
54
|
+
], StripeCheckoutSessionParameters.prototype, "successFrontendPath", void 0);
|
|
55
|
+
__decorate([
|
|
56
|
+
(0, swagger_1.ApiPropertyOptional)({
|
|
57
|
+
description: "The URL to which Stripe should redirect the customer after payment cancellation. This is appended to the host configured in the StripeClientConfigurationService",
|
|
58
|
+
}),
|
|
59
|
+
(0, class_validator_1.IsOptional)(),
|
|
60
|
+
__metadata("design:type", String)
|
|
61
|
+
], StripeCheckoutSessionParameters.prototype, "cancelFrontendPath", void 0);
|
|
62
|
+
exports.StripeCheckoutSessionParameters = StripeCheckoutSessionParameters;
|
|
63
|
+
//# sourceMappingURL=StripeCheckoutSessionParams.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"StripeCheckoutSessionParams.js","sourceRoot":"","sources":["../../../src/stripe-client/models/StripeCheckoutSessionParams.ts"],"names":[],"mappings":";AAAA,qEAAqE;AACrE,0CAA0C;;;;;;;;;;;;AAE1C,6CAAiE;AACjE,yDAAuC;AACvC,qDAMyB;AAEzB,MAAa,sBAAsB;CAKlC;AAJG;IAAC,IAAA,qBAAW,GAAE;;qDACC;AACf;IAAC,IAAA,qBAAW,GAAE;;wDACI;AAJtB,wDAKC;AAED,MAAa,+BAA+B;CA6B3C;AA5BG;IAAC,IAAA,6BAAmB,GAAE;IACrB,IAAA,4BAAU,GAAE;;0EACc;AAE3B;IAAC,IAAA,qBAAW,EAAC,EAAC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,sBAAsB,EAAC,CAAC;IAC1D,IAAA,yBAAO,GAAE;IACT,IAAA,gCAAc,EAAC,EAAC,IAAI,EAAE,IAAI,EAAC,CAAC;IAC5B,IAAA,wBAAI,EAAC,GAAG,EAAE,CAAC,sBAAsB,CAAC;;kEACE;AAGrC;IAAC,IAAA,qBAAW,EAAC,EAAC,IAAI,EAAE,MAAM,EAAC,CAAC;IAC3B,IAAA,sBAAI,EAAC,CAAC,cAAc,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;;6DACC;AAE5C;IAAC,IAAA,qBAAW,EAAC;QACT,WAAW,EACP,qJAAqJ;KAC5J,CAAC;IACD,IAAA,0BAAQ,GAAE;;4EACkB;AAE7B;IAAC,IAAA,6BAAmB,EAAC;QACjB,WAAW,EACP,kKAAkK;KACzK,CAAC;IACD,IAAA,4BAAU,GAAE;;2EACe;AA5BhC,0EA6BC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import Stripe from "stripe";
|
|
2
|
+
import CoreLoggerService from "../../logger/CoreLoggerService";
|
|
3
|
+
import { Person } from "../../person/entities/person.entity";
|
|
4
|
+
import { StripeCheckoutSessionParameters } from "../models/StripeCheckoutSessionParams";
|
|
5
|
+
import { StripeClientConfigurationService } from "../StripeClientConfigurationService";
|
|
6
|
+
export declare class StripeCheckoutService {
|
|
7
|
+
private readonly logger;
|
|
8
|
+
private readonly clientInstance;
|
|
9
|
+
private readonly stripeClientConfigurationService;
|
|
10
|
+
constructor(logger: CoreLoggerService, clientInstance: Stripe, stripeClientConfigurationService: StripeClientConfigurationService);
|
|
11
|
+
createCustomerPortalSession(parameters: {
|
|
12
|
+
user: Omit<Person, "nullChecks">;
|
|
13
|
+
}): Promise<string>;
|
|
14
|
+
createCheckoutSession(parameters: StripeCheckoutSessionParameters): Promise<string>;
|
|
15
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.StripeCheckoutService = void 0;
|
|
19
|
+
/* eslint-disable @typescript-eslint/naming-convention */
|
|
20
|
+
const common_1 = require("@nestjs/common");
|
|
21
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
22
|
+
const CoreLoggerService_1 = __importDefault(require("../../logger/CoreLoggerService"));
|
|
23
|
+
const StripeClientConfigurationService_1 = require("../StripeClientConfigurationService");
|
|
24
|
+
let StripeCheckoutService = class StripeCheckoutService {
|
|
25
|
+
constructor(logger, clientInstance, stripeClientConfigurationService) {
|
|
26
|
+
this.logger = logger;
|
|
27
|
+
this.clientInstance = clientInstance;
|
|
28
|
+
this.stripeClientConfigurationService = stripeClientConfigurationService;
|
|
29
|
+
this.logger.log("Setting up twitter client");
|
|
30
|
+
}
|
|
31
|
+
async createCustomerPortalSession(parameters) {
|
|
32
|
+
// TODO: This is a hack to get the customer ID. We should be able to get it from the user.
|
|
33
|
+
const customerId = parameters.user.auth0UserId;
|
|
34
|
+
const session = await this.clientInstance.billingPortal.sessions.create({
|
|
35
|
+
customer: customerId,
|
|
36
|
+
return_url: `${this.stripeClientConfigurationService.stripeRedirectsBaseUrl}/my/account`,
|
|
37
|
+
});
|
|
38
|
+
return session.url;
|
|
39
|
+
}
|
|
40
|
+
async createCheckoutSession(parameters) {
|
|
41
|
+
const mappedParameters = {
|
|
42
|
+
mode: parameters.mode,
|
|
43
|
+
client_reference_id: parameters.clientReferenceId,
|
|
44
|
+
line_items: parameters.lineItems,
|
|
45
|
+
success_url: `${this.stripeClientConfigurationService.stripeRedirectsBaseUrl}${parameters.successFrontendPath}`,
|
|
46
|
+
cancel_url: parameters.cancelFrontendPath
|
|
47
|
+
? `${this.stripeClientConfigurationService.stripeRedirectsBaseUrl}${parameters.cancelFrontendPath}`
|
|
48
|
+
: undefined,
|
|
49
|
+
};
|
|
50
|
+
const session = await this.clientInstance.checkout.sessions.create(mappedParameters);
|
|
51
|
+
if (!session.url) {
|
|
52
|
+
throw new Error("Failed to create checkout session");
|
|
53
|
+
}
|
|
54
|
+
return session.url;
|
|
55
|
+
}
|
|
56
|
+
};
|
|
57
|
+
StripeCheckoutService = __decorate([
|
|
58
|
+
(0, common_1.Injectable)(),
|
|
59
|
+
__param(1, (0, common_1.Inject)("StripeClient")),
|
|
60
|
+
__metadata("design:paramtypes", [CoreLoggerService_1.default,
|
|
61
|
+
stripe_1.default,
|
|
62
|
+
StripeClientConfigurationService_1.StripeClientConfigurationService])
|
|
63
|
+
], StripeCheckoutService);
|
|
64
|
+
exports.StripeCheckoutService = StripeCheckoutService;
|
|
65
|
+
//# sourceMappingURL=stripe-checkout.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-checkout.service.js","sourceRoot":"","sources":["../../../src/stripe-client/services/stripe-checkout.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,yDAAyD;AACzD,2CAAkD;AAClD,oDAA4B;AAC5B,uFAA+D;AAG/D,0FAAqF;AAG9E,IAAM,qBAAqB,GAA3B,MAAM,qBAAqB;IAC9B,YACqB,MAAyB,EAEzB,cAAsB,EACtB,gCAAkE;QAHlE,WAAM,GAAN,MAAM,CAAmB;QAEzB,mBAAc,GAAd,cAAc,CAAQ;QACtB,qCAAgC,GAAhC,gCAAgC,CAAkC;QAEnF,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,2BAA2B,CAAC,CAAC;IACjD,CAAC;IAEM,KAAK,CAAC,2BAA2B,CAAC,UAExC;QACG,0FAA0F;QAC1F,MAAM,UAAU,GAAG,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC;QAC/C,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,aAAa,CAAC,QAAQ,CAAC,MAAM,CACnE;YACI,QAAQ,EAAE,UAAU;YACpB,UAAU,EAAE,GAAG,IAAI,CAAC,gCAAgC,CAAC,sBAAsB,aAAa;SAC3F,CACJ,CAAC;QAEF,OAAO,OAAO,CAAC,GAAG,CAAC;IACvB,CAAC;IAEM,KAAK,CAAC,qBAAqB,CAC9B,UAA2C;QAE3C,MAAM,gBAAgB,GAAG;YACrB,IAAI,EAAE,UAAU,CAAC,IAA2D;YAC5E,mBAAmB,EAAE,UAAU,CAAC,iBAAiB;YACjD,UAAU,EAAE,UAAU,CAAC,SAAS;YAChC,WAAW,EAAE,GAAG,IAAI,CAAC,gCAAgC,CAAC,sBAAsB,GAAG,UAAU,CAAC,mBAAmB,EAAE;YAC/G,UAAU,EAAE,UAAU,CAAC,kBAAkB;gBACrC,CAAC,CAAC,GAAG,IAAI,CAAC,gCAAgC,CAAC,sBAAsB,GAAG,UAAU,CAAC,kBAAkB,EAAE;gBACnG,CAAC,CAAC,SAAS;SACqB,CAAC;QAEzC,MAAM,OAAO,GAAG,MAAM,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,QAAQ,CAAC,MAAM,CAC9D,gBAAgB,CACnB,CAAC;QAEF,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YACd,MAAM,IAAI,KAAK,CAAC,mCAAmC,CAAC,CAAC;SACxD;QAED,OAAO,OAAO,CAAC,GAAG,CAAC;IACvB,CAAC;CACJ,CAAA;AAhDY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAIJ,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;qCADE,2BAAiB;QAET,gBAAM;QACY,mEAAgC;GAL9E,qBAAqB,CAgDjC;AAhDY,sDAAqB"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { Job } from "bull";
|
|
2
|
+
import CoreLoggerService from "../../logger/CoreLoggerService";
|
|
3
|
+
import Stripe from "stripe";
|
|
4
|
+
export declare class StripeEventHandler {
|
|
5
|
+
private readonly logger;
|
|
6
|
+
constructor(logger: CoreLoggerService);
|
|
7
|
+
onError(job: Job<Stripe.Event>, error: any): void;
|
|
8
|
+
onActive(job: Job<Stripe.Event>): void;
|
|
9
|
+
onComplete(job: Job<Stripe.Event>): void;
|
|
10
|
+
handleEvent(job: Job<Stripe.Event>): Promise<void>;
|
|
11
|
+
}
|
|
@@ -0,0 +1,148 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StripeEventHandler = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const bull_1 = require("@nestjs/bull");
|
|
18
|
+
const CoreLoggerService_1 = __importDefault(require("../../logger/CoreLoggerService"));
|
|
19
|
+
const stripe_account_module_1 = require("../stripe-account.module");
|
|
20
|
+
let StripeEventHandler = class StripeEventHandler {
|
|
21
|
+
constructor(logger) {
|
|
22
|
+
this.logger = logger;
|
|
23
|
+
}
|
|
24
|
+
onError(job, error) {
|
|
25
|
+
this.logger.error(
|
|
26
|
+
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions, @typescript-eslint/no-unnecessary-type-assertion, @typescript-eslint/no-unsafe-member-access
|
|
27
|
+
`Failed job ${job.id} of type ${job.name}: ${error.message}`,
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
29
|
+
error.stack);
|
|
30
|
+
}
|
|
31
|
+
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
32
|
+
onActive(job) {
|
|
33
|
+
this.logger.log(`Active job ${job.id} of type ${job.name}`, job.data);
|
|
34
|
+
}
|
|
35
|
+
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
36
|
+
onComplete(job) {
|
|
37
|
+
this.logger.log(`Completed job ${job.id} of type ${job.name}`, job.data);
|
|
38
|
+
}
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
40
|
+
async handleEvent(job) {
|
|
41
|
+
const data = job.data.data;
|
|
42
|
+
const eventType = job.data.type;
|
|
43
|
+
// see - https://stripe.com/docs/billing/subscriptions/webhooks
|
|
44
|
+
switch (eventType) {
|
|
45
|
+
case "checkout.session.completed": {
|
|
46
|
+
// Payment is successful and the subscription is created.
|
|
47
|
+
// You should provision the subscription and save the customer ID to your database.
|
|
48
|
+
// e.g. set the billing status as paid until the next billing cycle + 1 or 2 days for grace period
|
|
49
|
+
// also called for payment links! - see https://stripe.com/docs/payments/checkout/fulfill-orders
|
|
50
|
+
return;
|
|
51
|
+
}
|
|
52
|
+
case "checkout.session.async_payment_succeeded": {
|
|
53
|
+
// Payment link payment is successful for async payment methods. (bank drafts, etc.)
|
|
54
|
+
return;
|
|
55
|
+
}
|
|
56
|
+
case "checkout.session.async_payment_failed": {
|
|
57
|
+
// Payment link payment is NOT successful for async payment methods. (bank drafts, etc.)
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
case "invoice.paid": {
|
|
61
|
+
// Continue to provision the subscription as payments continue to be made.
|
|
62
|
+
// Store the status in your database and check when a user accesses your service.
|
|
63
|
+
// This approach helps you avoid hitting rate limits.
|
|
64
|
+
// e.g. set the billing status as paid until the next billing cycle + 1 or 2 days for grace period
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
case "customer.subscription.trial_will_end": {
|
|
68
|
+
// Send notification to the user that the trial will end
|
|
69
|
+
return;
|
|
70
|
+
}
|
|
71
|
+
case "invoice.payment_failed": {
|
|
72
|
+
// The payment failed or the customer does not have a valid payment method.
|
|
73
|
+
// The subscription becomes past_due. Notify your customer and send them to the
|
|
74
|
+
// customer portal to update their payment information.
|
|
75
|
+
return;
|
|
76
|
+
}
|
|
77
|
+
case "customer.subscription.created": {
|
|
78
|
+
/*
|
|
79
|
+
Sent when the subscription is created.
|
|
80
|
+
The subscription status may be incomplete if customer
|
|
81
|
+
authentication is required to complete the payment
|
|
82
|
+
or if you set payment_behavior to default_incomplete.
|
|
83
|
+
For more details, read about subscription payment behavior.
|
|
84
|
+
*/
|
|
85
|
+
return;
|
|
86
|
+
}
|
|
87
|
+
case "customer.subscription.deleted": {
|
|
88
|
+
// Sent when a customer’s subscription ends.
|
|
89
|
+
return;
|
|
90
|
+
}
|
|
91
|
+
case "customer.subscription.updated": {
|
|
92
|
+
/**
|
|
93
|
+
* Sent when the subscription is successfully started, after the payment is confirmed.
|
|
94
|
+
* Also sent whenever a subscription is changed.
|
|
95
|
+
* For example, adding a coupon, applying a discount,
|
|
96
|
+
* adding an invoice item, and changing plans all trigger this event.
|
|
97
|
+
*/
|
|
98
|
+
return;
|
|
99
|
+
}
|
|
100
|
+
default: {
|
|
101
|
+
this.logger.warn(`Stripe webhook unknown event type`, {
|
|
102
|
+
eventType,
|
|
103
|
+
event: job.data,
|
|
104
|
+
data,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
};
|
|
110
|
+
__decorate([
|
|
111
|
+
(0, bull_1.OnQueueFailed)(),
|
|
112
|
+
__metadata("design:type", Function),
|
|
113
|
+
__metadata("design:paramtypes", [Object, Object]),
|
|
114
|
+
__metadata("design:returntype", void 0)
|
|
115
|
+
], StripeEventHandler.prototype, "onError", null);
|
|
116
|
+
__decorate([
|
|
117
|
+
(0, bull_1.OnQueueActive)()
|
|
118
|
+
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
119
|
+
,
|
|
120
|
+
__metadata("design:type", Function),
|
|
121
|
+
__metadata("design:paramtypes", [Object]),
|
|
122
|
+
__metadata("design:returntype", void 0)
|
|
123
|
+
], StripeEventHandler.prototype, "onActive", null);
|
|
124
|
+
__decorate([
|
|
125
|
+
(0, bull_1.OnQueueCompleted)()
|
|
126
|
+
// eslint-disable-next-line sonarjs/no-identical-functions
|
|
127
|
+
,
|
|
128
|
+
__metadata("design:type", Function),
|
|
129
|
+
__metadata("design:paramtypes", [Object]),
|
|
130
|
+
__metadata("design:returntype", void 0)
|
|
131
|
+
], StripeEventHandler.prototype, "onComplete", null);
|
|
132
|
+
__decorate([
|
|
133
|
+
(0, bull_1.Process)(),
|
|
134
|
+
__metadata("design:type", Function),
|
|
135
|
+
__metadata("design:paramtypes", [Object]),
|
|
136
|
+
__metadata("design:returntype", Promise)
|
|
137
|
+
], StripeEventHandler.prototype, "handleEvent", null);
|
|
138
|
+
StripeEventHandler = __decorate([
|
|
139
|
+
(0, common_1.Injectable)(),
|
|
140
|
+
(0, bull_1.Processor)(stripe_account_module_1.queueName)
|
|
141
|
+
// This should be provided manually to give the consumer ability to change logic
|
|
142
|
+
// it is not part of this modules provided/exported services
|
|
143
|
+
// eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
|
|
144
|
+
,
|
|
145
|
+
__metadata("design:paramtypes", [CoreLoggerService_1.default])
|
|
146
|
+
], StripeEventHandler);
|
|
147
|
+
exports.StripeEventHandler = StripeEventHandler;
|
|
148
|
+
//# sourceMappingURL=stripe-event-handler.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-event-handler.js","sourceRoot":"","sources":["../../../src/stripe-client/services/stripe-event-handler.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,uCAMsB;AAEtB,uFAA+D;AAE/D,oEAAmD;AAO5C,IAAM,kBAAkB,GAAxB,MAAM,kBAAkB;IAC3B,YAA6B,MAAyB;QAAzB,WAAM,GAAN,MAAM,CAAmB;IAAG,CAAC;IAE1D,OAAO,CAAC,GAAsB,EAAE,KAAU;QACtC,IAAI,CAAC,MAAM,CAAC,KAAK;QACb,0KAA0K;QAC1K,cAAc,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,IAAI,KAAK,KAAK,CAAC,OAAc,EAAE;QACnE,sEAAsE;QACtE,KAAK,CAAC,KAAK,CACd,CAAC;IACN,CAAC;IAGD,0DAA0D;IAC1D,QAAQ,CAAC,GAAsB;QAC3B,IAAI,CAAC,MAAM,CAAC,GAAG,CAAC,cAAc,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,IAAI,CAAC,CAAC;IAC1E,CAAC;IAGD,0DAA0D;IAC1D,UAAU,CAAC,GAAsB;QAC7B,IAAI,CAAC,MAAM,CAAC,GAAG,CACX,iBAAiB,GAAG,CAAC,EAAE,YAAY,GAAG,CAAC,IAAI,EAAE,EAC7C,GAAG,CAAC,IAAI,CACX,CAAC;IACN,CAAC;IAED,4DAA4D;IAE/C,AAAN,KAAK,CAAC,WAAW,CAAC,GAAsB;QAC3C,MAAM,IAAI,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAC3B,MAAM,SAAS,GAAG,GAAG,CAAC,IAAI,CAAC,IAAI,CAAC;QAChC,+DAA+D;QAC/D,QAAQ,SAAS,EAAE;YACf,KAAK,4BAA4B,CAAC,CAAC;gBAC/B,yDAAyD;gBACzD,mFAAmF;gBAEnF,kGAAkG;gBAElG,gGAAgG;gBAChG,OAAO;aACV;YACD,KAAK,0CAA0C,CAAC,CAAC;gBAC7C,oFAAoF;gBACpF,OAAO;aACV;YACD,KAAK,uCAAuC,CAAC,CAAC;gBAC1C,wFAAwF;gBACxF,OAAO;aACV;YACD,KAAK,cAAc,CAAC,CAAC;gBACjB,0EAA0E;gBAC1E,iFAAiF;gBACjF,qDAAqD;gBAErD,kGAAkG;gBAClG,OAAO;aACV;YACD,KAAK,sCAAsC,CAAC,CAAC;gBACzC,wDAAwD;gBACxD,OAAO;aACV;YAED,KAAK,wBAAwB,CAAC,CAAC;gBAC3B,2EAA2E;gBAC3E,+EAA+E;gBAC/E,uDAAuD;gBACvD,OAAO;aACV;YACD,KAAK,+BAA+B,CAAC,CAAC;gBAClC;;;;;;kBAME;gBACF,OAAO;aACV;YACD,KAAK,+BAA+B,CAAC,CAAC;gBAClC,6CAA6C;gBAC7C,OAAO;aACV;YACD,KAAK,+BAA+B,CAAC,CAAC;gBAClC;;;;;mBAKG;gBACH,OAAO;aACV;YAED,OAAO,CAAC,CAAC;gBACL,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,mCAAmC,EAAE;oBAClD,SAAS;oBACT,KAAK,EAAE,GAAG,CAAC,IAAI;oBACf,IAAI;iBACP,CAAC,CAAC;aACN;SACJ;IACL,CAAC;CACJ,CAAA;AArGG;IAAC,IAAA,oBAAa,GAAE;;;;iDAQf;AAED;IAAC,IAAA,oBAAa,GAAE;IAChB,0DAA0D;;;;;kDAGzD;AAED;IAAC,IAAA,uBAAgB,GAAE;IACnB,0DAA0D;;;;;oDAMzD;AAIY;IADZ,IAAA,cAAO,GAAE;;;;qDA0ET;AAtGQ,kBAAkB;IAL9B,IAAA,mBAAU,GAAE;IACZ,IAAA,gBAAS,EAAC,iCAAS,CAAC;IACrB,gFAAgF;IAChF,4DAA4D;IAC5D,iFAAiF;;qCAExC,2BAAiB;GAD7C,kBAAkB,CAuG9B;AAvGY,gDAAkB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawBodyRequest } from "@nestjs/common";
|
|
2
|
+
import { Queue } from "bull";
|
|
3
|
+
import { Request } from "express";
|
|
4
|
+
import Stripe from "stripe";
|
|
5
|
+
import CoreLoggerService from "../../logger/CoreLoggerService";
|
|
6
|
+
import { StripeClientConfigurationService } from "../StripeClientConfigurationService";
|
|
7
|
+
export declare class StripeWebhookHandler {
|
|
8
|
+
private readonly config;
|
|
9
|
+
private readonly logger;
|
|
10
|
+
private readonly clientInstance;
|
|
11
|
+
private queue;
|
|
12
|
+
constructor(config: StripeClientConfigurationService, logger: CoreLoggerService, clientInstance: Stripe, queue: Queue);
|
|
13
|
+
handleWebhook(request: RawBodyRequest<Request>): Promise<void>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
15
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
16
|
+
};
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.StripeWebhookHandler = void 0;
|
|
19
|
+
const bull_1 = require("@nestjs/bull");
|
|
20
|
+
const common_1 = require("@nestjs/common");
|
|
21
|
+
const stripe_1 = __importDefault(require("stripe"));
|
|
22
|
+
const CoreLoggerService_1 = __importDefault(require("../../logger/CoreLoggerService"));
|
|
23
|
+
const stripe_account_module_1 = require("../stripe-account.module");
|
|
24
|
+
const StripeClientConfigurationService_1 = require("../StripeClientConfigurationService");
|
|
25
|
+
let StripeWebhookHandler = class StripeWebhookHandler {
|
|
26
|
+
constructor(config, logger, clientInstance, queue) {
|
|
27
|
+
this.config = config;
|
|
28
|
+
this.logger = logger;
|
|
29
|
+
this.clientInstance = clientInstance;
|
|
30
|
+
this.queue = queue;
|
|
31
|
+
}
|
|
32
|
+
async handleWebhook(request) {
|
|
33
|
+
const signature = request.headers["stripe-signature"];
|
|
34
|
+
if (!signature) {
|
|
35
|
+
throw new Error("No stripe signature found in webhook request");
|
|
36
|
+
}
|
|
37
|
+
try {
|
|
38
|
+
const event = this.clientInstance.webhooks.constructEvent(request.body, // is a buffer according to nest docs
|
|
39
|
+
signature, this.config.webhookVerificationKey);
|
|
40
|
+
await this.queue.add(event);
|
|
41
|
+
}
|
|
42
|
+
catch (error) {
|
|
43
|
+
this.logger.error(`Webhook signature verification failed.`, error);
|
|
44
|
+
throw new common_1.BadRequestException("Webhook signature verification failed.");
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
StripeWebhookHandler = __decorate([
|
|
49
|
+
__param(2, (0, common_1.Inject)("StripeClient")),
|
|
50
|
+
__param(3, (0, bull_1.InjectQueue)(stripe_account_module_1.queueName)),
|
|
51
|
+
__metadata("design:paramtypes", [StripeClientConfigurationService_1.StripeClientConfigurationService,
|
|
52
|
+
CoreLoggerService_1.default,
|
|
53
|
+
stripe_1.default, Object])
|
|
54
|
+
], StripeWebhookHandler);
|
|
55
|
+
exports.StripeWebhookHandler = StripeWebhookHandler;
|
|
56
|
+
//# sourceMappingURL=stripe-webhook-handler.service.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-webhook-handler.service.js","sourceRoot":"","sources":["../../../src/stripe-client/services/stripe-webhook-handler.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;AAAA,uCAAyC;AACzC,2CAA2E;AAG3E,oDAA4B;AAC5B,uFAA+D;AAC/D,oEAAmD;AACnD,0FAAqF;AAE9E,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAC7B,YACqB,MAAwC,EACxC,MAAyB,EAEzB,cAAsB,EACP,KAAY;QAJ3B,WAAM,GAAN,MAAM,CAAkC;QACxC,WAAM,GAAN,MAAM,CAAmB;QAEzB,mBAAc,GAAd,cAAc,CAAQ;QACP,UAAK,GAAL,KAAK,CAAO;IAC7C,CAAC;IAEG,KAAK,CAAC,aAAa,CACtB,OAAgC;QAEhC,MAAM,SAAS,GAAG,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAEtD,IAAI,CAAC,SAAS,EAAE;YACZ,MAAM,IAAI,KAAK,CAAC,8CAA8C,CAAC,CAAC;SACnE;QAED,IAAI;YACA,MAAM,KAAK,GAAG,IAAI,CAAC,cAAc,CAAC,QAAQ,CAAC,cAAc,CACrD,OAAO,CAAC,IAAc,EAAE,qCAAqC;YAC7D,SAAS,EACT,IAAI,CAAC,MAAM,CAAC,sBAAsB,CACrC,CAAC;YAEF,MAAM,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;SAC/B;QAAC,OAAO,KAAK,EAAE;YACZ,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,wCAAwC,EAAE,KAAK,CAAC,CAAC;YACnE,MAAM,IAAI,4BAAmB,CACzB,wCAAwC,CAC3C,CAAC;SACL;IACL,CAAC;CACJ,CAAA;AAjCY,oBAAoB;IAIxB,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;IAEtB,WAAA,IAAA,kBAAW,EAAC,iCAAS,CAAC,CAAA;qCAJE,mEAAgC;QAChC,2BAAiB;QAET,gBAAM;GALlC,oBAAoB,CAiChC;AAjCY,oDAAoB"}
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.StripeAccountModule = exports.queueName = void 0;
|
|
13
|
+
const common_1 = require("@nestjs/common");
|
|
14
|
+
require("reflect-metadata");
|
|
15
|
+
const StripeClientConfigurationService_1 = require("./StripeClientConfigurationService");
|
|
16
|
+
const stripe_checkout_service_1 = require("./services/stripe-checkout.service");
|
|
17
|
+
const StripeConfigurationVariables_1 = __importDefault(require("./StripeConfigurationVariables"));
|
|
18
|
+
const config_1 = require("@nestjs/config");
|
|
19
|
+
const core_app_module_1 = require("../root-app/core-app.module");
|
|
20
|
+
const StripeClientProvider_1 = require("./StripeClientProvider");
|
|
21
|
+
const bull_1 = require("@nestjs/bull");
|
|
22
|
+
exports.queueName = "stripe-events";
|
|
23
|
+
let StripeAccountModule = class StripeAccountModule {
|
|
24
|
+
};
|
|
25
|
+
StripeAccountModule = __decorate([
|
|
26
|
+
(0, common_1.Module)({
|
|
27
|
+
imports: [
|
|
28
|
+
config_1.ConfigModule.forFeature(StripeConfigurationVariables_1.default),
|
|
29
|
+
core_app_module_1.CoreModule,
|
|
30
|
+
bull_1.BullModule.registerQueue({
|
|
31
|
+
name: exports.queueName,
|
|
32
|
+
}),
|
|
33
|
+
],
|
|
34
|
+
providers: [
|
|
35
|
+
StripeClientProvider_1.StripeClientProvider,
|
|
36
|
+
StripeClientConfigurationService_1.StripeClientConfigurationService,
|
|
37
|
+
stripe_checkout_service_1.StripeCheckoutService,
|
|
38
|
+
],
|
|
39
|
+
exports: [stripe_checkout_service_1.StripeCheckoutService],
|
|
40
|
+
controllers: [],
|
|
41
|
+
})
|
|
42
|
+
], StripeAccountModule);
|
|
43
|
+
exports.StripeAccountModule = StripeAccountModule;
|
|
44
|
+
//# sourceMappingURL=stripe-account.module.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-account.module.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-account.module.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,2CAAsC;AACtC,4BAA0B;AAC1B,yFAAoF;AACpF,gFAAyE;AACzE,kGAA6D;AAC7D,2CAA4C;AAC5C,iEAAuD;AACvD,iEAA4D;AAC5D,uCAAwC;AAE3B,QAAA,SAAS,GAAG,eAAe,CAAC;AAiBlC,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,mBAAmB;IAhB/B,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YACL,qBAAY,CAAC,UAAU,CAAC,sCAAe,CAAC;YACxC,4BAAU;YACV,iBAAU,CAAC,aAAa,CAAC;gBACrB,IAAI,EAAE,iBAAS;aAClB,CAAC;SACL;QACD,SAAS,EAAE;YACP,2CAAoB;YACpB,mEAAgC;YAChC,+CAAqB;SACxB;QACD,OAAO,EAAE,CAAC,+CAAqB,CAAC;QAChC,WAAW,EAAE,EAAE;KAClB,CAAC;GACW,mBAAmB,CAAG;AAAtB,kDAAmB"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { RawBodyRequest } from "@nestjs/common";
|
|
2
|
+
import { RequestWithUser } from "../authz/RequestWithUser";
|
|
3
|
+
import { StripeCheckoutSessionParameters } from "./models/StripeCheckoutSessionParams";
|
|
4
|
+
import { StripeCheckoutService } from "./services/stripe-checkout.service";
|
|
5
|
+
import { Request as ExpressRequest } from "express";
|
|
6
|
+
import { StripeWebhookHandler } from "./services/stripe-webhook-handler.service";
|
|
7
|
+
export declare class OrganisationController {
|
|
8
|
+
private readonly stripeService;
|
|
9
|
+
private readonly stripeWebhookService;
|
|
10
|
+
constructor(stripeService: StripeCheckoutService, stripeWebhookService: StripeWebhookHandler);
|
|
11
|
+
webhookReceiver(req: RawBodyRequest<ExpressRequest>): Promise<void>;
|
|
12
|
+
createCustomerPortalSession(request: RequestWithUser): Promise<string>;
|
|
13
|
+
createCheckoutSession(request: RequestWithUser, createSessionDto: StripeCheckoutSessionParameters): Promise<string>;
|
|
14
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
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;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
12
|
+
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.OrganisationController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const passport_1 = require("@nestjs/passport");
|
|
18
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
19
|
+
const StripeCheckoutSessionParams_1 = require("./models/StripeCheckoutSessionParams");
|
|
20
|
+
const stripe_checkout_service_1 = require("./services/stripe-checkout.service");
|
|
21
|
+
const stripe_webhook_handler_service_1 = require("./services/stripe-webhook-handler.service");
|
|
22
|
+
let OrganisationController = class OrganisationController {
|
|
23
|
+
constructor(stripeService, stripeWebhookService) {
|
|
24
|
+
this.stripeService = stripeService;
|
|
25
|
+
this.stripeWebhookService = stripeWebhookService;
|
|
26
|
+
}
|
|
27
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
28
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unicorn/prevent-abbreviations
|
|
29
|
+
async webhookReceiver(req) {
|
|
30
|
+
return this.stripeWebhookService.handleWebhook(req);
|
|
31
|
+
}
|
|
32
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
33
|
+
async createCustomerPortalSession(request) {
|
|
34
|
+
return this.stripeService.createCustomerPortalSession({
|
|
35
|
+
user: request.user,
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
39
|
+
async createCheckoutSession(request, createSessionDto) {
|
|
40
|
+
return this.stripeService.createCheckoutSession(createSessionDto);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
__decorate([
|
|
44
|
+
(0, common_1.Post)("webhook-receiver"),
|
|
45
|
+
(0, swagger_1.ApiOkResponse)(),
|
|
46
|
+
(0, swagger_1.ApiBadRequestResponse)()
|
|
47
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unicorn/prevent-abbreviations
|
|
48
|
+
,
|
|
49
|
+
__param(0, (0, common_1.Req)()),
|
|
50
|
+
__metadata("design:type", Function),
|
|
51
|
+
__metadata("design:paramtypes", [Object]),
|
|
52
|
+
__metadata("design:returntype", Promise)
|
|
53
|
+
], OrganisationController.prototype, "webhookReceiver", null);
|
|
54
|
+
__decorate([
|
|
55
|
+
(0, common_1.UseGuards)((0, passport_1.AuthGuard)("jwt")),
|
|
56
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
57
|
+
(0, common_1.Post)("customer-portal-session"),
|
|
58
|
+
(0, swagger_1.ApiOkResponse)()
|
|
59
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
60
|
+
,
|
|
61
|
+
__param(0, (0, common_1.Request)()),
|
|
62
|
+
__metadata("design:type", Function),
|
|
63
|
+
__metadata("design:paramtypes", [Object]),
|
|
64
|
+
__metadata("design:returntype", Promise)
|
|
65
|
+
], OrganisationController.prototype, "createCustomerPortalSession", null);
|
|
66
|
+
__decorate([
|
|
67
|
+
(0, common_1.UseGuards)((0, passport_1.AuthGuard)("jwt")),
|
|
68
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
69
|
+
(0, common_1.Post)("checkout-session"),
|
|
70
|
+
(0, swagger_1.ApiOkResponse)()
|
|
71
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
72
|
+
,
|
|
73
|
+
__param(0, (0, common_1.Request)()),
|
|
74
|
+
__param(1, (0, common_1.Body)()),
|
|
75
|
+
__metadata("design:type", Function),
|
|
76
|
+
__metadata("design:paramtypes", [Object, StripeCheckoutSessionParams_1.StripeCheckoutSessionParameters]),
|
|
77
|
+
__metadata("design:returntype", Promise)
|
|
78
|
+
], OrganisationController.prototype, "createCheckoutSession", null);
|
|
79
|
+
OrganisationController = __decorate([
|
|
80
|
+
(0, common_1.Controller)("payments/stripe"),
|
|
81
|
+
(0, swagger_1.ApiTags)("payments"),
|
|
82
|
+
__metadata("design:paramtypes", [stripe_checkout_service_1.StripeCheckoutService,
|
|
83
|
+
stripe_webhook_handler_service_1.StripeWebhookHandler])
|
|
84
|
+
], OrganisationController);
|
|
85
|
+
exports.OrganisationController = OrganisationController;
|
|
86
|
+
//# sourceMappingURL=stripe-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-controller.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,+CAA2C;AAC3C,6CAKyB;AAEzB,sFAAqF;AACrF,gFAAyE;AAEzE,8FAA+E;AAIxE,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAC/B,YACqB,aAAoC,EACpC,oBAA0C;QAD1C,kBAAa,GAAb,aAAa,CAAuB;QACpC,yBAAoB,GAApB,oBAAoB,CAAsB;IAC5D,CAAC;IAEJ,4DAA4D;IAKtD,AADN,4FAA4F;IAC5F,KAAK,CAAC,eAAe,CAAQ,GAAmC;QAC5D,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC;IAOK,AADN,6DAA6D;IAC7D,KAAK,CAAC,2BAA2B,CAAY,OAAwB;QACjE,OAAO,IAAI,CAAC,aAAa,CAAC,2BAA2B,CAAC;YAClD,IAAI,EAAE,OAAO,CAAC,IAAI;SACrB,CAAC,CAAC;IACP,CAAC;IAOK,AADN,6DAA6D;IAC7D,KAAK,CAAC,qBAAqB,CACZ,OAAwB,EAC3B,gBAAiD;QAEzD,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;CACJ,CAAA;AA1BS;IAJL,IAAA,aAAI,EAAC,kBAAkB,CAAC;IACxB,IAAA,uBAAa,GAAE;IACf,IAAA,+BAAqB,GAAE;IACxB,4FAA4F;;IACrE,WAAA,IAAA,YAAG,GAAE,CAAA;;;;6DAE3B;AAOK;IALL,IAAA,kBAAS,EAAC,IAAA,oBAAS,EAAC,KAAK,CAAC,CAAC;IAC3B,IAAA,uBAAa,GAAE;IACf,IAAA,aAAI,EAAC,yBAAyB,CAAC;IAC/B,IAAA,uBAAa,GAAE;IAChB,6DAA6D;;IAC1B,WAAA,IAAA,gBAAO,GAAE,CAAA;;;;yEAI3C;AAOK;IALL,IAAA,kBAAS,EAAC,IAAA,oBAAS,EAAC,KAAK,CAAC,CAAC;IAC3B,IAAA,uBAAa,GAAE;IACf,IAAA,aAAI,EAAC,kBAAkB,CAAC;IACxB,IAAA,uBAAa,GAAE;IAChB,6DAA6D;;IAExD,WAAA,IAAA,gBAAO,GAAE,CAAA;IACT,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAmB,6DAA+B;;mEAG5D;AApCQ,sBAAsB;IAFlC,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAC7B,IAAA,iBAAO,EAAC,UAAU,CAAC;qCAGoB,+CAAqB;QACd,qDAAoB;GAHtD,sBAAsB,CAqClC;AArCY,wDAAsB"}
|