suspend fun CreditCard.toCreditCardEditorState(storage: AutofillCreditCardsAddressesStorage): CreditCardEditorState { val crypto = storage.getCreditCardCrypto() val key = crypto.getOrGenerateKey() val cardNumber = crypto.decrypt(key, encryptedCardNumber)?.number ?: "" val startYear = expiryYear.toInt() val endYear = startYear + NUMBER_OF_YEARS_TO_SHOW return CreditCardEditorState( guid = guid, billingName = billingName, cardNumber = cardNumber, expiryMonth = expiryMonth.toInt(), expiryYears = Pair(startYear, endYear), isEditing = true, ) }
Returns a [CreditCardEditorState] from the given [CreditCard].