Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions src/common/swagger/payment.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,11 @@
"post": {
"summary": "결제 완료 처리",
"description": "아임포트 imp_uid로 결제 검증 후 DB에 결제 내역, 포인트 거래 내역, 최종 포인트를 저장합니다.",
"security": [
{
"bearerAuth": []
}
],
"tags": ["Payment"],
"requestBody": {
"required": true,
Expand Down Expand Up @@ -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": {
Expand Down
26 changes: 14 additions & 12 deletions src/payment/controller/payment.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) => {
Expand Down
2 changes: 1 addition & 1 deletion src/payment/payment.routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down