Skip to content

Commit

Permalink
chore: [IOBP-644] Add other onboardable method filters (#5785)
Browse files Browse the repository at this point in the history
## Short description
This PR adds a filter on onboardable methods in the add new method
section and a filter on methods with guest payment

## List of changes proposed in this pull request
- Upgraded the API definitions of e-commerce & walletv3;
- Created a utility function to filter the onboardable methods and guest
payment methods;

## How to test
- Check out this PR:
pagopa/io-dev-api-server#379
- Try the new payment checkout flow and onboarding flow with the feature
flag enabled
- You should be able to complete all the required steps with any error;
  • Loading branch information
Hantex9 authored May 29, 2024
1 parent 0e6759f commit 15086be
Show file tree
Hide file tree
Showing 7 changed files with 35 additions and 12 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 @@
"services_api": "https://raw.githubusercontent.com/pagopa/io-backend/master/api_services_app_backend.yaml",
"lollipop_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.32.1-RELEASE/api_lollipop_first_consumer.yaml",
"fast_login_api": "https://raw.githubusercontent.com/pagopa/io-backend/v13.32.1-RELEASE/openapi/generated/api_fast_login.yaml",
"pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/8b8a5b0c3ebc007d9b8f1a8dc4ae9b88b63b5794/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl",
"pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/8b8a5b0c3ebc007d9b8f1a8dc4ae9b88b63b5794/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl",
"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",
"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 @@ -4,6 +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 { Wallets } from "../../../../../../definitions/pagopa/ecommerce/Wallets";
import { selectPaymentsCheckoutState, walletPaymentDetailsSelector } from ".";

Expand All @@ -29,7 +30,11 @@ export const walletPaymentUserWalletLastUpdatedSelector = createSelector(

export const walletPaymentAllMethodsSelector = createSelector(
selectPaymentsCheckoutState,
state => pot.map(state.allPaymentMethods, _ => _.paymentMethods ?? [])
state =>
pot.map(
state.allPaymentMethods,
({ paymentMethods }) => paymentMethods?.filter(isValidPaymentMethod) ?? []
)
);

export const walletPaymentMethodByIdSelector = createSelector(
Expand Down
9 changes: 9 additions & 0 deletions ts/features/payments/checkout/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,11 @@
import { PaymentMethodManagementTypeEnum } from "../../../../../definitions/pagopa/ecommerce/PaymentMethodManagementType";
import { PaymentMethodResponse } from "../../../../../definitions/pagopa/ecommerce/PaymentMethodResponse";

export const WALLET_PAYMENT_FEEDBACK_URL =
"https://io.italia.it/diccilatua/ces-pagamento";

export const isValidPaymentMethod = (method: PaymentMethodResponse) =>
method.methodManagement === PaymentMethodManagementTypeEnum.ONBOARDABLE ||
method.methodManagement === PaymentMethodManagementTypeEnum.NOT_ONBOARDABLE ||
method.methodManagement ===
PaymentMethodManagementTypeEnum.ONBOARDABLE_WITH_PAYMENT;
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ const MOCK_WALLET: WalletInfo = {
paymentMethodAsset: "",
paymentMethodId: "",
status: WalletStatusEnum.CREATED,
clients: {},
updateDate: new Date(),
details: {
type: "",
Expand Down
11 changes: 2 additions & 9 deletions ts/features/payments/onboarding/store/selectors/index.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
import * as pot from "@pagopa/ts-commons/lib/pot";
import { createSelector } from "reselect";
import { PaymentMethodManagementTypeEnum } from "../../../../../../definitions/pagopa/walletv3/PaymentMethodManagementType";
import { GlobalState } from "../../../../../store/reducers/types";
import { PaymentMethodStatusEnum } from "../../../../../../definitions/pagopa/walletv3/PaymentMethodStatus";
import { isMethodOnboardable } from "../../utils";

const walletOnboardingSelector = (state: GlobalState) =>
state.features.payments.onboarding;
Expand All @@ -20,13 +19,7 @@ export const selectPaymentOnboardingMethods = createSelector(
onboarding =>
pot.map(
onboarding.paymentMethods,
({ paymentMethods }) =>
paymentMethods?.filter(
method =>
method.methodManagement ===
PaymentMethodManagementTypeEnum.ONBOARDABLE &&
method.status === PaymentMethodStatusEnum.ENABLED
) ?? []
({ paymentMethods }) => paymentMethods?.filter(isMethodOnboardable) ?? []
)
);

Expand Down
14 changes: 14 additions & 0 deletions ts/features/payments/onboarding/utils/index.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
import { PaymentMethodManagementTypeEnum } from "../../../../../definitions/pagopa/walletv3/PaymentMethodManagementType";
import { PaymentMethodResponse } from "../../../../../definitions/pagopa/walletv3/PaymentMethodResponse";
import { PaymentMethodStatusEnum } from "../../../../../definitions/pagopa/walletv3/PaymentMethodStatus";

export const ONBOARDING_FAQ_ENABLE_3DS = "https://io.italia.it/faq/#n3_3";
export const ONBOARDING_CALLBACK_URL_SCHEMA = "iowallet";
export const ONBOARDING_OUTCOME_PATH = "/wallets/outcomes";

export const isMethodOnboardable = ({
methodManagement,
status
}: PaymentMethodResponse) =>
[
PaymentMethodManagementTypeEnum.ONBOARDABLE,
PaymentMethodManagementTypeEnum.ONBOARDABLE_ONLY,
PaymentMethodManagementTypeEnum.ONBOARDABLE_WITH_PAYMENT
].includes(methodManagement) && status === PaymentMethodStatusEnum.ENABLED;
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe("handleGetPaymentsWalletUserMethods", () => {
paymentMethodId: "paymentMethodId",
paymentMethodAsset: "paymentMethodAsset",
applications: [],
clients: {},
status: WalletStatusEnum.CREATED,
updateDate: new Date(),
details: {
Expand Down

0 comments on commit 15086be

Please sign in to comment.