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

Removes P2P debit card option #46323

Merged
merged 10 commits into from
Jul 27, 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
32 changes: 24 additions & 8 deletions src/components/AddPaymentMethodMenu.tsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import type {RefObject} from 'react';
import React from 'react';
import React, {useEffect} from 'react';
import type {View} from 'react-native';
import type {OnyxEntry} from 'react-native-onyx';
import {withOnyx} from 'react-native-onyx';
Expand Down Expand Up @@ -70,6 +70,21 @@ function AddPaymentMethodMenu({

const canUsePersonalBankAccount = shouldShowPersonalBankAccountOption || isIOUReport;

const isPersonalOnlyOption = canUsePersonalBankAccount && !canUseBusinessBankAccount;

// We temporarily disabled P2P debit cards so we will automatically select the personal bank account option if there is no other option to select.
useEffect(() => {
if (!isVisible) {
return;
}

onItemSelected(CONST.PAYMENT_METHODS.PERSONAL_BANK_ACCOUNT);
}, [isPersonalOnlyOption, isVisible, onItemSelected]);

if (isPersonalOnlyOption) {
return null;
}

return (
<PopoverMenu
isVisible={isVisible}
Expand Down Expand Up @@ -99,13 +114,14 @@ function AddPaymentMethodMenu({
},
]
: []),
...[
{
text: translate('common.debitCard'),
icon: Expensicons.CreditCard,
onSelected: () => onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD),
},
],
// Adding a debit card for P2P payments is temporarily disabled
// ...[
// {
// text: translate('common.debitCard'),
// icon: Expensicons.CreditCard,
// onSelected: () => onItemSelected(CONST.PAYMENT_METHODS.DEBIT_CARD),
// },
// ],
]}
withoutOverlay
/>
Expand Down
4 changes: 4 additions & 0 deletions src/pages/settings/Wallet/AddDebitCardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,14 @@ import ScreenWrapper from '@components/ScreenWrapper';
import useLocalize from '@hooks/useLocalize';
import usePrevious from '@hooks/usePrevious';
import Navigation from '@libs/Navigation/Navigation';
import NotFoundPage from '@pages/ErrorPage/NotFoundPage';
import * as PaymentMethods from '@userActions/PaymentMethods';
import ONYXKEYS from '@src/ONYXKEYS';

function DebitCardPage() {
// Temporarily disabled
return <NotFoundPage />;

const {translate} = useLocalize();
const [formData] = useOnyx(ONYXKEYS.FORMS.ADD_PAYMENT_CARD_FORM);
const prevFormDataSetupComplete = usePrevious(!!formData?.setupComplete);
Expand Down
36 changes: 13 additions & 23 deletions src/pages/settings/Wallet/PaymentMethodList.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ import * as PaymentMethods from '@userActions/PaymentMethods';
import CONST from '@src/CONST';
import ONYXKEYS from '@src/ONYXKEYS';
import ROUTES from '@src/ROUTES';
import type {AccountData, BankAccountList, CardList, FundList} from '@src/types/onyx';
import type {AccountData, BankAccountList, CardList} from '@src/types/onyx';
import type {BankIcon} from '@src/types/onyx/Bank';
import type {Errors} from '@src/types/onyx/OnyxCommon';
import type PaymentMethod from '@src/types/onyx/PaymentMethod';
Expand All @@ -45,7 +45,7 @@ type PaymentMethodListOnyxProps = {
cardList: OnyxEntry<CardList>;

/** List of user's cards */
fundList: OnyxEntry<FundList>;
// fundList: OnyxEntry<FundList>;

/** Are we loading payment methods? */
isLoadingPaymentMethods: OnyxEntry<boolean>;
Expand Down Expand Up @@ -175,7 +175,8 @@ function PaymentMethodList({
bankAccountList = {},
buttonRef = () => {},
cardList = {},
fundList = {},
// Temporarily disabled because P2P debit cards are disabled.
// fundList = {},
filterType = '',
listHeaderComponent,
isLoadingPaymentMethods = true,
Expand Down Expand Up @@ -260,10 +261,11 @@ function PaymentMethodList({
return assignedCardsGrouped;
}

const paymentCardList = fundList ?? {};

// Hide any billing cards that are not P2P debit cards for now because you cannot make them your default method, or delete them
const filteredCardList = Object.values(paymentCardList).filter((card) => !!card.accountData?.additionalData?.isP2PDebitCard);
// All payment cards are temporarily disabled for use as a payment method
// const paymentCardList = fundList ?? {};
// const filteredCardList = Object.values(paymentCardList).filter((card) => !!card.accountData?.additionalData?.isP2PDebitCard);
const filteredCardList = {};
let combinedPaymentMethods = PaymentUtils.formatPaymentMethods(bankAccountList ?? {}, filteredCardList, styles);

if (filterType !== '') {
Expand Down Expand Up @@ -302,20 +304,7 @@ function PaymentMethodList({
};
});
return combinedPaymentMethods;
}, [
shouldShowAssignedCards,
fundList,
bankAccountList,
styles,
filterType,
isOffline,
cardList,
actionPaymentMethodType,
activePaymentMethodID,
StyleUtils,
shouldShowRightIcon,
onPress,
]);
}, [shouldShowAssignedCards, bankAccountList, styles, filterType, isOffline, cardList, actionPaymentMethodType, activePaymentMethodID, StyleUtils, shouldShowRightIcon, onPress]);

/**
* Render placeholder when there are no payments methods
Expand Down Expand Up @@ -423,9 +412,10 @@ export default withOnyx<PaymentMethodListProps, PaymentMethodListOnyxProps>({
cardList: {
key: ONYXKEYS.CARD_LIST,
},
fundList: {
key: ONYXKEYS.FUND_LIST,
},
// Temporarily disabled - used for P2P debit cards
// fundList: {
// key: ONYXKEYS.FUND_LIST,
// },
isLoadingPaymentMethods: {
key: ONYXKEYS.IS_LOADING_PAYMENT_METHODS,
},
Expand Down
Loading