Skip to content

Commit

Permalink
Merge branch 'master' into feature/fims
Browse files Browse the repository at this point in the history
  • Loading branch information
Vangaorth authored Apr 22, 2024
2 parents 9f7f4a0 + b881405 commit d1f1bb2
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 22 deletions.
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
14 changes: 7 additions & 7 deletions src/features/wallet/persistence/userWallet.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -59,21 +60,20 @@ const generateWalletData = () => {

const updateUserWalletApplication = (
walletId: string,
services?: ReadonlyArray<WalletApplication>
applications?: ReadonlyArray<WalletApplication>
) => {
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);
}
Expand Down
4 changes: 1 addition & 3 deletions src/features/wallet/routers/payment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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)
)
Expand Down
28 changes: 18 additions & 10 deletions src/features/wallet/types/failure.ts
Original file line number Diff line number Diff line change
@@ -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<typeof WalletPaymentFailure>;
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;
}
};

0 comments on commit d1f1bb2

Please sign in to comment.