Skip to content

Commit cf14c07

Browse files
fix: [PIDM-1484] Add CHECKOUT_CART as eCommerce identifier (#168)
Co-authored-by: pagopa-github-bot <github-bot@pagopa.it>
1 parent 2b0dcaa commit cf14c07

File tree

9 files changed

+43
-29
lines changed

9 files changed

+43
-29
lines changed

docker/docker-compose.yml

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,24 @@ services:
88
build:
99
dockerfile: Dockerfile
1010
context: ../
11+
environment:
12+
# override helm environment variables to enable all functions
13+
AzureWebJobs.BizEventToReceiptProcessor.Disabled: "false"
14+
AzureWebJobs.CartReceiptToReviewed.Disabled: "false"
15+
AzureWebJobs.ReceiptToReviewed.Disabled: "false"
16+
AzureWebJobs.RecoverFailedCartReceipt.Disabled: "false"
17+
AzureWebJobs.RecoverFailedCartReceiptMassive.Disabled: "false"
18+
AzureWebJobs.RecoverFailedReceipt.Disabled: "false"
19+
AzureWebJobs.RecoverFailedReceiptMassive.Disabled: "false"
20+
AzureWebJobs.RecoverNotNotifiedCartReceipt.Disabled: "false"
21+
AzureWebJobs.RecoverNotNotifiedCartReceiptMassive.Disabled: "false"
22+
AzureWebJobs.RecoverNotNotifiedReceipt.Disabled: "false"
23+
AzureWebJobs.RecoverNotNotifiedReceiptMassive.Disabled: "false"
24+
# Disable cron job
25+
AzureWebJobs.RecoverFailedCartReceiptScheduled.Disabled: "true"
26+
AzureWebJobs.RecoverFailedReceiptScheduled.Disabled: "true"
27+
AzureWebJobs.RecoverNotNotifiedCartTimerTriggerProcessor.Disabled: "true"
28+
AzureWebJobs.RecoverNotNotifiedTimerTriggerProcessor.Disabled: "true"
1129
env_file:
1230
- ./.env
1331
ports:

helm/Chart.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ apiVersion: v2
22
name: pagopareceiptpdfdatastore
33
description: Microservice description
44
type: application
5-
version: 0.150.0
6-
appVersion: 1.17.5
5+
version: 0.151.0
6+
appVersion: 1.17.5-1-PIDM-1484-fix-biz-view-generation
77
dependencies:
88
- name: microservice-chart
99
version: 8.0.2

helm/values-dev.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ microservice-chart: &microservice-chart
44
fullnameOverride: "pagopa-receipt-pdf-datastore"
55
image:
66
repository: ghcr.io/pagopa/pagopa-receipt-pdf-datastore
7-
tag: "1.17.5"
7+
tag: "1.17.5-1-PIDM-1484-fix-biz-view-generation"
88
pullPolicy: Always
99
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
1010
livenessProbe:

helm/values-prod.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ microservice-chart: &microservice-chart
44
fullnameOverride: "pagopa-receipt-pdf-datastore"
55
image:
66
repository: ghcr.io/pagopa/pagopa-receipt-pdf-datastore
7-
tag: "1.17.5"
7+
tag: "1.17.5-1-PIDM-1484-fix-biz-view-generation"
88
pullPolicy: Always
99
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
1010
livenessProbe:

helm/values-uat.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ microservice-chart: &microservice-chart
44
fullnameOverride: "pagopa-receipt-pdf-datastore"
55
image:
66
repository: ghcr.io/pagopa/pagopa-receipt-pdf-datastore
7-
tag: "1.17.5"
7+
tag: "1.17.5-1-PIDM-1484-fix-biz-view-generation"
88
pullPolicy: Always
99
# https://github.com/Azure/azure-functions-host/blob/dev/src/WebJobs.Script.WebHost/Controllers/HostController.cs
1010
livenessProbe:

integration-test/src/config/.env.local

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,4 @@ RECEIPTS_COSMOS_CART_CONTAINER_NAME=cart-for-receipts
99
RECEIPT_ERROR_COSMOS_DB_CONTAINER_NAME=receipts-message-errors
1010
CART_RECEIPT_ERROR_COSMOS_DB_CONTAINER_NAME=cart-receipts-message-errors
1111

12-
HELPDESK_URL=http://localhost:50717/
12+
HELPDESK_URL=http://localhost:60486

openapi/openapi.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"title": "Receipts Datastore Helpdesk",
55
"description": "Microservice for exposing REST APIs about receipts datastore helpdesk.",
66
"termsOfService": "https://www.pagopa.gov.it/",
7-
"version": "1.17.5"
7+
"version": "1.17.5-1-PIDM-1484-fix-biz-view-generation"
88
},
99
"servers": [
1010
{

pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
<groupId>it.gov.pagopa.receipt</groupId>
77
<artifactId>receipt-pdf-datastore</artifactId>
8-
<version>1.17.5</version>
8+
<version>1.17.5-1-PIDM-1484-fix-biz-view-generation</version>
99
<packaging>jar</packaging>
1010

1111
<name>pagopa-receipt-pdf-datastore</name>

src/main/java/it/gov/pagopa/receipt/pdf/datastore/utils/BizEventToReceiptUtils.java

Lines changed: 17 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package it.gov.pagopa.receipt.pdf.datastore.utils;
22

3-
import com.microsoft.azure.functions.HttpRequestMessage;
4-
import com.microsoft.azure.functions.HttpResponseMessage;
5-
import com.microsoft.azure.functions.HttpStatus;
63
import it.gov.pagopa.receipt.pdf.datastore.entity.cart.CartForReceipt;
74
import it.gov.pagopa.receipt.pdf.datastore.entity.cart.CartStatusType;
85
import it.gov.pagopa.receipt.pdf.datastore.entity.event.BizEvent;
@@ -13,7 +10,6 @@
1310
import it.gov.pagopa.receipt.pdf.datastore.entity.receipt.EventData;
1411
import it.gov.pagopa.receipt.pdf.datastore.entity.receipt.Receipt;
1512
import it.gov.pagopa.receipt.pdf.datastore.entity.receipt.enumeration.ReceiptStatusType;
16-
import it.gov.pagopa.receipt.pdf.datastore.model.ProblemJson;
1713
import it.gov.pagopa.receipt.pdf.datastore.service.BizEventToReceiptService;
1814
import lombok.Builder;
1915
import org.slf4j.Logger;
@@ -25,7 +21,6 @@
2521
import java.util.Collections;
2622
import java.util.List;
2723
import java.util.Locale;
28-
import java.util.Optional;
2924
import java.util.UUID;
3025
import java.util.regex.Matcher;
3126
import java.util.regex.Pattern;
@@ -39,7 +34,7 @@ public class BizEventToReceiptUtils {
3934
"AUTHENTICATED_CHANNELS", "IO,CHECKOUT,WISP,CHECKOUT_CART").split(","));
4035
private static final List<String> UNWANTED_REMITTANCE_INFO = Arrays.asList(System.getenv().getOrDefault(
4136
"UNWANTED_REMITTANCE_INFO", "pagamento multibeneficiario,pagamento bpay").split(","));
42-
private static final String ECOMMERCE = "CHECKOUT";
37+
private static final List<String> ECOMMERCE = Arrays.asList("CHECKOUT", "CHECKOUT_CART");
4338

4439

4540
private BizEventToReceiptUtils() {
@@ -118,7 +113,7 @@ public static BizEventValidityCheck isBizEventInvalid(BizEvent bizEvent) {
118113
if (Boolean.TRUE.equals(ECOMMERCE_FILTER_ENABLED)
119114
&& bizEvent.getTransactionDetails() != null
120115
&& bizEvent.getTransactionDetails().getInfo() != null
121-
&& ECOMMERCE.equals(bizEvent.getTransactionDetails().getInfo().getClientId())
116+
&& ECOMMERCE.contains(bizEvent.getTransactionDetails().getInfo().getClientId())
122117
) {
123118
return BizEventValidityCheck.builder()
124119
.invalid(true)
@@ -294,30 +289,31 @@ public static boolean isCartMod1(BizEvent bizEvent) {
294289
}
295290

296291
public static boolean isValidChannelOrigin(BizEvent bizEvent) {
297-
if (bizEvent.getTransactionDetails() == null) {
292+
var details = bizEvent.getTransactionDetails();
293+
if (details == null) {
298294
return false;
299295
}
300296

301-
var transactionDetails = bizEvent.getTransactionDetails();
302-
var transaction = transactionDetails.getTransaction();
303-
var info = transactionDetails.getInfo();
304-
var user = transactionDetails.getUser();
297+
String origin = details.getTransaction() != null
298+
? details.getTransaction().getOrigin()
299+
: null;
305300

306-
String origin = (transaction != null) ? transaction.getOrigin() : null;
307-
String clientId = (info != null) ? info.getClientId() : null;
308-
UserType userType = (user != null) ? user.getType() : null;
301+
String clientId = details.getInfo() != null
302+
? details.getInfo().getClientId()
303+
: null;
309304

310-
boolean originMatches = origin != null && AUTHENTICATED_CHANNELS.contains(origin);
311-
boolean clientIdMatches = clientId != null && AUTHENTICATED_CHANNELS.contains(clientId);
305+
UserType userType = details.getUser() != null
306+
? details.getUser().getType()
307+
: null;
312308

313-
boolean isCheckoutOrigin = ECOMMERCE.equalsIgnoreCase(origin);
314-
boolean isCheckoutClientId = ECOMMERCE.equalsIgnoreCase(clientId);
309+
boolean isAuthenticated = AUTHENTICATED_CHANNELS.contains(origin) || AUTHENTICATED_CHANNELS.contains(clientId);
310+
boolean isCheckout = ECOMMERCE.contains(origin) || ECOMMERCE.contains(clientId);
315311
boolean isRegisteredUser = UserType.REGISTERED.equals(userType);
316312

317-
if ((isCheckoutOrigin || isCheckoutClientId) && !isRegisteredUser) {
313+
if (isCheckout && !isRegisteredUser) {
318314
return false;
319315
}
320316

321-
return originMatches || clientIdMatches;
317+
return isAuthenticated;
322318
}
323319
}

0 commit comments

Comments
 (0)