public function isValid($value)
 {
     $this->_setValue($value);
     $validCreditCard = new Zend_Validate_CreditCard(array(Zend_Validate_CreditCard::MASTERCARD, Zend_Validate_CreditCard::VISA));
     if (!$validCreditCard->isValid($value)) {
         $this->_error(self::CREDITCARD);
         return false;
     }
     return true;
 }
Exemplo n.º 2
0
 /**
  * Set payment storage credit card attributes
  * @return bool
  * @param string $ccType
  * @param string $ccOwner
  * @param string $ccNumber
  * @param string $ccExpiresYear
  * @param string $ccExpiresMonth
  * @param string $ccCvv
  * @param string $cc_issue_year[optional]
  * @param string $cc_expires_month[optional]
  */
 public function setCreditCard($ccType, $ccOwner, $ccNumber, $ccExpiresYear, $ccExpiresMonth, $ccCvv, $ccIssueYear = null, $ccIssueMonth = null)
 {
     if (empty($ccType) || empty($ccNumber) || empty($ccExpiresYear) || empty($ccExpiresMonth)) {
         Axis::message()->addError(Axis::translate('checkout')->__('Set full Credit Card Information'));
         return false;
     }
     $validator = new Zend_Validate_CreditCard();
     $allowedCcTypes = $this->getCCTypes();
     $validator->setType($allowedCcTypes);
     if (!$validator->isValid($ccNumber)) {
         foreach ($validator->getMessages() as $message) {
             Axis::message()->addError($message);
         }
         return false;
     }
     return $this->getCreditCard()->setCcType($ccType)->setCcOwner($ccOwner)->setCcNumber($ccNumber)->setCcExpiresYear($ccExpiresYear)->setCcExpiresMonth($ccExpiresMonth)->setCcIssueYear($ccIssueYear)->setCcIssueMonth($ccIssueMonth)->setCcCvv($ccCvv) instanceof Axis_CreditCard;
 }
 /**
  * @group ZF-9477
  */
 public function testMultiInstitute()
 {
     $validator = new Zend_Validate_CreditCard(array('type' => Zend_Validate_CreditCard::MASTERCARD));
     $this->assertFalse($validator->isValid('4111111111111111'));
     $message = $validator->getMessages();
     $this->assertContains('not from an allowed institute', current($message));
 }
Exemplo n.º 4
0
 public static function validCreditCard($credit = array())
 {
     $error = array();
     if ($credit['card_type'] == '') {
         $error[] = 'Please select card type';
     }
     if ($credit['card_holder_name'] == '') {
         $error[] = 'Name of card holder cannot be empty';
     }
     if ($credit['card_cvc_code'] == '') {
         $error[] = 'CVC Code cannot be empty';
     }
     $cardValidator = new Zend_Validate_CreditCard(array('type' => array(Zend_Validate_CreditCard::VISA, Zend_Validate_CreditCard::AMERICAN_EXPRESS)));
     if (!$cardValidator->isValid($credit['card_number'])) {
         $error[] = 'Credit card not valid';
     }
     return $error;
 }
 /**
  * Remove non-numeric characters from credit card number and validate it
  *
  * @param  string $creditCardNumber
  * @throws TicketEvolution_Webservice_Exception
  * @return string
  */
 protected function _cleanAndValidateCreditCardNumber($creditCardNumber)
 {
     $cleanNumber = preg_replace('/[^0-9]/', '', $creditCardNumber);
     /**
      * @see Zend_Validate_CreditCard
      */
     require_once 'Zend/Validate/CreditCard.php';
     $valid = new Zend_Validate_CreditCard();
     if ($valid->isValid($cleanNumber)) {
         return $cleanNumber;
     } else {
         /**
          * @see TicketEvolution_Webservice_Exception
          */
         require_once 'TicketEvolution/Webservice/Exception.php';
         throw new TicketEvolution_Webservice_Exception('The credit card provided is not a valid credit card number');
     }
 }
Exemplo n.º 6
0
 /**
  * Test optional constructor parameters
  *
  * @return void
  */
 public function testOptionalConstructorParameter()
 {
     $validator = new Zend_Validate_CreditCard('Visa', array('Zend_Validate_CreditCardTest', 'staticCallback'));
     $this->assertEquals(array('Visa'), $validator->getType());
     $this->assertEquals(array('Zend_Validate_CreditCardTest', 'staticCallback'), $validator->getService());
 }