From 295c5e586a41dda204e26c1c65655fbbe4020648 Mon Sep 17 00:00:00 2001 From: Federico Mastrini Date: Fri, 12 Apr 2024 16:56:32 +0200 Subject: [PATCH] chore: [IOBP-616] Add missing parameters to payment's `calculateFees` request payload (#5667) ## Short description This PR adds `isAllCCP` and `primaryCreditorInstitution` parameters to the payment's `calculateFees` request payload ## List of changes proposed in this pull request - Updated pagoPA payments and wallet API definitions - Added `isAllCCP` and `primaryCreditorInstitution` to calculateFees request payload ## How to test In UAT environment, try to make a payment. You should be able to see the PSP list --------- Co-authored-by: Mario Perrotta Co-authored-by: Martino Cesari Tomba <60693085+forrest57@users.noreply.github.com> --- package.json | 4 ++-- .../screens/WalletPaymentPickMethodScreen.tsx | 12 +++++++++++- .../handleGetPaymentsWalletUserMethods.test.ts | 5 ++--- 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/package.json b/package.json index 176e767ecbd..216e376dc82 100644 --- a/package.json +++ b/package.json @@ -19,8 +19,8 @@ "idpay_api": "https://raw.githubusercontent.com/pagopa/cstar-infrastructure/v6.9.1/src/domains/idpay-app/api/idpay_appio_full/openapi.appio.full.yml", "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/bec0f57606a2002706bd5f5286fad3e508d2f50e/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl", - "pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/2adee4c0a8de8570e74710379f9cccb04c6925b6/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl", + "pagopa_api_walletv3": "https://raw.githubusercontent.com/pagopa/pagopa-infra/ebcc83fad083e1e7df3bcf97e9df3cd3b16e2045/src/domains/wallet-app/api/payment-wallet/v1/_openapi.json.tpl", + "pagopa_api_ecommerce": "https://raw.githubusercontent.com/pagopa/pagopa-infra/ebcc83fad083e1e7df3bcf97e9df3cd3b16e2045/src/domains/ecommerce-app/api/ecommerce-io/v1/_openapi.json.tpl", "private": true, "scripts": { "start": "react-native start", diff --git a/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx b/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx index 2bc9183b7b7..e15c280d819 100644 --- a/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx +++ b/ts/features/payments/checkout/screens/WalletPaymentPickMethodScreen.tsx @@ -99,11 +99,19 @@ const WalletPaymentPickMethodScreen = () => { selectedWalletOption ), O.map(([paymentAmountInCents, transaction, selectedWallet]) => { + // We can safely get this data from the first payment object + // This logic should be revisited once the cart feature will be implemented + const primaryPayment = transaction.payments[0]; + + const paymentToken = primaryPayment?.paymentToken; + const primaryTransfer = primaryPayment?.transferList?.[0]; + const isAllCCP = primaryPayment?.isAllCCP; + const primaryCreditorInstitution = primaryTransfer?.paFiscalCode; + const transferList = transaction.payments.reduce( (a, p) => [...a, ...(p.transferList ?? [])], [] as ReadonlyArray ); - const paymentToken = transaction.payments[0]?.paymentToken; dispatch( paymentsCalculatePaymentFeesAction.request({ @@ -111,6 +119,8 @@ const WalletPaymentPickMethodScreen = () => { paymentMethodId: selectedWallet.paymentMethodId, walletId: selectedWallet.walletId, paymentAmount: paymentAmountInCents, + isAllCCP, + primaryCreditorInstitution, transferList }) ); diff --git a/ts/features/payments/wallet/saga/__tests__/handleGetPaymentsWalletUserMethods.test.ts b/ts/features/payments/wallet/saga/__tests__/handleGetPaymentsWalletUserMethods.test.ts index fa0950c8904..6e92fa3297a 100644 --- a/ts/features/payments/wallet/saga/__tests__/handleGetPaymentsWalletUserMethods.test.ts +++ b/ts/features/payments/wallet/saga/__tests__/handleGetPaymentsWalletUserMethods.test.ts @@ -6,7 +6,6 @@ import { Wallets } from "../../../../../../definitions/pagopa/walletv3/Wallets"; import { withRefreshApiCall } from "../../../../fastLogin/saga/utils"; import { getPaymentsWalletUserMethods } from "../../store/actions"; import { handleGetPaymentsWalletUserMethods } from "../handleGetPaymentsWalletUserMethods"; -import { BrandEnum } from "../../../../../../definitions/pagopa/walletv3/WalletInfoDetails"; import { WalletCard } from "../../../../newWallet/types"; import { walletAddCards } from "../../../../newWallet/store/actions/cards"; import { getGenericError } from "../../../../../utils/errors"; @@ -35,7 +34,7 @@ describe("handleGetPaymentsWalletUserMethods", () => { type: "CREDITCARD", lastFourDigits: T_HPAN, expiryDate: T_EXPIRE_DATE, - brand: BrandEnum.VISA + brand: "VISA" } } ] @@ -47,7 +46,7 @@ describe("handleGetPaymentsWalletUserMethods", () => { category: "payment", walletId: T_WALLETID, hpan: T_HPAN, - brand: BrandEnum.VISA, + brand: "VISA", expireDate: getDateFromExpiryDate(T_EXPIRE_DATE), abiCode: undefined, holderEmail: undefined,