diff --git a/package.json b/package.json index 0b89cf75..7010cb34 100644 --- a/package.json +++ b/package.json @@ -20,8 +20,8 @@ "api_pn": "https://raw.githubusercontent.com/pagopa/io-backend/v13.32.1-RELEASE/api_pn.yaml", "api_idpay": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v6.5.0/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml", "api_fast_login": "https://raw.githubusercontent.com/pagopa/io-backend/v13.32.1-RELEASE/openapi/generated/api_fast_login.yaml", - "api_pagopa_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/fe1a6780a8589c0f160d668bcaf592b1a3442084/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl", - "api_pagopa_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/fe1a6780a8589c0f160d668bcaf592b1a3442084/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl", + "api_pagopa_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/8b8a5b0c3ebc007d9b8f1a8dc4ae9b88b63b5794/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl", + "api_pagopa_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/8b8a5b0c3ebc007d9b8f1a8dc4ae9b88b63b5794/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl", "author": "Matteo Boschi", "license": "MIT", "private": false, diff --git a/src/features/wallet/persistence/userWallet.ts b/src/features/wallet/persistence/userWallet.ts index 1b778eb5..6306ce8c 100644 --- a/src/features/wallet/persistence/userWallet.ts +++ b/src/features/wallet/persistence/userWallet.ts @@ -3,6 +3,7 @@ import { format } from "date-fns"; import * as E from "fp-ts/lib/Either"; import _ from "lodash"; import { WalletApplication } from "../../../../generated/definitions/pagopa/walletv3/WalletApplication"; +import { WalletApplicationInfo } from "../../../../generated/definitions/pagopa/walletv3/WalletApplicationInfo"; import { WalletApplicationStatusEnum } from "../../../../generated/definitions/pagopa/walletv3/WalletApplicationStatus"; import { WalletInfo } from "../../../../generated/definitions/pagopa/walletv3/WalletInfo"; import { WalletInfoDetails } from "../../../../generated/definitions/pagopa/walletv3/WalletInfoDetails"; @@ -59,21 +60,20 @@ const generateWalletData = () => { const updateUserWalletApplication = ( walletId: string, - services?: ReadonlyArray + applications?: ReadonlyArray ) => { - if (getUserWalletInfo(walletId) && services) { + if (getUserWalletInfo(walletId) && applications) { const userWallet = getUserWalletInfo(walletId) as WalletInfo; removeUserWallet(walletId); - const wallet: WalletInfo = { - ...userWallet, - applications: services.map( + const wallet = _.merge(userWallet, { + applications: applications.map( service => ({ ...service, updateDate: new Date() - } as WalletApplication) + } as WalletApplicationInfo) ) - }; + }); addUserWallet(wallet); return E.right(wallet); } diff --git a/src/features/wallet/routers/payment.ts b/src/features/wallet/routers/payment.ts index 4bacd322..28e28ba5 100644 --- a/src/features/wallet/routers/payment.ts +++ b/src/features/wallet/routers/payment.ts @@ -8,7 +8,6 @@ import { NewTransactionRequest } from "../../../../generated/definitions/pagopa/ import { RequestAuthorizationRequest } from "../../../../generated/definitions/pagopa/ecommerce/RequestAuthorizationRequest"; import { RequestAuthorizationResponse } from "../../../../generated/definitions/pagopa/ecommerce/RequestAuthorizationResponse"; import { RptId } from "../../../../generated/definitions/pagopa/ecommerce/RptId"; -import { ValidationFaultEnum } from "../../../../generated/definitions/pagopa/ecommerce/ValidationFault"; import { ioDevServerConfig } from "../../../config"; import { serverUrl } from "../../../utils/server"; import { getPaymentRequestsGetResponse } from "../payloads/payments"; @@ -52,8 +51,7 @@ addPaymentHandler("get", "/payment-requests/:rpt_id", (req, res) => () => res.status(404).json({ faultCodeCategory: FaultCategoryEnum.PAYMENT_UNKNOWN, - faultCodeDetail: - ValidationFaultEnum.PAA_PAGAMENTO_SCONOSCIUTO + faultCodeDetail: "" }), response => res.status(200).json(response) ) diff --git a/src/features/wallet/types/failure.ts b/src/features/wallet/types/failure.ts index 44814db9..bf1ed4ee 100644 --- a/src/features/wallet/types/failure.ts +++ b/src/features/wallet/types/failure.ts @@ -1,31 +1,39 @@ import * as t from "io-ts"; import { GatewayFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/GatewayFaultPaymentProblemJson"; import { PartyConfigurationFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PartyConfigurationFaultPaymentProblemJson"; -import { PartyTimeoutFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PartyTimeoutFaultPaymentProblemJson"; -import { PaymentStatusFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PaymentStatusFaultPaymentProblemJson"; -import { ValidationFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/ValidationFaultPaymentProblemJson"; +import { PaymentCanceledStatusFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PaymentCanceledStatusFaultPaymentProblemJson"; +import { PaymentDuplicatedStatusFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PaymentDuplicatedStatusFaultPaymentProblemJson"; +import { PaymentExpiredStatusFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PaymentExpiredStatusFaultPaymentProblemJson"; +import { PaymentOngoingStatusFaultPaymentProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/PaymentOngoingStatusFaultPaymentProblemJson"; +import { ValidationFaultPaymentDataErrorProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/ValidationFaultPaymentDataErrorProblemJson"; +import { ValidationFaultPaymentUnavailableProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/ValidationFaultPaymentUnavailableProblemJson"; +import { ValidationFaultPaymentUnknownProblemJson } from "../../../../generated/definitions/pagopa/ecommerce/ValidationFaultPaymentUnknownProblemJson"; export type WalletPaymentFailure = t.TypeOf; export const WalletPaymentFailure = t.union([ - ValidationFaultPaymentProblemJson, - PaymentStatusFaultPaymentProblemJson, GatewayFaultPaymentProblemJson, PartyConfigurationFaultPaymentProblemJson, - PartyTimeoutFaultPaymentProblemJson + ValidationFaultPaymentUnknownProblemJson, + ValidationFaultPaymentDataErrorProblemJson, + PaymentExpiredStatusFaultPaymentProblemJson, + PaymentOngoingStatusFaultPaymentProblemJson, + PaymentCanceledStatusFaultPaymentProblemJson, + ValidationFaultPaymentUnavailableProblemJson, + PaymentDuplicatedStatusFaultPaymentProblemJson ]); export const getStatusCodeForWalletFailure = ( failure: WalletPaymentFailure -): 404 | 409 | 502 | 503 | 504 => { - if (ValidationFaultPaymentProblemJson.is(failure)) { +): 400 | 404 | 409 | 502 | 503 => { + if (ValidationFaultPaymentUnknownProblemJson.is(failure)) { return 404; - } else if (PaymentStatusFaultPaymentProblemJson.is(failure)) { + } else if (PaymentDuplicatedStatusFaultPaymentProblemJson.is(failure)) { return 409; } else if (GatewayFaultPaymentProblemJson.is(failure)) { return 502; } else if (PartyConfigurationFaultPaymentProblemJson.is(failure)) { return 503; } else { - return 504; + return 400; } };