Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: [CHK-3318] remove npgff from pay wallet #2478

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 0 additions & 36 deletions src/domains/pay-wallet-app/04_apim_io_payment_wallet.tf
Original file line number Diff line number Diff line change
Expand Up @@ -69,15 +69,6 @@ module "apim_io_payment_wallet_api_v1" {
})
}

resource "azurerm_api_management_api_operation_policy" "delete_io_wallets" {
api_name = "${local.project}-io-payment-wallet-api-v1"
resource_group_name = local.pagopa_apim_rg
api_management_name = local.pagopa_apim_name
operation_id = "deleteIOPaymentWalletById"

xml_content = file("./api/io-payment-wallet/v1/_delete_wallet.xml.tpl")
}

resource "azurerm_api_management_api_operation_policy" "get_payment_methods_for_io" {
api_name = "${local.project}-io-payment-wallet-api-v1"
resource_group_name = local.pagopa_apim_rg
Expand All @@ -92,24 +83,6 @@ resource "azurerm_api_management_api_operation_policy" "get_payment_methods_for_
)
}

resource "azurerm_api_management_api_operation_policy" "get_wallets_by_user_and_walletId_for_io" {
api_name = "${local.project}-io-payment-wallet-api-v1"
resource_group_name = local.pagopa_apim_rg
api_management_name = local.pagopa_apim_name
operation_id = "getIOPaymentWalletById"

xml_content = templatefile("./api/io-payment-wallet/v1/_get_wallets_by_user_and_walletId.xml.tpl", { ecommerce_hostname = local.ecommerce_hostname })
}

resource "azurerm_api_management_api_operation_policy" "get_wallets_by_user_for_io" {
api_name = "${local.project}-io-payment-wallet-api-v1"
resource_group_name = local.pagopa_apim_rg
api_management_name = local.pagopa_apim_name
operation_id = "getIOPaymentWalletsByIdUser"

xml_content = templatefile("./api/io-payment-wallet/v1/_get_wallets_by_user.xml.tpl", { ecommerce_hostname = local.ecommerce_hostname })
}

resource "azurerm_api_management_api_operation_policy" "post_io_wallets" {
api_name = "${local.project}-io-payment-wallet-api-v1"
resource_group_name = local.pagopa_apim_rg
Expand All @@ -122,15 +95,6 @@ resource "azurerm_api_management_api_operation_policy" "post_io_wallets" {
})
}

resource "azurerm_api_management_api_operation_policy" "update_applications_for_io" {
api_name = "${local.project}-io-payment-wallet-api-v1"
resource_group_name = local.pagopa_apim_rg
api_management_name = local.pagopa_apim_name
operation_id = "updateIOPaymentWalletApplicationsById"

xml_content = file("./api/io-payment-wallet/v1/_update_applications.xml.tpl")
}


