Esempio n. 1
0
 /**
  * Assign data to info model instance
  *
  * @param   mixed $data
  * @return  Mage_Payment_Model_Info
  */
 public function assignData($data)
 {
     Mage::getSingleton('ratepaypayment/session')->setDirectDebitFlag(false);
     parent::assignData($data);
     $quote = $this->getHelper()->getQuote();
     $params = $data->getData();
     // dob
     $dob = isset($params[$this->_code . '_day']) ? $this->getDob($data) : false;
     if (!$this->getHelper()->isCompanySet($quote) && (!$this->getHelper()->isDobSet($quote) || $quote->getCustomerDob() != $dob)) {
         if ($dob) {
             $validAge = $this->getHelper()->isValidAge($dob);
             switch ($validAge) {
                 case 'success':
                     $this->getHelper()->setDob($quote, $dob);
                     break;
             }
         }
     }
     // phone
     if (!$this->getHelper()->isPhoneSet($quote)) {
         if (isset($params[$this->_code . '_phone'])) {
             $phone = $data->getData($this->_code . '_phone');
             if ($phone && $this->getHelper()->isValidPhone($phone)) {
                 $this->getHelper()->setPhone($quote, $phone);
             }
         }
     } else {
         $phoneCustomer = $this->getHelper()->getPhone($quote);
         $phoneParams = isset($params[$this->_code . '_phone']) ? $params[$this->_code . '_phone'] : false;
         if ($phoneCustomer != $phoneParams && !empty($phoneParams)) {
             if ($this->getHelper()->isValidPhone($phoneParams)) {
                 $this->getHelper()->setPhone($quote, $phoneParams);
             }
         }
     }
     // taxvat
     if (isset($params[$this->_code . '_taxvat'])) {
         if ($this->getHelper()->isValidTaxvat($quote, $params[$this->_code . '_taxvat'])) {
             $this->getHelper()->setTaxvat($quote, $params[$this->_code . '_taxvat']);
         }
     }
     //customer balance (store credit)
     if ($params['use_customer_balance'] == 1) {
         Mage::throwException($this->getHelper()->__('StoreCredit Error'));
     }
     return $this;
 }
Esempio n. 2
0
 /**
  * Validate payment method information object
  *
  * @return  RatePAY_Ratepaypayment_Model_Method_Rate
  */
 public function validate()
 {
     parent::validate();
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0TotalAmount() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0Amount() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0InterestRate() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0InterestAmount() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0ServiceCharge() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0AnnualPercentageRate() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0MonthlyDebitInterest() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0NumberOfRatesFull() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0NumberOfRates() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0Rate() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     Mage::getSingleton('ratepaypayment/session')->getRatepayRate0LastRate() == null ? Mage::throwException($this->_getHelper()->__('Berechnen Sie Ihre Raten!')) : "";
     return $this;
 }
