You are here

public static function CommercePaymentCreditCard::validateSecurityCode in Commerce Core 7

Validates the given credit card security code.

Parameters

string $security_code: The credit card security code.

array $type: The credit card type.

Return value

bool TRUE if the credit card security code is valid, FALSE otherwise.

2 calls to CommercePaymentCreditCard::validateSecurityCode()
CommercePaymentCreditCardTest::testsValidateSecurityCode in modules/payment/tests/commerce_payment_credit_card.test
@covers ::validateSecurityCode
commerce_payment_validate_credit_card_security_code in modules/payment/includes/commerce_payment.credit_card.inc
Validates a card security code based on the type of the credit card.

File

modules/payment/includes/commerce_payment.credit_card.inc, line 652
Credit-card helper functions for Drupal commerce.

Class

CommercePaymentCreditCard
Provides logic for listing card types and validating card details.

Code

public static function validateSecurityCode($security_code, array $type) {
  if (!is_numeric($security_code)) {
    return FALSE;
  }
  if (strlen($security_code) != $type['security_code_length']) {
    return FALSE;
  }
  return TRUE;
}