set payment method

This commit is contained in:
2025-11-23 10:03:44 +03:30
parent cc6614fe97
commit 4ea7c8d068
5 changed files with 95 additions and 2 deletions
@@ -4,6 +4,7 @@ import { AddItemToCartDto } from '../dto/add-item.dto';
import { UpdateItemQuantityDto } from '../dto/update-item.dto';
import { ApplyCouponDto } from '../dto/apply-coupon.dto';
import { SetAddressDto } from '../dto/set-address.dto';
import { SetPaymentMethodDto } from '../dto/set-payment-method.dto';
import { ApiTags, ApiOperation, ApiResponse, ApiBearerAuth, ApiBody, ApiParam } from '@nestjs/swagger';
import { AuthGuard } from '../../auth/guards/auth.guard';
import { UserId } from 'src/common/decorators/user-id.decorator';
@@ -84,4 +85,18 @@ export class CartController {
async setAddress(@UserId() userId: string, @RestId() restaurantId: string, @Body() setAddressDto: SetAddressDto) {
return this.cartService.setAddress(userId, restaurantId, setAddressDto);
}
@Patch('payment-method')
@ApiOperation({ summary: 'Set payment method for cart' })
@ApiBody({ type: SetPaymentMethodDto })
@ApiResponse({ status: 200, description: 'Payment method set successfully' })
@ApiResponse({ status: 400, description: 'Bad request (e.g., payment method is not active)' })
@ApiResponse({ status: 404, description: 'Payment method not found for restaurant' })
async setPaymentMethod(
@UserId() userId: string,
@RestId() restaurantId: string,
@Body() setPaymentMethodDto: SetPaymentMethodDto,
) {
return this.cartService.setPaymentMethod(userId, restaurantId, setPaymentMethodDto);
}
}