-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpayment.controller.js
More file actions
35 lines (30 loc) · 1.06 KB
/
payment.controller.js
File metadata and controls
35 lines (30 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import { parseWithBigInt, stringifyWithBigInt } from "../../bigintJson.js";
import { StatusCodes } from "http-status-codes";
import { CreatePaymentDto } from "../dto/payment.dto.js";
import { PaymentService } from "../service/payment.service.js";
export const paymentConfirm = async (req, res, next) => {
try {
const userId = req.user.userId;
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);
}
}
export const getPayments = async (req, res, next) => {
try {
const userId = req.user.userId;
const payments = await PaymentService.getPayments(userId);
const responseData = parseWithBigInt(stringifyWithBigInt(payments));
res.status(StatusCodes.OK).success(responseData);
} catch(err) {
next(err);
}
}