Skip to content

Commit

Permalink
remove all references to NPG switch business logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Gianluca Ciuffa authored and Gianluca Ciuffa committed Oct 10, 2024
1 parent 768e269 commit 3cae54b
Show file tree
Hide file tree
Showing 21 changed files with 357 additions and 1,924 deletions.
103 changes: 48 additions & 55 deletions src/domains/bizevents-app/api/lap-service/v1/_base_policy-jwt.xml
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,66 @@
<!-- 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" />
<include-fragment fragment-id="jwt-chk-wallet-session" />
<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>
<when condition="@("NPG".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="jwt-chk-wallet-session" />
<choose>
<when condition="@((string)context.Variables.GetValueOrDefault("xUserId","") != "")">

<!-- <trace source="transaction-service-IO-JWT-start" severity="information">transaction-service-IO-JWT-start</trace> -->
<when condition="@((string)context.Variables.GetValueOrDefault("xUserId","") != "")">

<!-- Post Token PDV : START Find PII -->
<send-request ignore-error="true" timeout="10" response-variable-name="pdvfindpii" mode="new">
<set-url>@(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"]))</set-url>
<set-method>GET</set-method>
<set-header name="x-api-key" exists-action="override">
<value>{{wallet-session-personal-data-vault-api-key}}</value>
</set-header>
</send-request>
<choose>
<when condition="@(((IResponse)context.Variables["pdvfindpii"]).StatusCode != 200)">
<return-response>
<set-status code="502" reason="Bad Gateway" />
</return-response>
</when>
</choose>

<set-variable name="pdvFindPII" value="@(((IResponse)context.Variables["pdvfindpii"]).Body.As<JObject>())" />
<set-variable name="fiscalCode" value="@((string)((JObject)context.Variables["pdvFindPII"])["pii"])" />
<choose>
<when condition="@(String.IsNullOrEmpty((string)context.Variables["fiscalCode"]))">
<return-response>
<set-status code="502" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("title", "Bad gateway - Invalid PDV response"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find PII")
).ToString();
}</set-body>
</return-response>
</when>
</choose>
<!-- Post Token PDV : END Find PII -->
<!-- <trace source="transaction-service-IO-JWT-start" severity="information">transaction-service-IO-JWT-start</trace> -->

<!-- <trace source="transaction-service-IO-JWT-end" severity="information">transaction-service-IO-JWT-end</trace> -->
<!-- Post Token PDV : START Find PII -->
<send-request ignore-error="true" timeout="10" response-variable-name="pdvfindpii" mode="new">
<set-url>@(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"]))</set-url>
<set-method>GET</set-method>
<set-header name="x-api-key" exists-action="override">
<value>{{wallet-session-personal-data-vault-api-key}}</value>
</set-header>
</send-request>
<choose>
<when condition="@(((IResponse)context.Variables["pdvfindpii"]).StatusCode != 200)">
<return-response>
<set-status code="502" reason="Bad Gateway" />
</return-response>
</when>
<otherwise>
</choose>

<set-variable name="pdvFindPII" value="@(((IResponse)context.Variables["pdvfindpii"]).Body.As<JObject>())" />
<set-variable name="fiscalCode" value="@((string)((JObject)context.Variables["pdvFindPII"])["pii"])" />
<choose>
<when condition="@(String.IsNullOrEmpty((string)context.Variables["fiscalCode"]))">
<return-response>
<set-status code="502" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("title", "Bad gateway - Not call PDV"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find xUserId")
).ToString();
}</set-body>
</return-response>
</otherwise>
return new JObject(
new JProperty("title", "Bad gateway - Invalid PDV response"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find PII")
).ToString();
}</set-body>
</return-response>
</when>
</choose>
<!-- Post Token PDV : END Find PII -->

<!-- <trace source="transaction-service-IO-JWT-end" severity="information">transaction-service-IO-JWT-end</trace> -->
</when>
<otherwise>
<return-response>
<set-status code="502" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("title", "Bad gateway - Not call PDV"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find xUserId")
).ToString();
}</set-body>
</return-response>
</otherwise>
</choose>