Esempio n. 3
0
 /**
  * Assign data to info model instance
  * 
  * @param mixed $data
  * @return RatePAY_Ratepaypayment_Model_Method_Directdebit
  */
 public function assignData($data)
 {
     parent::assignData($data);
     $quote = $this->getHelper()->getQuote();
     $params = $data->getData();
     // Bank data
     $ibanAccNo = $this->_clearIban($params[$this->_code . '_account_number']);
     $ibanAccNoCountryCode = substr($ibanAccNo, 0, 2);
     $bic = $params[$this->_code . '_bank_code_number'];
     if (!empty($ibanAccNo)) {
         if (!is_numeric($ibanAccNo)) {
             if ($ibanAccNoCountryCode == $this->getHelper()->getCountryCode($quote)) {
                 if ($ibanAccNoCountryCode == "DE") {
                     if (strlen($ibanAccNo) != 22) {
                         Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
                     }
                     unset($params[$this->_code . '_bic']);
                 }
                 if ($ibanAccNoCountryCode == "AT") {
                     if (strlen($ibanAccNo) != 20) {
                         Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
                     }
                     if ($bic == '') {
                         Mage::throwException($this->_getHelper()->__('insert bank code'));
                     } elseif (strlen($bic) != 8 && strlen($bic) != 11) {
                         Mage::throwException($this->_getHelper()->__('insert bank code'));
                     }
                     $params[$this->_code . '_bic'] = $bic;
                 }
                 if ($ibanAccNoCountryCode == "CH") {
                     if (strlen($ibanAccNo) != 21) {
                         Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
                     }
                     if ($bic == '') {
                         Mage::throwException($this->_getHelper()->__('insert bank code'));
                     } elseif (strlen($bic) != 8 && strlen($bic) != 11) {
                         Mage::throwException($this->_getHelper()->__('insert bank code'));
                     }
                     $params[$this->_code . '_bic'] = $bic;
                 }
             } else {
                 Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
             }
             unset($params[$this->_code . '_account_number']);
             unset($params[$this->_code . '_bank_code_number']);
             $params[$this->_code . '_iban'] = $ibanAccNo;
         } else {
             if ($this->getHelper()->getCountryCode($quote) != "DE") {
                 Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
             } elseif (!is_numeric($bic) || strlen($bic) != 8) {
                 Mage::throwException($this->_getHelper()->__('insert bank code'));
             }
         }
     }
     Mage::getSingleton('core/session')->setDirectDebitFlag(false);
     if ((isset($params[$this->_code . '_account_number']) && (!empty($params[$this->_code . '_account_number']) && !empty($params[$this->_code . '_bank_code_number'])) || !empty($params[$this->_code . '_iban'])) && !empty($params[$this->_code . '_account_holder'])) {
         $this->getHelper()->setBankData($params, $quote, $this->_code);
     }
     if (!isset($params[$this->_code . '_agreement'])) {
         Mage::throwException($this->_getHelper()->__('AGB Error'));
     }
     // dob
     $dob = isset($params[$this->_code . '_day']) ? $this->getDob($data) : false;
     if (!$this->getHelper()->isDobSet($quote) || $quote->getCustomerDob() != $dob) {
         if ($dob) {
             $validAge = $this->getHelper()->isValidAge($dob);
             switch ($validAge) {
                 case 'old':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'young':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'wrongdate':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'success':
                     $this->getHelper()->setDob($quote, $dob);
                     break;
             }
         } else {
             Mage::throwException($this->_getHelper()->__('Date Error'));
         }
     }
     // phone
     if (!$this->getHelper()->isPhoneSet($quote)) {
         if (isset($params[$this->_code . '_phone'])) {
             $phone = $data->getData($this->_code . '_phone');
             if ($phone && $this->getHelper()->isValidPhone($phone)) {
                 $this->getHelper()->setPhone($quote, $phone);
             } else {
                 Mage::throwException($this->_getHelper()->__('Phone Error'));
             }
         } else {
             Mage::throwException($this->_getHelper()->__('Phone Error'));
         }
     } else {
         $phoneCustomer = $this->getHelper()->getPhone($quote);
         $phoneParams = isset($params[$this->_code . '_phone']) ? $params[$this->_code . '_phone'] : false;
         if ($phoneCustomer != $phoneParams && !empty($phoneParams)) {
             if ($this->getHelper()->isValidPhone($phoneParams)) {
                 $this->getHelper()->setPhone($quote, $phoneParams);
             } else {
                 Mage::throwException($this->_getHelper()->__('Phone Error'));
             }
         } elseif (!$this->getHelper()->isValidPhone($phoneCustomer)) {
             Mage::throwException($this->_getHelper()->__('Phone Error'));
         }
     }
     // taxvat
     if (isset($params[$this->_code . '_taxvat'])) {
         if ($this->getHelper()->isValidTaxvat($params[$this->_code . '_taxvat'])) {
             $this->getHelper()->setTaxvat($quote, $params[$this->_code . '_taxvat']);
         } else {
             Mage::throwException($this->_getHelper()->__('VatId Error'));
         }
     }
     return $this;
 }
