Skip to content

Commit 514cc24

Browse files
committed
[FEAT] 결제 정보 저장 API JWT 인증 적용
1 parent 279dfc9 commit 514cc24

2 files changed

Lines changed: 15 additions & 13 deletions

File tree

src/payment/controller/payment.controller.js

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -5,19 +5,21 @@ import { PaymentService } from "../service/payment.service.js";
55

66
export const paymentConfirm = async (req, res, next) => {
77
try {
8-
const dto = new CreatePaymentDto({
9-
impUid: req.body.impUid,
10-
merchantUid: req.body.merchantUid,
11-
productId: req.body.productId,
12-
userId: req.body.userId,
13-
});
8+
const userId = req.user.id;
9+
10+
const dto = new CreatePaymentDto({
11+
impUid: req.body.impUid,
12+
merchantUid: req.body.merchantUid,
13+
productId: req.body.productId,
14+
userId: userId,
15+
});
1416

15-
const payment = await PaymentService.createPayment(dto);
16-
const responseData = parseWithBigInt(stringifyWithBigInt(payment));
17-
res.status(StatusCodes.CREATED).success(responseData);
18-
} catch (err) {
19-
next(err);
20-
}
17+
const payment = await PaymentService.createPayment(dto);
18+
const responseData = parseWithBigInt(stringifyWithBigInt(payment));
19+
res.status(StatusCodes.CREATED).success(responseData);
20+
} catch (err) {
21+
next(err);
22+
}
2123
}
2224

2325
export const getPayments = async (req, res, next) => {

src/payment/payment.routes.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import { authenticate } from "../middlewares/auth.middleware.js";
66
const router = express.Router();
77

88
// 결제 정보 저장 API
9-
router.post("/complete", paymentConfirm);
9+
router.post("/complete", authenticate, paymentConfirm);
1010

1111
// 결제 정보 조회 API
1212
router.get("", authenticate, getPayments);

0 commit comments

Comments
 (0)