App icon indicating copy to clipboard operation
App copied to clipboard

Add bank icons to the PaymentMethodsList

Open michaelhaxhiu opened this issue 5 years ago • 52 comments

If you haven’t already, check out our contributing guidelines for onboarding and email [email protected] to request to join our Slack channel!


Actual behavior:

Currently, bank accounts in the payment methods list only have the generic icon for banks/cards. Here's a screenshot for reference: 2021-07-06_12-15-34

Expected behavior:

We want the banks/cards to have their actual brand/logo icons, like this: 2021-07-02_12-23-37

Please consider the following when building the Expected behavior:

  1. Add the bank icons to the Expensicons file
  2. Modify paymentMethodList.js to attempt to match the right icon with each account
    • For bank accounts the bank name should be in bankAccount.additionalData.bankName
    • For credit cards, the bank name should be in card.bank
    • If the field is blank, or does not match an existing bank icon, default to the generic bank icon drive-download-20210723T192557Z-001.zip

These are the lists of all bank/card names. Given that there are a lot of different names for things like American Express, I think the best way to do it will be something like this rather than trying to match each one directly. If you have a better idea feel free to pitch it to me!

if (bankAccount.additionalData.bankName.toLowerCase().contains('americanexpress')) {
    // american express icon
}

banklist.csv bankaccountlist.csv

Platform:

  • Web ✅
  • Desktop ✅
  • Android ✅
  • iOS ✅

Expensify/Expensify Issue URL: https://github.com/Expensify/Expensify/issues/169740 Upwork job link: https://www.upwork.com/jobs/~01ab696311bb024cbd

michaelhaxhiu avatar Aug 03 '21 22:08 michaelhaxhiu

Triggered auto assignment to @marcaaron (Engineering), see https://stackoverflow.com/c/expensify/questions/4319 for more details.

MelvinBot avatar Aug 03 '21 22:08 MelvinBot

Triggered auto assignment to @arielgreen (External), see https://stackoverflow.com/c/expensify/questions/8582 for more details.

MelvinBot avatar Aug 03 '21 22:08 MelvinBot

@michaelhaxhiu ZIP is not downloadable

Santhosh-Sellavel avatar Aug 03 '21 22:08 Santhosh-Sellavel

@Santhosh-Sellavel can you try once more? I think it was an issue of copy/pasting that zip file from another GH respository.

michaelhaxhiu avatar Aug 03 '21 22:08 michaelhaxhiu

If we know possiblebankName we can use the same name for assets and retrieve them, it's a one-time job. No checks would be needed further. If no asset is found we use a default image.

Example asset name bankIcon_americanexpress.jpg. // Retrieval getResource(bankIcon_${bankName}).

@michaelhaxhiu

Santhosh-Sellavel avatar Aug 03 '21 22:08 Santhosh-Sellavel

@Santhosh-Sellavel can you try once more? I think it was an issue of copy/pasting that zip file from another GH respository.

It's working now check other attachments also.

Santhosh-Sellavel avatar Aug 03 '21 22:08 Santhosh-Sellavel

Proposal

@michaelhaxhiu we can do a implementation like shown below Screenshot 2021-08-04 at 4 43 36 AM

More or else we need to map bankName to a respective resource, we can easily retrieve the same.

Santhosh-Sellavel avatar Aug 03 '21 23:08 Santhosh-Sellavel

Proposal

  1. I'll add all bank icons to ExpensiIcons or src/components/Icon/BankIcons.js can be created
  2. in this.props.bankAccountsList or this.props.cardList loop, detect the icon, using:
const bankIcons = [{
    name: 'Citizens Bank',
    icon: CitizensBank
}]

const getIcon = (bankOrCardName) => {
    const icon = bankIcons.find((item) => item.name === bankOrCardName)
    return icon || defaultBankIcon
}

