From 0b10de5b5f8d4550deccba2cde42f7f222860f84 Mon Sep 17 00:00:00 2001 From: Marcin Gordel Date: Wed, 4 Oct 2023 12:46:24 +0200 Subject: [PATCH] fix(payment): fixed waiting for the invoices --- src/payment/service.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/payment/service.ts b/src/payment/service.ts index 331d64596..458e19bba 100644 --- a/src/payment/service.ts +++ b/src/payment/service.ts @@ -127,10 +127,13 @@ export class PaymentService { `Invoice has been rejected for provider ${agreement.provider.name}. Reason: ${reason.message}`, ); } - this.agreementsDebitNotes.delete(invoice.agreementId); - this.agreementsToPay.delete(invoice.agreementId); } catch (error) { this.logger?.error(`Invoice failed from provider ${invoice.providerId}. ${error}`); + } finally { + // Until we implement a re-acceptance mechanism for unsuccessful acceptances, + // we no longer have to wait for the invoice during an unsuccessful attempt. + this.agreementsDebitNotes.delete(invoice.agreementId); + this.agreementsToPay.delete(invoice.agreementId); } }