From 2bb71ef5a104856f543a52ece56f4eda6e860cb7 Mon Sep 17 00:00:00 2001 From: jos3duardo Date: Sun, 10 Aug 2025 21:06:27 -0400 Subject: [PATCH] Update payment status and increment attempts on processing error --- src/modules/payments/services/process-payment.service.ts | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/modules/payments/services/process-payment.service.ts b/src/modules/payments/services/process-payment.service.ts index b382533..478218b 100644 --- a/src/modules/payments/services/process-payment.service.ts +++ b/src/modules/payments/services/process-payment.service.ts @@ -49,8 +49,15 @@ export class ProcessPaymentService { `Error processing payment ${paymentId}:`, error.message, ); + + const status = + payment.attempts >= 2 + ? PaymentStatusEnum.FAILED + : PaymentStatusEnum.RETRY; + await this.repository.update(payment.id, { - status: PaymentStatusEnum.RETRY, + status, + attempts: +payment.attempts + 1, }); } }