From 3911049e9445cdff001a4da68b3503e492c9c587 Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Tue, 26 Nov 2024 16:29:15 +0100 Subject: [PATCH 01/12] [PAGOPA-2389] feat: Add new PAYING status --- .../controller/ReceiptTimerController.java | 31 ++++++++++++++-- .../exception/AppErrorCodeMessageEnum.java | 5 ++- .../model/enumz/ReceiptStatusEnum.java | 1 + .../service/RPTExtractorService.java | 20 ++++------- .../wispconverter/service/ReceiptService.java | 17 ++------- .../service/ReceiptTimerService.java | 35 +++++++++++++++---- 6 files changed, 72 insertions(+), 37 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index bdea20c1..628e5a98 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -8,8 +8,13 @@ import io.swagger.v3.oas.annotations.security.SecurityRequirement; import io.swagger.v3.oas.annotations.tags.Tag; import it.gov.pagopa.wispconverter.controller.model.ReceiptTimerRequest; +import it.gov.pagopa.wispconverter.exception.AppErrorCodeMessageEnum; +import it.gov.pagopa.wispconverter.exception.AppException; +import it.gov.pagopa.wispconverter.repository.model.enumz.ReceiptStatusEnum; import it.gov.pagopa.wispconverter.repository.model.enumz.WorkflowStatus; -import it.gov.pagopa.wispconverter.service.ReceiptTimerService; +import it.gov.pagopa.wispconverter.service.*; +import it.gov.pagopa.wispconverter.service.model.ReceiptDto; +import it.gov.pagopa.wispconverter.service.model.session.SessionDataDTO; import it.gov.pagopa.wispconverter.util.EndpointRETrace; import it.gov.pagopa.wispconverter.util.ErrorUtil; import lombok.RequiredArgsConstructor; @@ -34,6 +39,10 @@ public class ReceiptTimerController { private final ReceiptTimerService receiptTimerService; + private final RtReceiptCosmosService rtReceiptCosmosService; + + private final RPTExtractorService rptExtractorService; + private final ErrorUtil errorUtil; @Value("${wisp-converter.receipttimer-delta-activate.expirationtime.ms}") @@ -67,6 +76,24 @@ public void createTimer(@RequestBody ReceiptTimerRequest request) { @EndpointRETrace(status = WorkflowStatus.PAYMENT_TOKEN_TIMER_DELETION_PROCESSED, businessProcess = BP_TIMER_DELETE, reEnabled = true) public void deleteTimer(@RequestParam() String paymentTokens) { List tokens = Arrays.asList(paymentTokens.split(",")); - receiptTimerService.cancelScheduledMessage(tokens); + try { + // set receipts-rt status to PAYING stands for waiting SendPaymentOutcome and then paSendRTV2 (after the latter, the state will change to SENDING -> SENT) + // Get sessionData for the first ReceiptDTO because by design session-id is equal for all paymentTokens in input + ReceiptDto receiptDto = receiptTimerService.peek(tokens.get(0)); + if(receiptDto != null) { + String sessionId = receiptDto.getSessionId(); + SessionDataDTO sessionDataDTO = rptExtractorService.getSessionDataFromSessionId(sessionId); + // Update receipts-rt status to PAYING + sessionDataDTO.getAllPaymentNotices().forEach(paymentNotice -> + rtReceiptCosmosService.updateReceiptStatus(paymentNotice.getFiscalCode(), paymentNotice.getIuv(), paymentNotice.getCcp(), ReceiptStatusEnum.PAYING)); + } + // cancel scheduled message + receiptTimerService.cancelScheduledMessage(tokens); + } catch (Exception e) { + throw new AppException(AppErrorCodeMessageEnum.DELETE_PAYMENT_TOKEN_TIMER_FAILURE, e); + } finally { + // do or retry to cancel scheduled message + receiptTimerService.cancelScheduledMessage(tokens); + } } } diff --git a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java index c149ad27..bb741d6b 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java @@ -64,7 +64,10 @@ public enum AppErrorCodeMessageEnum { CLIENT_CHECKOUT(3004, "Checkout error", "Error while communicating with Checkout service. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with Checkout backend internal service in order to send a request about the cart creation. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), CLIENT_PAAINVIART(3005, "PaaInviaRT error", "Error while communicating with Station for paaInviaRT service. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with the creditor institution's station (external service) in order to sending of a paaInviaRT request. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), CLIENT_CARTSESSION_CACHING(3006, "Cart caching client error", "Error while communicating with cart caching API. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with an internal service endpoint dedicated to storing internal cache for handle unique session on cart. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), - UNKNOWN(0, "Unknown", "Unknown error", HttpStatus.INTERNAL_SERVER_ERROR, null); + UNKNOWN(0, "Unknown", "Unknown error", HttpStatus.INTERNAL_SERVER_ERROR, null), + // -- TIMER + DELETE_PAYMENT_TOKEN_TIMER_FAILURE(4001, "Impossible delete payment token timer", "Error while trying to delete payment token timer. Impossible finish operation for payment tokens: {0}.", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred wile trying to delete timer on payment tokens (timer for ClosePayment detection). This error may cause side effects such as sending ko receipt due to timer timeout."); + private final Integer code; private final String title; diff --git a/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java b/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java index 95f43766..5bb103bb 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java @@ -2,6 +2,7 @@ public enum ReceiptStatusEnum { REDIRECT, + PAYING, // the execution flow between ClosePayment sending and paSendRTV2 SENDING, SCHEDULED, SENT, diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java b/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java index d8b3cd16..73dd4fcc 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/RPTExtractorService.java @@ -8,6 +8,7 @@ import it.gov.digitpa.schemas._2011.pagamenti.CtRichiestaPagamentoTelematico; import it.gov.pagopa.wispconverter.exception.AppErrorCodeMessageEnum; import it.gov.pagopa.wispconverter.exception.AppException; +import it.gov.pagopa.wispconverter.repository.model.RPTRequestEntity; import it.gov.pagopa.wispconverter.service.mapper.RPTMapper; import it.gov.pagopa.wispconverter.service.model.PaymentRequestDomainDTO; import it.gov.pagopa.wispconverter.service.model.paymentrequest.PaymentRequestDTO; @@ -35,7 +36,7 @@ public class RPTExtractorService { private final ConfigCacheService cacheService; - private final ReService reService; + private final RptCosmosService rptCosmosService; private final JaxbElementUtil jaxbElementUtil; @@ -292,18 +293,11 @@ private PaymentRequestDTO extractRPT(byte[] rptBytes) { return paymentRequest; } - /* - public void sendEventForExtractedRPTs(Collection rpts) { + public SessionDataDTO getSessionDataFromSessionId(String sessionId) { + // try to retrieve the RPT previously persisted in storage from the sessionId + RPTRequestEntity rptRequestEntity = rptCosmosService.getRPTRequestEntity(sessionId); - // creating event to be persisted for RE - if (Boolean.TRUE.equals(isTracingOnREEnabled)) { - for (RPTContentDTO rpt : rpts) { - MDC.put(Constants.MDC_DOMAIN_ID, rpt.getRpt().getDomain().getDomainId()); - MDC.put(Constants.MDC_IUV, rpt.getIuv()); - MDC.put(Constants.MDC_CCP, rpt.getCcp()); - reService.sendEvent(WorkflowStatus.RPT_EXTRACTED); - } - } + // use the retrieved RPT for generate session data information on which the next execution will operate + return this.extractSessionData(rptRequestEntity.getPrimitive(), rptRequestEntity.getPayload()); } - */ } diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptService.java b/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptService.java index 2f606597..1d541f90 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptService.java @@ -16,7 +16,6 @@ import it.gov.pagopa.wispconverter.exception.AppErrorCodeMessageEnum; import it.gov.pagopa.wispconverter.exception.AppException; import it.gov.pagopa.wispconverter.repository.ReceiptDeadLetterRepository; -import it.gov.pagopa.wispconverter.repository.model.RPTRequestEntity; import it.gov.pagopa.wispconverter.repository.model.RTRequestEntity; import it.gov.pagopa.wispconverter.repository.model.ReceiptDeadLetterEntity; import it.gov.pagopa.wispconverter.repository.model.enumz.*; @@ -68,8 +67,6 @@ public class ReceiptService { private final ConfigCacheService configCacheService; - private final RptCosmosService rptCosmosService; - private final RtReceiptCosmosService rtReceiptCosmosService; private final RtRetryComosService rtRetryComosService; @@ -202,7 +199,7 @@ private void handleSingleReceiptForKOPaaInviaRt(ReceiptDto receipt, SessionIdDto String iuv = retrieveIuvFromCache(receipt, noticeNumber); // use the session-id for generate session data information on which the next execution will operate - SessionDataDTO sessionData = getSessionDataFromSessionId(receipt.getSessionId()); + SessionDataDTO sessionData = rptExtractorService.getSessionDataFromSessionId(receipt.getSessionId()); CommonFieldsDTO commonFields = sessionData.getCommonFields(); /* @@ -291,7 +288,7 @@ public void sendOkPaaInviaRtToCreditorInstitution(String payload) { CachedKeysMapping cachedMapping = decouplerService.getCachedMappingFromNavToIuv(paSendRTV2Request.getIdPA(), noticeNumber); // use session-id for generate session data information on which the next execution will operate - SessionDataDTO sessionData = getSessionDataFromSessionId(paymentNote); + SessionDataDTO sessionData = rptExtractorService.getSessionDataFromSessionId(paymentNote); CommonFieldsDTO commonFields = sessionData.getCommonFields(); // retrieve station from cache and extract receipt from request @@ -392,14 +389,6 @@ public ReceiptContentDTO generateOkRtFromSessionData( .build(); } - public SessionDataDTO getSessionDataFromSessionId(String sessionId) { - // try to retrieve the RPT previously persisted in storage from the sessionId - RPTRequestEntity rptRequestEntity = rptCosmosService.getRPTRequestEntity(sessionId); - - // use the retrieved RPT for generate session data information on which the next execution will operate - return this.rptExtractorService.extractSessionData(rptRequestEntity.getPrimitive(), rptRequestEntity.getPayload()); - } - private void sendReceiptToCreditorInstitution( SessionDataDTO sessionData, RPTContentDTO rpt, @@ -755,7 +744,7 @@ public void sendRTKoFromSessionId(String sessionId) { sessionIdDto.setSessionId(sessionId); this.deleteHangTimerCacheKey(sessionIdDto); - SessionDataDTO sessionDataDTO = getSessionDataFromSessionId(sessionId); + SessionDataDTO sessionDataDTO = rptExtractorService.getSessionDataFromSessionId(sessionId); gov.telematici.pagamenti.ws.papernodo.ObjectFactory objectFactory = new gov.telematici.pagamenti.ws.papernodo.ObjectFactory(); // retrieve configuration data from cache diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptTimerService.java b/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptTimerService.java index 677c322b..e8cb4499 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptTimerService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/ReceiptTimerService.java @@ -1,8 +1,7 @@ package it.gov.pagopa.wispconverter.service; -import com.azure.messaging.servicebus.ServiceBusClientBuilder; -import com.azure.messaging.servicebus.ServiceBusMessage; -import com.azure.messaging.servicebus.ServiceBusSenderClient; +import com.azure.messaging.servicebus.*; +import com.fasterxml.jackson.databind.ObjectMapper; import com.google.gson.Gson; import it.gov.pagopa.wispconverter.controller.model.ReceiptTimerRequest; import it.gov.pagopa.wispconverter.repository.CacheRepository; @@ -18,6 +17,7 @@ import org.springframework.stereotype.Service; import javax.annotation.PostConstruct; +import java.io.IOException; import java.nio.charset.StandardCharsets; import java.time.OffsetDateTime; import java.time.temporal.ChronoUnit; @@ -30,6 +30,7 @@ public class ReceiptTimerService { public static final String CACHING_KEY_TEMPLATE = "wisp_timer_%s"; public static final String PAYMENT_TOKEN_CACHING_KEY_TEMPLATE = "2_wisp_%s"; + private final ObjectMapper mapper = new ObjectMapper(); private final CacheRepository cacheRepository; private final ReService reService; @Value("${azure.sb.wisp-payment-timeout-queue.connectionString}") @@ -39,17 +40,22 @@ public class ReceiptTimerService { @Value("${disable-service-bus-sender}") private boolean disableServiceBusSender; private ServiceBusSenderClient serviceBusSenderClient; + private ServiceBusReceiverClient serviceBusReceiverClient; @Autowired private ECommerceHangTimerService eCommerceHangTimerService; @PostConstruct public void post() { - serviceBusSenderClient = - new ServiceBusClientBuilder() - .connectionString(connectionString) + ServiceBusClientBuilder builder = new ServiceBusClientBuilder(); + serviceBusSenderClient = builder.connectionString(connectionString) .sender() .queueName(queueName) .buildClient(); + + serviceBusReceiverClient = builder.connectionString(connectionString) + .receiver() + .queueName(queueName) + .buildClient(); } public void sendMessage(ReceiptTimerRequest message) { @@ -102,6 +108,21 @@ public void sendMessage(ReceiptTimerRequest message) { } } + public ReceiptDto peek(String paymentToken) { + // read sequence number from redis cache + String sequenceNumberKey = String.format(CACHING_KEY_TEMPLATE, paymentToken); + String sequenceNumberString = cacheRepository.read(sequenceNumberKey, String.class); + // read message without changing the service bus state + ServiceBusReceivedMessage message = serviceBusReceiverClient.peekMessage(Long.parseLong(sequenceNumberString)); + log.debug("Get message. Session: {}, Sequence #: {}. Contents: {}", message.getMessageId(), message.getSequenceNumber(), message.getBody()); + try { + return mapper.readValue(message.getBody().toStream(), ReceiptDto.class); + } catch (Exception e) { + log.error("Error when read ReceiptDto value from message: '{}'. Body: '{}'", message.getMessageId(), message.getBody()); + return null; + } + } + public void cancelScheduledMessage(List paymentTokens) { if (!disableServiceBusSender) { paymentTokens.forEach(this::cancelScheduledMessage); @@ -130,7 +151,7 @@ public void callCancelScheduledMessage(String sequenceNumberString) { try { serviceBusSenderClient.cancelScheduledMessage(sequenceNumber); } catch (Exception exception) { - log.debug(String.format("Scheduled message with sequence number [%s] not deleted. Cause: %s", sequenceNumberString, exception.getMessage())); + log.debug("Scheduled message with sequence number [{}] not deleted. Cause: {}", sequenceNumberString, exception.getMessage()); } } From c481e1ef7cf5018ded50db088ee01318ca073b2e Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Tue, 26 Nov 2024 16:41:32 +0000 Subject: [PATCH 02/12] Bump to version 1.0.2-1-PAGOPA-2389 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- openapi/openapi_redirect.json | 2 +- pom.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 01c67fef..19bf7bae 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-wisp-converter description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system type: application -version: 0.288.0 -appVersion: 1.0.2 +version: 0.289.0 +appVersion: 1.0.2-1-PAGOPA-2389 dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index 4f6cde36..d3b664ee 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: µservice-chart fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "1.0.2" + tag: "1.0.2-1-PAGOPA-2389" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 17ce211e..70b80fb2 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: µservice-chart fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "1.0.2" + tag: "1.0.2-1-PAGOPA-2389" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 4c8c55e5..072248c0 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: µservice-chart fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "1.0.2" + tag: "1.0.2-1-PAGOPA-2389" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 4cf87c68..1d07772a 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.\n\n# OPERATIVE INFO\n\n\n## EVENT MAPPING IN RE\n\n
Details\nFIELD | SCOPE | DESCRIPTION\n- | - | -\n**requestId** | BOTH | The identifier, set by X-Request-ID, from which the events can be grouped.\n**operationId** | BOTH | The identifier associated to a request identifier\n**clientOperationId** | BOTH | The identifier that associate a client to an operation identifier.\n**component** | BOTH | The applicative component from which the event is generated.
In NDP it is mapped with field 'componente'.
Values:
_WISP_SOAP_CONVERTER_
_WISP_CONVERTER_\n**insertedTimestamp** | BOTH | The time on which the event is inserted in RE storage\n**eventCategory** | BOTH | The category on which the event can be grouped.
In NDP it is mapped with field 'categoriaEvento'.
Values:
_INTERFACE_
_INTERNAL_\n**eventSubcategory** | BOTH | The subcategory related to the specific nature of the event.
In NDP it is mapped with field 'sottoTipoEvento'.
Values:
_REQ_
_RESP_
_INTERN_\n**callType** | INTERFACE | The type of role that the application has in the communication with the remote endpoint.
Values:
_SERVER_
_CLIENT_\n**outcome** | INTERFACE | The outcome of the operation described by the event.
In NDP it is mapped with field 'esito'.
Values:
_SEND_: Correctly sent request to HTTP endpoint. In NDP it is mapped with value 'INVIATA'.
_SEND_FAILURE_: Failed to send request to HTTP endpoint. In NDP it is mapped with value 'INVIATA_KO'
_RECEIVED_: Received an OK response from HTTP endpoint. In NDP it is mapped with value 'RICEVUTA_KO'
_RECEIVED_FAILURE_: Received a failure response from endpoint. In NDP it is mapped with value 'RICEVUTA_KO'
_NEVER_RECEIVED_: Failed to receive response at all from endpoint. In NDP it is mapped with value 'NO_RICEVUTA'
_EXECUTED_INTERNAL_STEP_: Executed internal step on execution. In NDP it is mapped with value 'CAMBIO_STATO'\n**httpMethod** | INTERFACE | The HTTP method of the endpoint related to the event.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpUri** | INTERFACE | The URI related to the called endpoint.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpHeaders** | INTERFACE | The list of HTTP headers extracted from the request/response analyzed by the event.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpCallRemoteAddress** | INTERFACE | The remote IP address extracted from the called endpoint.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpStatusCode** | INTERFACE | The status code extracted from the called endpoint.
This field is set only if the events that describe an HTTP communication with an external service.\n**executionTimeMs** | INTERFACE | The duration time of the invocation of the endpoint related to the event.
This field is set only if the events that describe an HTTP communication with an external service.\n**compressedPayload** | INTERFACE | The payload of the request/response analyzed by the event.
This value is zipped using GZip compression algorithm.\n**compressedPayloadLength** | INTERFACE | The length (in number of characters) of the compressed payload.\n**businessProcess** | INTERFACE | The descriptive label associated to the endpoint called by user and related to the whole process.\n**operationStatus** | INTERFACE | The final status of the whole operation.
This is set only in the events that describe the response in output to user.\n**operationErrorTitle** | INTERFACE | The error title extracted from the computation that refers to the error occurred during computation.
This is set only in the events that describe the response in output to user if there is an error.\n**operationErrorDetail** | INTERFACE | The error detail message extracted from the computation that refers to the error occurred during computation.
This is set only in the events that describe the response in output to user if there is an error.\n**operationErrorCode** | INTERFACE | The error code extracted from the computation that refers to the error occurred during computation.
This is set only in the events that describe the response in output to user if there is an error.\n**primitive** | INTERNAL | The typology of primitive analyzed and tracked by the event.
In NDP it is mapped with field 'eventType'.\n**sessionId** | INTERNAL | The session identifier generated by WISP SOAP Converter and used in the request.\n**cartId** | INTERNAL | The cart identifier used in the request.\n**iuv** | INTERNAL | The 'identificativo univoco pagamento' used in the request.\n**noticeNumber** | INTERNAL | The notice number (aka NAV code) used in the request.\n**domainId** | INTERNAL | The creditor institution identifier used in the request.\n**ccp** | INTERNAL | The 'codice contesto pagamento' used in the request.\n**psp** | INTERNAL | The payment service provider used in the request.\n**station** | INTERNAL | The station used in the request.\n**channel** | INTERNAL | The channel used in the request.\n**status** | INTERNAL | The state of the internal step executed.
Values:
_FOUND_RPT_IN_STORAGE_
_FOUND_RT_IN_STORAGE_
_EXTRACTED_DATA_FROM_RPT_
_CREATED_NEW_PAYMENT_POSITION_IN_GPD_
_GENERATED_NAV_FOR_NEW_PAYMENT_POSITION_
_UPDATED_EXISTING_PAYMENT_POSITION_IN_GPD_
_GENERATING_RT_FOR_INVALID_PAYMENT_POSITION_IN_GPD_
_GENERATING_RT_FOR_GPD_EXCEPTION_
_GENERATING_RT_FOR_REDIRECT_ERROR_
_GENERATED_CACHE_ABOUT_RPT_FOR_DECOUPLER_
_GENERATED_CACHE_ABOUT_RPT_FOR_CARTSESSION_CACHING_
_GENERATED_CACHE_ABOUT_RPT_FOR_RT_GENERATION_
_SAVED_RPT_IN_CART_RECEIVED_REDIRECT_URL_FROM_CHECKOUT_
_RT_NOT_GENERABLE_FOR_GPD_STATION_
_RT_NOT_GENERABLE_FOR_NOT_EXISTING_PAYMENT_POSITION_
_NEGATIVE_RT_TRY_TO_SEND_TO_CREDITOR_INSTITUTION_
_POSITIVE_RT_TRY_TO_SEND_TO_CREDITOR_INSTITUTION_
_RT_SEND_SUCCESS_
_RT_SENT_OK_
_RT_SEND_FAILURE_
_RT_ALREADY_SENT_
_RT_SEND_SCHEDULING_SUCCESS_
_RT_SEND_SCHEDULING_FAILURE_
_RT_SCHEDULED_SEND_SUCCESS_
_RT_SCHEDULED_SEND_FAILURE_
_RT_SEND_RESCHEDULING_FAILURE_
_RT_SEND_RESCHEDULING_REACHED_MAX_RETRIES_
_RT_SEND_RESCHEDULING_SUCCESS_
_RT_RECONCILIATION_PROCESS_
_RT_START_RECONCILIATION_PROCESS_
_RT_END_RECONCILIATION_PROCESS_
_RT_DEAD_LETTER_SAVED_
_RT_DEAD_LETTER_FAILED_
_RECEIPT_TIMER_GENERATION_CREATED_SCHEDULED_SEND_
_RECEIPT_TIMER_GENERATION_CACHED_SEQUENCE_NUMBER_
_RECEIPT_TIMER_GENERATION_DELETED_SCHEDULED_SEND_
_RECEIPT_TIMER_GENERATION_SKIP_DELETE_SCHEDULED_SEND_
_RECEIPT_TIMER_PAYMENT_TOKEN_TIMEOUT_TRIGGER_
_ECOMMERCE_HANG_TIMER_TRIGGER_
_ECOMMERCE_HANG_TIMER_CREATED_
_ECOMMERCE_HANG_TIMER_DELETED_
_RPT_TIMER_TRIGGER_
_RPT_TIMER_CREATED_
_RPT_TIMER_DELETED_
_RPT_TIMER_NOT_SET_
_COMMUNICATING_WITH_GPD_REQUEST_
_COMMUNICATING_WITH_GPD_RESPONSE_
_COMMUNICATING_WITH_IUV_GENERATOR_REQUEST_
_COMMUNICATING_WITH_IUV_GENERATOR_RESPONSE_
_COMMUNICATING_WITH_CHECKOUT_REQUEST_
_COMMUNICATING_WITH_CHECKOUT_RESPONSE_
_COMMUNICATING_WITH_DECOUPLER_CACHING_REQUEST_
_COMMUNICATING_WITH_DECOUPLER_CACHING_RESPONSE_
_COMMUNICATING_WITH_CREDITOR_INSTITUTION_REQUEST_
_COMMUNICATING_WITH_CREDITOR_INSTITUTION_RESPONSE_\n**info** | INTERNAL | The other information that can be inserted for the tracing.\n**paymentToken** | INTERNAL | The payment token.\n\n
\n\n\n## OPERATIONAL ERROR CODES\n\n
Details\nNAME | CODE | DESCRIPTION\n- | - | -\n**WIC-500** | *ERROR* | A not documented generic error occurred while execution. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1000** | *GENERIC_ERROR* | A generic error occurred while executing conversion flow. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1001** | *PARSING_GENERIC_ERROR* | A generic error occurred while parsing of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1002** | *PARSING_INVALID_HEADER* | An error occurred while parsing of the content header, associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT.\n**WIC-1003** | *PARSING_INVALID_BODY* | An error occurred while parsing of the content payload, associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT.\n**WIC-1004** | *PARSING_INVALID_XML_NODES* | An error occurred while parsing of the of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. The XML content extracted, either from payload or from header, is invalid because it is not possible to extract tag nodes from document. So, the document is probably empty.\n**WIC-1005** | *PARSING_INVALID_ZIPPED_PAYLOAD* | An error occurred while parsing of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. The SOAP request analyzed and stored in dedicated storage is not usable for convert the debt positions in GPD system. This is probably due to an invalid conversion of the SOAP request via GZip algorithm executed before the same is stored in its storage.\n**WIC-1006** | *PARSING_RPT_PRIMITIVE_NOT_VALID* | An error occurred while parsing of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. The primitive (the content related to header 'soapaction') cannot be handled by WISP Converter application in redirect process: only one of nodoInviaRPT and nodoInviaCarrelloRPT can be accepted.\n**WIC-1100** | *VALIDATION_INVALID_MULTIBENEFICIARY_CART* | An error occurred while analyzing the RPTs extracted from SOAP request. In particular, the request is arrived as nodoInviaCarrelloRPT as multi-beneficiary cart, but the number of RPTs in the request is lower than two, so it cannot be correctly handled as multi-beneficiary.\n**WIC-1101** | *VALIDATION_INVALID_IBANS* | An error occurred while analyzing the RPTs extracted from SOAP request. An IBAN must always be set in RPT transfers if they aren't related to digital stamps (which don't require an IBAN, because they will be reported to specific subject). In this case, in one or more RPT transfers not related to digital stamp, the IBAN is not correctly set.\n**WIC-1102** | *VALIDATION_INVALID_DEBTOR* | An error occurred while analyzing the RPTs extracted from SOAP request. In particular, in a cart there are different debtor subjects and this is not permitted for this flow. So, the whole cart is discarded.\n**WIC-1200** | *CONFIGURATION_INVALID_CACHE* | An error occurred while trying to access data from cached configuration. It is possible that the cache is not retrieved yet by this service or a corrupted configuration was returned from APIConfig Cache internal service. If this problem still occurs, please check the connectivity with APIConfig Cache.\n**WIC-1201** | *CONFIGURATION_INVALID_STATION* | An error occurred while retrieving data from local cached configuration. In particular, it is not possible to retrieve the configuration about the station because it does not exists in cache, and maybe also in general configuration. So, a change in whole configuration and/or a refresh on cache is required.\n**WIC-1202** | *CONFIGURATION_INVALID_CREDITOR_INSTITUTION_STATION* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the required station does not exists in cached configuration. So, a change in whole configuration and/or a refresh on cache is required.\n**WIC-1203** | *CONFIGURATION_INVALID_STATION_REDIRECT_URL* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration about redirection in error cases is not correctly set to points towards some creditor institution's endpoint. So, a change in configuration is required.\n**WIC-1204** | *CONFIGURATION_INVALID_STATION_SERVICE_URL* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration is not correctly set to points towards GPD service endpoint for RT generator. So, a change in configuration is required.\n**WIC-1205** | *CONFIGURATION_NOT_GPD_STATION* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration is not correctly set to points towards GPD service endpoint. So, a change in configuration is required.\n**WIC-1206** | *CONFIGURATION_INVALID_GPD_STATION* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration is correctly set to points towards GPD service endpoint but uses the 'v1' primitive version (and it must use the 'v2' version). So, a change in configuration is required.\n**WIC-1207** | *CONFIGURATION_INVALID_STATION_PROXY* | An error occurred while checking the station that will be used for the receipt send process. In particular, analyzing the station it turns out that the configuration is not correctly set to configure proxy structure for RT generator. So, a change in configuration is required.\n**WIC-1300** | *PAYMENT_POSITION_NOT_IN_PAYABLE_STATE* | An error occurred while checking an existing payment position. One or more RPTs extracted from the request refers to existing payment positions in GPD that have a state from which it is impossible to execute a payment flow. If the execution of this flow is related to a RPT cart, all the payments that can be retrieved or generated ex novo from those RPTs are declared as atomically invalid (if one RPT in cart is bad, all RPTs in cart are bad) and not payable with this flow.\n**WIC-1301** | *PAYMENT_POSITION_IN_INCONSISTENT_STATE* | An error occurred while checking an existing payment position in GPD system. The retrieved payment position, previously inserted in GPD by this same flow or by other procedures, is in an invalid state, not mappable to an existing value. This can be related to a wrong setting in GPD or a corruption of the retrieved data.\n**WIC-1302** | *PAYMENT_POSITION_NOT_VALID* | An error occurred while generating a payment position. In particular, something during the generation of a new payment position or the analysis of an existing payment position went wrong and the operation cannot be completed. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1303** | *PAYMENT_OPTION_NOT_EXTRACTABLE* | An error occurred while extracting a payment option from a payment position. This can be caused by a malformed payment position that does not have a payment option. Remember that a payment position in this flow must have one and only one payment option.\n**WIC-1400** | *RECEIPT_GENERATION_GENERIC_ERROR* | An error occurred while generating an RT (aka a receipt). An unhandled error occurred and it is impossible to complete the process. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1401** | *RECEIPT_GENERATION_WRONG_RESPONSE_FROM_CREDITOR_INSTITUTION* | An error occurred while generating an RT (aka a receipt). Specifically, the RT request is sent to creditor institution but this one responded with an invalid response from which is impossible to continue the analysis. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1402** | *RECEIPT_GENERATION_ERROR_RESPONSE_FROM_CREDITOR_INSTITUTION* | An error occurred while generating an RT (aka a receipt). Specifically, the RT request is sent to creditor institution but this one responded with an error response that explicit the occurred problem. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1403** | *RECEIPT_KO_NOT_SENT* | An error occurred while sending a negative RT (aka a KO receipt). So, no receipt can be sent lately to creditor institution and probably the process must be executed manually. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1404** | *RECEIPT_OK_NOT_SENT* | An error occurred while sending a positive RT (aka a OK receipt). So, no receipt can be sent lately to creditor institution and probably the process must be executed manually. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1405** | *RECEIPT_GENERATION_IDEMPOTENCY_LOCKED_BY_ANOTHER_PROCESS* | An error occurred while generating an RT (aka a receipt). Two or more generation processes are concurrently trying to execute the same operation on the same receipt but only one of them is currently 'authorized' to do so.\n**WIC-1406** | *RECEIPT_GENERATION_NOT_PROCESSABLE* | An error occurred while generating an RT (aka a receipt). The process of receipt generation cannot be started correctly because it is trying to lock the idempotency key that is already in a locked state. Probably the process is in execution by another thread.\n**WIC-1407** | *RECEIPT_GENERATION_ALREADY_PROCESSED* | An error occurred while generating an RT (aka a receipt). The process of receipt generation cannot be completed correctly because it is trying to unlock the idempotency key that is not in a locked state. Probably the process was already completed.\n**WIC-1408** | *RECEIPT_GENERATION_ANOMALY_ON_PROCESSING* | An error occurred while generating an RT (aka a receipt). The process of receipt generation cannot be completed correctly because there is a mismatch between the type of the cached receipt and the kind of request made for generate the same receipt. For example, the cached receipt is defined as negative paaInviaRT but the request was made to 'receipt/ok' endpoint. This is an anomaly that should never happens in a correct NMU flow execution but must be traced in case of error.\n**WIC-1409** | *RECEIPT_KO_NOT_GENERATED_BUT_MAYBE_RESCHEDULED* | An error occurred while generating a negative RT (aka a KO receipt). The receipt could be sent lately to creditor institution but for better understanding the cause, please use the Technical Support's APIs.\n**WIC-1410** | *RECEIPT_OK_NOT_GENERATED_BUT_MAYBE_RESCHEDULED* | An error occurred while generating a positive RT (aka a OK receipt). The receipt could be sent lately to creditor institution but for better understanding the cause, please use the Technical Support's APIs.\n**WIC-1411** | *RECEIPT_GENERATION_ERROR_DEAD_LETTER* | An error occurred while generating an RT (aka a receipt). Specifically, the creditor institution response status has not been recognized, for this reason the RT has been placed in the dead letter container.\n**WIC-2000** | *PERSISTENCE_SAVING_RE_ERROR* | An error occurred wile trying to store a new event in the Registro Eventi storage. The error is somewhat related to a persistence problem of the used storage and in the majority of the cases is temporary (maybe a 429 HTTP code). This error currently blocks the entire flow because that can lead to untraceable requests. For better understanding the cause, please execute a search in the log provider (Application Insights, Kibana, etc).\n**WIC-2001** | *PERSISTENCE_RPT_NOT_FOUND* | An error occurred while trying to retrieve the RPT content saved in storage by WISP SOAP Converter. This can be related either with the use of a wrong sessionId or a missed persistence from WISP SOAP Converter, so it is better to analyze the entire flow using Technical Support's APIs. This block totally the conversion of the RPTs in GPD's payment positions, so the whole process is discarded.\n**WIC-2002** | *PERSISTENCE_RT_NOT_FOUND* | An error occurred while trying to retrieve the RT content saved in storage by WISP Converter. This can be related either with the use of a wrong identifier, a missed persistence or an expired object, so it is better to analyze the entire flow using Technical Support's APIs.\n**WIC-2003** | *PERSISTENCE_REQUESTID_CACHING_ERROR* | An error occurred while trying to retrieve data from internal cache. Specifically, the cached key, defined in format wisp_nav2iuv__
\n", "termsOfService": "https://www.pagopa.gov.it/", "title": "WISP Converter", - "version": "1.0.2" + "version": "1.0.2-1-PAGOPA-2389" }, "servers": [ { diff --git a/openapi/openapi_redirect.json b/openapi/openapi_redirect.json index 20cc5da5..31746de3 100644 --- a/openapi/openapi_redirect.json +++ b/openapi/openapi_redirect.json @@ -2,7 +2,7 @@ "openapi": "3.0.1", "info": { "title": "WISP-Converter-redirect", - "version": "1.0.2" + "version": "1.0.2-1-PAGOPA-2389" }, "servers": [ { diff --git a/pom.xml b/pom.xml index aebe4c8f..13aaa69e 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 1.0.2 + 1.0.2-1-PAGOPA-2389 pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From 8eef0eeb72559e3964b265b9c4921af8a5735c35 Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:32:45 +0100 Subject: [PATCH 03/12] [PAGOPA-2389] fix: Use getAllRPTs method --- .../wispconverter/controller/ReceiptTimerController.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index 628e5a98..96a3b4ed 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -84,8 +84,8 @@ public void deleteTimer(@RequestParam() String paymentTokens) { String sessionId = receiptDto.getSessionId(); SessionDataDTO sessionDataDTO = rptExtractorService.getSessionDataFromSessionId(sessionId); // Update receipts-rt status to PAYING - sessionDataDTO.getAllPaymentNotices().forEach(paymentNotice -> - rtReceiptCosmosService.updateReceiptStatus(paymentNotice.getFiscalCode(), paymentNotice.getIuv(), paymentNotice.getCcp(), ReceiptStatusEnum.PAYING)); + sessionDataDTO.getAllRPTs().forEach(rpt -> + rtReceiptCosmosService.updateReceiptStatus(receiptDto.getFiscalCode(), rpt.getIuv(), rpt.getCcp(), ReceiptStatusEnum.PAYING)); } // cancel scheduled message receiptTimerService.cancelScheduledMessage(tokens); From cb21e3ec9eff198a86afeb427223094939f12d6c Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Tue, 26 Nov 2024 20:39:08 +0100 Subject: [PATCH 04/12] [PAGOPA-2389] refactoring --- .../wispconverter/controller/ReceiptTimerController.java | 7 ++++--- .../wispconverter/controller/RedirectController.java | 2 -- 2 files changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index 96a3b4ed..f1792a1b 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -87,13 +87,14 @@ public void deleteTimer(@RequestParam() String paymentTokens) { sessionDataDTO.getAllRPTs().forEach(rpt -> rtReceiptCosmosService.updateReceiptStatus(receiptDto.getFiscalCode(), rpt.getIuv(), rpt.getCcp(), ReceiptStatusEnum.PAYING)); } - // cancel scheduled message - receiptTimerService.cancelScheduledMessage(tokens); } catch (Exception e) { throw new AppException(AppErrorCodeMessageEnum.DELETE_PAYMENT_TOKEN_TIMER_FAILURE, e); } finally { - // do or retry to cancel scheduled message + // cancel scheduled message if PAYING status transition goes in exception receiptTimerService.cancelScheduledMessage(tokens); } + + // cancel scheduled message + receiptTimerService.cancelScheduledMessage(tokens); } } diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java index 40191c17..5f606af6 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/RedirectController.java @@ -71,6 +71,4 @@ public String redirect(@Parameter(description = "", example = "identificativoInt return "error"; } } - - } From 54d9b4abca61b9ef5874b00f858377263393ba2d Mon Sep 17 00:00:00 2001 From: pagopa-github-bot Date: Wed, 27 Nov 2024 10:23:17 +0000 Subject: [PATCH 05/12] Bump to version 1.0.2-2-PAGOPA-2389 [skip ci] --- helm/Chart.yaml | 4 ++-- helm/values-dev.yaml | 2 +- helm/values-prod.yaml | 2 +- helm/values-uat.yaml | 2 +- openapi/openapi.json | 2 +- openapi/openapi_redirect.json | 2 +- pom.xml | 2 +- 7 files changed, 8 insertions(+), 8 deletions(-) diff --git a/helm/Chart.yaml b/helm/Chart.yaml index 19bf7bae..01b69a8d 100644 --- a/helm/Chart.yaml +++ b/helm/Chart.yaml @@ -2,8 +2,8 @@ apiVersion: v2 name: pagopa-wisp-converter description: A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, interfacing them with GPD system type: application -version: 0.289.0 -appVersion: 1.0.2-1-PAGOPA-2389 +version: 0.290.0 +appVersion: 1.0.2-2-PAGOPA-2389 dependencies: - name: microservice-chart version: 3.0.0 diff --git a/helm/values-dev.yaml b/helm/values-dev.yaml index d3b664ee..dcb907b9 100644 --- a/helm/values-dev.yaml +++ b/helm/values-dev.yaml @@ -4,7 +4,7 @@ microservice-chart: µservice-chart fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "1.0.2-1-PAGOPA-2389" + tag: "1.0.2-2-PAGOPA-2389" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-prod.yaml b/helm/values-prod.yaml index 70b80fb2..710631ed 100644 --- a/helm/values-prod.yaml +++ b/helm/values-prod.yaml @@ -4,7 +4,7 @@ microservice-chart: µservice-chart fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "1.0.2-1-PAGOPA-2389" + tag: "1.0.2-2-PAGOPA-2389" pullPolicy: Always livenessProbe: httpGet: diff --git a/helm/values-uat.yaml b/helm/values-uat.yaml index 072248c0..fdcc486e 100644 --- a/helm/values-uat.yaml +++ b/helm/values-uat.yaml @@ -4,7 +4,7 @@ microservice-chart: µservice-chart fullnameOverride: "" image: repository: ghcr.io/pagopa/pagopa-wisp-converter - tag: "1.0.2-1-PAGOPA-2389" + tag: "1.0.2-2-PAGOPA-2389" pullPolicy: Always livenessProbe: httpGet: diff --git a/openapi/openapi.json b/openapi/openapi.json index 1d07772a..f35d4a29 100644 --- a/openapi/openapi.json +++ b/openapi/openapi.json @@ -4,7 +4,7 @@ "description": "A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments.\n\n# OPERATIVE INFO\n\n\n## EVENT MAPPING IN RE\n\n
Details\nFIELD | SCOPE | DESCRIPTION\n- | - | -\n**requestId** | BOTH | The identifier, set by X-Request-ID, from which the events can be grouped.\n**operationId** | BOTH | The identifier associated to a request identifier\n**clientOperationId** | BOTH | The identifier that associate a client to an operation identifier.\n**component** | BOTH | The applicative component from which the event is generated.
In NDP it is mapped with field 'componente'.
Values:
_WISP_SOAP_CONVERTER_
_WISP_CONVERTER_\n**insertedTimestamp** | BOTH | The time on which the event is inserted in RE storage\n**eventCategory** | BOTH | The category on which the event can be grouped.
In NDP it is mapped with field 'categoriaEvento'.
Values:
_INTERFACE_
_INTERNAL_\n**eventSubcategory** | BOTH | The subcategory related to the specific nature of the event.
In NDP it is mapped with field 'sottoTipoEvento'.
Values:
_REQ_
_RESP_
_INTERN_\n**callType** | INTERFACE | The type of role that the application has in the communication with the remote endpoint.
Values:
_SERVER_
_CLIENT_\n**outcome** | INTERFACE | The outcome of the operation described by the event.
In NDP it is mapped with field 'esito'.
Values:
_SEND_: Correctly sent request to HTTP endpoint. In NDP it is mapped with value 'INVIATA'.
_SEND_FAILURE_: Failed to send request to HTTP endpoint. In NDP it is mapped with value 'INVIATA_KO'
_RECEIVED_: Received an OK response from HTTP endpoint. In NDP it is mapped with value 'RICEVUTA_KO'
_RECEIVED_FAILURE_: Received a failure response from endpoint. In NDP it is mapped with value 'RICEVUTA_KO'
_NEVER_RECEIVED_: Failed to receive response at all from endpoint. In NDP it is mapped with value 'NO_RICEVUTA'
_EXECUTED_INTERNAL_STEP_: Executed internal step on execution. In NDP it is mapped with value 'CAMBIO_STATO'\n**httpMethod** | INTERFACE | The HTTP method of the endpoint related to the event.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpUri** | INTERFACE | The URI related to the called endpoint.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpHeaders** | INTERFACE | The list of HTTP headers extracted from the request/response analyzed by the event.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpCallRemoteAddress** | INTERFACE | The remote IP address extracted from the called endpoint.
This field is set only if the events that describe an HTTP communication with an external service.\n**httpStatusCode** | INTERFACE | The status code extracted from the called endpoint.
This field is set only if the events that describe an HTTP communication with an external service.\n**executionTimeMs** | INTERFACE | The duration time of the invocation of the endpoint related to the event.
This field is set only if the events that describe an HTTP communication with an external service.\n**compressedPayload** | INTERFACE | The payload of the request/response analyzed by the event.
This value is zipped using GZip compression algorithm.\n**compressedPayloadLength** | INTERFACE | The length (in number of characters) of the compressed payload.\n**businessProcess** | INTERFACE | The descriptive label associated to the endpoint called by user and related to the whole process.\n**operationStatus** | INTERFACE | The final status of the whole operation.
This is set only in the events that describe the response in output to user.\n**operationErrorTitle** | INTERFACE | The error title extracted from the computation that refers to the error occurred during computation.
This is set only in the events that describe the response in output to user if there is an error.\n**operationErrorDetail** | INTERFACE | The error detail message extracted from the computation that refers to the error occurred during computation.
This is set only in the events that describe the response in output to user if there is an error.\n**operationErrorCode** | INTERFACE | The error code extracted from the computation that refers to the error occurred during computation.
This is set only in the events that describe the response in output to user if there is an error.\n**primitive** | INTERNAL | The typology of primitive analyzed and tracked by the event.
In NDP it is mapped with field 'eventType'.\n**sessionId** | INTERNAL | The session identifier generated by WISP SOAP Converter and used in the request.\n**cartId** | INTERNAL | The cart identifier used in the request.\n**iuv** | INTERNAL | The 'identificativo univoco pagamento' used in the request.\n**noticeNumber** | INTERNAL | The notice number (aka NAV code) used in the request.\n**domainId** | INTERNAL | The creditor institution identifier used in the request.\n**ccp** | INTERNAL | The 'codice contesto pagamento' used in the request.\n**psp** | INTERNAL | The payment service provider used in the request.\n**station** | INTERNAL | The station used in the request.\n**channel** | INTERNAL | The channel used in the request.\n**status** | INTERNAL | The state of the internal step executed.
Values:
_FOUND_RPT_IN_STORAGE_
_FOUND_RT_IN_STORAGE_
_EXTRACTED_DATA_FROM_RPT_
_CREATED_NEW_PAYMENT_POSITION_IN_GPD_
_GENERATED_NAV_FOR_NEW_PAYMENT_POSITION_
_UPDATED_EXISTING_PAYMENT_POSITION_IN_GPD_
_GENERATING_RT_FOR_INVALID_PAYMENT_POSITION_IN_GPD_
_GENERATING_RT_FOR_GPD_EXCEPTION_
_GENERATING_RT_FOR_REDIRECT_ERROR_
_GENERATED_CACHE_ABOUT_RPT_FOR_DECOUPLER_
_GENERATED_CACHE_ABOUT_RPT_FOR_CARTSESSION_CACHING_
_GENERATED_CACHE_ABOUT_RPT_FOR_RT_GENERATION_
_SAVED_RPT_IN_CART_RECEIVED_REDIRECT_URL_FROM_CHECKOUT_
_RT_NOT_GENERABLE_FOR_GPD_STATION_
_RT_NOT_GENERABLE_FOR_NOT_EXISTING_PAYMENT_POSITION_
_NEGATIVE_RT_TRY_TO_SEND_TO_CREDITOR_INSTITUTION_
_POSITIVE_RT_TRY_TO_SEND_TO_CREDITOR_INSTITUTION_
_RT_SEND_SUCCESS_
_RT_SENT_OK_
_RT_SEND_FAILURE_
_RT_ALREADY_SENT_
_RT_SEND_SCHEDULING_SUCCESS_
_RT_SEND_SCHEDULING_FAILURE_
_RT_SCHEDULED_SEND_SUCCESS_
_RT_SCHEDULED_SEND_FAILURE_
_RT_SEND_RESCHEDULING_FAILURE_
_RT_SEND_RESCHEDULING_REACHED_MAX_RETRIES_
_RT_SEND_RESCHEDULING_SUCCESS_
_RT_RECONCILIATION_PROCESS_
_RT_START_RECONCILIATION_PROCESS_
_RT_END_RECONCILIATION_PROCESS_
_RT_DEAD_LETTER_SAVED_
_RT_DEAD_LETTER_FAILED_
_RECEIPT_TIMER_GENERATION_CREATED_SCHEDULED_SEND_
_RECEIPT_TIMER_GENERATION_CACHED_SEQUENCE_NUMBER_
_RECEIPT_TIMER_GENERATION_DELETED_SCHEDULED_SEND_
_RECEIPT_TIMER_GENERATION_SKIP_DELETE_SCHEDULED_SEND_
_RECEIPT_TIMER_PAYMENT_TOKEN_TIMEOUT_TRIGGER_
_ECOMMERCE_HANG_TIMER_TRIGGER_
_ECOMMERCE_HANG_TIMER_CREATED_
_ECOMMERCE_HANG_TIMER_DELETED_
_RPT_TIMER_TRIGGER_
_RPT_TIMER_CREATED_
_RPT_TIMER_DELETED_
_RPT_TIMER_NOT_SET_
_COMMUNICATING_WITH_GPD_REQUEST_
_COMMUNICATING_WITH_GPD_RESPONSE_
_COMMUNICATING_WITH_IUV_GENERATOR_REQUEST_
_COMMUNICATING_WITH_IUV_GENERATOR_RESPONSE_
_COMMUNICATING_WITH_CHECKOUT_REQUEST_
_COMMUNICATING_WITH_CHECKOUT_RESPONSE_
_COMMUNICATING_WITH_DECOUPLER_CACHING_REQUEST_
_COMMUNICATING_WITH_DECOUPLER_CACHING_RESPONSE_
_COMMUNICATING_WITH_CREDITOR_INSTITUTION_REQUEST_
_COMMUNICATING_WITH_CREDITOR_INSTITUTION_RESPONSE_\n**info** | INTERNAL | The other information that can be inserted for the tracing.\n**paymentToken** | INTERNAL | The payment token.\n\n
\n\n\n## OPERATIONAL ERROR CODES\n\n
Details\nNAME | CODE | DESCRIPTION\n- | - | -\n**WIC-500** | *ERROR* | A not documented generic error occurred while execution. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1000** | *GENERIC_ERROR* | A generic error occurred while executing conversion flow. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1001** | *PARSING_GENERIC_ERROR* | A generic error occurred while parsing of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1002** | *PARSING_INVALID_HEADER* | An error occurred while parsing of the content header, associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT.\n**WIC-1003** | *PARSING_INVALID_BODY* | An error occurred while parsing of the content payload, associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT.\n**WIC-1004** | *PARSING_INVALID_XML_NODES* | An error occurred while parsing of the of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. The XML content extracted, either from payload or from header, is invalid because it is not possible to extract tag nodes from document. So, the document is probably empty.\n**WIC-1005** | *PARSING_INVALID_ZIPPED_PAYLOAD* | An error occurred while parsing of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. The SOAP request analyzed and stored in dedicated storage is not usable for convert the debt positions in GPD system. This is probably due to an invalid conversion of the SOAP request via GZip algorithm executed before the same is stored in its storage.\n**WIC-1006** | *PARSING_RPT_PRIMITIVE_NOT_VALID* | An error occurred while parsing of the content associated to the SOAP request related to nodoInviaRPT or nodoInviaCarrelloRPT. The primitive (the content related to header 'soapaction') cannot be handled by WISP Converter application in redirect process: only one of nodoInviaRPT and nodoInviaCarrelloRPT can be accepted.\n**WIC-1100** | *VALIDATION_INVALID_MULTIBENEFICIARY_CART* | An error occurred while analyzing the RPTs extracted from SOAP request. In particular, the request is arrived as nodoInviaCarrelloRPT as multi-beneficiary cart, but the number of RPTs in the request is lower than two, so it cannot be correctly handled as multi-beneficiary.\n**WIC-1101** | *VALIDATION_INVALID_IBANS* | An error occurred while analyzing the RPTs extracted from SOAP request. An IBAN must always be set in RPT transfers if they aren't related to digital stamps (which don't require an IBAN, because they will be reported to specific subject). In this case, in one or more RPT transfers not related to digital stamp, the IBAN is not correctly set.\n**WIC-1102** | *VALIDATION_INVALID_DEBTOR* | An error occurred while analyzing the RPTs extracted from SOAP request. In particular, in a cart there are different debtor subjects and this is not permitted for this flow. So, the whole cart is discarded.\n**WIC-1200** | *CONFIGURATION_INVALID_CACHE* | An error occurred while trying to access data from cached configuration. It is possible that the cache is not retrieved yet by this service or a corrupted configuration was returned from APIConfig Cache internal service. If this problem still occurs, please check the connectivity with APIConfig Cache.\n**WIC-1201** | *CONFIGURATION_INVALID_STATION* | An error occurred while retrieving data from local cached configuration. In particular, it is not possible to retrieve the configuration about the station because it does not exists in cache, and maybe also in general configuration. So, a change in whole configuration and/or a refresh on cache is required.\n**WIC-1202** | *CONFIGURATION_INVALID_CREDITOR_INSTITUTION_STATION* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the required station does not exists in cached configuration. So, a change in whole configuration and/or a refresh on cache is required.\n**WIC-1203** | *CONFIGURATION_INVALID_STATION_REDIRECT_URL* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration about redirection in error cases is not correctly set to points towards some creditor institution's endpoint. So, a change in configuration is required.\n**WIC-1204** | *CONFIGURATION_INVALID_STATION_SERVICE_URL* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration is not correctly set to points towards GPD service endpoint for RT generator. So, a change in configuration is required.\n**WIC-1205** | *CONFIGURATION_NOT_GPD_STATION* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration is not correctly set to points towards GPD service endpoint. So, a change in configuration is required.\n**WIC-1206** | *CONFIGURATION_INVALID_GPD_STATION* | An error occurred while checking the station that will be used for the payment process. In particular, analyzing the station that is related to the segregation code extracted from a payment option's notice number, it turns out that the configuration is correctly set to points towards GPD service endpoint but uses the 'v1' primitive version (and it must use the 'v2' version). So, a change in configuration is required.\n**WIC-1207** | *CONFIGURATION_INVALID_STATION_PROXY* | An error occurred while checking the station that will be used for the receipt send process. In particular, analyzing the station it turns out that the configuration is not correctly set to configure proxy structure for RT generator. So, a change in configuration is required.\n**WIC-1300** | *PAYMENT_POSITION_NOT_IN_PAYABLE_STATE* | An error occurred while checking an existing payment position. One or more RPTs extracted from the request refers to existing payment positions in GPD that have a state from which it is impossible to execute a payment flow. If the execution of this flow is related to a RPT cart, all the payments that can be retrieved or generated ex novo from those RPTs are declared as atomically invalid (if one RPT in cart is bad, all RPTs in cart are bad) and not payable with this flow.\n**WIC-1301** | *PAYMENT_POSITION_IN_INCONSISTENT_STATE* | An error occurred while checking an existing payment position in GPD system. The retrieved payment position, previously inserted in GPD by this same flow or by other procedures, is in an invalid state, not mappable to an existing value. This can be related to a wrong setting in GPD or a corruption of the retrieved data.\n**WIC-1302** | *PAYMENT_POSITION_NOT_VALID* | An error occurred while generating a payment position. In particular, something during the generation of a new payment position or the analysis of an existing payment position went wrong and the operation cannot be completed. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1303** | *PAYMENT_OPTION_NOT_EXTRACTABLE* | An error occurred while extracting a payment option from a payment position. This can be caused by a malformed payment position that does not have a payment option. Remember that a payment position in this flow must have one and only one payment option.\n**WIC-1400** | *RECEIPT_GENERATION_GENERIC_ERROR* | An error occurred while generating an RT (aka a receipt). An unhandled error occurred and it is impossible to complete the process. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1401** | *RECEIPT_GENERATION_WRONG_RESPONSE_FROM_CREDITOR_INSTITUTION* | An error occurred while generating an RT (aka a receipt). Specifically, the RT request is sent to creditor institution but this one responded with an invalid response from which is impossible to continue the analysis. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1402** | *RECEIPT_GENERATION_ERROR_RESPONSE_FROM_CREDITOR_INSTITUTION* | An error occurred while generating an RT (aka a receipt). Specifically, the RT request is sent to creditor institution but this one responded with an error response that explicit the occurred problem. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1403** | *RECEIPT_KO_NOT_SENT* | An error occurred while sending a negative RT (aka a KO receipt). So, no receipt can be sent lately to creditor institution and probably the process must be executed manually. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1404** | *RECEIPT_OK_NOT_SENT* | An error occurred while sending a positive RT (aka a OK receipt). So, no receipt can be sent lately to creditor institution and probably the process must be executed manually. For better understanding the cause, please use the Technical Support's APIs.\n**WIC-1405** | *RECEIPT_GENERATION_IDEMPOTENCY_LOCKED_BY_ANOTHER_PROCESS* | An error occurred while generating an RT (aka a receipt). Two or more generation processes are concurrently trying to execute the same operation on the same receipt but only one of them is currently 'authorized' to do so.\n**WIC-1406** | *RECEIPT_GENERATION_NOT_PROCESSABLE* | An error occurred while generating an RT (aka a receipt). The process of receipt generation cannot be started correctly because it is trying to lock the idempotency key that is already in a locked state. Probably the process is in execution by another thread.\n**WIC-1407** | *RECEIPT_GENERATION_ALREADY_PROCESSED* | An error occurred while generating an RT (aka a receipt). The process of receipt generation cannot be completed correctly because it is trying to unlock the idempotency key that is not in a locked state. Probably the process was already completed.\n**WIC-1408** | *RECEIPT_GENERATION_ANOMALY_ON_PROCESSING* | An error occurred while generating an RT (aka a receipt). The process of receipt generation cannot be completed correctly because there is a mismatch between the type of the cached receipt and the kind of request made for generate the same receipt. For example, the cached receipt is defined as negative paaInviaRT but the request was made to 'receipt/ok' endpoint. This is an anomaly that should never happens in a correct NMU flow execution but must be traced in case of error.\n**WIC-1409** | *RECEIPT_KO_NOT_GENERATED_BUT_MAYBE_RESCHEDULED* | An error occurred while generating a negative RT (aka a KO receipt). The receipt could be sent lately to creditor institution but for better understanding the cause, please use the Technical Support's APIs.\n**WIC-1410** | *RECEIPT_OK_NOT_GENERATED_BUT_MAYBE_RESCHEDULED* | An error occurred while generating a positive RT (aka a OK receipt). The receipt could be sent lately to creditor institution but for better understanding the cause, please use the Technical Support's APIs.\n**WIC-1411** | *RECEIPT_GENERATION_ERROR_DEAD_LETTER* | An error occurred while generating an RT (aka a receipt). Specifically, the creditor institution response status has not been recognized, for this reason the RT has been placed in the dead letter container.\n**WIC-2000** | *PERSISTENCE_SAVING_RE_ERROR* | An error occurred wile trying to store a new event in the Registro Eventi storage. The error is somewhat related to a persistence problem of the used storage and in the majority of the cases is temporary (maybe a 429 HTTP code). This error currently blocks the entire flow because that can lead to untraceable requests. For better understanding the cause, please execute a search in the log provider (Application Insights, Kibana, etc).\n**WIC-2001** | *PERSISTENCE_RPT_NOT_FOUND* | An error occurred while trying to retrieve the RPT content saved in storage by WISP SOAP Converter. This can be related either with the use of a wrong sessionId or a missed persistence from WISP SOAP Converter, so it is better to analyze the entire flow using Technical Support's APIs. This block totally the conversion of the RPTs in GPD's payment positions, so the whole process is discarded.\n**WIC-2002** | *PERSISTENCE_RT_NOT_FOUND* | An error occurred while trying to retrieve the RT content saved in storage by WISP Converter. This can be related either with the use of a wrong identifier, a missed persistence or an expired object, so it is better to analyze the entire flow using Technical Support's APIs.\n**WIC-2003** | *PERSISTENCE_REQUESTID_CACHING_ERROR* | An error occurred while trying to retrieve data from internal cache. Specifically, the cached key, defined in format wisp_nav2iuv__
\n", "termsOfService": "https://www.pagopa.gov.it/", "title": "WISP Converter", - "version": "1.0.2-1-PAGOPA-2389" + "version": "1.0.2-2-PAGOPA-2389" }, "servers": [ { diff --git a/openapi/openapi_redirect.json b/openapi/openapi_redirect.json index 31746de3..b725ac89 100644 --- a/openapi/openapi_redirect.json +++ b/openapi/openapi_redirect.json @@ -2,7 +2,7 @@ "openapi": "3.0.1", "info": { "title": "WISP-Converter-redirect", - "version": "1.0.2-1-PAGOPA-2389" + "version": "1.0.2-2-PAGOPA-2389" }, "servers": [ { diff --git a/pom.xml b/pom.xml index 13aaa69e..3e1bd4a1 100644 --- a/pom.xml +++ b/pom.xml @@ -13,7 +13,7 @@ it.gov.pagopa wisp-converter - 1.0.2-1-PAGOPA-2389 + 1.0.2-2-PAGOPA-2389 pagoPA WISP Converter A service that permits to handle nodoInviaRPT and nodoInviaCarrelloRPT request from WISP, converting them in NMU payments. From a4cf296be1cc8c49a03686dc2e22a0d6da013de7 Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:41:57 +0100 Subject: [PATCH 06/12] [PAGOPA-2389] refactoring: Add check for REDIRECT status --- .../controller/ReceiptTimerController.java | 4 +- .../service/RtReceiptCosmosService.java | 39 +++++++++++++++++++ 2 files changed, 40 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index f1792a1b..e6d2aeee 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -10,7 +10,6 @@ import it.gov.pagopa.wispconverter.controller.model.ReceiptTimerRequest; import it.gov.pagopa.wispconverter.exception.AppErrorCodeMessageEnum; import it.gov.pagopa.wispconverter.exception.AppException; -import it.gov.pagopa.wispconverter.repository.model.enumz.ReceiptStatusEnum; import it.gov.pagopa.wispconverter.repository.model.enumz.WorkflowStatus; import it.gov.pagopa.wispconverter.service.*; import it.gov.pagopa.wispconverter.service.model.ReceiptDto; @@ -84,8 +83,7 @@ public void deleteTimer(@RequestParam() String paymentTokens) { String sessionId = receiptDto.getSessionId(); SessionDataDTO sessionDataDTO = rptExtractorService.getSessionDataFromSessionId(sessionId); // Update receipts-rt status to PAYING - sessionDataDTO.getAllRPTs().forEach(rpt -> - rtReceiptCosmosService.updateReceiptStatus(receiptDto.getFiscalCode(), rpt.getIuv(), rpt.getCcp(), ReceiptStatusEnum.PAYING)); + sessionDataDTO.getAllRPTs().forEach(rtReceiptCosmosService::updateStatusToPaying); } } catch (Exception e) { throw new AppException(AppErrorCodeMessageEnum.DELETE_PAYMENT_TOKEN_TIMER_FAILURE, e); diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java b/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java index 121ae078..32208c96 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java @@ -78,6 +78,45 @@ public boolean updateReceiptStatus(String ci, String iuv, String ccp, ReceiptSta } } + @Transactional + public boolean updateStatusToPaying(RPTContentDTO rptContentDTO) { + String fiscalCode = rptContentDTO.getRpt().getDomain().getDomainId(); + Optional rtEntityOpt = this.findById(fiscalCode, rptContentDTO.getIuv(), rptContentDTO.getCcp()); + if(rtEntityOpt.isPresent()) { + RTEntity rtEntity = rtEntityOpt.get(); + // change status only if is REDIRECT, if it is equals or next to PAYING (ie PAYING, SENDING, SENT) + // must not go back or overwritten with the same value + if(rtEntity.getReceiptStatus().equals(ReceiptStatusEnum.REDIRECT)) { + this.updateReceiptStatus(rtEntity, ReceiptStatusEnum.PAYING); + log.debug("Receipt-rt with id = {} has been updated with status PAYING", rtEntity.getId()); + return true; + } + log.warn("Attempt to update receipt-rt with id = {} has been failed because is the status is {}", + rtEntity.getId(), rtEntity.getReceiptStatus()); + } + + return false; + } + + @Transactional + public boolean updateReceiptStatus(RTEntity rtEntity, ReceiptStatusEnum status) { + try { + rtEntity.setReceiptStatus(status); + rtRepository.save(rtEntity); + + return true; + } catch (CosmosException e) { + log.error("An exception occurred while saveRTEntity: " + e.getMessage()); + return false; + } + } + + public Optional findById(String domainId, String iuv, String ccp) { + String id = String.format("%s_%s_%s", domainId, iuv, ccp); + // Remove illegal characters ['/', '\', '#'] because cannot be used in Resource ID + return rtRepository.findById(id, new PartitionKey(id)); + } + public boolean receiptRtExist(String domainId, String iuv, String ccp) { String id = getId(domainId, iuv, ccp); return rtRepository.findById(id, new PartitionKey(id)).isPresent(); From 86a22ba85753b76990db36030eecd524fae114bf Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Wed, 27 Nov 2024 17:44:22 +0100 Subject: [PATCH 07/12] [PAGOPA-2389] refactoring --- .../service/RtReceiptCosmosService.java | 25 +++++++++---------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java b/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java index 32208c96..7fcd2815 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java @@ -79,6 +79,18 @@ public boolean updateReceiptStatus(String ci, String iuv, String ccp, ReceiptSta } @Transactional + public boolean updateReceiptStatus(RTEntity rtEntity, ReceiptStatusEnum status) { + try { + rtEntity.setReceiptStatus(status); + rtRepository.save(rtEntity); + + return true; + } catch (CosmosException e) { + log.error("An exception occurred while saveRTEntity: " + e.getMessage()); + return false; + } + } + public boolean updateStatusToPaying(RPTContentDTO rptContentDTO) { String fiscalCode = rptContentDTO.getRpt().getDomain().getDomainId(); Optional rtEntityOpt = this.findById(fiscalCode, rptContentDTO.getIuv(), rptContentDTO.getCcp()); @@ -98,19 +110,6 @@ public boolean updateStatusToPaying(RPTContentDTO rptContentDTO) { return false; } - @Transactional - public boolean updateReceiptStatus(RTEntity rtEntity, ReceiptStatusEnum status) { - try { - rtEntity.setReceiptStatus(status); - rtRepository.save(rtEntity); - - return true; - } catch (CosmosException e) { - log.error("An exception occurred while saveRTEntity: " + e.getMessage()); - return false; - } - } - public Optional findById(String domainId, String iuv, String ccp) { String id = String.format("%s_%s_%s", domainId, iuv, ccp); // Remove illegal characters ['/', '\', '#'] because cannot be used in Resource ID From 8470b6e8e37ec40c80c5961bb69c220a3653775f Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:23:35 +0100 Subject: [PATCH 08/12] [PAGOPA-2389] fix: Remove useless code --- .../wispconverter/controller/ReceiptTimerController.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index e6d2aeee..6ce47de1 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -91,8 +91,5 @@ public void deleteTimer(@RequestParam() String paymentTokens) { // cancel scheduled message if PAYING status transition goes in exception receiptTimerService.cancelScheduledMessage(tokens); } - - // cancel scheduled message - receiptTimerService.cancelScheduledMessage(tokens); } } From 676a537d89fd801e798aaae9fcc198bf462fae82 Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:30:29 +0100 Subject: [PATCH 09/12] [PAGOPA-2389] doc: Add comment for ReceiptStatusEnum --- .../repository/model/enumz/ReceiptStatusEnum.java | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java b/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java index 5bb103bb..97591993 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java @@ -2,7 +2,10 @@ public enum ReceiptStatusEnum { REDIRECT, - PAYING, // the execution flow between ClosePayment sending and paSendRTV2 + // PAYING status track the execution flow between + // (DELETE receipt/timer, POST receipt/ko call), -> e.g. ClosePayment inbound and (ClosePayment KO or SPR KO) + // (DELETE receipt/timer, POST receipt/ok call) -> e.g. ClosePayment inbound and paSendRTV2 + PAYING, SENDING, SCHEDULED, SENT, From 8f8a4e0f6aae8a8b38b31b92e635ecfa7784e3f8 Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Mon, 2 Dec 2024 15:46:06 +0100 Subject: [PATCH 10/12] [PAGOPA-2389] refactoring: Update AppErrorCodeMessageEnum --- .../wispconverter/controller/ReceiptTimerController.java | 2 +- .../wispconverter/exception/AppErrorCodeMessageEnum.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index 6ce47de1..b4f2f922 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -86,7 +86,7 @@ public void deleteTimer(@RequestParam() String paymentTokens) { sessionDataDTO.getAllRPTs().forEach(rtReceiptCosmosService::updateStatusToPaying); } } catch (Exception e) { - throw new AppException(AppErrorCodeMessageEnum.DELETE_PAYMENT_TOKEN_TIMER_FAILURE, e); + throw new AppException(AppErrorCodeMessageEnum.CHANGE_STATUS_TO_PAYING_FAILURE, e); } finally { // cancel scheduled message if PAYING status transition goes in exception receiptTimerService.cancelScheduledMessage(tokens); diff --git a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java index bb741d6b..17ded131 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java @@ -65,8 +65,8 @@ public enum AppErrorCodeMessageEnum { CLIENT_PAAINVIART(3005, "PaaInviaRT error", "Error while communicating with Station for paaInviaRT service. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with the creditor institution's station (external service) in order to sending of a paaInviaRT request. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), CLIENT_CARTSESSION_CACHING(3006, "Cart caching client error", "Error while communicating with cart caching API. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with an internal service endpoint dedicated to storing internal cache for handle unique session on cart. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), UNKNOWN(0, "Unknown", "Unknown error", HttpStatus.INTERNAL_SERVER_ERROR, null), - // -- TIMER - DELETE_PAYMENT_TOKEN_TIMER_FAILURE(4001, "Impossible delete payment token timer", "Error while trying to delete payment token timer. Impossible finish operation for payment tokens: {0}.", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred wile trying to delete timer on payment tokens (timer for ClosePayment detection). This error may cause side effects such as sending ko receipt due to timer timeout."); + // -- STATUS RECEIPTS-RT + CHANGE_STATUS_TO_PAYING_FAILURE(4001, "Receipt status update error", "Error while trying to update receipt status to PAYING at the time of DELETE receipt/time call.", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while trying to update receipt status to PAYING at the time of DELETE receipt/timer i.e. ClosePayment inbound. This error may cause side effects such as sending ko if paSendRTV2 (ie.SendPaymentOutcome sending) is received with a n-hour delay."); private final Integer code; From 45fed783b610cec2629f7402261b21c6d7949322 Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Mon, 2 Dec 2024 16:32:03 +0100 Subject: [PATCH 11/12] [PAGOPA-2389] refactoring --- .../wispconverter/controller/ReceiptTimerController.java | 2 +- .../wispconverter/exception/AppErrorCodeMessageEnum.java | 5 ++--- .../repository/model/enumz/ReceiptStatusEnum.java | 4 +--- 3 files changed, 4 insertions(+), 7 deletions(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index b4f2f922..772e3c8a 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -86,7 +86,7 @@ public void deleteTimer(@RequestParam() String paymentTokens) { sessionDataDTO.getAllRPTs().forEach(rtReceiptCosmosService::updateStatusToPaying); } } catch (Exception e) { - throw new AppException(AppErrorCodeMessageEnum.CHANGE_STATUS_TO_PAYING_FAILURE, e); + throw new AppException(AppErrorCodeMessageEnum.RECEIPT_RT_STATUS_TO_PAYING_FAILURE, e); } finally { // cancel scheduled message if PAYING status transition goes in exception receiptTimerService.cancelScheduledMessage(tokens); diff --git a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java index 17ded131..df9552fe 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/exception/AppErrorCodeMessageEnum.java @@ -47,6 +47,7 @@ public enum AppErrorCodeMessageEnum { RECEIPT_KO_NOT_GENERATED_BUT_MAYBE_RESCHEDULED(1409, "KO Receipt not generated", "Error while generating KO receipt. It is not possible to generate the receipt and it could be scheduled for a next send.", HttpStatus.UNPROCESSABLE_ENTITY, "An error occurred while generating a negative RT (aka a KO receipt). The receipt could be sent lately to creditor institution but for better understanding the cause, please use the Technical Support's APIs."), RECEIPT_OK_NOT_GENERATED_BUT_MAYBE_RESCHEDULED(1410, "OK Receipt not generated", "Error while generating OK receipt. It is not possible to generate the receipt and it could be scheduled for a next send.", HttpStatus.UNPROCESSABLE_ENTITY, "An error occurred while generating a positive RT (aka a OK receipt). The receipt could be sent lately to creditor institution but for better understanding the cause, please use the Technical Support's APIs."), RECEIPT_GENERATION_ERROR_DEAD_LETTER(1411, "Receipt generation not completed", "Error while generating receipt. The creditor institution sent an error response related to the sent RT: [Outcome: {0}, Fault code: {1}, Fault string: {2}, Fault description: {3}].", HttpStatus.UNPROCESSABLE_ENTITY, "An error occurred while generating an RT (aka a receipt). Specifically, the creditor institution response status has not been recognized, for this reason the RT has been placed in the dead letter container."), + RECEIPT_RT_STATUS_TO_PAYING_FAILURE(1412, "Receipt status update error", "Error while trying to update receipt status to PAYING at the time of DELETE receipt/time call.", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while trying to update receipt status to PAYING at the time of DELETE receipt/timer i.e. ClosePayment inbound. This error may cause side effects such as sending ko if paSendRTV2 (ie.SendPaymentOutcome sending) is received with a n-hour delay."), // --- DB and storage interaction errors --- PERSISTENCE_SAVING_RE_ERROR(2000, "Impossible to save event", "Error while trying to store an event in Registro Eventi. Impossible to store event: {0}.", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred wile trying to store a new event in the Registro Eventi storage. The error is somewhat related to a persistence problem of the used storage and in the majority of the cases is temporary (maybe a 429 HTTP code). This error currently does not blocks the entire flow but, for better understanding the cause, please execute a search in the log provider (Application Insights, Kibana, etc)."), PERSISTENCE_RPT_NOT_FOUND(2001, "RPT not found", "Error while retrieving RPT. RPT with sessionId [{0}] not found.", HttpStatus.NOT_FOUND, "An error occurred while trying to retrieve the RPT content saved in storage by WISP SOAP Converter. This can be related either with the use of a wrong sessionId or a missed persistence from WISP SOAP Converter, so it is better to analyze the entire flow using Technical Support's APIs. This block totally the conversion of the RPTs in GPD's payment positions, so the whole process is discarded."), @@ -64,9 +65,7 @@ public enum AppErrorCodeMessageEnum { CLIENT_CHECKOUT(3004, "Checkout error", "Error while communicating with Checkout service. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with Checkout backend internal service in order to send a request about the cart creation. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), CLIENT_PAAINVIART(3005, "PaaInviaRT error", "Error while communicating with Station for paaInviaRT service. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with the creditor institution's station (external service) in order to sending of a paaInviaRT request. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), CLIENT_CARTSESSION_CACHING(3006, "Cart caching client error", "Error while communicating with cart caching API. {0}", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while communicating with an internal service endpoint dedicated to storing internal cache for handle unique session on cart. It can be related to any client problem, so the best way to handle this is to use the Technical Support's APIs in order to find the cause."), - UNKNOWN(0, "Unknown", "Unknown error", HttpStatus.INTERNAL_SERVER_ERROR, null), - // -- STATUS RECEIPTS-RT - CHANGE_STATUS_TO_PAYING_FAILURE(4001, "Receipt status update error", "Error while trying to update receipt status to PAYING at the time of DELETE receipt/time call.", HttpStatus.INTERNAL_SERVER_ERROR, "An error occurred while trying to update receipt status to PAYING at the time of DELETE receipt/timer i.e. ClosePayment inbound. This error may cause side effects such as sending ko if paSendRTV2 (ie.SendPaymentOutcome sending) is received with a n-hour delay."); + UNKNOWN(0, "Unknown", "Unknown error", HttpStatus.INTERNAL_SERVER_ERROR, null); private final Integer code; diff --git a/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java b/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java index 97591993..2cb3f6a1 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java +++ b/src/main/java/it/gov/pagopa/wispconverter/repository/model/enumz/ReceiptStatusEnum.java @@ -2,9 +2,7 @@ public enum ReceiptStatusEnum { REDIRECT, - // PAYING status track the execution flow between - // (DELETE receipt/timer, POST receipt/ko call), -> e.g. ClosePayment inbound and (ClosePayment KO or SPR KO) - // (DELETE receipt/timer, POST receipt/ok call) -> e.g. ClosePayment inbound and paSendRTV2 + // PAYING status cover the time between DELETE receipt/timer and (POST receipt/ok or receipt/ko) calls PAYING, SENDING, SCHEDULED, From 3c15060483ca9ac44c0b625ab320e32e3632392b Mon Sep 17 00:00:00 2001 From: Angelo Caporaso <56113767+cap-ang@users.noreply.github.com> Date: Tue, 17 Dec 2024 11:00:55 +0100 Subject: [PATCH 12/12] [PAGOPA-2389] refactoring --- .../pagopa/wispconverter/controller/ReceiptTimerController.java | 2 ++ .../pagopa/wispconverter/service/RtReceiptCosmosService.java | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java index 772e3c8a..f16f09a6 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java +++ b/src/main/java/it/gov/pagopa/wispconverter/controller/ReceiptTimerController.java @@ -85,6 +85,8 @@ public void deleteTimer(@RequestParam() String paymentTokens) { // Update receipts-rt status to PAYING sessionDataDTO.getAllRPTs().forEach(rtReceiptCosmosService::updateStatusToPaying); } + } catch (AppException appException) { + throw appException; } catch (Exception e) { throw new AppException(AppErrorCodeMessageEnum.RECEIPT_RT_STATUS_TO_PAYING_FAILURE, e); } finally { diff --git a/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java b/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java index 7fcd2815..0d3449ec 100644 --- a/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java +++ b/src/main/java/it/gov/pagopa/wispconverter/service/RtReceiptCosmosService.java @@ -103,7 +103,7 @@ public boolean updateStatusToPaying(RPTContentDTO rptContentDTO) { log.debug("Receipt-rt with id = {} has been updated with status PAYING", rtEntity.getId()); return true; } - log.warn("Attempt to update receipt-rt with id = {} has been failed because is the status is {}", + log.warn("Attempt to update receipt-rt with id = {} has been failed because the current status is {}", rtEntity.getId(), rtEntity.getReceiptStatus()); }