Skip to content

Commit

Permalink
[PAGOPA-2389] refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
cap-ang committed Dec 2, 2024
1 parent 8f8a4e0 commit 45fed78
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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."),
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 45fed78

Please sign in to comment.