<set-header name="Ocp-Apim-Subscription-Keykey" exists-action="override">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,73 +16,66 @@
<!-- 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" />
<include-fragment fragment-id="jwt-chk-wallet-session" />
<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>
<when condition="@("NPG".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="jwt-chk-wallet-session" />
<choose>
<when condition="@((string)context.Variables.GetValueOrDefault("xUserId","") != "")">

<!-- <trace source="transaction-service-IO-JWT-start" severity="information">transaction-service-IO-JWT-start</trace> -->
<when condition="@((string)context.Variables.GetValueOrDefault("xUserId","") != "")">

<!-- Post Token PDV : START Find PII -->
<send-request ignore-error="true" timeout="10" response-variable-name="pdvfindpii" mode="new">
<set-url>@(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"]))</set-url>
<set-method>GET</set-method>
<set-header name="x-api-key" exists-action="override">
<value>{{wallet-session-personal-data-vault-api-key}}</value>
</set-header>
</send-request>
<choose>
<when condition="@(((IResponse)context.Variables["pdvfindpii"]).StatusCode != 200)">
<return-response>
<set-status code="502" reason="Bad Gateway" />
</return-response>
</when>
</choose>

<set-variable name="pdvFindPII" value="@(((IResponse)context.Variables["pdvfindpii"]).Body.As<JObject>())" />
<set-variable name="fiscalCode" value="@((string)((JObject)context.Variables["pdvFindPII"])["pii"])" />
<choose>
<when condition="@(String.IsNullOrEmpty((string)context.Variables["fiscalCode"]))">
<return-response>
<set-status code="502" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("title", "Bad gateway - Invalid PDV response"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find PII")
).ToString();
}</set-body>
</return-response>
</when>
</choose>
<!-- Post Token PDV : END Find PII -->
<!-- <trace source="transaction-service-IO-JWT-start" severity="information">transaction-service-IO-JWT-start</trace> -->

<!-- <trace source="transaction-service-IO-JWT-end" severity="information">transaction-service-IO-JWT-end</trace> -->
<!-- Post Token PDV : START Find PII -->
<send-request ignore-error="true" timeout="10" response-variable-name="pdvfindpii" mode="new">
<set-url>@(String.Format("${pdv_api_base_path}/tokens/{0}/pii", (string) context.Variables["xUserId"]))</set-url>
<set-method>GET</set-method>
<set-header name="x-api-key" exists-action="override">
<value>{{wallet-session-personal-data-vault-api-key}}</value>
</set-header>
</send-request>
<choose>
<when condition="@(((IResponse)context.Variables["pdvfindpii"]).StatusCode != 200)">
<return-response>
<set-status code="502" reason="Bad Gateway" />
</return-response>
</when>
<otherwise>
</choose>

<set-variable name="pdvFindPII" value="@(((IResponse)context.Variables["pdvfindpii"]).Body.As<JObject>())" />
<set-variable name="fiscalCode" value="@((string)((JObject)context.Variables["pdvFindPII"])["pii"])" />
<choose>
<when condition="@(String.IsNullOrEmpty((string)context.Variables["fiscalCode"]))">
<return-response>
<set-status code="502" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("title", "Bad gateway - Not call PDV"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find xUserId")
).ToString();
}</set-body>
</return-response>
</otherwise>
return new JObject(
new JProperty("title", "Bad gateway - Invalid PDV response"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find PII")
).ToString();
}</set-body>
</return-response>
</when>
</choose>
<!-- Post Token PDV : END Find PII -->

<!-- <trace source="transaction-service-IO-JWT-end" severity="information">transaction-service-IO-JWT-end</trace> -->
</when>
<otherwise>
<return-response>
<set-status code="502" />
<set-header name="Content-Type" exists-action="override">
<value>application/json</value>
</set-header>
<set-body>@{
return new JObject(
new JProperty("title", "Bad gateway - Not call PDV"),
new JProperty("status", 502),
new JProperty("detail", "Cannot find xUserId")
).ToString();
}</set-body>
</return-response>
</otherwise>
</choose>

<set-header name="Ocp-Apim-Subscription-Keykey" exists-action="override">
Expand Down
Loading

0 comments on commit 3cae54b

Please sign in to comment.