Esempio n. 4
0
 /**
  * Assign data to info model instance
  * 
  * @param mixed $data
  * @return RatePAY_Ratepaypayment_Model_Method_Directdebit
  */
 public function assignData($data)
 {
     parent::assignData($data);
     $quote = $this->getHelper()->getQuote();
     $params = $data->getData();
     $country = $this->getHelper()->getCountryCode($quote);
     $b2b = isset($params[$this->_code . '_taxvat']);
     $dob = isset($params[$this->_code . '_day']) ? $this->getDob($data) : false;
     // Bank data
     if (!empty($params[$this->_code . '_iban'])) {
         $iban = $this->_clearIban($params[$this->_code . '_iban']);
         if (substr($iban, 0, 2) != $country) {
             Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
         } elseif ($country == 'DE' && strlen($iban) != 22) {
             Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
         } elseif ($country == 'AT' && strlen($iban) != 20) {
             Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
         } elseif ($country == 'NL' && strlen($iban) != 18) {
             Mage::throwException($this->_getHelper()->__('IBAN invalid Error'));
         }
         if ($country != "DE") {
             $bic = $params[$this->_code . '_bic'];
             if (strlen($bic) != 8 && strlen($bic) != 11) {
                 Mage::throwException($this->_getHelper()->__('insert bank bic'));
             }
         }
     } elseif (!empty($params[$this->_code . '_account_number'])) {
         $accountnumber = $params[$this->_code . '_account_number'];
         $bankcode = $params[$this->_code . '_bank_code_number'];
         if (!is_numeric($accountnumber)) {
             Mage::throwException($this->_getHelper()->__('insert account number'));
         } elseif (empty($bankcode) || !is_numeric($bankcode)) {
             Mage::throwException($this->_getHelper()->__('insert bank code'));
         }
     } else {
         Mage::throwException($this->_getHelper()->__('insert bank data'));
     }
     Mage::getSingleton('ratepaypayment/session')->setDirectDebitFlag(false);
     if (isset($params[$this->_code . '_account_number']) && (!empty($params[$this->_code . '_account_number']) && !empty($params[$this->_code . '_bank_code_number'])) || !empty($params[$this->_code . '_iban'])) {
         $this->getHelper()->setBankData($params, $quote, $this->_code);
     }
     if (!isset($params[$this->_code . '_agreement'])) {
         Mage::throwException($this->_getHelper()->__('AGB Error'));
     }
     if (!$b2b && (!$this->getHelper()->isDobSet($quote) || $quote->getCustomerDob() != $dob)) {
         if ($dob) {
             $validAge = $this->getHelper()->isValidAge($dob);
             switch ($validAge) {
                 case 'old':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'young':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'wrongdate':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'success':
                     $this->getHelper()->setDob($quote, $dob);
                     break;
             }
         } else {
             Mage::throwException($this->_getHelper()->__('Date Error'));
         }
     }
     // phone
     if (!$this->getHelper()->isPhoneSet($quote)) {
         if (isset($params[$this->_code . '_phone'])) {
             $phone = $data->getData($this->_code . '_phone');
             if ($phone && $this->getHelper()->isValidPhone($phone)) {
                 $this->getHelper()->setPhone($quote, $phone);
             } else {
                 Mage::throwException($this->_getHelper()->__('Phone Error'));
             }
         } else {
             Mage::throwException($this->_getHelper()->__('Phone Error'));
         }
     } else {
         $phoneCustomer = $this->getHelper()->getPhone($quote);
         $phoneParams = isset($params[$this->_code . '_phone']) ? $params[$this->_code . '_phone'] : false;
         if ($phoneCustomer != $phoneParams && !empty($phoneParams)) {
             if ($this->getHelper()->isValidPhone($phoneParams)) {
                 $this->getHelper()->setPhone($quote, $phoneParams);
             } else {
                 Mage::throwException($this->_getHelper()->__('Phone Error'));
             }
         } elseif (!$this->getHelper()->isValidPhone($phoneCustomer)) {
             Mage::throwException($this->_getHelper()->__('Phone Error'));
         }
     }
     // taxvat
     if ($b2b) {
         if ($this->getHelper()->isValidTaxvat($quote, $params[$this->_code . '_taxvat'])) {
             $this->getHelper()->setTaxvat($quote, $params[$this->_code . '_taxvat']);
         } else {
             Mage::throwException($this->_getHelper()->__('VatId Error'));
         }
     }
     //customer balance (store credit)
     if ($params['use_customer_balance'] == 1) {
         Mage::throwException($this->getHelper()->__('StoreCredit Error'));
     }
     return $this;
 }
Esempio n. 5
0
 /**
  * Assign data to info model instance
  *
  * @param   mixed $data
  * @return  Mage_Payment_Model_Info
  */
 public function assignData($data)
 {
     Mage::getSingleton('core/session')->setDirectDebitFlag(false);
     parent::assignData($data);
     $quote = $this->getHelper()->getQuote();
     $params = $data->getData();
     // dob
     $dob = isset($params[$this->_code . '_day']) ? $this->getDob($data) : false;
     if (!$this->getHelper()->isCompanySet($quote) && (!$this->getHelper()->isDobSet($quote) || $quote->getCustomerDob() != $dob)) {
         if ($dob) {
             $validAge = $this->getHelper()->isValidAge($dob);
             switch ($validAge) {
                 case 'old':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'young':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'wrongdate':
                     Mage::throwException($this->_getHelper()->__('Date Error'));
                     break;
                 case 'success':
                     $this->getHelper()->setDob($quote, $dob);
                     break;
             }
         } else {
             Mage::throwException($this->_getHelper()->__('Date Error'));
         }
     }
     // phone
     if (!$this->getHelper()->isPhoneSet($quote)) {
         if (isset($params[$this->_code . '_phone'])) {
             $phone = $data->getData($this->_code . '_phone');
             if ($phone && $this->getHelper()->isValidPhone($phone)) {
                 $this->getHelper()->setPhone($quote, $phone);
             } else {
                 Mage::throwException($this->_getHelper()->__('Phone Error'));
             }
         } else {
             Mage::throwException($this->_getHelper()->__('Phone Error'));
         }
     } else {
         $phoneCustomer = $this->getHelper()->getPhone($quote);
         $phoneParams = isset($params[$this->_code . '_phone']) ? $params[$this->_code . '_phone'] : false;
         if ($phoneCustomer != $phoneParams && !empty($phoneParams)) {
             if ($this->getHelper()->isValidPhone($phoneParams)) {
                 $this->getHelper()->setPhone($quote, $phoneParams);
             } else {
                 Mage::throwException($this->_getHelper()->__('Phone Error'));
             }
         } elseif (!$this->getHelper()->isValidPhone($phoneCustomer)) {
             Mage::throwException($this->_getHelper()->__('Phone Error'));
         }
     }
     // taxvat
     if (isset($params[$this->_code . '_taxvat'])) {
         if ($this->getHelper()->isValidTaxvat($params[$this->_code . '_taxvat'])) {
             $this->getHelper()->setTaxvat($quote, $params[$this->_code . '_taxvat']);
         } else {
             Mage::throwException($this->_getHelper()->__('VatId Error'));
         }
     }
     return $this;
 }