Open Bug 1752145 Opened 3 years ago Updated 3 years ago

Refactor CreditCard.SUPPORTED_NETWORKS to be an array of objects

Categories

(Toolkit :: Form Autofill, task, P3)

task

Tracking

()

People

(Reporter: tgiles, Unassigned)

References

(Blocks 1 open bug)

Details

Currently CreditCard.SUPPORTED_NETWORKS is an array of strings which we use to derive credit card logos, other aliases for particular network names. Instead of SUPPORTED_NETWORKS being an array of strings, we should convert it to an array of objects. For example:

[
  {
    "names": ["amex", "AmericanExpress"], logo: "chrome://formautofill/content/third-party/cc-logo-amex.svg"
  },
  {
    "names": ["mastercard", "master card"], logo: "chrome://formautofill/content/third-party/cc-logo-mastercard.svg"
  },
...
]

This would allow use to remove some helper functions and simplify some operations when dealing with SUPPORTED_NETWORKS, which should also simplify some testing scenarios involving this code.

Blocks: 1737329

We can possibly remove NETWORK_NAMES as well, if we specify alternative names in SUPPORTED_NETWORKS.

We can create UnknownNetwork object, that will be used if we fail to detect network. That way we can avoid having null or undefined and always expect a working object.

We can create a function getCreditCardNetwork(some_args_describing_what_we_know) that will return proper cc-network object. So we won't need to expose array outside of module.

Severity: -- → N/A
Priority: -- → P3
You need to log in before you can comment on or make changes to this bug.