resource "azurerm_api_management_named_value" "pay_wallet_family_friends_user_ids" {
name = "pay-wallet-family-friends-user-ids"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,7 @@
<!-- fragment to read user id from session token jwt claims. it return userId as sessionTokenUserId variable taken from jwt claims. if the session token
is an opaque token a "session-token-not-found" string is returned-->
<include-fragment fragment-id="pay-wallet-user-id-from-session-token" />
<choose>
<when condition="@("PM".Equals("{{ecommerce-for-io-pm-npg-ff}}") || ("NPGFF".Equals("{{ecommerce-for-io-pm-npg-ff}}") && !"{{pay-wallet-family-friends-user-ids}}".Contains(((string)context.Variables["sessionTokenUserId"]))))">
<set-variable name="sessionToken" value="@(context.Request.Headers.GetValueOrDefault("Authorization", "").Replace("Bearer ",""))" />
</when>
<otherwise>

<!-- Delete headers required for backend service START -->
<set-header name="x-user-id" exists-action="delete" />
<set-header name="x-client-id" exists-action="delete" />
Expand All @@ -24,8 +20,7 @@
<!-- Headers settings required for backend service END -->
<set-variable name="blueDeploymentPrefix" value="@(context.Request.Headers.GetValueOrDefault("deployment","").Contains("blue")?"/beta":"")" />
<set-backend-service base-url="@("https://${hostname}"+context.Variables["blueDeploymentPrefix"]+"/pagopa-wallet-service")" />
</otherwise>
</choose>

<set-header name="x-client-id" exists-action="override" >
<value>IO</value>
</set-header>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,76 +1,6 @@
<policies>
<inbound>
<base />
<choose>
<when condition="@("PM".Equals("{{ecommerce-for-io-pm-npg-ff}}") || ("NPGFF".Equals("{{ecommerce-for-io-pm-npg-ff}}") && !"{{pay-wallet-family-friends-user-ids}}".Contains(((string)context.Variables["sessionTokenUserId"]))))">
<!-- START delete wallet -->
<set-variable name="idWalletPM" value="@{
string walletId = context.Request.MatchedParameters["walletId"];
return Convert.ToInt32("0x" + walletId.Substring(walletId.Length - 12), 16).ToString();
}" />
<send-request ignore-error="false" timeout="10" response-variable-name="pmWalletDeleteResponse">
<set-url>@($"{{pm-host}}/pp-restapi-CD/v1/wallet/{(string)context.Variables["idWalletPM"]}")</set-url>
<set-method>DELETE</set-method>
<set-header name="Authorization" exists-action="override">
<value>@($"Bearer {((String)context.Variables["sessionToken"])}")</value>
</set-header>
</send-request>
<!-- END delete wallet -->
<set-variable name="deleteStatusCode" value="@(((IResponse)context.Variables["pmWalletDeleteResponse"]).StatusCode)" />
<choose>
<when condition="@(((int)context.Variables["deleteStatusCode"]) == 200 || ((int)context.Variables["deleteStatusCode"]) == 204)">
<return-response>
<set-status code="204" reason="No content" />
</return-response>
</when>
<when condition="@(((int)context.Variables["deleteStatusCode"]) == 401)">
<return-response>
<set-status code="401" reason="Unauthorized" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>
{
"title": "Unauthorized",
"status": 401,
"detail": "Unauthorized"
}
</set-body>
</return-response>
</when>
<when condition="@(((int)context.Variables["deleteStatusCode"]) == 404)">
<return-response>
<set-status code="404" reason="Not Found" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>
{
"title": "Not Found",
"status": 404,
"detail": "Wallet not found"
}
</set-body>
</return-response>
</when>
<otherwise>
<return-response>
<set-status code="502" reason="Bad Gateway" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>
{
"title": "Error deleting wallet",
"status": 502,
"detail": "There was an error deleting wallet"
}
</set-body>
</return-response>
</otherwise>
</choose>
</when>
</choose>
</inbound>
<outbound>
<base />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,43 +1,10 @@
<policies>
<inbound>
<base />
<choose>
<when condition="@("PM".Equals("{{ecommerce-for-io-pm-npg-ff}}") || ("NPGFF".Equals("{{ecommerce-for-io-pm-npg-ff}}") && !"{{pay-wallet-family-friends-user-ids}}".Contains(((string)context.Variables["sessionTokenUserId"]))))">
<include-fragment fragment-id="pm-chk-wallet-session" />
</when>
</choose>
<set-backend-service base-url="https://${ecommerce_hostname}/pagopa-ecommerce-payment-methods-service"/>
</inbound>
<outbound>
<base />
<choose>
<when condition="@("PM".Equals("{{ecommerce-for-io-pm-npg-ff}}") || ("NPGFF".Equals("{{ecommerce-for-io-pm-npg-ff}}") && !"{{pay-wallet-family-friends-user-ids}}".Contains(((string)context.Variables["sessionTokenUserId"]))))">
<set-body>@{
JObject response = context.Response.Body.As<JObject>();

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<string> pmEnabledMethods = new HashSet<string>(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();
}
</set-body>
</when>
</choose>
</outbound>
<backend>
<base />
Expand Down
Loading
Loading