Stripe Pricing + Subscriptions

This commit is contained in:
2024-08-21 21:13:43 +02:00
parent 48bff89526
commit b4609d07ba
16 changed files with 969 additions and 1035 deletions

View File

@@ -1,4 +1,4 @@
import { Body, Controller, HttpException, HttpStatus, Post, Req, Res } from '@nestjs/common';
import { Body, Controller, Get, HttpException, HttpStatus, Param, Post, Req, Res } from '@nestjs/common';
import { Request, Response } from 'express';
import { Checkout } from 'src/models/main.model.js';
import Stripe from 'stripe';
@@ -13,8 +13,8 @@ export class PaymentController {
// return this.paymentService.createSubscription(subscriptionData);
// }
@Post('create-checkout-session')
async calculateTax(@Body() checkout: Checkout) {
return this.paymentService.checkout(checkout);
async createCheckoutSession(@Body() checkout: Checkout) {
return this.paymentService.createCheckoutSession(checkout);
}
@Post('webhook')
async handleWebhook(@Req() req: Request, @Res() res: Response): Promise<void> {
@@ -33,4 +33,8 @@ export class PaymentController {
throw new HttpException('Webhook Error', HttpStatus.BAD_REQUEST);
}
}
@Get('subscriptions/:email')
async findSubscriptionsById(@Param('email') email: string): Promise<any> {
return await this.paymentService.getSubscription(email);
}
}