예제 #1
0
파일: Cc.php 프로젝트: kid17/magento2
 /**
  * Validate payment method information object
  *
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  * @SuppressWarnings(PHPMD.CyclomaticComplexity)
  * @SuppressWarnings(PHPMD.NPathComplexity)
  */
 public function validate()
 {
     /*
      * calling parent validate function
      */
     parent::validate();
     $info = $this->getInfoInstance();
     $errorMsg = false;
     $availableTypes = explode(',', $this->getConfigData('cctypes'));
     $ccNumber = $info->getCcNumber();
     // remove credit card number delimiters such as "-" and space
     $ccNumber = preg_replace('/[\\-\\s]+/', '', $ccNumber);
     $info->setCcNumber($ccNumber);
     $ccType = '';
     if (in_array($info->getCcType(), $availableTypes)) {
         if ($this->validateCcNum($ccNumber) || $this->otherCcType($info->getCcType()) && $this->validateCcNumOther($ccNumber)) {
             $ccTypeRegExpList = ['SO' => '/(^(6334)[5-9](\\d{11}$|\\d{13,14}$))|(^(6767)(\\d{12}$|\\d{14,15}$))/', 'SM' => '/(^(5[0678])\\d{11,18}$)|(^(6[^05])\\d{11,18}$)|(^(601)[^1]\\d{9,16}$)|(^(6011)\\d{9,11}$)' . '|(^(6011)\\d{13,16}$)|(^(65)\\d{11,13}$)|(^(65)\\d{15,18}$)' . '|(^(49030)[2-9](\\d{10}$|\\d{12,13}$))|(^(49033)[5-9](\\d{10}$|\\d{12,13}$))' . '|(^(49110)[1-2](\\d{10}$|\\d{12,13}$))|(^(49117)[4-9](\\d{10}$|\\d{12,13}$))' . '|(^(49118)[0-2](\\d{10}$|\\d{12,13}$))|(^(4936)(\\d{12}$|\\d{14,15}$))/', 'VI' => '/^4[0-9]{12}([0-9]{3})?$/', 'MC' => '/^5[1-5][0-9]{14}$/', 'AE' => '/^3[47][0-9]{13}$/', 'DI' => '/^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})' . '|36[0-9]{12}|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}' . '|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}' . '|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}' . '|5[0-9]{14}))$/', 'JCB' => '/^(30[0-5][0-9]{13}|3095[0-9]{12}|35(2[8-9][0-9]{12}|[3-8][0-9]{13})|36[0-9]{12}' . '|3[8-9][0-9]{14}|6011(0[0-9]{11}|[2-4][0-9]{11}|74[0-9]{10}|7[7-9][0-9]{10}' . '|8[6-9][0-9]{10}|9[0-9]{11})|62(2(12[6-9][0-9]{10}|1[3-9][0-9]{11}|[2-8][0-9]{12}' . '|9[0-1][0-9]{11}|92[0-5][0-9]{10})|[4-6][0-9]{13}|8[2-8][0-9]{12})|6(4[4-9][0-9]{13}' . '|5[0-9]{14}))$/'];
             $ccNumAndTypeMatches = isset($ccTypeRegExpList[$info->getCcType()]) && preg_match($ccTypeRegExpList[$info->getCcType()], $ccNumber);
             $ccType = $ccNumAndTypeMatches ? $info->getCcType() : 'OT';
             if (!$ccNumAndTypeMatches && !$this->otherCcType($info->getCcType())) {
                 $errorMsg = __('Credit card number mismatch with credit card type.');
             }
         } else {
             $errorMsg = __('Invalid Credit Card Number');
         }
     } else {
         $errorMsg = __('Credit card type is not allowed for this payment method.');
     }
     //validate credit card verification number
     if ($errorMsg === false && $this->hasVerification()) {
         $verifcationRegEx = $this->getVerificationRegEx();
         $regExp = isset($verifcationRegEx[$info->getCcType()]) ? $verifcationRegEx[$info->getCcType()] : '';
         if (!$info->getCcCid() || !$regExp || !preg_match($regExp, $info->getCcCid())) {
             $errorMsg = __('Please enter a valid credit card verification number.');
         }
     }
     if ($ccType != 'SS' && !$this->_validateExpDate($info->getCcExpYear(), $info->getCcExpMonth())) {
         $errorMsg = __('We found an incorrect credit card expiration date.');
     }
     if ($errorMsg) {
         throw new \Magento\Framework\Exception\LocalizedException($errorMsg);
     }
     return $this;
 }
 public function validate()
 {
     parent::validate();
 }
예제 #3
0
 /**
  * This is the neatest entry point for calculating the customer ref once an order ID has been
  * generated. There doesn't appear to be any other way that we can hook into the order placement
  * process for this specific payment method after the order ID has been created.
  *
  * @return PaymentMethod
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function validate()
 {
     $this->getInfoInstance()->setAdditionalInformation("customer_ref", $this->getCustomerRef());
     return parent::validate();
 }
예제 #4
0
 /**
  * @return $this
  * @throws \Magento\Framework\Exception\LocalizedException
  */
 public function validate()
 {
     \Magento\Payment\Model\Method\AbstractMethod::validate();
     return $this;
 }
예제 #5
0
 public function validate()
 {
     parent::validate();
     $this->_debugger->debug('validate');
     return;
 }