public static function CreditCard::validateSecurityCode in Commerce Core 8.2
Validates the given credit card security code.
Parameters
string $security_code: The credit card security code.
\Drupal\commerce_payment\CreditCardType $type: The credit card type.
Return value
bool TRUE if the credit card security code is valid, FALSE otherwise.
2 calls to CreditCard::validateSecurityCode()
- CreditCardTest::testsValidateSecurityCode in modules/
payment/ tests/ src/ Unit/ CreditCardTest.php - @covers ::validateSecurityCode @dataProvider securityCodeProvider
- PaymentMethodAddForm::validateCreditCardForm in modules/
payment/ src/ PluginForm/ PaymentMethodAddForm.php - Validates the credit card form.
File
- modules/
payment/ src/ CreditCard.php, line 265
Class
- CreditCard
- Provides logic for listing card types and validating card details.
Namespace
Drupal\commerce_paymentCode
public static function validateSecurityCode(string $security_code, CreditCardType $type) : bool {
if (!is_numeric($security_code)) {
return FALSE;
}
if (strlen($security_code) != $type
->getSecurityCodeLength()) {
return FALSE;
}
return TRUE;
}