@darraghor/nest-backend-libs 2.12.3 → 2.12.5
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/LICENSE.md +17 -0
- package/README.md +31 -0
- package/dist/invitations/invitation.service.d.ts +2 -2
- package/dist/invitations/invitation.service.js.map +1 -1
- package/dist/stripe-client/services/stripe-checkout.service.d.ts +4 -2
- package/dist/stripe-client/services/stripe-checkout.service.js +16 -0
- package/dist/stripe-client/services/stripe-checkout.service.js.map +1 -1
- package/dist/stripe-client/services/stripe-webhook-handler.service.js +1 -0
- package/dist/stripe-client/services/stripe-webhook-handler.service.js.map +1 -1
- package/dist/stripe-client/stripe-account.module.js +5 -2
- package/dist/stripe-client/stripe-account.module.js.map +1 -1
- package/dist/stripe-client/stripe-checkout-controller.d.ts +16 -0
- package/dist/stripe-client/{stripe-controller.js → stripe-checkout-controller.js} +20 -49
- package/dist/stripe-client/stripe-checkout-controller.js.map +1 -0
- package/dist/stripe-client/stripe-customer-portal-controller.d.ts +7 -0
- package/dist/stripe-client/stripe-customer-portal-controller.js +50 -0
- package/dist/stripe-client/stripe-customer-portal-controller.js.map +1 -0
- package/dist/stripe-client/stripe-unauthenticated-checkout-controller.d.ts +15 -0
- package/dist/stripe-client/stripe-unauthenticated-checkout-controller.js +56 -0
- package/dist/stripe-client/stripe-unauthenticated-checkout-controller.js.map +1 -0
- package/dist/stripe-client/stripe-webhook-controller.d.ts +8 -0
- package/dist/stripe-client/stripe-webhook-controller.js +52 -0
- package/dist/stripe-client/stripe-webhook-controller.js.map +1 -0
- package/package.json +3 -3
- package/dist/stripe-client/stripe-controller.d.ts +0 -15
- package/dist/stripe-client/stripe-controller.js.map +0 -1
package/LICENSE.md
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
All rights reserved.
|
|
2
|
+
|
|
3
|
+
This code and any package of the code is not open source.
|
|
4
|
+
|
|
5
|
+
License is granted to use this code on an individual basis by purchasing a license from the author. Purchasing a license grants a non-exclusive, non-transferable, limited license to use the software.
|
|
6
|
+
|
|
7
|
+
By using this software, you agree to the terms of this license agreement. The software is owned by the licensor and is protected by copyright laws.
|
|
8
|
+
|
|
9
|
+
You may not reverse engineer, decompile or disassemble the software, nor may you rent, lease or lend it or parts of it.
|
|
10
|
+
|
|
11
|
+
This agreement can be terminated if you fail to comply with any of its terms and the licensor is not liable for any damages arising from the use of this software.
|
|
12
|
+
|
|
13
|
+
You acknowledge that the software is provided "AS IS" without any warranty, express or implied. The licensor does not guarantee that the software will meet your requirements or that it will be uninterrupted or error-free.
|
|
14
|
+
|
|
15
|
+
This license agreement is the entire agreement between you and the licensor and supersedes all prior or contemporaneous communications and proposals. It will be governed by the laws of the jurisdiction in which the licensor is located.
|
|
16
|
+
|
|
17
|
+
https://www.usemiller.com
|
package/README.md
CHANGED
|
@@ -1,2 +1,33 @@
|
|
|
1
1
|
# nest-backend-libs
|
|
2
|
+
|
|
2
3
|
A collection of nest modules for building backends faster
|
|
4
|
+
|
|
5
|
+
## Stripe Module
|
|
6
|
+
|
|
7
|
+
A module for integrating stripe into your nest application.
|
|
8
|
+
|
|
9
|
+
### Default functionality
|
|
10
|
+
|
|
11
|
+
Webhook handling into a queue is automatically added to the module
|
|
12
|
+
A controller to generate a customer portal session for authenticated users is added to the module
|
|
13
|
+
|
|
14
|
+
### You must manually add the following to your own module
|
|
15
|
+
|
|
16
|
+
A controller to create a checkout session for either Authenticated or Unauthenticated users (your choice if you want your front end app to force users to auth or not)
|
|
17
|
+
|
|
18
|
+
A handler for the webhook queue events (you can use the example directly in Miller if you haven't modified anything)
|
|
19
|
+
|
|
20
|
+
### Env vars
|
|
21
|
+
|
|
22
|
+
STRIPE_ACCESS_TOKEN
|
|
23
|
+
Why: To create stripe sessions using the api
|
|
24
|
+
Where: https://dashboard.stripe.com/apikeys
|
|
25
|
+
|
|
26
|
+
STRIPE_WEBHOOK_VERIFICATION_KEY
|
|
27
|
+
Why: To verify the webhook signature
|
|
28
|
+
Where: https://dashboard.stripe.com/apikeys
|
|
29
|
+
|
|
30
|
+
STRIPE_REDIRECTS_BASE_URL
|
|
31
|
+
Why: To securely redirect the user to the correct website after checkout we don't use a full url
|
|
32
|
+
in the request object, only a path which is combined with this base url
|
|
33
|
+
Where: your frontend configuration
|
|
@@ -2,15 +2,15 @@ import { Repository } from "typeorm";
|
|
|
2
2
|
import { CreateInvitationDto } from "./dto/create-invitation.dto";
|
|
3
3
|
import { Invitation } from "./entities/invitation.entity";
|
|
4
4
|
import { SmtpEmailClient } from "../smtp-email-client/email-client.service";
|
|
5
|
-
import { Person } from "../person/entities/person.entity";
|
|
6
5
|
import { Organisation } from "../organisation/entities/organisation.entity";
|
|
7
6
|
import { InvitationsConfigurationService } from "./InvitationConfigurationService";
|
|
7
|
+
import { RequestPerson } from "../authz/RequestWithUser";
|
|
8
8
|
export declare class InvitationService {
|
|
9
9
|
private invitationRepository;
|
|
10
10
|
private organisationRepository;
|
|
11
11
|
private readonly emailClient;
|
|
12
12
|
private readonly configService;
|
|
13
13
|
constructor(invitationRepository: Repository<Invitation>, organisationRepository: Repository<Organisation>, emailClient: SmtpEmailClient, configService: InvitationsConfigurationService);
|
|
14
|
-
create(createDto: CreateInvitationDto, createdBy:
|
|
14
|
+
create(createDto: CreateInvitationDto, createdBy: RequestPerson): Promise<Invitation>;
|
|
15
15
|
remove(uuid: string, currentUserId: number): Promise<Invitation>;
|
|
16
16
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"invitation.service.js","sourceRoot":"","sources":["../../src/invitations/invitation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6CAAiD;AACjD,qCAAmC;AACnC,6DAAoD;AAEpD,oEAAwD;AACxD,oFAA0E;
|
|
1
|
+
{"version":3,"file":"invitation.service.js","sourceRoot":"","sources":["../../src/invitations/invitation.service.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0C;AAC1C,6CAAiD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,WAAA,IAAA,0BAAgB,EAAC,8BAAU,CAAC,CAAA;IAE5B,WAAA,IAAA,0BAAgB,EAAC,kCAAY,CAAC,CAAA;qCADD,oBAAU;QAER,oBAAU;QACZ,sCAAe;QACb,gEAA+B;GAP1D,iBAAiB,CA2F7B;AA3FY,8CAAiB"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import Stripe from "stripe";
|
|
2
2
|
import { Repository } from "typeorm";
|
|
3
|
+
import { RequestPerson } from "../../authz/RequestWithUser";
|
|
3
4
|
import CoreLoggerService from "../../logger/CoreLoggerService";
|
|
4
|
-
import { Person } from "../../person/entities/person.entity";
|
|
5
5
|
import { StripeCheckoutEvent } from "../entities/stripe-checkout-event.entity";
|
|
6
6
|
import { StripeCheckoutSessionRequestDto } from "../models/StripeCheckoutSessionRequestDto";
|
|
7
7
|
import { StripeCheckoutSessionResponseDto } from "../models/StripeCheckoutSessionResponseDto";
|
|
@@ -13,7 +13,9 @@ export declare class StripeCheckoutService {
|
|
|
13
13
|
private eventRepository;
|
|
14
14
|
constructor(logger: CoreLoggerService, clientInstance: Stripe, stripeClientConfigurationService: StripeClientConfigurationService, eventRepository: Repository<StripeCheckoutEvent>);
|
|
15
15
|
createCustomerPortalSession(parameters: {
|
|
16
|
-
user:
|
|
16
|
+
user: RequestPerson;
|
|
17
17
|
}): Promise<string>;
|
|
18
|
+
createAuthenticatedCheckoutSession(parameters: StripeCheckoutSessionRequestDto, user: RequestPerson): Promise<StripeCheckoutSessionResponseDto>;
|
|
18
19
|
createCheckoutSession(parameters: StripeCheckoutSessionRequestDto): Promise<StripeCheckoutSessionResponseDto>;
|
|
20
|
+
private createSession;
|
|
19
21
|
}
|
|
@@ -46,6 +46,19 @@ let StripeCheckoutService = class StripeCheckoutService {
|
|
|
46
46
|
});
|
|
47
47
|
return session.url;
|
|
48
48
|
}
|
|
49
|
+
async createAuthenticatedCheckoutSession(parameters, user) {
|
|
50
|
+
const mappedParameters = {
|
|
51
|
+
mode: parameters.mode,
|
|
52
|
+
client_reference_id: user.uuid,
|
|
53
|
+
line_items: parameters.lineItems,
|
|
54
|
+
customer_email: user.email,
|
|
55
|
+
success_url: `${this.stripeClientConfigurationService.stripeRedirectsBaseUrl}${parameters.successFrontendPath}`,
|
|
56
|
+
cancel_url: parameters.cancelFrontendPath
|
|
57
|
+
? `${this.stripeClientConfigurationService.stripeRedirectsBaseUrl}${parameters.cancelFrontendPath}`
|
|
58
|
+
: undefined,
|
|
59
|
+
};
|
|
60
|
+
return this.createSession(mappedParameters);
|
|
61
|
+
}
|
|
49
62
|
async createCheckoutSession(parameters) {
|
|
50
63
|
const mappedParameters = {
|
|
51
64
|
mode: parameters.mode,
|
|
@@ -56,6 +69,9 @@ let StripeCheckoutService = class StripeCheckoutService {
|
|
|
56
69
|
? `${this.stripeClientConfigurationService.stripeRedirectsBaseUrl}${parameters.cancelFrontendPath}`
|
|
57
70
|
: undefined,
|
|
58
71
|
};
|
|
72
|
+
return this.createSession(mappedParameters);
|
|
73
|
+
}
|
|
74
|
+
async createSession(mappedParameters) {
|
|
59
75
|
const session = await this.clientInstance.checkout.sessions.create(mappedParameters);
|
|
60
76
|
if (!session.url) {
|
|
61
77
|
throw new Error("Failed to create checkout session");
|
|
@@ -1 +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,6CAAiD;AACjD,oDAA4B;AAC5B,qCAAmC;
|
|
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,6CAAiD;AACjD,oDAA4B;AAC5B,qCAAmC;AAEnC,uFAA+D;AAC/D,2FAA6E;AAE7E,iGAA4F;AAC5F,0FA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AAE,CAAC;QAEtC,OAAO,QAAQ,CAAC;IACpB,CAAC;CACJ,CAAA;AAvFY,qBAAqB;IADjC,IAAA,mBAAU,GAAE;IAIJ,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;IAGtB,WAAA,IAAA,0BAAgB,EAAC,kDAAmB,CAAC,CAAA;qCAJb,2BAAiB;QAET,gBAAM;QACY,mEAAgC;QAE1D,oBAAU;GAP9B,qBAAqB,CAuFjC;AAvFY,sDAAqB"}
|
|
@@ -49,6 +49,7 @@ let StripeWebhookHandler = class StripeWebhookHandler {
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
StripeWebhookHandler = __decorate([
|
|
52
|
+
(0, common_1.Injectable)(),
|
|
52
53
|
__param(2, (0, common_1.Inject)("StripeClient")),
|
|
53
54
|
__param(3, (0, bull_1.InjectQueue)("stripe-events")),
|
|
54
55
|
__metadata("design:paramtypes", [StripeClientConfigurationService_1.StripeClientConfigurationService,
|
|
@@ -1 +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,
|
|
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,2CAKwB;AAGxB,oDAA4B;AAC5B,uFAA+D;AAC/D,0FAAqF;AAG9E,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAER;IACA;IAEA;IAET;IANZ,YACqB,MAAwC,EACxC,MAAyB,EAEzB,cAAsB,EAE/B,KAAY;QALH,WAAM,GAAN,MAAM,CAAkC;QACxC,WAAM,GAAN,MAAM,CAAmB;QAEzB,mBAAc,GAAd,cAAc,CAAQ;QAE/B,UAAK,GAAL,KAAK,CAAO;IACrB,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;AAlCY,oBAAoB;IADhC,IAAA,mBAAU,GAAE;IAKJ,WAAA,IAAA,eAAM,EAAC,cAAc,CAAC,CAAA;IAEtB,WAAA,IAAA,kBAAW,EAAC,eAAe,CAAC,CAAA;qCAJJ,mEAAgC;QAChC,2BAAiB;QAET,gBAAM;GALlC,oBAAoB,CAkChC;AAlCY,oDAAoB"}
|
|
@@ -19,9 +19,11 @@ const config_1 = require("@nestjs/config");
|
|
|
19
19
|
const core_app_module_1 = require("../root-app/core-app.module");
|
|
20
20
|
const StripeClientProvider_1 = require("./StripeClientProvider");
|
|
21
21
|
const bull_1 = require("@nestjs/bull");
|
|
22
|
-
const stripe_controller_1 = require("./stripe-controller");
|
|
23
22
|
const typeorm_1 = require("@nestjs/typeorm");
|
|
24
23
|
const stripe_checkout_event_entity_1 = require("./entities/stripe-checkout-event.entity");
|
|
24
|
+
const stripe_webhook_handler_service_1 = require("./services/stripe-webhook-handler.service");
|
|
25
|
+
const stripe_webhook_controller_1 = require("./stripe-webhook-controller");
|
|
26
|
+
const stripe_customer_portal_controller_1 = require("./stripe-customer-portal-controller");
|
|
25
27
|
let StripeAccountModule = class StripeAccountModule {
|
|
26
28
|
};
|
|
27
29
|
StripeAccountModule = __decorate([
|
|
@@ -38,9 +40,10 @@ StripeAccountModule = __decorate([
|
|
|
38
40
|
StripeClientProvider_1.StripeClientProvider,
|
|
39
41
|
StripeClientConfigurationService_1.StripeClientConfigurationService,
|
|
40
42
|
stripe_checkout_service_1.StripeCheckoutService,
|
|
43
|
+
stripe_webhook_handler_service_1.StripeWebhookHandler,
|
|
41
44
|
],
|
|
42
45
|
exports: [stripe_checkout_service_1.StripeCheckoutService],
|
|
43
|
-
controllers: [
|
|
46
|
+
controllers: [stripe_webhook_controller_1.StripeWebhookController, stripe_customer_portal_controller_1.StripeCustomerPortalController],
|
|
44
47
|
})
|
|
45
48
|
], StripeAccountModule);
|
|
46
49
|
exports.StripeAccountModule = StripeAccountModule;
|
|
@@ -1 +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;AACxC,
|
|
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;AACxC,6CAA8C;AAC9C,0FAA4E;AAC5E,8FAA+E;AAC/E,2EAAoE;AACpE,2FAAmF;AAoB5E,IAAM,mBAAmB,GAAzB,MAAM,mBAAmB;CAAG,CAAA;AAAtB,mBAAmB;IAlB/B,IAAA,eAAM,EAAC;QACJ,OAAO,EAAE;YACL,qBAAY,CAAC,UAAU,CAAC,sCAAe,CAAC;YACxC,uBAAa,CAAC,UAAU,CAAC,CAAC,kDAAmB,CAAC,CAAC;YAC/C,4BAAU;YACV,iBAAU,CAAC,aAAa,CAAC;gBACrB,IAAI,EAAE,eAAe;aACxB,CAAC;SACL;QACD,SAAS,EAAE;YACP,2CAAoB;YACpB,mEAAgC;YAChC,+CAAqB;YACrB,qDAAoB;SACvB;QACD,OAAO,EAAE,CAAC,+CAAqB,CAAC;QAChC,WAAW,EAAE,CAAC,mDAAuB,EAAE,kEAA8B,CAAC;KACzE,CAAC;GACW,mBAAmB,CAAG;AAAtB,kDAAmB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { RequestWithUser } from "../authz/RequestWithUser";
|
|
2
|
+
import { StripeCheckoutSessionRequestDto } from "./models/StripeCheckoutSessionRequestDto";
|
|
3
|
+
import { StripeCheckoutService } from "./services/stripe-checkout.service";
|
|
4
|
+
import { StripeCheckoutSessionResponseDto } from "./models/StripeCheckoutSessionResponseDto";
|
|
5
|
+
/**
|
|
6
|
+
* This controller creates authenticated checkout sessions for Stripe.
|
|
7
|
+
* It adds the user's email address and user ID to the session.
|
|
8
|
+
* Users MUST be logged in to use this controller.
|
|
9
|
+
*
|
|
10
|
+
* This is not automatically included in the StripeClientModule.
|
|
11
|
+
*/
|
|
12
|
+
export declare class StripeCheckoutController {
|
|
13
|
+
private readonly stripeService;
|
|
14
|
+
constructor(stripeService: StripeCheckoutService);
|
|
15
|
+
createCheckoutSession(request: RequestWithUser, createSessionDto: StripeCheckoutSessionRequestDto): Promise<StripeCheckoutSessionResponseDto>;
|
|
16
|
+
}
|
|
@@ -12,63 +12,33 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
12
12
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.
|
|
15
|
+
exports.StripeCheckoutController = void 0;
|
|
16
16
|
const common_1 = require("@nestjs/common");
|
|
17
17
|
const passport_1 = require("@nestjs/passport");
|
|
18
18
|
const swagger_1 = require("@nestjs/swagger");
|
|
19
19
|
const StripeCheckoutSessionRequestDto_1 = require("./models/StripeCheckoutSessionRequestDto");
|
|
20
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
21
|
const StripeCheckoutSessionResponseDto_1 = require("./models/StripeCheckoutSessionResponseDto");
|
|
23
|
-
|
|
22
|
+
/**
|
|
23
|
+
* This controller creates authenticated checkout sessions for Stripe.
|
|
24
|
+
* It adds the user's email address and user ID to the session.
|
|
25
|
+
* Users MUST be logged in to use this controller.
|
|
26
|
+
*
|
|
27
|
+
* This is not automatically included in the StripeClientModule.
|
|
28
|
+
*/
|
|
29
|
+
let StripeCheckoutController = class StripeCheckoutController {
|
|
24
30
|
stripeService;
|
|
25
|
-
|
|
26
|
-
constructor(stripeService, stripeWebhookService) {
|
|
31
|
+
constructor(stripeService) {
|
|
27
32
|
this.stripeService = stripeService;
|
|
28
|
-
this.stripeWebhookService = stripeWebhookService;
|
|
29
33
|
}
|
|
30
|
-
// eslint-disable-next-line @typescript-eslint/require-await
|
|
31
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unicorn/prevent-abbreviations
|
|
32
|
-
async webhookReceiver(req) {
|
|
33
|
-
return this.stripeWebhookService.handleWebhook(req);
|
|
34
|
-
}
|
|
35
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
36
|
-
async createCustomerPortalSession(request) {
|
|
37
|
-
return this.stripeService.createCustomerPortalSession({
|
|
38
|
-
user: request.user,
|
|
39
|
-
});
|
|
40
|
-
}
|
|
41
|
-
// @UseGuards(AuthGuard("jwt"))
|
|
42
|
-
// @ApiBearerAuth()
|
|
43
34
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
44
35
|
async createCheckoutSession(request, createSessionDto) {
|
|
45
|
-
return this.stripeService.
|
|
36
|
+
return this.stripeService.createAuthenticatedCheckoutSession(createSessionDto, request.user);
|
|
46
37
|
}
|
|
47
38
|
};
|
|
48
|
-
__decorate([
|
|
49
|
-
(0, common_1.Post)("webhook-receiver"),
|
|
50
|
-
(0, swagger_1.ApiOkResponse)(),
|
|
51
|
-
(0, swagger_1.ApiBadRequestResponse)()
|
|
52
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unicorn/prevent-abbreviations
|
|
53
|
-
,
|
|
54
|
-
__param(0, (0, common_1.Req)()),
|
|
55
|
-
__metadata("design:type", Function),
|
|
56
|
-
__metadata("design:paramtypes", [Object]),
|
|
57
|
-
__metadata("design:returntype", Promise)
|
|
58
|
-
], StripeClientController.prototype, "webhookReceiver", null);
|
|
59
39
|
__decorate([
|
|
60
40
|
(0, common_1.UseGuards)((0, passport_1.AuthGuard)("jwt")),
|
|
61
41
|
(0, swagger_1.ApiBearerAuth)(),
|
|
62
|
-
(0, common_1.Post)("customer-portal-session"),
|
|
63
|
-
(0, swagger_1.ApiOkResponse)()
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
65
|
-
,
|
|
66
|
-
__param(0, (0, common_1.Request)()),
|
|
67
|
-
__metadata("design:type", Function),
|
|
68
|
-
__metadata("design:paramtypes", [Object]),
|
|
69
|
-
__metadata("design:returntype", Promise)
|
|
70
|
-
], StripeClientController.prototype, "createCustomerPortalSession", null);
|
|
71
|
-
__decorate([
|
|
72
42
|
(0, common_1.Post)("checkout-session"),
|
|
73
43
|
(0, swagger_1.ApiOkResponse)({ type: StripeCheckoutSessionResponseDto_1.StripeCheckoutSessionResponseDto })
|
|
74
44
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
@@ -78,12 +48,13 @@ __decorate([
|
|
|
78
48
|
__metadata("design:type", Function),
|
|
79
49
|
__metadata("design:paramtypes", [Object, StripeCheckoutSessionRequestDto_1.StripeCheckoutSessionRequestDto]),
|
|
80
50
|
__metadata("design:returntype", Promise)
|
|
81
|
-
],
|
|
82
|
-
|
|
51
|
+
], StripeCheckoutController.prototype, "createCheckoutSession", null);
|
|
52
|
+
StripeCheckoutController = __decorate([
|
|
83
53
|
(0, common_1.Controller)("payments/stripe"),
|
|
84
|
-
(0, swagger_1.ApiTags)("payments")
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
54
|
+
(0, swagger_1.ApiTags)("payments")
|
|
55
|
+
// eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
|
|
56
|
+
,
|
|
57
|
+
__metadata("design:paramtypes", [stripe_checkout_service_1.StripeCheckoutService])
|
|
58
|
+
], StripeCheckoutController);
|
|
59
|
+
exports.StripeCheckoutController = StripeCheckoutController;
|
|
60
|
+
//# sourceMappingURL=stripe-checkout-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-checkout-controller.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-checkout-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAA0E;AAC1E,+CAA2C;AAC3C,6CAAsE;AAEtE,8FAAyF;AACzF,gFAAyE;AACzE,gGAA2F;AAE3F;;;;;;GAMG;AAII,IAAM,wBAAwB,GAA9B,MAAM,wBAAwB;IACJ;IAA7B,YAA6B,aAAoC;QAApC,kBAAa,GAAb,aAAa,CAAuB;IAAG,CAAC;IAO/D,AADN,6DAA6D;IAC7D,KAAK,CAAC,qBAAqB,CACZ,OAAwB,EAC3B,gBAAiD;QAEzD,OAAO,IAAI,CAAC,aAAa,CAAC,kCAAkC,CACxD,gBAAgB,EAChB,OAAO,CAAC,IAAI,CACf,CAAC;IACN,CAAC;CACJ,CAAA;AATS;IALL,IAAA,kBAAS,EAAC,IAAA,oBAAS,EAAC,KAAK,CAAC,CAAC;IAC3B,IAAA,uBAAa,GAAE;IACf,IAAA,aAAI,EAAC,kBAAkB,CAAC;IACxB,IAAA,uBAAa,EAAC,EAAC,IAAI,EAAE,mEAAgC,EAAC,CAAC;IACxD,6DAA6D;;IAExD,WAAA,IAAA,gBAAO,GAAE,CAAA;IACT,WAAA,IAAA,aAAI,GAAE,CAAA;;6CAAmB,iEAA+B;;qEAM5D;AAhBQ,wBAAwB;IAHpC,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAC7B,IAAA,iBAAO,EAAC,UAAU,CAAC;IACpB,iFAAiF;;qCAEjC,+CAAqB;GADxD,wBAAwB,CAiBpC;AAjBY,4DAAwB"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { RequestWithUser } from "../authz/RequestWithUser";
|
|
2
|
+
import { StripeCheckoutService } from "./services/stripe-checkout.service";
|
|
3
|
+
export declare class StripeCustomerPortalController {
|
|
4
|
+
private readonly stripeService;
|
|
5
|
+
constructor(stripeService: StripeCheckoutService);
|
|
6
|
+
createCustomerPortalSession(request: RequestWithUser): Promise<string>;
|
|
7
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
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.StripeCustomerPortalController = 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 stripe_checkout_service_1 = require("./services/stripe-checkout.service");
|
|
20
|
+
let StripeCustomerPortalController = class StripeCustomerPortalController {
|
|
21
|
+
stripeService;
|
|
22
|
+
constructor(stripeService) {
|
|
23
|
+
this.stripeService = stripeService;
|
|
24
|
+
}
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
26
|
+
async createCustomerPortalSession(request) {
|
|
27
|
+
return this.stripeService.createCustomerPortalSession({
|
|
28
|
+
user: request.user,
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
__decorate([
|
|
33
|
+
(0, common_1.UseGuards)((0, passport_1.AuthGuard)("jwt")),
|
|
34
|
+
(0, swagger_1.ApiBearerAuth)(),
|
|
35
|
+
(0, common_1.Post)("customer-portal-session"),
|
|
36
|
+
(0, swagger_1.ApiOkResponse)()
|
|
37
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
38
|
+
,
|
|
39
|
+
__param(0, (0, common_1.Request)()),
|
|
40
|
+
__metadata("design:type", Function),
|
|
41
|
+
__metadata("design:paramtypes", [Object]),
|
|
42
|
+
__metadata("design:returntype", Promise)
|
|
43
|
+
], StripeCustomerPortalController.prototype, "createCustomerPortalSession", null);
|
|
44
|
+
StripeCustomerPortalController = __decorate([
|
|
45
|
+
(0, common_1.Controller)("payments/stripe"),
|
|
46
|
+
(0, swagger_1.ApiTags)("payments"),
|
|
47
|
+
__metadata("design:paramtypes", [stripe_checkout_service_1.StripeCheckoutService])
|
|
48
|
+
], StripeCustomerPortalController);
|
|
49
|
+
exports.StripeCustomerPortalController = StripeCustomerPortalController;
|
|
50
|
+
//# sourceMappingURL=stripe-customer-portal-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-customer-portal-controller.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-customer-portal-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAoE;AACpE,+CAA2C;AAC3C,6CAAsE;AAEtE,gFAAyE;AAIlE,IAAM,8BAA8B,GAApC,MAAM,8BAA8B;IACV;IAA7B,YAA6B,aAAoC;QAApC,kBAAa,GAAb,aAAa,CAAuB;IAAG,CAAC;IAO/D,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;CACJ,CAAA;AALS;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;;;;iFAI3C;AAZQ,8BAA8B;IAF1C,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAC7B,IAAA,iBAAO,EAAC,UAAU,CAAC;qCAE4B,+CAAqB;GADxD,8BAA8B,CAa1C;AAbY,wEAA8B"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { StripeCheckoutSessionRequestDto } from "./models/StripeCheckoutSessionRequestDto";
|
|
2
|
+
import { StripeCheckoutService } from "./services/stripe-checkout.service";
|
|
3
|
+
import { StripeCheckoutSessionResponseDto } from "./models/StripeCheckoutSessionResponseDto";
|
|
4
|
+
/**
|
|
5
|
+
* This controller creates checkout sessions for Stripe.
|
|
6
|
+
* It does not require the user to be logged in.
|
|
7
|
+
* So it does not add the user's email address and user ID to the stripe session.
|
|
8
|
+
*
|
|
9
|
+
* This is not automatically included in the StripeClientModule.
|
|
10
|
+
*/
|
|
11
|
+
export declare class StripeUnauthenticatedCheckoutController {
|
|
12
|
+
private readonly stripeService;
|
|
13
|
+
constructor(stripeService: StripeCheckoutService);
|
|
14
|
+
createCheckoutSession(createSessionDto: StripeCheckoutSessionRequestDto): Promise<StripeCheckoutSessionResponseDto>;
|
|
15
|
+
}
|
|
@@ -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
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.StripeUnauthenticatedCheckoutController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const StripeCheckoutSessionRequestDto_1 = require("./models/StripeCheckoutSessionRequestDto");
|
|
19
|
+
const stripe_checkout_service_1 = require("./services/stripe-checkout.service");
|
|
20
|
+
const StripeCheckoutSessionResponseDto_1 = require("./models/StripeCheckoutSessionResponseDto");
|
|
21
|
+
/**
|
|
22
|
+
* This controller creates checkout sessions for Stripe.
|
|
23
|
+
* It does not require the user to be logged in.
|
|
24
|
+
* So it does not add the user's email address and user ID to the stripe session.
|
|
25
|
+
*
|
|
26
|
+
* This is not automatically included in the StripeClientModule.
|
|
27
|
+
*/
|
|
28
|
+
let StripeUnauthenticatedCheckoutController = class StripeUnauthenticatedCheckoutController {
|
|
29
|
+
stripeService;
|
|
30
|
+
constructor(stripeService) {
|
|
31
|
+
this.stripeService = stripeService;
|
|
32
|
+
}
|
|
33
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
34
|
+
async createCheckoutSession(createSessionDto) {
|
|
35
|
+
return this.stripeService.createCheckoutSession(createSessionDto);
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
__decorate([
|
|
39
|
+
(0, common_1.Post)("checkout-session"),
|
|
40
|
+
(0, swagger_1.ApiOkResponse)({ type: StripeCheckoutSessionResponseDto_1.StripeCheckoutSessionResponseDto })
|
|
41
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
42
|
+
,
|
|
43
|
+
__param(0, (0, common_1.Body)()),
|
|
44
|
+
__metadata("design:type", Function),
|
|
45
|
+
__metadata("design:paramtypes", [StripeCheckoutSessionRequestDto_1.StripeCheckoutSessionRequestDto]),
|
|
46
|
+
__metadata("design:returntype", Promise)
|
|
47
|
+
], StripeUnauthenticatedCheckoutController.prototype, "createCheckoutSession", null);
|
|
48
|
+
StripeUnauthenticatedCheckoutController = __decorate([
|
|
49
|
+
(0, common_1.Controller)("payments/stripe"),
|
|
50
|
+
(0, swagger_1.ApiTags)("payments")
|
|
51
|
+
// eslint-disable-next-line @darraghor/nestjs-typed/injectable-should-be-provided
|
|
52
|
+
,
|
|
53
|
+
__metadata("design:paramtypes", [stripe_checkout_service_1.StripeCheckoutService])
|
|
54
|
+
], StripeUnauthenticatedCheckoutController);
|
|
55
|
+
exports.StripeUnauthenticatedCheckoutController = StripeUnauthenticatedCheckoutController;
|
|
56
|
+
//# sourceMappingURL=stripe-unauthenticated-checkout-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-unauthenticated-checkout-controller.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-unauthenticated-checkout-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAsD;AACtD,6CAAuD;AACvD,8FAAyF;AACzF,gFAAyE;AACzE,gGAA2F;AAE3F;;;;;;GAMG;AAII,IAAM,uCAAuC,GAA7C,MAAM,uCAAuC;IACnB;IAA7B,YAA6B,aAAoC;QAApC,kBAAa,GAAb,aAAa,CAAuB;IAAG,CAAC;IAK/D,AADN,6DAA6D;IAC7D,KAAK,CAAC,qBAAqB,CACf,gBAAiD;QAEzD,OAAO,IAAI,CAAC,aAAa,CAAC,qBAAqB,CAAC,gBAAgB,CAAC,CAAC;IACtE,CAAC;CACJ,CAAA;AALS;IAHL,IAAA,aAAI,EAAC,kBAAkB,CAAC;IACxB,IAAA,uBAAa,EAAC,EAAC,IAAI,EAAE,mEAAgC,EAAC,CAAC;IACxD,6DAA6D;;IAExD,WAAA,IAAA,aAAI,GAAE,CAAA;;qCAAmB,iEAA+B;;oFAG5D;AAVQ,uCAAuC;IAHnD,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAC7B,IAAA,iBAAO,EAAC,UAAU,CAAC;IACpB,iFAAiF;;qCAEjC,+CAAqB;GADxD,uCAAuC,CAWnD;AAXY,0FAAuC"}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { RawBodyRequest } from "@nestjs/common";
|
|
2
|
+
import { Request as ExpressRequest } from "express";
|
|
3
|
+
import { StripeWebhookHandler } from "./services/stripe-webhook-handler.service";
|
|
4
|
+
export declare class StripeWebhookController {
|
|
5
|
+
private readonly stripeWebhookService;
|
|
6
|
+
constructor(stripeWebhookService: StripeWebhookHandler);
|
|
7
|
+
webhookReceiver(req: RawBodyRequest<ExpressRequest>): Promise<void>;
|
|
8
|
+
}
|
|
@@ -0,0 +1,52 @@
|
|
|
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.StripeWebhookController = void 0;
|
|
16
|
+
const common_1 = require("@nestjs/common");
|
|
17
|
+
const swagger_1 = require("@nestjs/swagger");
|
|
18
|
+
const stripe_webhook_handler_service_1 = require("./services/stripe-webhook-handler.service");
|
|
19
|
+
/*
|
|
20
|
+
* This is a controller that is used to receive webhooks from Stripe.
|
|
21
|
+
* It is not used to send requests to Stripe.
|
|
22
|
+
* It is automatically registered by the StripeClientModule.
|
|
23
|
+
*/
|
|
24
|
+
let StripeWebhookController = class StripeWebhookController {
|
|
25
|
+
stripeWebhookService;
|
|
26
|
+
constructor(stripeWebhookService) {
|
|
27
|
+
this.stripeWebhookService = stripeWebhookService;
|
|
28
|
+
}
|
|
29
|
+
// eslint-disable-next-line @typescript-eslint/require-await
|
|
30
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unicorn/prevent-abbreviations
|
|
31
|
+
async webhookReceiver(req) {
|
|
32
|
+
return this.stripeWebhookService.handleWebhook(req);
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
__decorate([
|
|
36
|
+
(0, common_1.Post)("webhook-receiver"),
|
|
37
|
+
(0, swagger_1.ApiOkResponse)(),
|
|
38
|
+
(0, swagger_1.ApiBadRequestResponse)()
|
|
39
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars, unicorn/prevent-abbreviations
|
|
40
|
+
,
|
|
41
|
+
__param(0, (0, common_1.Req)()),
|
|
42
|
+
__metadata("design:type", Function),
|
|
43
|
+
__metadata("design:paramtypes", [Object]),
|
|
44
|
+
__metadata("design:returntype", Promise)
|
|
45
|
+
], StripeWebhookController.prototype, "webhookReceiver", null);
|
|
46
|
+
StripeWebhookController = __decorate([
|
|
47
|
+
(0, common_1.Controller)("payments/stripe"),
|
|
48
|
+
(0, swagger_1.ApiTags)("payments"),
|
|
49
|
+
__metadata("design:paramtypes", [stripe_webhook_handler_service_1.StripeWebhookHandler])
|
|
50
|
+
], StripeWebhookController);
|
|
51
|
+
exports.StripeWebhookController = StripeWebhookController;
|
|
52
|
+
//# sourceMappingURL=stripe-webhook-controller.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"stripe-webhook-controller.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-webhook-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAAqE;AAErE,6CAA8E;AAE9E,8FAA+E;AAE/E;;;;GAIG;AAGI,IAAM,uBAAuB,GAA7B,MAAM,uBAAuB;IACH;IAA7B,YAA6B,oBAA0C;QAA1C,yBAAoB,GAApB,oBAAoB,CAAsB;IAAG,CAAC;IAE3E,4DAA4D;IAKtD,AADN,4FAA4F;IAC5F,KAAK,CAAC,eAAe,CAAQ,GAAmC;QAC5D,OAAO,IAAI,CAAC,oBAAoB,CAAC,aAAa,CAAC,GAAG,CAAC,CAAC;IACxD,CAAC;CACJ,CAAA;AAHS;IAJL,IAAA,aAAI,EAAC,kBAAkB,CAAC;IACxB,IAAA,uBAAa,GAAE;IACf,IAAA,+BAAqB,GAAE;IACxB,4FAA4F;;IACrE,WAAA,IAAA,YAAG,GAAE,CAAA;;;;8DAE3B;AAVQ,uBAAuB;IAFnC,IAAA,mBAAU,EAAC,iBAAiB,CAAC;IAC7B,IAAA,iBAAO,EAAC,UAAU,CAAC;qCAEmC,qDAAoB;GAD9D,uBAAuB,CAWnC;AAXY,0DAAuB"}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@darraghor/nest-backend-libs",
|
|
3
|
-
"version": "2.12.
|
|
4
|
-
"license": "
|
|
3
|
+
"version": "2.12.5",
|
|
4
|
+
"license": "SEE LICENSE IN LICENSE.md",
|
|
5
5
|
"description": "Some helpers for personal projects in nestjs",
|
|
6
6
|
"homepage": "https://github.com/darraghoriordan/nest-backend-libs",
|
|
7
7
|
"repository": {
|
|
@@ -103,7 +103,7 @@
|
|
|
103
103
|
"@typescript-eslint/eslint-plugin": "5.49.0",
|
|
104
104
|
"@typescript-eslint/parser": "5.49.0",
|
|
105
105
|
"copyfiles": "2.4.1",
|
|
106
|
-
"eslint": "8.
|
|
106
|
+
"eslint": "8.26.0",
|
|
107
107
|
"eslint-config-prettier": "8.6.0",
|
|
108
108
|
"eslint-plugin-eslint-comments": "3.2.0",
|
|
109
109
|
"eslint-plugin-jest": "27.2.1",
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import { RawBodyRequest } from "@nestjs/common";
|
|
2
|
-
import { RequestWithUser } from "../authz/RequestWithUser";
|
|
3
|
-
import { StripeCheckoutSessionRequestDto } from "./models/StripeCheckoutSessionRequestDto";
|
|
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
|
-
import { StripeCheckoutSessionResponseDto } from "./models/StripeCheckoutSessionResponseDto";
|
|
8
|
-
export declare class StripeClientController {
|
|
9
|
-
private readonly stripeService;
|
|
10
|
-
private readonly stripeWebhookService;
|
|
11
|
-
constructor(stripeService: StripeCheckoutService, stripeWebhookService: StripeWebhookHandler);
|
|
12
|
-
webhookReceiver(req: RawBodyRequest<ExpressRequest>): Promise<void>;
|
|
13
|
-
createCustomerPortalSession(request: RequestWithUser): Promise<string>;
|
|
14
|
-
createCheckoutSession(request: RequestWithUser, createSessionDto: StripeCheckoutSessionRequestDto): Promise<StripeCheckoutSessionResponseDto>;
|
|
15
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"stripe-controller.js","sourceRoot":"","sources":["../../src/stripe-client/stripe-controller.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,2CAQwB;AACxB,+CAA2C;AAC3C,6CAKyB;AAEzB,8FAAyF;AACzF,gFAAyE;AAEzE,8FAA+E;AAC/E,gGAA2F;AAIpF,IAAM,sBAAsB,GAA5B,MAAM,sBAAsB;IAEV;IACA;IAFrB,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;IAED,+BAA+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