Open Bug 1759180 Opened 3 years ago Updated 3 years ago

Refactor CreditCard.getType to be a member function instead of static

Categories

(Toolkit :: Form Autofill, task, P3)

task

Tracking

()

People

(Reporter: tgiles, Unassigned)

References

Details

Currently CreditCard.getType is a static function of CreditCard.jsm. As part of fixing Bug 1758369, we needed to ensure the input going into getType was valid, so we removed spaces and dashes from the parameter. However, this same kind of validation logic is done when creating a new CreditCard object. We shouldn't need to be using the same kind of validation in two different places so we should sync these parts of the codebase.

There are two places where we call CreditCard.getType(), in FormAutofillStorageBase and FormAutofillPrompter. These instances should be updated to creating a new CreditCard object and using this new card object as a source of truth since we can utilize the card number validation as part of creating the card object.

However, these changes will involve investigation of the test_getType() since these edge cases at the beginning of the task do not pass validation if the number is used to create a new CreditCard object.

We should also look into the fact that we can't create a CreditCard object if the passed number is invalid. We'll throw an exception in that case which doesn't seem like intended behavior.

Thinking about it more, we should probably change the name of this function entirely. getType is relatively vague, like do we mean the card's provider/issuer or the card's network? The internals of getType would say that it is the card's network and so the function name should align with this for future clarity.

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