diff --git a/src/common/swagger/payment.json b/src/common/swagger/payment.json index 864e480..a133476 100644 --- a/src/common/swagger/payment.json +++ b/src/common/swagger/payment.json @@ -4,6 +4,11 @@ "post": { "summary": "결제 완료 처리", "description": "아임포트 imp_uid로 결제 검증 후 DB에 결제 내역, 포인트 거래 내역, 최종 포인트를 저장합니다.", + "security": [ + { + "bearerAuth": [] + } + ], "tags": ["Payment"], "requestBody": { "required": true, @@ -66,6 +71,25 @@ } } }, + "401": { + "description": "JWT 인증 실패 (Unauthorized)", + "content": { + "application/json": { + "schema": { + "$ref": "#/components/schemas/ErrorResponse" + }, + "example": { + "resultType": "FAIL", + "error": { + "errorCode": "AUTH001", + "reason": "유효하지 않은 토큰입니다.", + "data": null + }, + "success": null + } + } + } + }, "500": { "description": "서버 오류", "content": { diff --git a/src/payment/controller/payment.controller.js b/src/payment/controller/payment.controller.js index f0a8afc..15ef90a 100644 --- a/src/payment/controller/payment.controller.js +++ b/src/payment/controller/payment.controller.js @@ -5,19 +5,21 @@ import { PaymentService } from "../service/payment.service.js"; export const paymentConfirm = async (req, res, next) => { try { - const dto = new CreatePaymentDto({ - impUid: req.body.impUid, - merchantUid: req.body.merchantUid, - productId: req.body.productId, - userId: req.body.userId, - }); + const userId = req.user.id; + + const dto = new CreatePaymentDto({ + impUid: req.body.impUid, + merchantUid: req.body.merchantUid, + productId: req.body.productId, + userId: userId, + }); - const payment = await PaymentService.createPayment(dto); - const responseData = parseWithBigInt(stringifyWithBigInt(payment)); - res.status(StatusCodes.CREATED).success(responseData); - } catch (err) { - next(err); - } + const payment = await PaymentService.createPayment(dto); + const responseData = parseWithBigInt(stringifyWithBigInt(payment)); + res.status(StatusCodes.CREATED).success(responseData); + } catch (err) { + next(err); + } } export const getPayments = async (req, res, next) => { diff --git a/src/payment/payment.routes.js b/src/payment/payment.routes.js index 42901e9..4073d6f 100644 --- a/src/payment/payment.routes.js +++ b/src/payment/payment.routes.js @@ -6,7 +6,7 @@ import { authenticate } from "../middlewares/auth.middleware.js"; const router = express.Router(); // 결제 정보 저장 API -router.post("/complete", paymentConfirm); +router.post("/complete", authenticate, paymentConfirm); // 결제 정보 조회 API router.get("", authenticate, getPayments);