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:

CreditCards 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:

browser.set(SaveCreditCardCallback.class, (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:

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

To remove any record from the store use:

creditCards.remove(ceditCard);

To clear the whole credit card store use:

creditCards.clear();
Go Top