diff --git a/src/events/events.service.ts b/src/events/events.service.ts index 3b2ee07..d64ceac 100644 --- a/src/events/events.service.ts +++ b/src/events/events.service.ts @@ -48,7 +48,7 @@ export class EventService { } catch (error) { this.logger.error(`{startPaymentProcess} Fatal error: ${error}`); if (await this.openOrdersService.existsByOrderId(order.id)) { - this.openOrdersService.delete(order.id); + this.openOrdersService.delete({ orderId: order.id }); } this.publishPaymentFailedEvent(order); } @@ -130,7 +130,7 @@ export class EventService { // get the order Context for the payment const openOrder = await this.getOpenOrder(paymentId); // delete the open order - this.openOrdersService.delete(paymentId); + this.openOrdersService.delete({ paymentId }); return this.publishPaymentProcessedEvent(openOrder.order); } diff --git a/src/open-orders/open-orders.service.ts b/src/open-orders/open-orders.service.ts index 3226063..916d0dd 100644 --- a/src/open-orders/open-orders.service.ts +++ b/src/open-orders/open-orders.service.ts @@ -64,16 +64,14 @@ export class OpenOrdersService { * @returns A Promise that resolves to the deleted open order. * @throws NotFoundException if the open order is not found. */ - async delete(paymentId: string): Promise { - this.logger.log(`{delete} Deleting open order for payment: ${paymentId}`); + async delete(query: { paymentId: string } | { orderId: string }): Promise { + this.logger.log(`{delete} Deleting open order for: ${JSON.stringify(query)}`); - const deletedOrder = await this.openOrderModel.findOneAndDelete({ - paymentId, - }); + const deletedOrder = await this.openOrderModel.findOneAndDelete({ query }); if (!deletedOrder) { throw new NotFoundException( - `Open order for payment: ${paymentId} not found`, + `Open order for ${JSON.stringify(query)} not found`, ); }