Class CreditCard
Responsibility: Validate well-formed credit card number from American Express, Unionpay, Diners Club, Diners Club US, Discover, JCB, Laser, Maestro, Mastercard, Solo, Visa and Mir. Credit card contains several items of metadata, including a hologram, account number, logo, expiration date, security code and the card holder name. The algorithms for verifying the combination of metadata are only known to the issuing company, this validator is only for well-formed credit card number. It also provides an ability to attach callbacks with custom validations.
- MvcCore\Ext\Forms\Validator implements MvcCore\Ext\Forms\IValidator
-
MvcCore\Ext\Forms\Validators\CreditCard
Located at ext-form-validator-special/src/MvcCore/Ext/Forms/Validators/CreditCard.php
public
string[]
&
|
#
GetAllowedTypes( )
Get allowed credit card types. If no allowed credit card types defined, then all credit card types are allowed automatically. |
public
|
#
SetAllowedTypes( )
Set multiple allowed credit card types. If no allowed credit card types defined,
then all credit card types are allowed automatically.
This function is dangerous, because it removes all previously defined credit card types to allow.
If you only add another credit card type, use: |
public
|
#
AddAllowedTypes( )
Add multiple allowed credit card types. If no allowed credit card types defined,
then all credit card types are allowed automatically.
Example: |
public
|
#
AddAllowedType( string $allowedType )
Add allowed credit card type. If no allowed credit card types defined,
then all credit card types are allowed automatically.
Example: |
public
callable[]
&
|
#
GetExternalValidationCallbacks( )
Get list of external validation services defined as |
public
|
#
SetExternalValidationCallbacks( )
Set list of external validation services defined as |
public
|
#
AddExternalValidationCallbacks( )
Add list of external validation services defined as |
public
|
#
AddExternalValidationCallback( callable[] $externalValidationCallback, integer|null $priorityIndex = NULL )
Add external validation service defined as |
public
string|null
|
CreateInstance(),
GetErrorMessage(),
SetField(),
SetForm(),
__construct(),
setUpFieldProps(),
throwNewInvalidArgumentException()
|
string |
AMERICAN_EXPRESS
Detected CCI list. |
#
'American_Express'
|
string |
UNIONPAY
|
#
'Unionpay'
|
string |
DINERS_CLUB
|
#
'Diners_Club'
|
string |
DINERS_CLUB_US
|
#
'Diners_Club_US'
|
string |
DISCOVER
|
#
'Discover'
|
string |
JCB
|
#
'JCB'
|
string |
LASER
|
#
'Laser'
|
string |
MAESTRO
|
#
'Maestro'
|
string |
MASTERCARD
|
#
'Mastercard'
|
string |
SOLO
|
#
'Solo'
|
string |
VISA
|
#
'Visa'
|
string |
MIR
|
#
'Mir'
|
integer |
ERROR_CHECKSUM
Error message index(es). |
#
0
|
integer |
ERROR_CONTENT
|
#
1
|
integer |
ERROR_INVALID
|
#
2
|
integer |
ERROR_LENGTH
|
#
3
|
integer |
ERROR_PREFIX
|
#
4
|
integer |
ERROR_SERVICE
|
#
5
|
integer |
ERROR_SERVICEFAILURE
|
#
6
|
protected static
array
|
$cardTypes
List of CCV names. |
#
[
self::AMERICAN_EXPRESS,
self::DINERS_CLUB,
self::DINERS_CLUB_US,
self::DISCOVER,
self::JCB,
self::LASER,
self::MAESTRO,
self::MASTERCARD,
self::SOLO,
self::UNIONPAY,
self::VISA,
self::MIR,
]
|
protected static
array
|
$cardLengths
List of allowed CCV lengths. |
#
[
self::AMERICAN_EXPRESS => [15],
self::DINERS_CLUB => [14],
self::DINERS_CLUB_US => [16],
self::DISCOVER => [16, 19],
self::JCB => [15, 16],
self::LASER => [16, 17, 18, 19],
self::MAESTRO => [12, 13, 14, 15, 16, 17, 18, 19],
self::MASTERCARD => [16],
self::SOLO => [16, 18, 19],
self::UNIONPAY => [16, 17, 18, 19],
self::VISA => [13, 16, 19],
self::MIR => [13, 16],
]
|
protected static
array
|
$cardPrefixes
List of accepted CCV provider tags. |
#
[
self::AMERICAN_EXPRESS => ['34', '37'],
self::DINERS_CLUB => ['300', '301', '302', '303', '304', '305', '36'],
self::DINERS_CLUB_US => ['54', '55'],
self::DISCOVER => ['6011', '622126', '622127', '622128', '622129', '62213', '62214', '62215', '62216', '62217', '62218', '62219', '6222', '6223', '6224', '6225', '6226', '6227', '6228', '62290', '62291', '622920', '622921', '622922', '622923', '622924', '622925', '644', '645', '646', '647', '648', '649', '65'],
self::JCB => ['1800', '2131', '3528', '3529', '353', '354', '355', '356', '357', '358'],
self::LASER => ['6304', '6706', '6771', '6709'],
self::MAESTRO => ['5018', '5020', '5038', '6304', '6759', '6761', '6762', '6763', '6764', '6765', '6766', '6772'],
self::MASTERCARD => ['2221', '2222', '2223', '2224', '2225', '2226', '2227', '2228', '2229', '223', '224', '225', '226', '227', '228', '229', '23', '24', '25', '26', '271', '2720', '51', '52', '53', '54', '55'],
self::SOLO => ['6334', '6767'],
self::UNIONPAY => ['622126', '622127', '622128', '622129', '62213', '62214', '62215', '62216', '62217', '62218', '62219', '6222', '6223', '6224', '6225', '6226', '6227', '6228', '62290', '62291', '622920', '622921', '622922', '622923', '622924', '622925'],
self::VISA => ['4'],
self::MIR => ['2200', '2201', '2202', '2203', '2204'],
]
|
protected static
array
|
$errorMessages
Validation failure message template definitions. |
#
[
self::ERROR_CHECKSUM => "Field '{0}' contains an invalid checksum.",
self::ERROR_CONTENT => "Field '{0}' must contain only digits.",
self::ERROR_LENGTH => "Field '{0}' contains an invalid amount of digits.",
self::ERROR_PREFIX => "Field '{0}' is not from an allowed institute.",
self::ERROR_SERVICE => "Field '{0}' seems to be an invalid credit card number.",
self::ERROR_SERVICEFAILURE => "Field '{0}' throws an exception while validating the input.",
]
|
protected
string[]
|
$allowedTypes
Allowed credit card types. If no allowed credit card types defined,
then all credit card types are allowed automatically.
Array of string constants like: |
#
[]
|
protected
callable[]
|
$externalValidationCallbacks
List of external validation services defined as |
#
[]
|
$field,
$fieldSpecificProperties,
$form,
$toolClass
|