diff --git a/src/domains/nodo-app/03_apim_named_values.tf b/src/domains/nodo-app/03_apim_named_values.tf
new file mode 100644
index 0000000000..024107bda8
--- /dev/null
+++ b/src/domains/nodo-app/03_apim_named_values.tf
@@ -0,0 +1,81 @@
+# decoupler named values
+
+# named value containing primitive names for routing algorithm
+resource "azurerm_api_management_named_value" "node_decoupler_primitives" {
+ name = "node-decoupler-primitives"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "node-decoupler-primitives"
+ value = var.node_decoupler_primitives
+}
+
+
+resource "azurerm_api_management_named_value" "nexi_nodo_address" {
+ name = "nexi-nodo-address"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "nexi-nodo-address"
+ value = var.nexi_nodo_address
+}
+
+resource "azurerm_api_management_named_value" "nexi_nodo_pg_address" {
+ name = "nexi-nodo-pg-address"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "nexi-nodo-pg-address"
+ value = var.nexi_nodo_pg_address
+}
+
+resource "azurerm_api_management_named_value" "pagopa_nodo_address" {
+ name = "pagopa-nodo-address"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "pagopa-nodo-address"
+ value = var.nexi_nodo_pg_address
+}
+
+resource "azurerm_api_management_named_value" "nexi_nodo_weight" {
+ name = "nexi-nodo-weight"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "nexi-nodo-weight"
+ value = var.nexi_nodo_weight
+}
+
+resource "azurerm_api_management_named_value" "pagopa_nodo_weight" {
+ name = "pagopa-nodo-weight"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "pagopa-nodo-weight"
+ value = var.pagopa_nodo_weight
+}
+resource "azurerm_api_management_named_value" "nexi_pg_nodo_weight" {
+ name = "nexi-pg-nodo-weight"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "nexi-pg-nodo-weight"
+ value = var.nexi_pg_nodo_weight
+}
+
+resource "azurerm_api_management_named_value" "nexi_nodo_priority" {
+ name = "nexi-nodo-priority"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "nexi-nodo-priority"
+ value = var.nexi_nodo_priority
+}
+
+resource "azurerm_api_management_named_value" "pagopa_nodo_priority" {
+ name = "pagopa-nodo-priority"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "pagopa-nodo-priority"
+ value = var.pagopa_nodo_priority
+}
+resource "azurerm_api_management_named_value" "nexi_pg_nodo_priority" {
+ name = "nexi-pg-nodo-priority"
+ api_management_name = data.azurerm_api_management.apim.name
+ resource_group_name = local.pagopa_apim_rg
+ display_name = "nexi-pg-nodo-priority"
+ value = var.nexi_pg_nodo_priority
+}
diff --git a/src/domains/nodo-app/10_apim_nodo_services_decoupler.tf b/src/domains/nodo-app/10_apim_nodo_services_decoupler.tf
new file mode 100644
index 0000000000..f7e3c16e1c
--- /dev/null
+++ b/src/domains/nodo-app/10_apim_nodo_services_decoupler.tf
@@ -0,0 +1,151 @@
+###############
+## Decoupler ##
+###############
+
+# convert configuration from JSON to XML
+resource "null_resource" "decoupler_configuration_from_json_2_xml" {
+
+ triggers = {
+ "changes-in-config-decoupler" : sha1(file("./api_product/nodo_pagamenti_api/decoupler/cfg/${var.env}/decoupler_configuration.json"))
+ }
+ provisioner "local-exec" {
+ command = "sh ./api_product/nodo_pagamenti_api/decoupler/cfg/decoupler_configurator.sh ${var.env}"
+ }
+}
+
+
+# fragment for loading configuration inside policy
+# https://github.com/hashicorp/terraform-provider-azurerm/issues/17016#issuecomment-1314991599
+# https://learn.microsoft.com/en-us/azure/templates/microsoft.apimanagement/2022-04-01-preview/service/policyfragments?pivots=deployment-language-terraform
+resource "terraform_data" "sha256_decoupler_configuration" {
+ input = sha256(file("./api_product/nodo_pagamenti_api/decoupler/cfg/${var.env}/decoupler-configuration.xml"))
+}
+resource "azapi_resource" "decoupler_configuration" {
+
+ depends_on = [null_resource.decoupler_configuration_from_json_2_xml]
+
+ type = "Microsoft.ApiManagement/service/policyFragments@2022-04-01-preview"
+ name = "decoupler-configuration"
+ parent_id = data.azurerm_api_management.apim.id
+ ignore_missing_property = false
+ body = jsonencode({
+ properties = {
+ description = "Configuration of NDP decoupler"
+ format = "rawxml"
+ value = file("./api_product/nodo_pagamenti_api/decoupler/cfg/${var.env}/decoupler-configuration.xml")
+ }
+ })
+
+ lifecycle {
+ ignore_changes = [output]
+ }
+}
+
+# decoupler algorithm fragment
+resource "terraform_data" "sha256_decoupler_algorithm" {
+ input = sha256(file("./api_product/nodo_pagamenti_api/decoupler/decoupler-algorithm.xml"))
+}
+resource "azapi_resource" "decoupler_algorithm" {
+ type = "Microsoft.ApiManagement/service/policyFragments@2022-04-01-preview"
+ name = "decoupler-algorithm"
+ parent_id = data.azurerm_api_management.apim.id
+ ignore_missing_property = false
+ body = jsonencode({
+ properties = {
+ description = "Logic about NPD decoupler"
+ format = "rawxml"
+ value = file("./api_product/nodo_pagamenti_api/decoupler/decoupler-algorithm.xml")
+ }
+ })
+
+ lifecycle {
+ ignore_changes = [output]
+ }
+}
+
+# fragment for managing inbound policy if primitive is activatePaymentV2
+resource "terraform_data" "sha256_decoupler_activate_inbound" {
+ input = sha256(file("./api_product/nodo_pagamenti_api/decoupler/decoupler-activate-inbound.xml"))
+}
+resource "azapi_resource" "decoupler_activate_inbound" {
+ type = "Microsoft.ApiManagement/service/policyFragments@2022-04-01-preview"
+ name = "decoupler-activate-inbound"
+ parent_id = data.azurerm_api_management.apim.id
+ ignore_missing_property = false
+ body = jsonencode({
+ properties = {
+ description = "Inbound logic for Activate primitive of NDP decoupler"
+ format = "rawxml"
+ value = file("./api_product/nodo_pagamenti_api/decoupler/decoupler-activate-inbound.xml")
+ }
+ })
+
+ lifecycle {
+ ignore_changes = [output]
+ }
+}
+
+# fragment for managing outbound policy if primitive is activatePayment or activateIO
+resource "terraform_data" "sha256_decoupler_activate_outbound" {
+ input = sha256(file("./api_product/nodo_pagamenti_api/decoupler/decoupler-activate-outbound.xml"))
+}
+resource "azapi_resource" "decoupler_activate_outbound" {
+ type = "Microsoft.ApiManagement/service/policyFragments@2022-04-01-preview"
+ name = "decoupler-activate-outbound"
+ parent_id = data.azurerm_api_management.apim.id
+ ignore_missing_property = false
+ body = jsonencode({
+ properties = {
+ description = "Outbound logic for Activate primitive of NDP decoupler"
+ format = "rawxml"
+ value = file("./api_product/nodo_pagamenti_api/decoupler/decoupler-activate-outbound.xml")
+ }
+ })
+
+ lifecycle {
+ ignore_changes = [output]
+ }
+}
+
+resource "terraform_data" "sha256_on_erro_soap_handler" {
+ input = sha256(file("./api_product/nodo_pagamenti_api/on_error_soap_req.xml"))
+}
+resource "azapi_resource" "on_erro_soap_handler" {
+ type = "Microsoft.ApiManagement/service/policyFragments@2022-04-01-preview"
+ name = "onerror-soap-req"
+ parent_id = data.azurerm_api_management.apim.id
+
+ body = jsonencode({
+ properties = {
+ description = "On error SOAP request"
+ format = "rawxml"
+ value = file("./api_product/nodo_pagamenti_api/on_error_soap_req.xml")
+ }
+ })
+
+ lifecycle {
+ ignore_changes = [output]
+ }
+}
+
+# fragment for managing outbound policy for nodoInviaRPT and nodoInviaCarrelloRPT
+resource "terraform_data" "sha256_nodoinviarpt_wisp_nodoinviacarrellorpt_outbound_policy" {
+ input = sha256(file("./api/nodopagamenti_api/nodoPerPa/v1/wisp_nodoInviaRPT_nodoInviaCarrelloRPT_outbound_policy.xml"))
+}
+resource "azapi_resource" "wisp_nodoinviarpt_nodoinviacarrellorpt_outbound_policy" {
+ type = "Microsoft.ApiManagement/service/policyFragments@2022-04-01-preview"
+ name = "wisp-nodoinviarpt-nodoinviacarrellorpt-outbound"
+ parent_id = data.azurerm_api_management.apim.id
+ ignore_missing_property = false
+ body = jsonencode({
+ properties = {
+ description = "Outbound policy for nodoInviaRPT / nodoInviaCarrelloRPT regarding WISP"
+ format = "rawxml"
+ value = file("./api/nodopagamenti_api/nodoPerPa/v1/wisp_nodoInviaRPT_nodoInviaCarrelloRPT_outbound_policy.xml")
+ }
+ })
+
+ lifecycle {
+ ignore_changes = [output]
+ }
+}
diff --git a/src/domains/nodo-app/99_main.tf b/src/domains/nodo-app/99_main.tf
index 8e123dd751..bc95300e1b 100644
--- a/src/domains/nodo-app/99_main.tf
+++ b/src/domains/nodo-app/99_main.tf
@@ -30,6 +30,7 @@ terraform {
}
provider "azurerm" {
+ skip_provider_registration = true
features {
key_vault {
purge_soft_delete_on_destroy = false
diff --git a/src/domains/nodo-app/99_variables.tf b/src/domains/nodo-app/99_variables.tf
index 0e36cb5ec5..293bc5d2e3 100644
--- a/src/domains/nodo-app/99_variables.tf
+++ b/src/domains/nodo-app/99_variables.tf
@@ -382,9 +382,54 @@ variable "apim_nodo_decoupler_enable" {
variable "node_decoupler_primitives" {
type = string
description = "Node decoupler primitives"
- default = "nodoChiediNumeroAvviso,nodoChiediCatalogoServizi,nodoAttivaRPT,nodoVerificaRPT,nodoChiediInformativaPA,nodoChiediInformativaPSP,nodoChiediTemplateInformativaPSP,nodoPAChiediInformativaPA,nodoChiediSceltaWISP,demandPaymentNotice"
+ default = "nodoChiediNumeroAvviso,nodoChiediCatalogoServizi,nodoChiediInformativaPA,nodoChiediInformativaPSP,nodoChiediTemplateInformativaPSP,nodoPAChiediInformativaPA,nodoChiediSceltaWISP,demandPaymentNotice"
}
+variable "nexi_nodo_address" {
+ type = string
+ description = "Nexi NdP address, used in decoupler configuration"
+}
+
+variable "nexi_nodo_pg_address" {
+ type = string
+ description = "Nexi NdP PostgreSQL address, used in decoupler configuration"
+}
+
+variable "nexi_nodo_weight" {
+ type = number
+ description = "Nexi NdP routing weight (0-100)"
+ default = 100
+}
+
+variable "pagopa_nodo_weight" {
+ type = number
+ description = "PagoPA NdP routing weight (0-100)"
+ default = 0
+}
+
+variable "nexi_pg_nodo_weight" {
+ type = number
+ description = "Nexi PostgreSQL NdP routing priority"
+ default = 0
+}
+
+variable "nexi_nodo_priority" {
+ type = number
+ description = "Nexi NdP routing priority"
+ default = 3
+}
+
+variable "pagopa_nodo_priority" {
+ type = number
+ description = "PagoPA NdP routing priority"
+ default = 1
+}
+
+variable "nexi_pg_nodo_priority" {
+ type = number
+ description = "Nexi PostgreSQL NdP routing priority"
+ default = 2
+}
variable "nodo_pagamenti_subkey_required" {
type = bool
diff --git a/src/core/api/nodopagamenti_api/nodoPerPa/v1/wisp_nodoInviaRPT_nodoInviaCarrelloRPT_outbound_policy.xml b/src/domains/nodo-app/api/nodopagamenti_api/nodoPerPa/v1/wisp_nodoInviaRPT_nodoInviaCarrelloRPT_outbound_policy.xml
similarity index 100%
rename from src/core/api/nodopagamenti_api/nodoPerPa/v1/wisp_nodoInviaRPT_nodoInviaCarrelloRPT_outbound_policy.xml
rename to src/domains/nodo-app/api/nodopagamenti_api/nodoPerPa/v1/wisp_nodoInviaRPT_nodoInviaCarrelloRPT_outbound_policy.xml
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/base_policy.xml.tpl b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/base_policy.xml.tpl
new file mode 100644
index 0000000000..ad4e036413
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/base_policy.xml.tpl
@@ -0,0 +1,155 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ @{
+ // get request body content
+ XElement doc = context.Request.Body.As(preserveContent: true);
+ try {
+ XElement body = doc.Descendants(doc.Name.Namespace + "Body").FirstOrDefault();
+ // get primitive
+ XElement primitive = (XElement) body.FirstNode;
+ var soapAction = (string)context.Variables["soapAction"];
+ var primitives = new string[]{"nodoInviaRPT", "nodoInviaCarrelloRPT"};
+ if (primitives.Contains(soapAction)) {
+ // get prev field
+ XElement password = primitive.Descendants("password").FirstOrDefault();
+ String passwordValue = ((string)context.Variables["password"]);
+ if (password != null) {
+ password.Value = passwordValue;
+ } else {
+ password = XElement.Parse("" + passwordValue + "");
+ primitive.AddFirst(password);
+ }
+ }
+ else {
+ // get prev field
+ XElement prevField = primitive.Descendants("idChannel").FirstOrDefault();
+ if (prevField == null) {
+ prevField = primitive.Descendants("identificativoCanale").FirstOrDefault();
+ }
+ if (prevField == null) {
+ prevField = primitive.Descendants("identificativoStazioneIntermediarioPA").FirstOrDefault();
+ }
+ // if password exists then set default password
+ // otherwise add a password field with default value
+ XElement password = primitive.Descendants("password").FirstOrDefault();
+ String passwordValue = ((string) context.Variables["password"]);
+ if (password != null) {
+ password.Value = passwordValue;
+ } else {
+ password = XElement.Parse("" + passwordValue + "");
+ prevField.AddAfterSelf(password);
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ // do nothing
+ }
+ return doc.ToString();;
+ }
+
+
+ {{xForwardedFor}}
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ [COUNT] Request
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/decoupler_configurator.sh b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/decoupler_configurator.sh
new file mode 100644
index 0000000000..f9fc67c62d
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/decoupler_configurator.sh
@@ -0,0 +1,11 @@
+#!/usr/bin/env bash
+
+env=$1
+file="./api_product/nodo_pagamenti_api/decoupler/cfg/$env/decoupler_configuration.json"
+destination="./api_product/nodo_pagamenti_api/decoupler/cfg/$env/decoupler-configuration.xml"
+
+
+new_conf=$(cat $file | jq '@json' | sed "s;https://;https:\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\/;g" | sed "s;http://;http:\\\\\\\\\\\\\\\\\\/\\\\\\\\\\\\\\\\\\/;g" )
+echo "
+
+" > $destination
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/dev/decoupler-configuration.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/dev/decoupler-configuration.xml
new file mode 100644
index 0000000000..6ff24e54b2
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/dev/decoupler-configuration.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/dev/decoupler_configuration.json b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/dev/decoupler_configuration.json
new file mode 100644
index 0000000000..fbca9157b6
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/dev/decoupler_configuration.json
@@ -0,0 +1,29 @@
+[
+ {
+ "node_id": "NDP002SIT",
+ "description": "Nodo OnCloud Nexi",
+ "node_uri": "\\{\\{nexi-nodo-address\\}\\}",
+ "routing": "\\{\\{nexi-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": [],
+ "list_priority": "\\{\\{nexi-nodo-priority\\}\\}"
+ },
+ {
+ "node_id": "NDP001DEV",
+ "description": "Nodo Azure PagoPA",
+ "node_uri": "\\{\\{pagopa-nodo-address\\}\\}",
+ "routing": "{\\{\\pagopa-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": ["15376371009"],
+ "list_priority": "{\\{\\pagopa-nodo-priority\\}\\}"
+ },
+ {
+ "node_id": "NDP004IT",
+ "description": "Nodo PostgreSQL OnPrem Nexi",
+ "node_uri": "\\{\\{nexi-nodo-pg-address\\}\\}",
+ "routing": "\\{\\{nexi-pg-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": ["88888888888"],
+ "list_priority": "\\{\\{nexi-pg-nodo-priority\\}\\}"
+ }
+]
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/prod/decoupler-configuration.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/prod/decoupler-configuration.xml
new file mode 100644
index 0000000000..849b1656a9
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/prod/decoupler-configuration.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/prod/decoupler_configuration.json b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/prod/decoupler_configuration.json
new file mode 100644
index 0000000000..8e1b77e72b
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/prod/decoupler_configuration.json
@@ -0,0 +1,29 @@
+[
+ {
+ "node_id": "NDP003PROD",
+ "description": "Nexi on premise PROD",
+ "node_uri": "\\{\\{nexi-nodo-address\\}\\}",
+ "routing": "\\{\\{nexi-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": [],
+ "list_priority": 3
+ },
+ {
+ "node_id": "NDP001PROD",
+ "description": "Nodo Azure PagoPA",
+ "node_uri": "\\{\\{pagopa-nodo-address\\}\\}",
+ "routing": "{\\{\\pagopa-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": ["00874410376"],
+ "list_priority": 1
+ },
+ {
+ "node_id": "NDP004PROD",
+ "description": "Nodo PostgreSQL OnPrem Nexi",
+ "node_uri": "\\{\\{nexi-nodo-pg-address\\}\\}",
+ "routing": "\\{\\{nexi-pg-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": ["96289850586"],
+ "list_priority": 2
+ }
+]
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/uat/decoupler-configuration.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/uat/decoupler-configuration.xml
new file mode 100644
index 0000000000..e9fa27737a
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/uat/decoupler-configuration.xml
@@ -0,0 +1,3 @@
+
+
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/uat/decoupler_configuration.json b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/uat/decoupler_configuration.json
new file mode 100644
index 0000000000..b5fc2642cd
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/cfg/uat/decoupler_configuration.json
@@ -0,0 +1,29 @@
+[
+ {
+ "node_id": "NDP002UAT",
+ "description": "Nodo OnCloud Nexi",
+ "node_uri": "\\{\\{nexi-nodo-address\\}\\}",
+ "routing": "\\{\\{nexi-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": [],
+ "list_priority": 3
+ },
+ {
+ "node_id": "NDP001UAT",
+ "description": "Nodo Azure PagoPA",
+ "node_uri": "\\{\\{pagopa-nodo-address\\}\\}",
+ "routing": "{\\{\\pagopa-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": ["80023530167"],
+ "list_priority": 1
+ },
+ {
+ "node_id": "NDP004UAT",
+ "description": "Nodo PostgreSQL OnPrem Nexi",
+ "node_uri": "\\{\\{nexi-nodo-pg-address\\}\\}",
+ "routing": "\\{\\{nexi-pg-nodo-weight\\}\\}",
+ "broker_psps": [],
+ "cis": ["80005570561"],
+ "list_priority": 2
+ }
+]
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-activate-inbound.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-activate-inbound.xml
new file mode 100644
index 0000000000..7dd00cefcd
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-activate-inbound.xml
@@ -0,0 +1,93 @@
+
+
+
+
+
+
+
+
+
+
+
+ (preserveContent: true);
+ XElement body = doc.Descendants(doc.Name.Namespace + "Body").FirstOrDefault();
+ XElement primitive = (XElement) body.FirstNode;
+ string channelId = (string) primitive.Descendants("idChannel").FirstOrDefault();
+
+ var soapAction = (string)context.Variables["soapAction"];
+ return activatePayment.Contains(soapAction) && ecommerceChannels.Contains(channelId);
+ } catch (Exception e) {
+ return false;
+ }
+ }">
+
+
+
+
+
+
+
+ text/xml
+
+
+
+
+ KO
+
+ PPT_WISP_SESSIONE_SCONOSCIUTA
+ User session expired.
+ NodoDeiPagamentiSPC
+ Too many times occurred between Checkout redirect and activatePaymentNoticeV2
+
+
+
+
+ ]]>
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-activate-outbound.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-activate-outbound.xml
new file mode 100644
index 0000000000..81ea964950
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-activate-outbound.xml
@@ -0,0 +1,170 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ {{wisp-dismantling-converter-base-url}}/receipt/timer
+ POST
+
+ application/json
+
+ @{
+ var paymentTokenObj = JObject.Parse((string)context.Variables["wisp-paymentToken-obj"]);
+ paymentTokenObj["expirationTime"] = JToken.FromObject(context.Variables["paymentToken-expirationTime"]);
+ return paymentTokenObj.ToString();
+ }
+
+
+
+
+
+
+
+ @{
+ var requestData = JObject.Parse((string) context.Variables["requestData"]);
+ var noticeNumber = requestData.ContainsKey("noticeNumber") ? (string) requestData["noticeNumber"] : "";
+ var ci = requestData.ContainsKey("ci") ? (string) requestData["ci"] : "";
+ string error = "[WRN-DASH-WISP] " +
+ "noticeNumer :" + noticeNumber + " ci: "+ ci;
+ return error;
+ }
+
+
+
+
+
+
+
+
+
+
+
+
+ (preserveContent: true);
+ XElement body = response.Descendants(response.Name.Namespace + "Body").FirstOrDefault();
+ XElement primitive = (XElement) body.FirstNode;
+ outcomeWfespCart = (string) primitive.Descendants("esitoComplessivoOperazione").FirstOrDefault();
+ } catch (Exception e)
+ {
+ // do nothing
+ }
+ return outcomeWfespCart;
+ }" />
+
+
+
+
+
+ text/xml
+
+
+
+
+
+ OK
+ {{context.Variables["wfesp_fixed_url_completed"]}}
+
+
+
+
+
+
+
+
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-algorithm.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-algorithm.xml
new file mode 100644
index 0000000000..07e39dc30c
--- /dev/null
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/decoupler/decoupler-algorithm.xml
@@ -0,0 +1,422 @@
+
+
+
+
+
+
+
+
+ (int)obj["routing"]));
+ return sorted.ToString();
+ }" />
+
+
+ ("baseUrl", "");
+ }" />
+
+
+
+
+ (int)obj["list_priority"]));
+ return sorted.ToString();
+ }" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ("baseUrl", "NONE");
+ return new JObject(
+ new JProperty("nodeId", baseNodeId),
+ new JProperty("nodeUri", baseUrl),
+ new JProperty("ttl", 3600)
+ ).ToString();
+ }" />
+
+
+
+
+
+
+
+
+
+ ("enable_nm3_switch", "").Equals("true");
+ if (enable_nm3_switch) {
+ foreach (JObject item in configuration) {
+ bool brokerPspFound = false;
+ bool ciFound = false;
+ var brokerPsps = item.GetValue("broker_psps").ToList();
+ var cis = item.GetValue("cis").ToList();
+ if (brokerPsps.Count == 0 || (brokerPsps.Count > 0 && brokerPsps.Contains(requestData.GetValue("brokerPsp")))) {
+ brokerPspFound = true;
+ }
+ if (cis.Count == 0 || (cis.Count > 0 && cis.Contains(requestData.GetValue("ci")))) {
+ ciFound = true;
+ }
+ if (brokerPspFound && ciFound) {
+ return new JObject(
+ new JProperty("nodeId", item.GetValue("node_id").ToString()),
+ new JProperty("nodeUri", item.GetValue("node_uri").ToString()),
+ new JProperty("ttl", requestData.GetValue("ttl"))
+ ).ToString();
+ }
+ }
+ }
+ var baseNodeId = context.Variables.GetValueOrDefault("baseNodeId", "");
+ var baseUrl = context.Variables.GetValueOrDefault("baseUrl", "");
+ return new JObject(
+ new JProperty("nodeId", baseNodeId),
+ new JProperty("nodeUri", baseUrl),
+ new JProperty("ttl", requestData.GetValue("ttl"))
+ ).ToString();
+ }" />
+
+
+
+
+ ("baseUrl", "");
+ return target.Equals("NONE") ? defaultBaseUrl : target;
+ }" />
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ ("baseNodeId", "NONE");
+ var baseUrl = context.Variables.GetValueOrDefault("baseUrl", "NONE");
+ return new JObject(
+ new JProperty("nodeId", baseNodeId),
+ new JProperty("nodeUri", baseUrl),
+ new JProperty("ttl", 3600)
+ ).ToString();
+ }" />
+
+
+
+
+ ("baseUrl", "");
+ return target.Equals("NONE") ? defaultBaseUrl : target;
+ }" />
+
+
+
+
+
+
+
+
+
+
+
+ (preserveContent: true);
+ try {
+ XElement body = doc.Descendants(doc.Name.Namespace + "Body").FirstOrDefault();
+ XElement primitive = (XElement) body.FirstNode;
+ string channelId = (string) primitive.Descendants("identificativoCanale").FirstOrDefault();
+ string pspBrokerId = (string) primitive.Descendants("identificativoIntermediarioPSP").FirstOrDefault();
+ // check if nodoInviaRPT or nodoInviaCarrelloRPT, to set ci value correctly
+ XElement header = doc.Descendants(doc.Name.Namespace + "Header").FirstOrDefault();
+ string ciId = "";
+ // listaRPT is set only in nodoInviaCarrelloRPT
+ // in this case we retrieve the ci from the first RPT (primaryCI)
+ if(primitive.Descendants("listaRPT").FirstOrDefault() != null) {
+ XElement listaRPT = primitive.Descendants("listaRPT").FirstOrDefault();
+ XElement firstRPT = listaRPT.Descendants("elementoListaRPT").FirstOrDefault();
+ ciId = (string) firstRPT.Descendants("identificativoDominio").FirstOrDefault();
+ } else {
+ ciId = (string) header.Descendants("identificativoDominio").FirstOrDefault();
+ }
+ // check cis only if whitelist contains at least one element
+ // variable isCiAndStationOk set to true, if ci and station not whitelisted then will
+ // be set to false
+ bool isCiAndStationOk = true;
+ if (cis.Count() > 0) {
+ // check if ciId is whitelisted
+ if(cis.Contains(ciId)) {
+ // check if ci relation with some station is present
+ if(stationsList.Contains(ciId + "-")) {
+ // if present, check if ci-station relation is whitelisted
+ string stationId = (string) header.Descendants("identificativoStazioneIntermediarioPA").FirstOrDefault();
+ if(!stations.Contains(ciId + "-" + stationId)) {
+ isCiAndStationOk = false;
+ }
+ }
+ } else {
+ isCiAndStationOk = false;
+ }
+ }
+ // check if 'tipoVersamento' is accepted for WISP dismantling only if the request is a 'nodoInviaRPT'
+ bool isNodoInviaRptWithAllowedPaymentType = false;
+ bool isNodoInviaRPT = "nodoInviaRPT".Equals((string)context.Variables["soapAction"]);
+ if (isNodoInviaRPT) {
+ byte[] rptAsBytearray = Convert.FromBase64String((string) primitive.Descendants("rpt").FirstOrDefault());
+ string rptAsString = System.Text.Encoding.UTF8.GetString(rptAsBytearray);
+ XElement rpt = XElement.Parse(rptAsString);
+ string rptPaymentType = rpt.Descendants(rpt.Name.Namespace + "tipoVersamento").FirstOrDefault()?.Value;
+ string[] paymentTypes = ((string) context.Variables["wisp_whitelisted_nodoinviarpt_paymenttypes"]).Split(',');
+ isNodoInviaRptWithAllowedPaymentType = paymentTypes.Contains(rptPaymentType);
+ }
+ bool isValidNodoInviaRptOrNodoInviaCarrelloRPT = !isNodoInviaRPT || isNodoInviaRptWithAllowedPaymentType;
+ // last, check all the conditions and return the final result
+ isWhitelisted = (brokersWhitelisted || brokers.Contains(pspBrokerId)) &&
+ (channelsWhitelisted || channels.Contains(channelId)) &&
+ isCiAndStationOk && isValidNodoInviaRptOrNodoInviaCarrelloRPT;
+ } catch (Exception e) {
+ // do nothing
+ }
+
+ return isWhitelisted;
+ }" />
+
+ ("is_whitelisted", false) )">
+
+
+
+
+
+
+
+
+ ("receipt_query_param", "NONE").Equals("NONE") )">
+
+
+
+ @(context.Variables["wisp_converter_url"] + "/receipt?" + context.Variables["receipt_query_param"])
+ GET
+
+ application/json
+
+
+
+
+
+
+
+
+
+
+
+
+ (preserveContent: true);
+ XElement body = doc.Descendants(doc.Name.Namespace + "Body").FirstOrDefault();
+ XElement primitive = (XElement) body.FirstNode;
+ string channelId = (string) primitive.Descendants("identificativoCanale").FirstOrDefault();
+ // listaRPT is set only in nodoInviaCarrelloRPT
+ // we want to act only if there is nodoInviaCarrello
+ isWfesp = wfespChannels.Contains(channelId);
+ } catch (Exception e) {
+ // do nothing
+ }
+ }
+ return isWfesp;
+ }" />
+
diff --git a/src/domains/nodo-app/api_product/nodo_pagamenti_api/on_error_soap_req.xml b/src/domains/nodo-app/api_product/nodo_pagamenti_api/on_error_soap_req.xml
index 30912c736f..ce4c91ef2c 100644
--- a/src/domains/nodo-app/api_product/nodo_pagamenti_api/on_error_soap_req.xml
+++ b/src/domains/nodo-app/api_product/nodo_pagamenti_api/on_error_soap_req.xml
@@ -1,15 +1,16 @@
-
+ @((string) context.Variables["renewrequest"])
-
+ execute on-error request
+
@{return ((string) context.Variables["baseUrl"]+"/webservices/input"); }
POST
text/xml
- @{
- return (string) context.Variables["renewrequest"];
+ @{
+ return (string) context.Variables["renewrequest"];
}
(preserveContent: true))" />
@@ -17,11 +18,35 @@
text/xml
- @{
+ @{
string message = (string)context.Variables["leggirisposta"];
- return message;
+ return message;
}
+
+
+ @{
+ string error = "[ALERT][ON-SOAP-ERROR][REASON] A policy error has occurred, " +
+ "Reason:" + context.LastError.Reason;
+ return error;
+ }
+
+
+ @{
+ string error = "[ALERT][ON-SOAP-ERROR][STACK-TRACE] A policy error has occurred, " +
+ "Source: " + context.LastError.Source + ", " +
+ "Reason: " + context.LastError.Reason + ", " +
+ "Message: " + context.LastError.Message + ", " +
+ "Scope: " + context.LastError.Scope + ", " +
+ "Section: " + context.LastError.Section + ", " +
+ "Path: " + context.LastError.Path + ", " +
+ "PolicyId: " + context.LastError.PolicyId;
+ return error;
+ }
+
+
+
+
diff --git a/src/domains/nodo-app/env/weu-dev/terraform.tfvars b/src/domains/nodo-app/env/weu-dev/terraform.tfvars
index 83b4e4945c..8b75b0a527 100644
--- a/src/domains/nodo-app/env/weu-dev/terraform.tfvars
+++ b/src/domains/nodo-app/env/weu-dev/terraform.tfvars
@@ -217,3 +217,9 @@ wfesp_dismantling = {
channel_list = "13212880150_90"
wfesp_fixed_url = "https://wfesp.pagopa.gov.it/redirect/wpl05/get?idSession="
}
+
+
+# decoupler
+nexi_nodo_address = "http:\\/\\/10.70.66.200/nodo-sit"
+nexi_nodo_pg_address = "https:\\/\\/10.79.20.32/sit"
+pagopa_nodo_address = "https:\\/\\/weudev.nodo.internal.dev.platform.pagopa.it/nodo"
diff --git a/src/domains/nodo-app/env/weu-prod/terraform.tfvars b/src/domains/nodo-app/env/weu-prod/terraform.tfvars
index 12e3e375ea..15a390189e 100644
--- a/src/domains/nodo-app/env/weu-prod/terraform.tfvars
+++ b/src/domains/nodo-app/env/weu-prod/terraform.tfvars
@@ -290,3 +290,9 @@ wfesp_dismantling = {
channel_list = "disabled" # When we want to activate WFESP dismantling, insert correct channel list "13212880150_90"
wfesp_fixed_url = "https://wfesp.pagopa.gov.it/redirect/wpl05/get?idSession="
}
+
+nexi_nodo_address = "https:\\/\\/10.79.20.34"
+nexi_nodo_pg_address = "https:\\/\\/10.79.20.25"
+pagopa_nodo_address = "https:\\/\\/weuprod.nodo.internal.platform.pagopa.it/nodo"
+
+
diff --git a/src/domains/nodo-app/env/weu-uat/terraform.tfvars b/src/domains/nodo-app/env/weu-uat/terraform.tfvars
index 728d6c8e85..aa596edb92 100644
--- a/src/domains/nodo-app/env/weu-uat/terraform.tfvars
+++ b/src/domains/nodo-app/env/weu-uat/terraform.tfvars
@@ -239,3 +239,8 @@ wfesp_dismantling = {
channel_list = "13212880150_90"
wfesp_fixed_url = "https://wfesp.pagopa.gov.it/redirect/wpl05/get?idSession="
}
+
+nexi_nodo_address = "http:\\/\\/10.70.74.200/nodo-uat"
+nexi_nodo_pg_address = "https:\\/\\/10.79.20.32"
+pagopa_nodo_address = "https:\\/\\/weuuat.nodo.internal.uat.platform.pagopa.it/nodo"
+
diff --git a/src/next-core/03_apim_named_values.tf b/src/next-core/03_apim_named_values.tf
index 55d1abe173..2a8fc9bf73 100644
--- a/src/next-core/03_apim_named_values.tf
+++ b/src/next-core/03_apim_named_values.tf
@@ -69,14 +69,7 @@ resource "azurerm_api_management_named_value" "schema_ip_nexi" {
value = var.schema_ip_nexi
}
-# 8. Nodo PagoPA
-resource "azurerm_api_management_named_value" "schema_ip_nodo_pagopa" {
- name = "schema-ip-nodo-pagopa"
- api_management_name = module.apim[0].name
- resource_group_name = azurerm_resource_group.rg_api.name
- display_name = "schema-ip-nodo-pagopa"
- value = var.env_short == "p" ? "https://weu${var.env}.nodo.internal.platform.pagopa.it/${local.soap_basepath_nodo_postgres_pagopa}" : "https://weu${var.env}.nodo.internal.${var.env}.platform.pagopa.it/${local.soap_basepath_nodo_postgres_pagopa}"
-}
+
# DEFAULT NODO CONFIGURATION
resource "azurerm_api_management_named_value" "default_nodo_backend" {