You are here

protected function CreditCardPaymentMethodBase::validateStartDate in Ubercart 8.4

Validates a start date on a card.

Parameters

int $month: The 1 or 2-digit numeric representation of the month, i.e. 1, 6, 12.

int $year: The 4-digit numeric representation of the year, i.e. 2008.

Return value

bool TRUE for cards whose start date is blank (both month and year) or in the past, FALSE otherwise.

1 call to CreditCardPaymentMethodBase::validateStartDate()
CreditCardPaymentMethodBase::cartProcess in payment/uc_credit/src/CreditCardPaymentMethodBase.php
Called when checkout is submitted with this payment method selected.

File

payment/uc_credit/src/CreditCardPaymentMethodBase.php, line 767

Class

CreditCardPaymentMethodBase
Defines a base credit card payment method plugin implementation.

Namespace

Drupal\uc_credit

Code

protected function validateStartDate($month, $year) {
  if (empty($month) && empty($year)) {
    return TRUE;
  }
  if (empty($month) || empty($year)) {
    return FALSE;
  }
  if ($year > date('Y')) {
    return FALSE;
  }
  elseif ($year == date('Y')) {
    if ($month > date('n')) {
      return FALSE;
    }
  }
  return TRUE;
}