Refactor CreditCard.getType to be a member function instead of static
Categories
(Toolkit :: Form Autofill, task, P3)
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.
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.
Reporter | ||
Comment 1•3 years ago
|
||
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.
Updated•3 years ago
|
Description
•