From 3cae54b288f3299975f000861aec6ee49b5c3417 Mon Sep 17 00:00:00 2001 From: Gianluca Ciuffa Date: Thu, 10 Oct 2024 09:32:22 +0200 Subject: [PATCH] remove all references to NPG switch business logic --- .../api/lap-service/v1/_base_policy-jwt.xml | 103 ++++---- .../v1/_base_policy-jwt.xml | 103 ++++---- .../api/ecommerce-io/v2/_auth_request.xml.tpl | 219 ++++-------------- .../api/ecommerce-io/v2/_base_policy.xml.tpl | 53 +---- .../v2/_calculate_fees_policy.xml.tpl | 199 ++++------------ .../v2/_delete_transaction.xml.tpl | 60 ----- .../v2/_get_payment_methods.xml.tpl | 33 --- .../v2/_get_wallets_by_user_with_pm.xml.tpl | 199 ---------------- .../ecommerce-io/v2/get_transaction.xml.tpl | 93 -------- .../ecommerce-io/v2/post_transactions.xml.tpl | 167 ++----------- .../04_apim_io_payment_wallet.tf | 1 - .../io-payment-wallet/v1/_base_policy.xml.tpl | 7 - .../v1/_delete_wallet.xml.tpl | 70 ------ .../v1/_get_payment_methods.xml.tpl | 59 ++--- .../v1/_get_wallets_by_user.xml.tpl | 195 +--------------- .../_get_wallets_by_user_and_walletId.xml.tpl | 207 ----------------- .../v1/_post_wallets.xml.tpl | 146 +++--------- .../v1/_update_applications.xml.tpl | 113 +-------- .../shared-app/04_apim_io_wallet_session.tf | 15 -- .../session-wallet/v1/_base_policy.xml.tpl | 195 ++++++++-------- .../v1/_fragment_policiy_chk_token.tpl.xml | 44 ---- 21 files changed, 357 insertions(+), 1924 deletions(-) delete mode 100644 src/domains/shared-app/api/session-wallet/v1/_fragment_policiy_chk_token.tpl.xml diff --git a/src/domains/bizevents-app/api/lap-service/v1/_base_policy-jwt.xml b/src/domains/bizevents-app/api/lap-service/v1/_base_policy-jwt.xml index 994a7959c5..3575eb7b28 100644 --- a/src/domains/bizevents-app/api/lap-service/v1/_base_policy-jwt.xml +++ b/src/domains/bizevents-app/api/lap-service/v1/_base_policy-jwt.xml @@ -16,73 +16,66 @@ + - - - - - - - - - + - - - @(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"])) - GET - - {{wallet-session-personal-data-vault-api-key}} - - - - - - - - - - - ())" /> - - - - - - - application/json - - @{ - return new JObject( - new JProperty("title", "Bad gateway - Invalid PDV response"), - new JProperty("status", 502), - new JProperty("detail", "Cannot find PII") - ).ToString(); - } - - - - + - + + + @(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"])) + GET + + {{wallet-session-personal-data-vault-api-key}} + + + + + + + - + + + ())" /> + + + application/json @{ - return new JObject( - new JProperty("title", "Bad gateway - Not call PDV"), - new JProperty("status", 502), - new JProperty("detail", "Cannot find xUserId") - ).ToString(); - } - - + return new JObject( + new JProperty("title", "Bad gateway - Invalid PDV response"), + new JProperty("status", 502), + new JProperty("detail", "Cannot find PII") + ).ToString(); + } + + + + + + + + + + application/json + + @{ + return new JObject( + new JProperty("title", "Bad gateway - Not call PDV"), + new JProperty("status", 502), + new JProperty("detail", "Cannot find xUserId") + ).ToString(); + } + + diff --git a/src/domains/bizevents-app/api/transaction-service/v1/_base_policy-jwt.xml b/src/domains/bizevents-app/api/transaction-service/v1/_base_policy-jwt.xml index a5f822fd6a..44ac8896ea 100644 --- a/src/domains/bizevents-app/api/transaction-service/v1/_base_policy-jwt.xml +++ b/src/domains/bizevents-app/api/transaction-service/v1/_base_policy-jwt.xml @@ -16,73 +16,66 @@ + - - - - - - - - - + - - - @(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"])) - GET - - {{wallet-session-personal-data-vault-api-key}} - - - - - - - - - - - ())" /> - - - - - - - application/json - - @{ - return new JObject( - new JProperty("title", "Bad gateway - Invalid PDV response"), - new JProperty("status", 502), - new JProperty("detail", "Cannot find PII") - ).ToString(); - } - - - - + - + + + @(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"])) + GET + + {{wallet-session-personal-data-vault-api-key}} + + + + + + + - + + + ())" /> + + + application/json @{ - return new JObject( - new JProperty("title", "Bad gateway - Not call PDV"), - new JProperty("status", 502), - new JProperty("detail", "Cannot find xUserId") - ).ToString(); - } - - + return new JObject( + new JProperty("title", "Bad gateway - Invalid PDV response"), + new JProperty("status", 502), + new JProperty("detail", "Cannot find PII") + ).ToString(); + } + + + + + + + + + + application/json + + @{ + return new JObject( + new JProperty("title", "Bad gateway - Not call PDV"), + new JProperty("status", 502), + new JProperty("detail", "Cannot find xUserId") + ).ToString(); + } + + diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/_auth_request.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/_auth_request.xml.tpl index d7b119150b..b870ce945c 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/_auth_request.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/_auth_request.xml.tpl @@ -19,200 +19,79 @@ - - - - - - - @($"{{pm-host}}/pp-restapi-CD/v1/wallet/{(string)context.Variables["idWallet"]}") + + + @($"https://${wallet-basepath}/pagopa-wallet-service/wallets/{(string)context.Variables["walletId"]}") GET - - @($"Bearer {(string)context.Variables.GetValueOrDefault("sessionToken","")}") + + @((string)context.Request.Headers.GetValueOrDefault("x-user-id","")) - - ())" /> - + + ())" /> + - + - + application/json { - "title": "Unable to get wallet type", - "status": 502, - "detail": "Unable to get wallet type", + "title": "Wallet not found", + "status": 404, + "detail": "Cannot retrieve wallet for input wallet id", } - - - - - @("{{pagopa-appservice-proxy-url}}/payment-activations/" + context.Variables["requestTransactionId"]) - GET - - CLIENT_IO - - - - - ()["idPagamento"])" /> - - - - - @($"{{pm-host}}/pp-restapi-CD/v2/wallet/{(string)context.Variables["idWallet"]}") - PUT - - @($"Bearer {(string)context.Variables.GetValueOrDefault("sessionToken","")}") - - - application/json - - @((string)context.Variables["putWalletRequest"]) - - - - - - - application/json - - { - "title": "Unable to set Psp", - "status": 502, - "detail": "Unable to set Psp", - } - - - - - - - - - - application/json - - @{ - JObject response = new JObject(); - response["authorizationUrl"] = $"https://${authurl-basepath}/ecommerce/io-webview/v1/pay?transactionId={(string)context.Variables["requestTransactionId"]}#idWallet={(string)context.Variables["idWallet"]}&idPayment={(string)context.Variables["idPayment"]}&sessionToken={(string)context.Variables["sessionToken"]}&language=IT"; - response["authorizationRequestId"] = (string)context.Variables["requestTransactionId"]; - return response.ToString(); - } - - - + + application/json { - "title": "Unable to execute auth request", - "status": 404, - "detail": "Transaction not found", + "title": "Bad gateway", + "status": 502, + "detail": "Wallet not available", } - - - - - @($"https://${wallet-basepath}/pagopa-wallet-service/wallets/{(string)context.Variables["walletId"]}") - GET - - @((string)context.Request.Headers.GetValueOrDefault("x-user-id","")) - - - - - ())" /> - - - - - - - application/json - - { - "title": "Wallet not found", - "status": 404, - "detail": "Cannot retrieve wallet for input wallet id", - } - - - - - - - application/json - - { - "title": "Bad gateway", - "status": 502, - "detail": "Wallet not available", - } - - - - - - @{ - JObject requestBody = (JObject)context.Variables["body"]; - JObject authDetail = (JObject)requestBody["details"]; - string walletId = (string)context.Variables["walletId"]; - string detailType = (string)authDetail["detailType"]; - string paymentMethodId = (string)context.Variables.GetValueOrDefault("paymentMethodId",""); - JObject requestBodyDetails = new JObject(); - requestBodyDetails["detailType"] = (string)authDetail["detailType"]; - switch(detailType) - { - case "wallet": - requestBodyDetails = authDetail; - requestBodyDetails["walletId"] = walletId; - break; - case "apm": - paymentMethodId = (string)authDetail["paymentMethodId"]; - authDetail.Remove("paymentMethodId"); - requestBodyDetails = authDetail; - break; - case "redirect": - paymentMethodId = (string)authDetail["paymentMethodId"]; - authDetail.Remove("paymentMethodId"); - requestBodyDetails = authDetail; - break; - default: - break; - } - requestBody["details"] = requestBodyDetails; - requestBody["paymentInstrumentId"] = paymentMethodId; - return requestBody.ToString(); - } - + @{ + JObject requestBody = (JObject)context.Variables["body"]; + JObject authDetail = (JObject)requestBody["details"]; + string walletId = (string)context.Variables["walletId"]; + string detailType = (string)authDetail["detailType"]; + string paymentMethodId = (string)context.Variables.GetValueOrDefault("paymentMethodId",""); + JObject requestBodyDetails = new JObject(); + requestBodyDetails["detailType"] = (string)authDetail["detailType"]; + switch(detailType) + { + case "wallet": + requestBodyDetails = authDetail; + requestBodyDetails["walletId"] = walletId; + break; + case "apm": + paymentMethodId = (string)authDetail["paymentMethodId"]; + authDetail.Remove("paymentMethodId"); + requestBodyDetails = authDetail; + break; + case "redirect": + paymentMethodId = (string)authDetail["paymentMethodId"]; + authDetail.Remove("paymentMethodId"); + requestBodyDetails = authDetail; + break; + default: + break; + } + requestBody["details"] = requestBodyDetails; + requestBody["paymentInstrumentId"] = paymentMethodId; + return requestBody.ToString(); + } diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/_base_policy.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/_base_policy.xml.tpl index 551d9344ce..c1e7c048c4 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/_base_policy.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/_base_policy.xml.tpl @@ -16,48 +16,17 @@ is an opaque token a "session-token-not-found" string is returned--> - - - - - - - - @((string)context.Variables.GetValueOrDefault("xUserId","")) - - - IO - - - - - - - - - @($"{{pm-host}}/pp-restapi-CD/v1/users/check-session?sessionToken={(string)context.Variables["sessionToken"]}") - GET - - @("Bearer " + (string)context.Variables["sessionToken"]) - - - - - - - - { - "status": 401, - "title": "Unauthorized", - "detail": "Invalid token" - } - - - - - - - + + + + + + @((string)context.Variables.GetValueOrDefault("xUserId","")) + + + IO + + diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/_calculate_fees_policy.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/_calculate_fees_policy.xml.tpl index 7d668cb5e1..3d24173493 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/_calculate_fees_policy.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/_calculate_fees_policy.xml.tpl @@ -44,187 +44,72 @@ + + - - - - - - - - - - @($"https://${ecommerce-basepath}/pagopa-ecommerce-payment-methods-service/payment-methods/{(string)context.Variables["paymentMethodId"]}") + + + @($"https://${wallet-basepath}/pagopa-wallet-service/wallets/{(string)context.Variables["walletId"]}/auth-data") GET - - IO - - - - @($"{{pm-host}}/pp-restapi-CD/v3/paypal/psps") - GET - - @($"Bearer {(string)context.Variables.GetValueOrDefault("sessionToken","")}") - - - - - - @($"{{pm-host}}/pp-restapi-CD/v2/payments/{(string)context.Variables["idPayment"]}/psps?idWallet={(string)context.Variables["idWallet"]}&language={(string)context.Variables["language"]}&isList=true") - GET - - @($"Bearer {(string)context.Variables.GetValueOrDefault("sessionToken","")}") - - + + ())" /> + + - + - + application/json { - "title": "Bad Gateway", - "status": 502, - "detail": "PSP not available", + "title": "Unable to get auth data", + "status": 404, + "detail": "Unable to get auth data", } - - - - - (preserveContent: true))" /> - - - - application/json - - @{ - bool isPayPal = (bool)context.Variables["isPayPal"]; - JArray psps = (JArray)(((JObject)context.Variables["pmPspsResponse"])["data"]); - JObject response = new JObject(); - JArray pspResponse = new JArray(); - foreach (JObject pmPsp in psps) { - JObject psp = new JObject(); - psp["abi"] = pmPsp["codiceAbi"]; - psp["bundleName"] = pmPsp["ragioneSociale"]; - psp["pspBusinessName"] = pmPsp["ragioneSociale"]; - if(isPayPal) { - psp["taxPayerFee"] = pmPsp["maxFee"]; - psp["idPsp"] = (string)pmPsp["idPsp"]; - psp["idBundle"] = pmPsp["idPsp"]; - } else { - psp["taxPayerFee"] = pmPsp["fee"]; - psp["idPsp"] = (string)pmPsp["id"]; - psp["idBundle"] = pmPsp["idPsp"]; - } - pspResponse.Add(psp); - } - response["paymentMethodName"] = ((string)((JObject)context.Variables["paymentMethod"])["name"]); - response["paymentMethodDescription"] = ((string)((JObject)context.Variables["paymentMethod"])["description"]); - response["paymentMethodStatus"] = ((string)((JObject)context.Variables["paymentMethod"])["status"]); - response["belowThreshold"] = false; - response["bundles"] = (JArray)pspResponse; - response["asset"] = "https://assets.cdn.platform.pagopa.it/creditcard/generic.png"; - return response.ToString(); - } - - - - - - - + application/json { - "title": "Unable to get Psps", - "status": 404, - "detail": "Psps not found", - } + "title": "Bad gateway", + "status": 502, + "detail": "Wallet not available", + } - - - - - - - @($"https://${wallet-basepath}/pagopa-wallet-service/wallets/{(string)context.Variables["walletId"]}/auth-data") - GET - - - - ())" /> - - - - - - - - application/json - - { - "title": "Unable to get auth data", - "status": 404, - "detail": "Unable to get auth data", - } - - - - - - - application/json - - { - "title": "Bad gateway", - "status": 502, - "detail": "Wallet not available", - } - - - - - - - 100 - - @{ - var bin = (string)context.Variables.GetValueOrDefault("bin", ""); - JObject inBody = (JObject)context.Variables["body"]; - inBody.Remove("walletId"); - inBody.Remove("paymentToken"); - inBody.Remove("language"); - inBody.Add("touchpoint","IO"); - if(!String.IsNullOrEmpty(bin)) { - inBody.Add("bin", bin); - } - foreach (JObject transfer in ((JArray)(inBody["transferList"]))) { - if( transfer.ContainsKey("paFiscalCode") == true ) - { - var creditorInstitution = ((string)transfer["paFiscalCode"]); - transfer.Add("creditorInstitution",creditorInstitution); - transfer.Remove("paFiscalCode"); - } - } - return inBody.ToString(); - } - + + 100 + + @{ + var bin = (string)context.Variables.GetValueOrDefault("bin", ""); + JObject inBody = (JObject)context.Variables["body"]; + inBody.Remove("walletId"); + inBody.Remove("paymentToken"); + inBody.Remove("language"); + inBody.Add("touchpoint","IO"); + if(!String.IsNullOrEmpty(bin)) { + inBody.Add("bin", bin); + } + foreach (JObject transfer in ((JArray)(inBody["transferList"]))) { + if( transfer.ContainsKey("paFiscalCode") == true ) + { + var creditorInstitution = ((string)transfer["paFiscalCode"]); + transfer.Add("creditorInstitution",creditorInstitution); + transfer.Remove("paFiscalCode"); + } + } + return inBody.ToString(); + } diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/_delete_transaction.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/_delete_transaction.xml.tpl index f3ef69cb7b..f8a5763c42 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/_delete_transaction.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/_delete_transaction.xml.tpl @@ -1,66 +1,6 @@ - - - - - - @("{{pagopa-appservice-proxy-url}}/payment-activations/" + context.Variables["requestTransactionId"]) - GET - - CLIENT_IO - - - - ())" /> - - - - @("{{pm-host}}/pp-restapi-CD/v1/payments/" + ((JObject)context.Variables["pagopaProxyResponseBody"])["idPagamento"]) - DELETE - - @("Bearer " + (string)context.Variables["sessionToken"]) - - - - - - - - - - - - - - - - - - - - - - - - - - application/json - - { - "title": "Unable to found transaction", - "status": 404, - "detail": "Transaction not found", - } - - - - - diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_payment_methods.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_payment_methods.xml.tpl index 73c7344da9..0455f530a4 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_payment_methods.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_payment_methods.xml.tpl @@ -1,42 +1,9 @@ - - - - - - - - @{ - JObject response = context.Response.Body.As(); - - if (context.Response.StatusCode != 200) { - return response.ToString(); - } - - string enabled_payment_wallet_method_ids_pm = "${enabled_payment_wallet_method_ids_pm}"; - string[] values = enabled_payment_wallet_method_ids_pm.Split(','); - HashSet pmEnabledMethods = new HashSet(values); - - foreach (var method in ((JArray) response["paymentMethods"])) { - string id = (string) method["id"]; - if (pmEnabledMethods.Contains(id)) { - method["status"] = "ENABLED"; - method["methodManagement"] = "ONBOARDABLE_ONLY"; - } else { - method["status"] = "DISABLED"; - } - } - - return response.ToString(); - } - - - diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_wallets_by_user_with_pm.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_wallets_by_user_with_pm.xml.tpl index de4c090c6a..59ce29e724 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_wallets_by_user_with_pm.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/_get_wallets_by_user_with_pm.xml.tpl @@ -1,205 +1,6 @@ - - - - - - - {{pm-host}}/pp-restapi-CD/v3/wallet - GET - - @($"Bearer {((string)context.Variables["sessionToken"])}") - - - - - - - - application/json - - - { - "title": "Unauthorized", - "status": 401, - "detail": "Unauthorized" - } - - - - - - - - application/json - - - { - "title": "Error retrieving user wallet data", - "status": 502, - "detail": "There was an error retrieving user wallet data" - } - - - - - ())" /> - - - - - - - application/json - - - { - "title": "Wallet not found", - "status": 404, - "detail": "No wallet found for input wallet token" - } - - - - - - - - - https://${ecommerce-hostname}/pagopa-ecommerce-payment-methods-service/payment-methods - GET - - IO - - - - - - - - application/json - - - { - "title": "Error retrieving eCommerce payment methods", - "status": 502, - "detail": "There was an error retrieving eCommerce payment methods" - } - - - - - ())" /> - - - - - - application/json - - - @{ - JObject pmWalletResponse = (JObject)context.Variables["pmUserWalletResponseBody"]; - var walletApplications = new List{"PAGOPA"}; - var eCommerceWalletTypes = new Dictionary - { - { "Card", "CARDS" }, - { "BPay", "BANCOMATPAY" }, - { "PayPal", "PAYPAL" } - }; - var eCommercePaymentMethodIds = new Dictionary(); - JObject paymentMethods = (JObject)context.Variables["paymentMethodsResponseBody"]; - foreach(JObject paymentMethod in (JArray)paymentMethods["paymentMethods"]){ - eCommercePaymentMethodIds[paymentMethod["name"].ToString()] = paymentMethod["id"].ToString(); - } - Object[] wallets = pmWalletResponse["data"] - .Where(wallet =>{ - return eCommerceWalletTypes.ContainsKey((string) wallet["walletType"]); - }) - .Select(wallet =>{ - JObject result = new JObject(); - //convert wallet id (long) to UUID v4 with all bit set to 0 (except for the version). - //wallet id long value is stored into UUID latest 8 byte - string walletIdHex = ((long)wallet["idWallet"]).ToString("X").PadLeft(16,'0'); - string walletIdToUuid = "00000000-0000-4000-"+walletIdHex.Substring(0,4)+"-"+walletIdHex.Substring(4); - result["walletId"] = walletIdToUuid; - string pmWalletType = (string) wallet["walletType"]; - string eCommerceWalletType = eCommerceWalletTypes[pmWalletType]; - string paymentMethodAsset = null; - result["paymentMethodId"] = eCommercePaymentMethodIds[eCommerceWalletType]; - result["status"] = "VALIDATED"; - - TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"); - - DateTime creationDateTime = DateTime.Parse(((string)wallet["createDate"]).Replace(" ","T")); - DateTime utcCreationDateTime = TimeZoneInfo.ConvertTimeToUtc(creationDateTime, zone); - DateTimeOffset creationDateTimeOffset = new DateTimeOffset(utcCreationDateTime); - result["creationDate"] = creationDateTimeOffset.ToString("o"); - result["updateDate"] = result["creationDate"]; - - var convertedApplications = new List(); - foreach(JValue application in wallet["enableableFunctions"]){ - string applicationName = application.ToString().ToUpper(); - if(walletApplications.Contains(applicationName) && wallet[application.ToString()] != null){ - JObject converted = new JObject(); - converted["name"] = applicationName; - converted["status"] = Convert.ToBoolean(wallet[application.ToString()]) == true ? "ENABLED" : "DISABLED"; - converted["updateDate"] = result["creationDate"]; - convertedApplications.Add(converted); - } - } - result["applications"] = JArray.FromObject(convertedApplications); - JObject details = new JObject(); - details["type"] = eCommerceWalletType; - if (eCommerceWalletType == "CARDS") { - details["lastFourDigits"] = $"{wallet["info"]["blurredNumber"]}"; - details["expiryDate"] = $"{(string)wallet["info"]["expireYear"]}{(string)wallet["info"]["expireMonth"]}"; - details["brand"] = wallet["info"]["brand"]; - paymentMethodAsset = (string)wallet["info"]["brandLogo"]; - } - if (eCommerceWalletType == "PAYPAL") { - var info = (JObject)(wallet["info"]); - var pspArray = (JArray)(info["pspInfo"]); - var pspInfo = (JObject)(pspArray[0]); - details["pspId"] = pspInfo["abi"]; - details["maskedEmail"] = pspInfo["email"]; - details["pspBusinessName"] = pspInfo["ragioneSociale"]; - paymentMethodAsset = "https://assets.cdn.platform.pagopa.it/apm/paypal.png"; - } - if (eCommerceWalletType == "BANCOMATPAY") { - details["maskedNumber"] = wallet["info"]["numberObfuscated"]; - details["instituteCode"] = wallet["info"]["instituteCode"]; - details["bankName"] = wallet["info"]["bankName"]; - paymentMethodAsset = (string)wallet["info"]["brandLogo"]; - } - result["details"] = details; - result["paymentMethodAsset"] = paymentMethodAsset; - - Boolean favourite = (Boolean) wallet["favourite"]; - JObject clients = new JObject(); - JObject clientIO = new JObject(); - clientIO["status"] = "ENABLED"; - if(favourite == true) { - DateTime localDateUtc = DateTime.UtcNow; - DateTimeOffset lastUsageDateTimeOffset = new DateTimeOffset(localDateUtc); - clientIO["lastUsage"] = lastUsageDateTimeOffset.ToString("o"); - } - clients["IO"] = clientIO; - result["clients"] = clients; - - return result; - }).ToArray(); - - JObject response = new JObject(); - response["wallets"] = JArray.FromObject(wallets); - return response.ToString(); - } - - - - diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/get_transaction.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/get_transaction.xml.tpl index f4ecb26c50..f8a5763c42 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/get_transaction.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/get_transaction.xml.tpl @@ -1,99 +1,6 @@ - - - - - - @("{{pagopa-appservice-proxy-url}}/payment-activations/" + context.Variables["requestTransactionId"]) - GET - - CLIENT_IO - - - - ())" /> - - - - - - @("{{pm-host}}/pp-restapi-CD/v1/payments/" + ((JObject)context.Variables["pagopaProxyResponseBody"])["idPagamento"] + "/actions/check") - GET - - - - application/json - - @{ - JObject eCommerceResponseBody = new JObject(); - eCommerceResponseBody["transactionId"] = (string) context.Variables["requestTransactionId"]; - eCommerceResponseBody["status"] = "ACTIVATED"; - eCommerceResponseBody["clientId"] = "IO"; - JObject payment = new JObject(); - payment["rptId"] = (string) context.Variables["cacheRptId"]; - payment["amount"] = (int) context.Variables["cacheAmount"]; - payment["paymentToken"] = (string) ((JObject) context.Variables["pagopaProxyResponseBody"])["idPagamento"]; - JArray payments = new JArray(); - payments.Add(payment); - eCommerceResponseBody["payments"] = payments; - return eCommerceResponseBody.ToString(); - } - - - - - - - application/json - - @{ - JObject eCommerceResponseBody = new JObject(); - eCommerceResponseBody["transactionId"] = (string) context.Variables["requestTransactionId"]; - eCommerceResponseBody["status"] = "ACTIVATION_REQUESTED"; - eCommerceResponseBody["payments"] = new JArray(); - JObject payment = new JObject(); - payment["rptId"] = (string) context.Variables["cacheRptId"]; - payment["amount"] = (int) context.Variables["cacheAmount"]; - JArray payments = new JArray(); - payments.Add(payment); - eCommerceResponseBody["payments"] = payments; - return eCommerceResponseBody.ToString(); - } - - - - - - - - application/json - - { - "title": "Unable to get transaction status", - "status": 404, - "detail": "Transaction not found", - } - - - - - diff --git a/src/domains/ecommerce-app/api/ecommerce-io/v2/post_transactions.xml.tpl b/src/domains/ecommerce-app/api/ecommerce-io/v2/post_transactions.xml.tpl index 569dbe779a..2ce52bab6a 100644 --- a/src/domains/ecommerce-app/api/ecommerce-io/v2/post_transactions.xml.tpl +++ b/src/domains/ecommerce-app/api/ecommerce-io/v2/post_transactions.xml.tpl @@ -1,167 +1,30 @@ - - - - - - ())" /> - ())" /> - - - - - - - application/json - - - @{ - return (string) context.Variables["newTransactionCached"]; - } - - - - - - - - - - application/json - - - { - "status": 401, - "title": "Unauthorized", - "details": "Missing Authorization header" - } - - - - - - ().Length; - }" /> - - 1)"> - - - - application/json - - - { - "status": 422, - "title": "Invalid payment request", - "details": "Cannot pay more than one payment notice at once" - } - - - - - - - - - @{ - JObject pagopaProxyBody = new JObject(); - pagopaProxyBody["rptId"] = ((string) context.Variables["rptId"]); - pagopaProxyBody["codiceContestoPagamento"] = ((string) context.Variables["ccp"]); - pagopaProxyBody["importoSingoloVersamento"] = ((int) context.Variables["amount"]); - return pagopaProxyBody.ToString(); - } - - - CLIENT_IO - - - - @{ - JObject requestBody = context.Request.Body.As(preserveContent: true); - requestBody["orderId"] = "ORDER_ID"; //To be removed since it is mandatory for transaction request body, but it should not be - requestBody["emailToken"] = (String)context.Variables["email"]; - return requestBody.ToString(); - } - - IO - - - @(Guid.NewGuid().ToString()) - - - @((String)context.Variables["xUserId"]) - - - + @{ + JObject requestBody = context.Request.Body.As(preserveContent: true); + requestBody["orderId"] = "ORDER_ID"; //To be removed since it is mandatory for transaction request body, but it should not be + requestBody["emailToken"] = (String)context.Variables["email"]; + return requestBody.ToString(); + } + + IO + + + @(Guid.NewGuid().ToString()) + + + @((String)context.Variables["xUserId"]) + - - - - - - - - @{ - return (string) context.Variables["finalResponse"]; - } - - - - - application/json - - - @{ - JObject errorResponse = new JObject(); - JObject value = (JObject) ((JObject) context.Variables["pagopaProxyResponseBody"]); - errorResponse["title"] = (string) value["title"]; - errorResponse["faultCodeDetail"] = (string) value["detail_v2"]; - errorResponse["faultCodeCategory"] = (string) value["category"]; - return errorResponse.ToString(); - } - - - - - - - - - { - "status": 502, - "title": "Bad Gateway", - "details": "Error while contacting pagopa-proxy" - } - - - diff --git a/src/domains/pay-wallet-app/04_apim_io_payment_wallet.tf b/src/domains/pay-wallet-app/04_apim_io_payment_wallet.tf index d8aa7797f0..00d430414b 100644 --- a/src/domains/pay-wallet-app/04_apim_io_payment_wallet.tf +++ b/src/domains/pay-wallet-app/04_apim_io_payment_wallet.tf @@ -145,7 +145,6 @@ resource "azurerm_api_management_named_value" "pay_wallet_family_friends_user_id } } - ####################################################################### ## Fragment policy to extract user id from session token ## ####################################################################### diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_base_policy.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_base_policy.xml.tpl index 6880befc75..a5de721550 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_base_policy.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_base_policy.xml.tpl @@ -4,11 +4,6 @@ - - - - - @@ -24,8 +19,6 @@ - - IO diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_delete_wallet.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_delete_wallet.xml.tpl index 1269b9139c..92bfb2ad6e 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_delete_wallet.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_delete_wallet.xml.tpl @@ -1,76 +1,6 @@ - - - - - - @($"{{pm-host}}/pp-restapi-CD/v1/wallet/{(string)context.Variables["idWalletPM"]}") - DELETE - - @($"Bearer {((String)context.Variables["sessionToken"])}") - - - - - - - - - - - - - - - application/json - - - { - "title": "Unauthorized", - "status": 401, - "detail": "Unauthorized" - } - - - - - - - - application/json - - - { - "title": "Not Found", - "status": 404, - "detail": "Wallet not found" - } - - - - - - - - application/json - - - { - "title": "Error deleting wallet", - "status": 502, - "detail": "There was an error deleting wallet" - } - - - - - - diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_payment_methods.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_payment_methods.xml.tpl index 477c1e999b..1a4baf725a 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_payment_methods.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_payment_methods.xml.tpl @@ -1,48 +1,15 @@ - + + + + + - - - - - - - - - - - - @{ - JObject response = context.Response.Body.As(); - - if (context.Response.StatusCode != 200) { - return response.ToString(); - } - - string enabled_payment_wallet_method_ids_pm = "${enabled_payment_wallet_method_ids_pm}"; - string[] values = enabled_payment_wallet_method_ids_pm.Split(','); - HashSet pmEnabledMethods = new HashSet(values); - - foreach (var method in ((JArray) response["paymentMethods"])) { - string id = (string) method["id"]; - if (pmEnabledMethods.Contains(id)) { - method["status"] = "ENABLED"; - method["methodManagement"] = "ONBOARDABLE_ONLY"; - } else { - method["status"] = "DISABLED"; - } - } - - return response.ToString(); - } - - - - - - - - - - - + + + + + + + + diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user.xml.tpl index 9014a33d5b..59ce29e724 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user.xml.tpl @@ -1,199 +1,6 @@ - - - - - - {{pm-host}}/pp-restapi-CD/v3/wallet - GET - - @($"Bearer {((String)context.Variables["sessionToken"])}") - - - - - - - - application/json - - { - "title": "Unauthorized", - "status": 401, - "detail": "Unauthorized" - } - - - - - - - application/json - - - { - "title": "Error retrieving user wallet data", - "status": 502, - "detail": "There was an error retrieving user wallet data" - } - - - - - ())" /> - - - - - - - application/json - - - { - "title": "Wallet not found", - "status": 404, - "detail": "No wallet found for input wallet token" - } - - - - - - - - https://${ecommerce_hostname}/pagopa-ecommerce-payment-methods-service/payment-methods - GET - - IO - - - - - - - - application/json - - - { - "title": "Error retrieving eCommerce payment methods", - "status": 502, - "detail": "There was an error retrieving eCommerce payment methods" - } - - - - - ())" /> - - - - - application/json - - - @{ - JObject pmWalletResponse = (JObject)context.Variables["pmUserWalletResponseBody"]; - var walletApplications = new List{"PAGOPA"}; - var eCommerceWalletTypes = new Dictionary - { - { "Card", "CARDS" }, - { "BPay", "BANCOMATPAY" }, - { "PayPal", "PAYPAL" } - }; - var eCommercePaymentMethodIds = new Dictionary(); - JObject paymentMethods = (JObject)context.Variables["paymentMethodsResponseBody"]; - foreach(JObject paymentMethod in (JArray)paymentMethods["paymentMethods"]){ - eCommercePaymentMethodIds[paymentMethod["name"].ToString()] = paymentMethod["id"].ToString(); - } - Object[] wallets = pmWalletResponse["data"] - .Where(wallet =>{ - return eCommerceWalletTypes.ContainsKey((string) wallet["walletType"]); - }) - .Select(wallet =>{ - JObject result = new JObject(); - //convert wallet id (long) to UUID v4 with all bit set to 0 (except for the version). - //wallet id long value is stored into UUID latest 8 byte - string walletIdHex = ((long)wallet["idWallet"]).ToString("X").PadLeft(16,'0'); - string walletIdToUuid = "00000000-0000-4000-"+walletIdHex.Substring(0,4)+"-"+walletIdHex.Substring(4); - result["walletId"] = walletIdToUuid; - string pmWalletType = (string) wallet["walletType"]; - string eCommerceWalletType = eCommerceWalletTypes[pmWalletType]; - result["paymentMethodId"] = eCommercePaymentMethodIds[eCommerceWalletType]; - result["status"] = "VALIDATED"; - - TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"); - - DateTime creationDateTime = DateTime.Parse(((string)wallet["createDate"]).Replace(" ","T")); - DateTime utcCreationDateTime = TimeZoneInfo.ConvertTimeToUtc(creationDateTime, zone); - DateTimeOffset creationDateTimeOffset = new DateTimeOffset(utcCreationDateTime); - result["creationDate"] = creationDateTimeOffset.ToString("o"); - result["updateDate"] = result["creationDate"]; - - var convertedApplications = new List(); - foreach(JValue application in wallet["enableableFunctions"]){ - string applicationName = application.ToString().ToUpper(); - if(walletApplications.Contains(applicationName) && wallet[application.ToString()] != null){ - JObject converted = new JObject(); - converted["name"] = applicationName; - converted["status"] = Convert.ToBoolean(wallet[application.ToString()]) == true ? "ENABLED" : "DISABLED"; - converted["updateDate"] = result["creationDate"]; - convertedApplications.Add(converted); - } - } - result["applications"] = JArray.FromObject(convertedApplications); - JObject details = new JObject(); - details["type"] = eCommerceWalletType; - string paymentMethodAsset = null; - if (eCommerceWalletType == "CARDS") { - details["lastFourDigits"] = $"{wallet["info"]["blurredNumber"]}"; - details["expiryDate"] = $"{(string)wallet["info"]["expireYear"]}{(string)wallet["info"]["expireMonth"]}"; - details["brand"] = wallet["info"]["brand"]; - paymentMethodAsset = (string)wallet["info"]["brandLogo"]; - } - if (eCommerceWalletType == "PAYPAL") { - var info = (JObject)(wallet["info"]); - var pspArray = (JArray)(info["pspInfo"]); - var pspInfo = (JObject)(pspArray[0]); - details["pspId"] = pspInfo["abi"]; - details["maskedEmail"] = pspInfo["email"]; - details["pspBusinessName"] = pspInfo["ragioneSociale"]; - paymentMethodAsset = "https://assets.cdn.platform.pagopa.it/apm/paypal.png"; - } - if (eCommerceWalletType == "BANCOMATPAY") { - details["maskedNumber"] = wallet["info"]["numberObfuscated"]; - details["instituteCode"] = wallet["info"]["instituteCode"]; - details["bankName"] = wallet["info"]["bankName"]; - paymentMethodAsset = (string)wallet["info"]["brandLogo"]; - } - result["details"] = details; - result["paymentMethodAsset"] = paymentMethodAsset; - - Boolean favourite = (Boolean) wallet["favourite"]; - JObject clients = new JObject(); - JObject clientIO = new JObject(); - clientIO["status"] = "ENABLED"; - if(favourite == true) { - DateTime localDateUtc = DateTime.UtcNow; - DateTimeOffset lastUsageDateTimeOffset = new DateTimeOffset(localDateUtc); - clientIO["lastUsage"] = lastUsageDateTimeOffset.ToString("o"); - } - clients["IO"] = clientIO; - result["clients"] = clients; - - return result; - }).ToArray(); - - JObject response = new JObject(); - response["wallets"] = JArray.FromObject(wallets); - return response.ToString(); - } - - - - + diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user_and_walletId.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user_and_walletId.xml.tpl index b5baa8f973..92bfb2ad6e 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user_and_walletId.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_get_wallets_by_user_and_walletId.xml.tpl @@ -1,213 +1,6 @@ - - - - - - {{pm-host}}/pp-restapi-CD/v3/wallet - GET - - @($"Bearer {((String)context.Variables["sessionToken"])}") - - - - - - - - application/json - - { - "title": "Unauthorized", - "status": 401, - "detail": "Unauthorized" - } - - - - - - - application/json - - { - "title": "Error retrieving user wallet data", - "status": 502, - "detail": "There was an error retrieving user wallet data" - } - - - - ())" /> - - - - - - - application/json - - { - "title": "Wallet not found", - "status": 404, - "detail": "No wallet found for input wallet token" - } - - - - - - - https://${ecommerce_hostname}/pagopa-ecommerce-payment-methods-service/payment-methods - GET - - IO - - - - - - - - application/json - - { - "title": "Error retrieving eCommerce payment methods", - "status": 502, - "detail": "There was an error retrieving eCommerce payment methods" - } - - - - ())" /> - - {"PAGOPA"}; - var eCommerceWalletTypes = new Dictionary - { - { "Card", "CARDS" }, - { "BPay", "BANCOMATPAY" }, - { "PayPal", "PAYPAL" } - }; - var eCommercePaymentMethodIds = new Dictionary(); - JObject paymentMethods = (JObject)context.Variables["paymentMethodsResponseBody"]; - foreach(JObject paymentMethod in (JArray)paymentMethods["paymentMethods"]){ - eCommercePaymentMethodIds[paymentMethod["name"].ToString()] = paymentMethod["id"].ToString(); - } - JObject walletResult = (JObject) pmWalletResponse["data"] - .Where(wallet =>{ - return eCommerceWalletTypes.ContainsKey((string) wallet["walletType"]) && (((string)context.Variables["walletId"]).Equals((string)wallet["idWallet"])); - }) - .Select(wallet =>{ - - JObject result = new JObject(); - //convert wallet id (long) to UUID v4 with all bit set to 0 (except for the version). - //wallet id long value is stored into UUID latest 8 byte - string walletIdHex = ((long)wallet["idWallet"]).ToString("X").PadLeft(16,'0'); - string walletIdToUuid = "00000000-0000-4000-"+walletIdHex.Substring(0,4)+"-"+walletIdHex.Substring(4); - result["walletId"] = walletIdToUuid; - string pmWalletType = (string) wallet["walletType"]; - string eCommerceWalletType = eCommerceWalletTypes[pmWalletType]; - result["paymentMethodId"] = eCommercePaymentMethodIds[eCommerceWalletType]; - result["status"] = "VALIDATED"; - - TimeZoneInfo zone = TimeZoneInfo.FindSystemTimeZoneById("Central European Standard Time"); - - DateTime creationDateTime = DateTime.Parse(((string)wallet["createDate"]).Replace(" ","T")); - DateTime utcCreationDateTime = TimeZoneInfo.ConvertTimeToUtc(creationDateTime, zone); - DateTimeOffset creationDateTimeOffset = new DateTimeOffset(utcCreationDateTime); - result["creationDate"] = creationDateTimeOffset.ToString("o"); - result["updateDate"] = result["creationDate"]; - - string paymentMethodAsset=null; - var convertedApplications = new List(); - foreach(JValue application in wallet["enableableFunctions"]){ - string applicationName = application.ToString().ToUpper(); - if(walletApplications.Contains(applicationName) && wallet[application.ToString()] != null){ - JObject converted = new JObject(); - converted["name"] = applicationName; - converted["status"] = Convert.ToBoolean(wallet[application.ToString()]) == true ? "ENABLED" : "DISABLED"; - converted["updateDate"] = result["creationDate"]; - convertedApplications.Add(converted); - } - } - result["applications"] = JArray.FromObject(convertedApplications); - JObject details = new JObject(); - details["type"] = eCommerceWalletType; - if (eCommerceWalletType == "CARDS") { - details["lastFourDigits"] = $"{wallet["info"]["blurredNumber"]}"; - details["expiryDate"] = $"{(string)wallet["info"]["expireYear"]}{(string)wallet["info"]["expireMonth"]}"; - details["brand"] = wallet["info"]["brand"]; - paymentMethodAsset = (string)wallet["info"]["brandLogo"]; - } - if (eCommerceWalletType == "PAYPAL") { - var info = (JObject)(wallet["info"]); - var pspArray = (JArray)(info["pspInfo"]); - var pspInfo = (JObject)(pspArray[0]); - details["pspId"] = pspInfo["abi"]; - details["maskedEmail"] = pspInfo["email"]; - details["pspBusinessName"] = pspInfo["ragioneSociale"]; - paymentMethodAsset = "https://assets.cdn.platform.pagopa.it/apm/paypal.png"; - } - if (eCommerceWalletType == "BANCOMATPAY") { - details["maskedNumber"] = wallet["info"]["numberObfuscated"]; - details["instituteCode"] = wallet["info"]["instituteCode"]; - details["bankName"] = wallet["info"]["bankName"]; - paymentMethodAsset = (string)wallet["info"]["brandLogo"]; - } - result["details"] = details; - result["paymentMethodAsset"] = paymentMethodAsset; - - Boolean favourite = (Boolean) wallet["favourite"]; - JObject clients = new JObject(); - JObject clientIO = new JObject(); - clientIO["status"] = "ENABLED"; - if(favourite == true) { - DateTime localDateUtc = DateTime.UtcNow; - DateTimeOffset lastUsageDateTimeOffset = new DateTimeOffset(localDateUtc); - clientIO["lastUsage"] = lastUsageDateTimeOffset.ToString("o"); - } - clients["IO"] = clientIO; - result["clients"] = clients; - - return result; - - }).SingleOrDefault(); - return walletResult; - }" /> - - - - - - application/json - - @(((JObject)context.Variables["walletResponseBody"]).ToString()) - - - - - - - application/json - - { - "title": "Wallet not found", - "status": 404, - "detail": "Wallet not found" - } - - - - - diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_post_wallets.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_post_wallets.xml.tpl index b29a028442..30229ae9a2 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_post_wallets.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_post_wallets.xml.tpl @@ -1,121 +1,41 @@ - - - - - - - @("https://${ecommerce_hostname}/pagopa-ecommerce-payment-methods-service/payment-methods/" + context.Variables["paymentMethodId"]) - GET - - IO - - - - - - - - application/json - - - { - "title": "Error retrieving eCommerce payment methods", - "status": 502, - "detail": "There was an error retrieving eCommerce payment methods" - } - - - - - ())" /> - - - { - { "CP", "pm-onboarding/creditcard" }, - { "BPAY", "pm-onboarding/bpay" }, - { "PPAL", "pm-onboarding/paypal" } - }; - - string redirectUrlPrefix; - paymentMethodTypeCodes.TryGetValue(returnedPaymentMethodTypeCode, out redirectUrlPrefix); - return redirectUrlPrefix; - }" /> - - - - - - application/json - - - { - "title": "Error retrieving eCommerce payment methods", - "status": 502, - "detail": "Invalid payment method name" - } - - - - - - - - - application/json - - @{ - return new JObject( - new JProperty("redirectUrl", $"https://${env}payment-wallet.pagopa.it/{(string)context.Variables["redirectUrlPrefix"]}#sessionToken={((string) context.Variables["sessionToken"])}") - ).ToString(); - } - - - - - - - - - - - - @{ - JObject inBody = context.Response.Body.As(preserveContent: true); - var redirectUrl = inBody["redirectUrl"]; - inBody["redirectUrl"] = redirectUrl + "&sessionToken=" + ((string)context.Variables.GetValueOrDefault("x-jwt-token","")); - inBody.Remove("walletId"); - return inBody.ToString(); - } - - + + + + + + @{ + JObject inBody = context.Response.Body.As(preserveContent: true); + var redirectUrl = inBody["redirectUrl"]; + inBody["redirectUrl"] = redirectUrl + "&sessionToken=" + ((string)context.Variables.GetValueOrDefault("x-jwt-token","")); + inBody.Remove("walletId"); + return inBody.ToString(); + } diff --git a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_update_applications.xml.tpl b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_update_applications.xml.tpl index 499271f8f1..ff630bf54e 100644 --- a/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_update_applications.xml.tpl +++ b/src/domains/pay-wallet-app/api/io-payment-wallet/v1/_update_applications.xml.tpl @@ -1,119 +1,14 @@ - - - - - - - - @($"{{pm-host}}/pp-restapi-CD/v2/wallet/{(string)context.Variables["idWalletPM"]}/payment-status") - PUT - - application/json - - - @($"Bearer {((String)context.Variables["sessionToken"])}") - - @{ - JObject requestBody = (JObject)context.Variables["requestBody"]; - JArray applications = (JArray)requestBody["applications"]; - foreach(JObject application in applications){ - String name = application["name"].ToString(); - String status = application["status"].ToString(); - if(name.Equals("PAGOPA")) { - return new JObject( - new JProperty("data", new JObject( - new JProperty("pagoPA", status.Equals("ENABLED")) - )) - ).ToString(); - } - } - return new JObject().ToString(); - } - - - - - - - - - - - - - - application/json - - - { - "title": "Unauthorized", - "status": 401, - "detail": "Unauthorized" - } - - - - - - - - application/json - - - { - "title": "Forbidden", - "status": 403, - "detail": "Forbidden" - } - - - - - - - - application/json - - - { - "title": "Not Found", - "status": 404, - "detail": "Wallet not found" - } - - - - - - - - application/json - - - { - "title": "Error changing wallet status", - "status": 502, - "detail": "There was an error changing wallet status" - } - - - - - - + - + - + - + \ No newline at end of file diff --git a/src/domains/shared-app/04_apim_io_wallet_session.tf b/src/domains/shared-app/04_apim_io_wallet_session.tf index 2bf4262ad0..d87391fd5e 100644 --- a/src/domains/shared-app/04_apim_io_wallet_session.tf +++ b/src/domains/shared-app/04_apim_io_wallet_session.tf @@ -61,21 +61,6 @@ module "apim_session_wallet_product" { ################################################# ## API session wallet token pagoPA for IO ## ################################################# -resource "azurerm_api_management_named_value" "ecommerce_io_pm_enabled" { - name = "enable-pm-ecommerce-io" - api_management_name = local.pagopa_apim_name - resource_group_name = local.pagopa_apim_rg - display_name = "enable-pm-ecommerce-io" - value = var.ecommerce_io_pm_enabled -} - -resource "azurerm_api_management_named_value" "ecommerce_for_io_pm_npg" { - name = "ecommerce-for-io-pm-npg-ff" - api_management_name = local.pagopa_apim_name - resource_group_name = local.pagopa_apim_rg - display_name = "ecommerce-for-io-pm-npg-ff" - value = var.ecommerce_for_io_pm_npg -} locals { apim_session_wallet_api = { diff --git a/src/domains/shared-app/api/session-wallet/v1/_base_policy.xml.tpl b/src/domains/shared-app/api/session-wallet/v1/_base_policy.xml.tpl index b7128af459..432a65e3a3 100644 --- a/src/domains/shared-app/api/session-wallet/v1/_base_policy.xml.tpl +++ b/src/domains/shared-app/api/session-wallet/v1/_base_policy.xml.tpl @@ -107,119 +107,110 @@ + + + @("${io_backend_base_path}/pagopa/api/v1/user?version=20200114") + GET + + application/json + + + @("Bearer " + (string)context.Variables.GetValueOrDefault("walletToken")) + + - - - - + + + + + application/json + + + { + "title": "Unauthorized", + "status": 401, + "detail": "Invalid session token" + } + + - - - - @("${io_backend_base_path}/pagopa/api/v1/user?version=20200114") - GET - - application/json - - - @("Bearer " + (string)context.Variables.GetValueOrDefault("walletToken")) - - - - - - - - application/json - - - { - "title": "Unauthorized", - "status": 401, - "detail": "Invalid session token" - } - - - - - - - - application/json - - - { - "title": "Error starting session", - "status": 502, - "detail": "There was an error while getting user info" - } - - - - - ())" /> - + + + + + application/json + + + { + "title": "Error starting session", + "status": 502, + "detail": "There was an error while getting user info" + } + + + + + ())" /> + - - - ${pdv_api_base_path}/tokens - PUT - - {{ecommerce-personal-data-vault-api-key}} - - @{ - JObject userAuthBody = (JObject)context.Variables["userAuthBody"]; - string spidEmail = (String)userAuthBody["spid_email"]; - string noticeEmail = (String)userAuthBody["notice_email"]; - string email = String.IsNullOrEmpty(noticeEmail) ? spidEmail : noticeEmail; - return new JObject( - new JProperty("pii", email) - ).ToString(); - } - - - - - - - - + + + ${pdv_api_base_path}/tokens + PUT + + {{ecommerce-personal-data-vault-api-key}} + + @{ + JObject userAuthBody = (JObject)context.Variables["userAuthBody"]; + string spidEmail = (String)userAuthBody["spid_email"]; + string noticeEmail = (String)userAuthBody["notice_email"]; + string email = String.IsNullOrEmpty(noticeEmail) ? spidEmail : noticeEmail; + return new JObject( + new JProperty("pii", email) + ).ToString(); + } + + + + + + + + - ())" /> - - + ())" /> + + - - - + + + // Return the HMAC SHA512-signed JWT as the value for the Authorization header + return $"{jwtHeaderBase64UrlEncoded}.{jwtPayloadBase64UrlEncoded}.{jwtSignatureBase64UrlEncoded}"; + }" /> - - diff --git a/src/domains/shared-app/api/session-wallet/v1/_fragment_policiy_chk_token.tpl.xml b/src/domains/shared-app/api/session-wallet/v1/_fragment_policiy_chk_token.tpl.xml deleted file mode 100644 index 54617223f3..0000000000 --- a/src/domains/shared-app/api/session-wallet/v1/_fragment_policiy_chk_token.tpl.xml +++ /dev/null @@ -1,44 +0,0 @@ - - - - @($"{{pm-host}}/pp-restapi-CD/v1/users/check-session?sessionToken={(string)context.Variables["sessionToken"]}") - GET - - @($"Bearer {((String)context.Variables["sessionToken"])}") - - - - - - - - application/json - - - { - "title": "Unauthorized", - "status": 401, - "detail": "Invalid session token" - } - - - - - - - - application/json - - - { - "title": "Error checking session", - "status": 502, - "detail": "There was an error checking session for token" - } - - - - - ())" /> - -