update : add log
This commit is contained in:
@@ -21,10 +21,8 @@ class PaymentGateway implements IPaymentGateway {
|
|||||||
case GatewayProvider.Asanpardakht:
|
case GatewayProvider.Asanpardakht:
|
||||||
//TODO:fix this
|
//TODO:fix this
|
||||||
return this.asanpardakhtGateway.token();
|
return this.asanpardakhtGateway.token();
|
||||||
case GatewayProvider.SEP: {
|
case GatewayProvider.SEP:
|
||||||
console.log("SEP", data.amount, data.description, data.email, data.mobile, data.callbackPath);
|
|
||||||
return await this.sepGateway.processPayment(data.amount, data.description, data.email, data.mobile, data.callbackPath);
|
return await this.sepGateway.processPayment(data.amount, data.description, data.email, data.mobile, data.callbackPath);
|
||||||
}
|
|
||||||
default:
|
default:
|
||||||
throw new BadRequestError(`Payment provider ${gatewayType} is not supported`);
|
throw new BadRequestError(`Payment provider ${gatewayType} is not supported`);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -56,7 +56,8 @@ class OrderService {
|
|||||||
|
|
||||||
const city = userAddress.city as unknown as ICity;
|
const city = userAddress.city as unknown as ICity;
|
||||||
const province = userAddress.province as unknown as IProvince;
|
const province = userAddress.province as unknown as IProvince;
|
||||||
|
console.log("city", city);
|
||||||
|
console.log("province", province);
|
||||||
const shipmentAddress: IShipmentAddress = {
|
const shipmentAddress: IShipmentAddress = {
|
||||||
address: userAddress.address,
|
address: userAddress.address,
|
||||||
city: city.name,
|
city: city.name,
|
||||||
|
|||||||
@@ -136,15 +136,19 @@ class PaymentService {
|
|||||||
if (!paymentMethod) throw new BadRequestError(PaymentMessage.PaymentMethodNotFound);
|
if (!paymentMethod) throw new BadRequestError(PaymentMessage.PaymentMethodNotFound);
|
||||||
|
|
||||||
const { price, description } = this.calculateTotalPrice(cart, cartShipmentItems);
|
const { price, description } = this.calculateTotalPrice(cart, cartShipmentItems);
|
||||||
|
console.log("start handle payment");
|
||||||
// extracted to handle payment creation
|
// extracted to handle payment creation
|
||||||
const { payment, paymentData } = await this.handlePaymentCreation(paymentMethod, price, user, description, session);
|
const { payment, paymentData } = await this.handlePaymentCreation(paymentMethod, price, user, description, session);
|
||||||
|
console.log("handle payment done");
|
||||||
|
|
||||||
|
console.log("start create order");
|
||||||
// create order and order items
|
// create order and order items
|
||||||
const { order, orderItems } = await this.orderService.createOrder(user, payment, cartShipmentItems, session);
|
const { order, orderItems } = await this.orderService.createOrder(user, payment, cartShipmentItems, session);
|
||||||
|
console.log("create order done");
|
||||||
// clear cart and adjust stock
|
// clear cart and adjust stock
|
||||||
|
console.log("start finalize order");
|
||||||
await this.finalizeOrder(user, cartShipmentItems, session);
|
await this.finalizeOrder(user, cartShipmentItems, session);
|
||||||
|
console.log("Done");
|
||||||
|
|
||||||
await session.commitTransaction();
|
await session.commitTransaction();
|
||||||
await session.endSession();
|
await session.endSession();
|
||||||
|
|||||||
Reference in New Issue
Block a user