Back to Devexpress

Payment Card Editor

windowsforms-404084-ui-templates-data-editors-payment-card-editor.md

latest3.8 KB
Original Source

Payment Card Editor

  • Nov 21, 2022
  • 3 minutes to read

The Payment Card Editor (PaymentCardBox) is a masked field used for credit card/payment information.

Card Details (Edit Value)

Use the Card property to obtain the card details entered by the user, or specify the details in code.

csharp
using DevExpress.UITemplates.Collection.Utilities;

// Gets the card details.
PaymentCard card = paymentCardBox1.Card;

The Card property returns a PaymentCard object. Its settings include:

Property NameTypeDescription
CardTypePaymentCard.TypeGets the card type.
ExpirationDateDateTimeGets the card’s expiry date.
NumberstringGets the card number.
CVCstringGets the security code.

Card Type

The editor automatically detects card type from the starting first number during input and displays the corresponding logo. The PaymentCard.Type enumeration contains values that specify type of a payment card (PaymentCard.CardType).

MemberDescription
VisaVISA
VisaElectronVisa Electron
MasterCardMasterCard
MaestroMaestro
AmericanExpressAmerican Express (AMEX)
DinersClubInternationalDiners Club - International
DinersClubCarteBlancheDiners Club - Carte Blanche
DinersClubNorthAmericaDiners Club - North America
JCBJCB
DiscoverDiscover
InvalidThe card type validation fails.
UndefinedUndefined card type.

Important

This EAP does not support American Express (AMEX) and Diners Club - Carte Blanche card types.

Card Number Validation & Error Indication

The Payment Card Editor uses the Luhn‘s algorithm to validate the card number. This algorithm only ensures that the card number is a valid number. It does not ensure that it exists in any bank database.

Note

YOUR_PROJECT\Utilities\Luhn.css implements the Luhn’s algorithm.

The editor displays a warning hint if the user has entered incorrect card details. If the editor displays the footer label, the label also displays the warning message.

Use the InvalidCardWarningTitle property to specify a custom tooltip title.

Turn off the ShowInvalidCardWarningToolTip option if you do not want to show the warning hint.

Note

YOUR_PROJECT\Utilities\PaymentCardType.css implements the validation of card details. The PaymentCardType.Guess method checks the card number and type. The Validate method validates the card data and warns if the card verification fails.

You can override these methods if the default implementation does not meet your business requirements.

Field Labels

Use the HeaderLabel and FooterLabel properties to specify text labels.

csharp
paymentCardBox1.HeaderLabel = "Payment Details";
paymentCardBox1.FooterLabel = "Card number, expiration date, security code";

HTML & CSS Template Customization

The Payment Card Editor is created with HTML & CSS templates. This allows you to create fully custom text input controls. Template customizations are handled with our HTML Template Editor that is integrated into the Visual Studio IDE. This tool uses an embedded Syntax Editor with autocomplete, tag navigation, and preview.