VGSCardNumberEditText

A user interface element for entering and modifying the credit card number of different card brands. When you define this input field, you could specify a few attributes that are preferable for this control. For example, app:numberDivider or app:cardBrandIconGravity which are unique for this field type.

Validation

By default, all fields have their specific validations that allow for getting more accurate user data. In case a developer needs to change or override the default validation, we give such a possibility.

Note: Default behavior validates only already recognized card numbers that meet the requirements. Read more about already existing brands.

There are several ways to change the basic validation flow:

Determining validation rules

Override valid card brands

By default, popular card brands like Visa, MasterCard, American Express, etc. will be detected by the SDK. You can override this behavior and specify which brands should be detected. You can do it using setValidCardBrands(vararg cardBrand: CardBrand) function of VGSCardNumberEditText.

You can specify your custom CardBrand or use the extension function to map default cards CardType.VISA.toCardBrand()

Card brand icon visibility

By default, the payment card brand icon is always visible. VGS Collect SDK gives the ability to change the default behavior and show the brand icon according to the content inside the field. The system makes a decision on how it should adjust the brand visibility based on the app:brandIconVisibility attribute.

The app:brandIconVisibility attribute could be configured with one of the following parameters:

  • always: Preview icon is visible all the time.

  • ifDetected: Preview icon is visible only when the card brand is detected.

  • hasContent: Preview icon is visible when some input exists.

  • never: Preview icon is never visible.

Custom card brand

By default, VGSCollect supports only the default list of payment card brands. For more accurate detection, you can create a local brand or just a new custom brand that we don't support yet.

Define the number group divider

To set the symbol that will divide groups of digits in the card number, add app:numberDivider to your field's declaration in XML. By default, the widget doesn't have any pre-configured divider and all numbers will be a single line.

Also, VGS Collect SDK gives the ability to change or remove the divider symbol before it has been submitted to the Proxy.

To set the symbol that will divide groups of digits in the card number, add app:outputNumberDivider to your field's declaration in XML. By default, Collect SDK removes the divider from the card number.

circle-info

app:numberDivider and app:outputNumberDivider should contain only one character.

Override card brand icon

VGS Collect offers a list of default card brand resources for preview and UI identification of the current ones by your end-user. If none of the prebuilt resources meet your needs, you can override your own resource. Creating your own resource gives you precise control over the appearance of the element on the screen.

You can use CardIconAdapter class to create custom Drawables as a preview image for the VGSCardNumberEditText.

Set brand icon gravity

Specifies how to align the icon with the view’s x-axis. To specify gravity programmatically, you could use the Android Gravity class. By default, gravity is in end position.

circle-info

At the current moment, we support only start and end position.

Override card brand number mask

If you don't want to create a completely new custom card brand, but want just to change the preview number mask, VGSCollect allows you to override card number masks from already defined brands.

Set field name

Sets the text to be used for data transfer to the VGS proxy. Usually, it is similar to field-name in JSON path in your inbound route filters. It is highly important to specify this parameter because the VGSCollect module relies on it too.

circle-exclamation

Define the required state

Specifies whether the text inside the input field is required to be filled.

When app:isRequired set as true thre input data should be valid only. If app:isRequired set as false, the input data will be valid in case the field is empty. Otherwise input data should be valid.

By default, a widget is required.

Specify the keyboard type

You should always declare the input method for these input fields by adding the app:inputType to tell the system to display the appropriate soft input method (such as an on-screen keyboard).

For example, if you'd like an input method for entering a phone number, specify app:inputType as number or numberPassword

Additional XML attributes

Set the validation state of this view. Set true if this view has enabled validation, it's false otherwise.

Adds a default behavior rule for the validation field.

Sets the symbol that will divide groups of digits in the card number.

Sets the symbol that will divide groups of digits before submit to the Proxy.

Specifies how to align the icon by the view’s x-axis. To specify gravity programmatically you could use android

Plain textclass.

Set the type of the content with a constant as defined for input field.

Specify soft input method for the input method action. By default, the system uses a

Plain textor

Plain textaction.

Default font family (named by string or as a font resource reference) for the text.

Sets the text to be used for data transfer to VGS proxy. Usually, it is similar to field-name in JSON path in your inbound route filters.

Specifies whether the text inside input field is required to be filled.

Size of the text.

If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle.

If set, causes words that are longer than the view is wide to be ellipsized instead of broken in the middle.

Text to display.

Text color.

Makes the View be at most this many lines tall.

Makes the View be at least this many lines tall.

Style (normal, bold, italic) for text.

Makes the cursor visible (the default) or invisible.

Specifies how to align the text by the view’s x- or y-axis when the text is smaller than the view.

When the text is allowed to be wider than the view (and therefore can be scrolled horizontally).

Hint text to display when the text is empty.

Specifies visibility for card brand preview icon.

Last updated