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

chore: [IOBP-665,IOBP-570] PayPal metadata and latest used payment method adaption #5803

Merged
merged 6 commits into from
Jun 4, 2024
Merged
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
2 changes: 2 additions & 0 deletions locales/en/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,8 @@ wallet:
title: Vuoi interrompere l'operazione?
confirm: Sì, interrompi
cancel: No, torna indietro
methodType:
fastPayPalPayment: Pagamento veloce con PayPal
methodSelection:
header: Seleziona un metodo
yourMethods: Saved
Expand Down
2 changes: 2 additions & 0 deletions locales/it/index.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1714,6 +1714,8 @@ wallet:
title: Vuoi interrompere l'operazione?
confirm: Sì, interrompi
cancel: No, torna indietro
methodType:
fastPayPalPayment: Pagamento veloce con PayPal
methodSelection:
header: Seleziona un metodo
yourMethods: Salvati
Expand Down
4 changes: 2 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"services_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.35.0-RELEASE/api_services_app_backend.yaml",
"lollipop_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.35.0-RELEASE/api_lollipop_first_consumer.yaml",
"fast_login_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.35.0-RELEASE/openapi/generated/api_fast_login.yaml",
"pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/95477f43e87016a979d26b5a81eee32c308af96d/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl",
"pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/95477f43e87016a979d26b5a81eee32c308af96d/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl",
"pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/4ecc4c41f0a0692361d6d93ab7481a22c99bc21d/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl",
"pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/4ecc4c41f0a0692361d6d93ab7481a22c99bc21d/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl",
"trial_system": "https://raw.githubusercontent.com/pagopa/io-backend/features/add-openapi-trial-service/api_trial_system.yaml",
"private": true,
"scripts": {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,10 +228,16 @@ const mapUserWalletToRadioItem = (
startImage
};
} else if (details.maskedEmail !== undefined) {
const details = method.details as UIWalletInfoDetails;
const description =
details.pspBusinessName && details.maskedEmail
? `${details.pspBusinessName} · ${details.maskedEmail}`
: undefined;
return {
id: method.walletId,
value: "PayPal",
startImage
value: I18n.t("wallet.payment.methodType.fastPayPalPayment"),
startImage,
description
};
} else if (details.maskedNumber !== undefined) {
return {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import { getGenericError } from "../../../../../../utils/errors";
import { readablePrivacyReport } from "../../../../../../utils/reporters";
import { WalletStatusEnum } from "../../../../../../../definitions/pagopa/ecommerce/WalletStatus";
import { selectWalletPaymentSessionToken } from "../../../store/selectors";
import { WalletClientStatusEnum } from "../../../../../../../definitions/pagopa/ecommerce/WalletClientStatus";

describe("Test handleWalletPaymentGetUserWallets saga", () => {
const T_SESSION_TOKEN = "ABCD";
Expand All @@ -25,6 +26,12 @@ describe("Test handleWalletPaymentGetUserWallets saga", () => {
paymentMethodId: "paymentMethodId",
paymentMethodAsset: "paymentMethodAsset",
applications: [],
clients: {
IO: {
status: WalletClientStatusEnum.ENABLED,
lastUsage: new Date()
}
},
status: WalletStatusEnum.VALIDATED,
updateDate: new Date()
}
Expand Down
8 changes: 4 additions & 4 deletions ts/features/payments/checkout/store/reducers/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import {
selectPaymentPspAction,
walletPaymentSetCurrentStep
} from "../actions/orchestration";
import { getLatestUsedWallet } from "../../utils";
export const WALLET_PAYMENT_STEP_MAX = 4;

export type PaymentsCheckoutState = {
Expand Down Expand Up @@ -132,10 +133,9 @@ const reducer = (
return {
...state,
userWallets: pot.some(action.payload),
selectedWallet: O.fromNullable(
action.payload?.wallets?.reduce((acc, curr) =>
acc.updateDate > curr.updateDate ? acc : curr
)
selectedWallet: pipe(
O.fromNullable(action.payload.wallets),
O.chain(getLatestUsedWallet)
)
};
case getType(paymentsGetPaymentUserMethodsAction.failure):
Expand Down
12 changes: 2 additions & 10 deletions ts/features/payments/checkout/store/selectors/paymentMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import { createSelector } from "reselect";
import { PaymentMethodsResponse } from "../../../../../../definitions/pagopa/ecommerce/PaymentMethodsResponse";
import { isValidPaymentMethod } from "../../utils";
import { getLatestUsedWallet, isValidPaymentMethod } from "../../utils";
import { Wallets } from "../../../../../../definitions/pagopa/ecommerce/Wallets";
import { selectPaymentsCheckoutState, walletPaymentDetailsSelector } from ".";

Expand All @@ -17,15 +17,7 @@ export const walletPaymentUserWalletsSelector = createSelector(
export const walletPaymentUserWalletLastUpdatedSelector = createSelector(
walletPaymentUserWalletsSelector,
userWalletsPot =>
pipe(
userWalletsPot,
pot.toOption,
O.map(userWallets =>
userWallets.reduce((acc, curr) =>
acc.updateDate > curr.updateDate ? acc : curr
)
)
)
pipe(userWalletsPot, pot.toOption, O.chain(getLatestUsedWallet))
);

export const walletPaymentAllMethodsSelector = createSelector(
Expand Down
23 changes: 23 additions & 0 deletions ts/features/payments/checkout/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
import * as RA from "fp-ts/lib/ReadonlyArray";
import * as O from "fp-ts/lib/Option";
import { pipe } from "fp-ts/lib/function";
import { PaymentMethodManagementTypeEnum } from "../../../../../definitions/pagopa/ecommerce/PaymentMethodManagementType";
import { PaymentMethodResponse } from "../../../../../definitions/pagopa/ecommerce/PaymentMethodResponse";
import { WalletInfo } from "../../../../../definitions/pagopa/ecommerce/WalletInfo";
import { WalletClientStatusEnum } from "../../../../../definitions/pagopa/walletv3/WalletClientStatus";

export const WALLET_PAYMENT_FEEDBACK_URL =
"https://io.italia.it/diccilatua/ces-pagamento";
Expand All @@ -9,3 +14,21 @@ export const isValidPaymentMethod = (method: PaymentMethodResponse) =>
method.methodManagement === PaymentMethodManagementTypeEnum.NOT_ONBOARDABLE ||
method.methodManagement ===
PaymentMethodManagementTypeEnum.ONBOARDABLE_WITH_PAYMENT;

export const getLatestUsedWallet = (
wallets: ReadonlyArray<WalletInfo>
): O.Option<WalletInfo> =>
pipe(
wallets,
RA.filter(
wallet => wallet.clients.IO.status === WalletClientStatusEnum.ENABLED
),
RA.reduce<WalletInfo, WalletInfo | undefined>(undefined, (acc, curr) =>
acc?.clients.IO?.lastUsage &&
curr.clients.IO?.lastUsage &&
acc.clients.IO.lastUsage > curr.clients.IO.lastUsage
? acc
: curr
),
O.fromNullable
);
Loading