Skip to content

Commit

Permalink
chore: [IOBP-715] Expired payment methods filtering (#5903)
Browse files Browse the repository at this point in the history
## Short description
This PR adds a filter to hide saved payment methods that are expired at
the time of payment.

## List of changes proposed in this pull request
- Added a condition into the selector that filters all the available
payment methods in the payment flow.

## How to test
- Enable the new wallet section FF;
- Simulate with the dev-server an expired card editing the `expiryDate`
attribute
- You shouldn't be able to see that expired payment method while
performing a payment
  • Loading branch information
Hantex9 authored Jun 28, 2024
1 parent 56bc826 commit d4b1cb7
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions ts/features/payments/checkout/store/selectors/paymentMethods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ import { getLatestUsedWallet, isValidPaymentMethod } from "../../utils";
import { Wallets } from "../../../../../../definitions/pagopa/ecommerce/Wallets";
import { WalletApplicationStatusEnum } from "../../../../../../definitions/pagopa/ecommerce/WalletApplicationStatus";
import { WalletApplicationNameEnum } from "../../../../../../definitions/pagopa/ecommerce/WalletApplicationName";
import { UIWalletInfoDetails } from "../../../common/types/UIWalletInfoDetails";
import { isPaymentMethodExpired } from "../../../common/utils";
import { selectPaymentsCheckoutState, walletPaymentDetailsSelector } from ".";

export const walletPaymentUserWalletsSelector = createSelector(
Expand All @@ -19,13 +21,17 @@ export const walletPaymentEnabledUserWalletsSelector = createSelector(
walletPaymentUserWalletsSelector,
userWalletsPot =>
pot.map(userWalletsPot, userWallets =>
userWallets.filter(wallet =>
wallet.applications.find(
app =>
app.name === WalletApplicationNameEnum.PAGOPA &&
app.status === WalletApplicationStatusEnum.ENABLED
)
)
userWallets.filter(wallet => {
const walletDetails = wallet.details as UIWalletInfoDetails;
return (
!isPaymentMethodExpired(walletDetails) &&
wallet.applications.find(
app =>
app.name === WalletApplicationNameEnum.PAGOPA &&
app.status === WalletApplicationStatusEnum.ENABLED
)
);
})
)
);

Expand Down

0 comments on commit d4b1cb7

Please sign in to comment.