Spaces:
Running
Running
Download apps/api/dist/billing/billing.controller.js from Benaah/MicProtocol: direct link, hf CLI and curl.
- Browser
- Download file 8.97 kB
-
https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/dist/billing/billing.controller.js
- Command line
-
hf download hf://spaces/Benaah/MicProtocol/apps/api/dist/billing/billing.controller.js
-
curl -L -o billing.controller.js https://huggingface.co/spaces/Benaah/MicProtocol/resolve/main/apps/api/dist/billing/billing.controller.js
8.97 kB
| ; | |
| var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { | |
| var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; | |
| if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); | |
| 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; | |
| return c > 3 && r && Object.defineProperty(target, key, r), r; | |
| }; | |
| var __metadata = (this && this.__metadata) || function (k, v) { | |
| if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); | |
| }; | |
| var __param = (this && this.__param) || function (paramIndex, decorator) { | |
| return function (target, key) { decorator(target, key, paramIndex); } | |
| }; | |
| Object.defineProperty(exports, "__esModule", { value: true }); | |
| exports.BillingController = void 0; | |
| const common_1 = require("@nestjs/common"); | |
| const swagger_1 = require("@nestjs/swagger"); | |
| const better_auth_guard_1 = require("../auth/better-auth.guard"); | |
| const billing_service_1 = require("./billing.service"); | |
| const stripe_webhook_guard_1 = require("./stripe-webhook.guard"); | |
| const mpesa_webhook_guard_1 = require("./mpesa-webhook.guard"); | |
| const payhero_webhook_guard_1 = require("./payhero-webhook.guard"); | |
| const paystack_webhook_guard_1 = require("./paystack-webhook.guard"); | |
| const billing_dto_1 = require("./billing.dto"); | |
| const raw_body_middleware_1 = require("../common/middleware/raw-body.middleware"); | |
| let BillingController = class BillingController { | |
| billingService; | |
| constructor(billingService) { | |
| this.billingService = billingService; | |
| } | |
| listPlans() { | |
| return this.billingService.listPlans(); | |
| } | |
| getWorkspaceSubscription(req, workspaceId) { | |
| const userId = req.userId || req.headers["x-user-id"]; | |
| return this.billingService.getWorkspaceSubscription(userId, workspaceId); | |
| } | |
| createStripeCheckout(req, body) { | |
| const userId = req.userId || req.headers["x-user-id"]; | |
| return this.billingService.createStripeCheckout(userId, body); | |
| } | |
| initiateMpesaCheckout(req, body) { | |
| const userId = req.userId || req.headers["x-user-id"]; | |
| return this.billingService.initiateMpesaCheckout(userId, body); | |
| } | |
| initiatePaystackCheckout(req, body) { | |
| const userId = req.userId || req.headers["x-user-id"]; | |
| return this.billingService.initiatePaystackCheckout(userId, { | |
| ...body, | |
| email: body.email || `${userId}@placeholder.local`, | |
| }); | |
| } | |
| verifyPaystackCheckout(req, body) { | |
| const userId = req.userId || req.headers["x-user-id"]; | |
| return this.billingService.verifyPaystackCheckout(userId, body.workspaceId, body.reference); | |
| } | |
| handleStripeWebhook(req) { | |
| const event = req.stripeEvent; | |
| return this.billingService.handleStripeWebhook(event); | |
| } | |
| handleMpesaWebhook(req) { | |
| return this.billingService.handleMpesaWebhook(req.body); | |
| } | |
| handlePayheroWebhook(req) { | |
| return this.billingService.handlePayheroWebhook(req.body, req.query); | |
| } | |
| handlePaystackWebhook(req) { | |
| return this.billingService.handlePaystackWebhook(req.body); | |
| } | |
| }; | |
| exports.BillingController = BillingController; | |
| __decorate([ | |
| (0, common_1.Get)("plans"), | |
| (0, swagger_1.ApiOperation)({ summary: "List all subscription plans" }), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", []), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "listPlans", null); | |
| __decorate([ | |
| (0, common_1.Get)("workspaces/:workspaceId/subscription"), | |
| (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard), | |
| (0, swagger_1.ApiBearerAuth)(), | |
| (0, swagger_1.ApiParam)({ name: "workspaceId" }), | |
| (0, swagger_1.ApiOperation)({ summary: "Get current workspace subscription" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Param)("workspaceId")), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, String]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "getWorkspaceSubscription", null); | |
| __decorate([ | |
| (0, common_1.Post)("checkout/stripe"), | |
| (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard), | |
| (0, swagger_1.ApiBearerAuth)(), | |
| (0, swagger_1.ApiOperation)({ summary: "Initialize Stripe checkout" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, billing_dto_1.CreateStripeCheckoutDto]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "createStripeCheckout", null); | |
| __decorate([ | |
| (0, common_1.Post)("checkout/mpesa"), | |
| (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard), | |
| (0, swagger_1.ApiBearerAuth)(), | |
| (0, swagger_1.ApiOperation)({ summary: "Initialize M-Pesa STK push checkout" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, billing_dto_1.InitiateMpesaCheckoutDto]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "initiateMpesaCheckout", null); | |
| __decorate([ | |
| (0, common_1.Post)("checkout/paystack"), | |
| (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard), | |
| (0, swagger_1.ApiBearerAuth)(), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "Initialize Paystack checkout (card, M-Pesa, Airtel Money)", | |
| }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, Object]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "initiatePaystackCheckout", null); | |
| __decorate([ | |
| (0, common_1.Post)("checkout/paystack/verify"), | |
| (0, common_1.UseGuards)(better_auth_guard_1.BetterAuthGuard), | |
| (0, swagger_1.ApiBearerAuth)(), | |
| (0, swagger_1.ApiOperation)({ summary: "Manually verify a Paystack transaction reference" }), | |
| __param(0, (0, common_1.Req)()), | |
| __param(1, (0, common_1.Body)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object, Object]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "verifyPaystackCheckout", null); | |
| __decorate([ | |
| (0, common_1.Post)("webhooks/stripe"), | |
| (0, common_1.UseInterceptors)(raw_body_middleware_1.RawBodyMiddleware), | |
| (0, common_1.UseGuards)(stripe_webhook_guard_1.StripeWebhookGuard), | |
| (0, swagger_1.ApiOperation)({ summary: "Stripe webhook callback - signature verified" }), | |
| __param(0, (0, common_1.Req)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "handleStripeWebhook", null); | |
| __decorate([ | |
| (0, common_1.Post)("webhooks/mpesa"), | |
| (0, common_1.UseInterceptors)(raw_body_middleware_1.RawBodyMiddleware), | |
| (0, common_1.UseGuards)(mpesa_webhook_guard_1.MpesaWebhookGuard), | |
| (0, swagger_1.ApiOperation)({ summary: "M-Pesa callback - signature verified in production" }), | |
| __param(0, (0, common_1.Req)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "handleMpesaWebhook", null); | |
| __decorate([ | |
| (0, common_1.Post)("webhooks/payhero"), | |
| (0, common_1.UseInterceptors)(raw_body_middleware_1.RawBodyMiddleware), | |
| (0, common_1.UseGuards)(payhero_webhook_guard_1.PayheroWebhookGuard), | |
| (0, swagger_1.ApiOperation)({ summary: "PayHero webhook callback - query signature verified" }), | |
| __param(0, (0, common_1.Req)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "handlePayheroWebhook", null); | |
| __decorate([ | |
| (0, common_1.Post)("webhooks/paystack"), | |
| (0, common_1.UseInterceptors)(raw_body_middleware_1.RawBodyMiddleware), | |
| (0, common_1.UseGuards)(paystack_webhook_guard_1.PaystackWebhookGuard), | |
| (0, swagger_1.ApiOperation)({ | |
| summary: "Paystack webhook callback - HMAC-SHA512 signature verified", | |
| }), | |
| __param(0, (0, common_1.Req)()), | |
| __metadata("design:type", Function), | |
| __metadata("design:paramtypes", [Object]), | |
| __metadata("design:returntype", void 0) | |
| ], BillingController.prototype, "handlePaystackWebhook", null); | |
| exports.BillingController = BillingController = __decorate([ | |
| (0, swagger_1.ApiTags)("Billing"), | |
| (0, common_1.Controller)("billing"), | |
| __metadata("design:paramtypes", [billing_service_1.BillingService]) | |
| ], BillingController); | |
| //# sourceMappingURL=billing.controller.js.map |