combinedPaymentMethods.push({
    type: MENU_ITEM,
    title: bankAccount.addressName,
    // eslint-disable-next-line
    description: formattedBankAccountNumber,
    icon: getIcon(card.cardName),
    onPress: e => this.props.onPress(e, bankAccount.bankAccountID),
    key: `bankAccount-${bankAccount.bankAccountID}`,
});
  1. in the renderItem function add iconHeight and iconWidth props to make it bigger.

And here's the result:

Screen Shot 2021-08-04 at 2 06 54 PM

kakajann avatar Aug 04 '21 09:08 kakajann

I add the all bank icon with bank name and we check condition bank name compare all icon if this icon name equal to bank name or credit card bank name this icon is set in createPaymentMethodList() in "/src/pages/settings/Payments/PaymentMethodList.js" if does not match we use default bank icon or credit card icon

arpitdeveloper avatar Aug 04 '21 09:08 arpitdeveloper

Hi everyone, as we mentioned in the description, there are lots of bank names in the list like americanexpress.com.uk and americanexpress.com.australia which should both map to the American Express Icon. Those can't be changed in the DB so we need to match in a different way than just straight ===, meaning that none of the proposed solutions will work.

stitesExpensify avatar Aug 04 '21 21:08 stitesExpensify

@stitesExpensify cannot access banknames list banklist.csv bankaccountlist.csv

from here

Santhosh-Sellavel avatar Aug 04 '21 21:08 Santhosh-Sellavel

Working @stitesExpensify

Santhosh-Sellavel avatar Aug 04 '21 22:08 Santhosh-Sellavel

We can map bankNames and icon for icons we have. We can create a separate file for this. Using the method getBankIcon we can retrieve the icon.

Example like

{
      'americanexpress.com.australia': AmericanExpressIcon,
      'americanexpress.com.uk': AmericanExpressIcon
}

@stitesExpensify

Proposal

@michaelhaxhiu we can do a implementation like shown below Screenshot 2021-08-04 at 4 43 36 AM

More or else we need to map bankName to a respective resource, we can easily retrieve the same.

This one time mapping for bank Icons we have

Santhosh-Sellavel avatar Aug 04 '21 22:08 Santhosh-Sellavel

But the best way to handle this image should be available in API itself, URI pointing to a resource over web, like we have our profile pic in personalDetails.

From where do we get bankAccount.additionalData. Is it a third-party integration? addtionalData should have a logoURI, like it has bankName.

While we fetch bank account details, logoURI can be added in response in backEnd

And lazy load image here in client-side using logoURI.

@stitesExpensify

Santhosh-Sellavel avatar Aug 04 '21 23:08 Santhosh-Sellavel

From where do we get bankAccount.additionalData. Is it a third-party integration? addtionalData should have a logoURI, like it has bankName.

We get that data from a lot of different places both internal and external. A lot of it is legacy data too which makes it hard to go back and change. IMO we don't want to do a database change for this issue.

We can map bankNames and icon for icons we have. We can create a separate file for this.

Is there a reason you prefer this over the solution in the description? If we write a function to map all of these, then we could just write a function to map them on the fly right? This has the additional benefit that we are covered for all future bank account names that are not in our current list.

stitesExpensify avatar Aug 05 '21 00:08 stitesExpensify

  Is there a reason you prefer this over the solution in the description? 

We don't need the assets to be bundled with apps, because more than 90% of assets are useless for any normal user. It increases app size.

Santhosh-Sellavel avatar Aug 05 '21 00:08 Santhosh-Sellavel

   If we write a function to map all of these, then we could just write a function to map them on the fly right? 

Yes, we can do this.

Santhosh-Sellavel avatar Aug 05 '21 00:08 Santhosh-Sellavel

@stitesExpensify

Santhosh-Sellavel avatar Aug 05 '21 21:08 Santhosh-Sellavel

We don't need the assets to be bundled with apps, because more than 90% of assets are useless for any normal user. It increases app size.

That makes sense, but there are 2 downsides to that IMO.

  1. We would have to do a massive database migration to add an icon link to each bank account
  2. The icons would not work if we are offline

Yes, we can do this.

Great, let's do it that way then.

stitesExpensify avatar Aug 05 '21 21:08 stitesExpensify