List icon Contents

Credit cards

This guide describes how to save, update, and manage credit cards.

Overview

Chromium has a built-in functionality that allows remembering credit cards entered into web forms. When the user submits a web form containing a credit card info then the library will ask whether to save it to the credit card store.

If you save it, the next time you load the form, the library will suggest to autofill it.

Web Form Autofill Credit Card

The web form autofill functionality must be enabled in this case.

To access and manage all saved credit cards, use CreditCards:

Java
Kotlin
CreditCards creditCards = profile.creditCards();
val creditCards = profile.creditCards()

Saving credit cards

When the user submits a form containing credit card info (a cardholder name, number, expiration date, CVV/CVC), the library will ask you if you’d like to save the card via SaveCreditCardCallback. In the callback, you will be prompted to save or decline to save this card. For example:

Java
Kotlin
browser.set(SaveCreditCardCallback.class, (params, tell) -> tell.save());
browser.register(SaveCreditCardCallback { params, tell ->
    tell.save()
})

If you choose to save then this card will be added to the credit card store. Next time you enter the same credit card to a form the callback will not be invoked.

If you choose to decline to save the card then it will not be added to the store and next time when entering the exact same credit card the callback will be invoked again.

Managing credit cards

Each record in the credit card store is represented by a separate object of CreditCard. It contains cardholder name, number, expiration date, CVV/CVC, etc.

To read all records use:

Java
Kotlin
creditCards.all().forEach(creditCard -> {
    String number = creditCard.number();
    CreditCardNetwork network = creditCard.network();
});
creditCards.all().forEach { creditCard ->
    val number = creditCard.number()
    val network = creditCard.network()
}

To remove any record from the store use:

Java
Kotlin
creditCards.remove(creditCard);
creditCards.remove(creditCard)

To clear the whole credit card store use:

Java
Kotlin
creditCards.clear();
creditCards.clear()