Specific brand rules are fetched from a CardTypes JSON file, which holds the validation rules and card brand logos for each brand. The validation logic in the SDK, is based off a set of default rules for any card type. CardValidationConfigĬlass MainActivity : AppCompatActivity ( ) Card validation rules
android library imports omitted import com. Then use this to initialize the validation. To do this, first create a CardValidationConfig using the builder as shown below. You typically use this to enable the submit button.Īfter implementing the AccessCheckoutCardValidationListener, you must initialize the validation for your views. This method is called when all fields are in a valid state. isValid indicates whether the field is in a valid or invalid state. This method is called with the validity of the expiry date field. You can use the icons right away and apply them to your views. Access Worldpay hosts both PNG and SVG versions of the supported card brands. The card brand contains a list of images which you may then use to display an icon for the identified card brand. If the card brand can't be identified, a null response is returned. You can use this method to determine the logo of the card, which can be applied as a UI effect. This method is called with a card brand based on the details that your customer is entering. This method is called with the validity of the pan field.
The cardholderName validation essentially tests for a valid string greater than 0 characters in length that does not look like a card number.This method is called with the validity of the CVC field.
Valid.cardholderName(value: string): object If a valid card type cannot be determined, the card field in the response will be null.Ī fake session where a user is entering a card number may look like: Input
You can install card-validator through npm.
For example, if you detect a user is entering (or has entered) an American Express card number, you can update the maxlength attribute of your CVV input element from 3 to 4 and even update the corresponding label from 'CVV' to 'CID'. Additionally, by having access to the current card type, you can better manage the state of your credit card form as a whole. This is useful for scenarios in which you wish to render an accompanying payment method icon (Visa, MasterCard, etc.). Conversely, if a user enters “41x” that value can no longer pass strict validation and you can provide a response immediately.Ĭredit Card Validator will also provide a determined card type (using credit-card-type). In a credit card field, entering “411” is not necessarily valid for submission, but it is still potentially valid. It includes first class support for 'potential' validity so you can use it to present appropriate UI to your user as they type.Ī typical use case in a credit card form is to notify the user if the data they are entering is invalid. It is designed as a CommonJS module for use in Node.js, io.js, or the browser. Credit Card Validator provides validation utilities for credit card data inputs.