/**
  * add birthdate to params list, if it is available
  *
  * @param Mage_Sales_Model_Quote $quote Quote
  * @return array Either empty or with birthdate
  */
 public function convertBirthdate($quote)
 {
     if (is_null($quote->getCustomerDob())) {
         return array();
     }
     return array('GEBURTSDATUM' => Mage::getModel('core/date')->date('d.m.Y', $quote->getCustomerDob()));
 }
 /**
  * @param Mage_Sales_Model_Quote $quote
  * @return array
  */
 protected function _buildParams($quote)
 {
     $billingAddress = $quote->getBillingAddress();
     $gender = 'female';
     if ($quote->getCustomerGender() == self::GENDER_MALE) {
         $gender = 'male';
     }
     $street = preg_split("/\\s+(?=\\S*+\$)/", $billingAddress->getStreet1());
     $params = array('gender' => $gender, 'firstname' => $billingAddress->getFirstname(), 'lastname' => $billingAddress->getLastname(), 'country' => $billingAddress->getCountry(), 'street' => $street[0], 'housenumber' => $street[1], 'zip' => $billingAddress->getPostcode(), 'city' => $billingAddress->getCity(), 'birthday' => $this->_formatDob($quote->getCustomerDob()), 'currency' => 'EUR', 'amount' => $this->_formatAmount($quote->getGrandTotal()));
     return $params;
 }
Exemplo n.º 3
0
 /**
  * Open Invoice NL is not available if quote has a coupon
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return boolean
  */
 public function isAvailable($quote = null)
 {
     /* availability depends on quote */
     if (false == $quote instanceof Mage_Sales_Model_Quote) {
         return false;
     }
     /* not available if there is no gender or no birthday */
     if (is_null($quote->getCustomerGender()) || is_null($quote->getCustomerDob())) {
         return false;
     }
     return parent::isAvailable($quote);
 }
Exemplo n.º 4
0
 /**
  * Open Invoice DE is not available if quote has a coupon
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return boolean
  */
 public function isAvailable($quote = null)
 {
     /* availability depends on quote */
     if (false == $quote instanceof Mage_Sales_Model_Quote) {
         return false;
     }
     /* not available if quote contains a coupon and allow_discounted_carts is disabled */
     if (!$this->isAvailableForDiscountedCarts() && $quote->getSubtotal() != $quote->getSubtotalWithDiscount()) {
         return false;
     }
     /* not available if there is no gender or no birthday */
     if (is_null($quote->getCustomerGender()) || is_null($quote->getCustomerDob())) {
         return false;
     }
     return parent::isAvailable($quote);
 }
Exemplo n.º 5
0
 /**
  * Gets the Day of Birth from the Quote or Order if guest, else from the customer
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote
  * @return String
  */
 public function getDob($quote)
 {
     return $quote->getCustomerDob();
 }
Exemplo n.º 6
0
 /**
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return bool
  */
 protected function _isAvailableRatePay($quote)
 {
     $currencies = explode(',', $this->getConfigData('currencies'));
     if (!in_array($quote->getQuoteCurrencyCode(), $currencies)) {
         return false;
     }
     $dob = $quote->getCustomerDob();
     $minAge = (int) $this->getConfigData('min_age');
     //we only need to check the dob if it's set. Else we ask for dob on payment selection page.
     if ($dob) {
         $dobObject = new DateTime($dob);
         $currentYear = date('Y');
         $currentMonth = date('m');
         $currentDay = date('d');
         $ageCheckDate = $currentYear - $minAge . '-' . $currentMonth . '-' . $currentDay;
         $ageCheckObject = new DateTime($ageCheckDate);
         if ($ageCheckObject < $dobObject) {
             return false;
         }
     }
     if ($quote->hasVirtualItems()) {
         return false;
     }
     if (!$this->compareAddresses($quote)) {
         return false;
     }
     return parent::isAvailable($quote);
 }
Exemplo n.º 7
0
 /**
  * Gets all needed Informations for customer Block of the Request
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quoteOrOrder
  * @return array
  */
 public function getRequestCustomer($quoteOrOrder)
 {
     $customer = array();
     $contacts = array();
     $billing = array();
     $shipping = array();
     $dob = new Zend_Date($quoteOrOrder->getCustomerDob());
     $customer['dob'] = $dob->toString("yyyy-MM-dd");
     $customer['gender'] = $this->getHelper()->getGenderCode($quoteOrOrder);
     $customer['firstName'] = $quoteOrOrder->getBillingAddress()->getFirstname();
     $customer['lastName'] = $quoteOrOrder->getBillingAddress()->getLastname();
     $customer['ip'] = Mage::helper('core/http')->getRemoteAddr(false);
     $customer['nationality'] = $quoteOrOrder->getBillingAddress()->getCountryId();
     $customer['company'] = $quoteOrOrder->getBillingAddress()->getCompany();
     $customer['vatId'] = $quoteOrOrder->getCustomerTaxvat();
     $contacts['email'] = $quoteOrOrder->getCustomerEmail();
     $contacts['phone'] = $quoteOrOrder->getBillingAddress()->getTelephone();
     if ($quoteOrOrder->getBillingAddress()->getFax() != '') {
         $contacts['fax'] = $quoteOrOrder->getBillingAddress()->getFax();
     }
     // Different handling of street fields in case of NL orders
     $billingStreetFull = $quoteOrOrder->getBillingAddress()->getStreetFull();
     $billingStreet1 = $quoteOrOrder->getBillingAddress()->getStreet1();
     $billingStreet2 = $quoteOrOrder->getBillingAddress()->getStreet2();
     if ($quoteOrOrder->getBillingAddress()->getCountryId() == "NL" && !empty($billingStreet2)) {
         $billing['street'] = $billingStreet1;
         $billing['streetAdditional'] = $billingStreet2;
     } else {
         $billing['street'] = preg_replace('~[\\r\\n]+~', ' ', $billingStreetFull);
     }
     $billing['zipCode'] = $quoteOrOrder->getBillingAddress()->getPostcode();
     $billing['city'] = $quoteOrOrder->getBillingAddress()->getCity();
     $billing['countryId'] = $quoteOrOrder->getBillingAddress()->getCountryId();
     $shipping['firstName'] = $quoteOrOrder->getShippingAddress()->getFirstname();
     $shipping['lastName'] = $quoteOrOrder->getShippingAddress()->getLastname();
     // Different handling of street fields in case of NL orders
     $shippingStreetFull = $quoteOrOrder->getShippingAddress()->getStreetFull();
     $shippingStreet1 = $quoteOrOrder->getShippingAddress()->getStreet1();
     $shippingStreet2 = $quoteOrOrder->getShippingAddress()->getStreet2();
     if ($quoteOrOrder->getShippingAddress()->getCountryId() == "NL" && !empty($shippingStreet2)) {
         $shipping['street'] = $shippingStreet1;
         $shipping['streetAdditional'] = $shippingStreet2;
     } else {
         $shipping['street'] = preg_replace('~[\\r\\n]+~', ' ', $shippingStreetFull);
     }
     $shipping['zipCode'] = $quoteOrOrder->getShippingAddress()->getPostcode();
     $shipping['city'] = $quoteOrOrder->getShippingAddress()->getCity();
     $shipping['countryId'] = $quoteOrOrder->getShippingAddress()->getCountryId();
     if ($quoteOrOrder->getShippingAddress()->getCompany()) {
         $shipping['company'] = $quoteOrOrder->getShippingAddress()->getCompany();
     }
     $customer['contacts'] = $contacts;
     $customer['billing'] = $billing;
     $customer['shipping'] = $shipping;
     return $customer;
 }
Exemplo n.º 8
0
 function CreateMagentoShopRequest(Mage_Sales_Model_Quote $quote)
 {
     $request = new Byjuno_Cdp_Helper_Api_Classes_ByjunoRequest();
     $request->setClientId(Mage::getStoreConfig('byjuno/api/clientid', Mage::app()->getStore()));
     $request->setUserID(Mage::getStoreConfig('byjuno/api/userid', Mage::app()->getStore()));
     $request->setPassword(Mage::getStoreConfig('byjuno/api/password', Mage::app()->getStore()));
     $request->setVersion("1.00");
     try {
         $request->setRequestEmail(Mage::getStoreConfig('byjuno/api/mail', Mage::app()->getStore()));
     } catch (Exception $e) {
     }
     $b = $quote->getCustomerDob();
     if (!empty($b)) {
         $request->setDateOfBirth(Mage::getModel('core/date')->date('Y-m-d', strtotime($b)));
     }
     Mage::getSingleton('checkout/session')->setData('dob_amasty', '');
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["dob"])) {
         $request->setDateOfBirth(Mage::getModel('core/date')->date('Y-m-d', strtotime($_POST["billing"]["dob"])));
         Mage::getSingleton('checkout/session')->setData('dob_amasty', $_POST["billing"]["dob"]);
     }
     $g = $quote->getCustomerGender();
     if (!empty($g)) {
         if ($g == '1') {
             $request->setGender('1');
         } else {
             if ($g == '2') {
                 $request->setGender('2');
             }
         }
     }
     $request->setRequestId(uniqid((string) $quote->getBillingAddress()->getId() . "_"));
     $reference = $quote->getCustomer()->getId();
     if (empty($reference)) {
         $request->setCustomerReference("guest_" . $quote->getBillingAddress()->getId());
     } else {
         $request->setCustomerReference($quote->getCustomer()->getId());
     }
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["method"]) && $_POST["method"] == 'guest') {
         $request->setCustomerReference(uniqid("guest_"));
     }
     $request->setFirstName((string) $quote->getBillingAddress()->getFirstname());
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["firstname"])) {
         $request->setFirstName((string) $_POST["billing"]["firstname"]);
     }
     $request->setLastName((string) $quote->getBillingAddress()->getLastname());
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["lastname"])) {
         $request->setLastName((string) $_POST["billing"]["lastname"]);
     }
     $request->setFirstLine(trim((string) $quote->getBillingAddress()->getStreetFull()));
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["street"])) {
         $street = '';
         if (!empty($_POST["billing"]["street"][0])) {
             $street .= $_POST["billing"]["street"][0];
         }
         if (!empty($_POST["billing"]["street"][1])) {
             $street .= $_POST["billing"]["street"][1];
         }
         $request->setFirstLine((string) trim($street));
     }
     $request->setCountryCode(strtoupper((string) $quote->getBillingAddress()->getCountry()));
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["country_id"])) {
         $request->setCountryCode((string) $_POST["billing"]["country_id"]);
     }
     $request->setPostCode((string) $quote->getBillingAddress()->getPostcode());
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["postcode"])) {
         $request->setPostCode($_POST["billing"]["postcode"]);
     }
     $request->setTown((string) $quote->getBillingAddress()->getCity());
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["city"])) {
         $request->setTown($_POST["billing"]["city"]);
     }
     $request->setFax((string) trim($quote->getBillingAddress()->getFax(), '-'));
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["fax"])) {
         $request->setFax(trim($_POST["billing"]["fax"], '-'));
     }
     $request->setLanguage((string) substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2));
     if ($quote->getBillingAddress()->getCompany()) {
         $request->setCompanyName1($quote->getBillingAddress()->getCompany());
     }
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["company"])) {
         $request->setCompanyName1(trim($_POST["billing"]["company"], '-'));
     }
     $request->setTelephonePrivate((string) trim($quote->getBillingAddress()->getTelephone(), '-'));
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["telephone"])) {
         $request->setTelephonePrivate(trim($_POST["billing"]["telephone"], '-'));
     }
     $request->setEmail((string) $quote->getBillingAddress()->getEmail());
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["email"])) {
         $request->setEmail((string) $_POST["billing"]["email"]);
     }
     Mage::getSingleton('checkout/session')->setData('gender_amasty', '');
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty') {
         $g = isset($_POST["billing"]["gender"]) ? $_POST["billing"]["gender"] : '';
         $request->setGender($g);
         Mage::getSingleton('checkout/session')->setData('gender_amasty', $g);
     }
     if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && !empty($_POST["billing"]["prefix"])) {
         if (strtolower($_POST["billing"]["prefix"]) == 'herr') {
             $request->setGender('1');
             Mage::getSingleton('checkout/session')->setData('gender_amasty', '1');
         } else {
             if (strtolower($_POST["billing"]["prefix"]) == 'frau') {
                 $request->setGender('2');
                 Mage::getSingleton('checkout/session')->setData('gender_amasty', '2');
             }
         }
     }
     $extraInfo["Name"] = 'ORDERCLOSED';
     $extraInfo["Value"] = 'NO';
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'ORDERAMOUNT';
     $extraInfo["Value"] = number_format($quote->getGrandTotal(), 2, '.', '');
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'ORDERCURRENCY';
     $extraInfo["Value"] = $quote->getBaseCurrencyCode();
     $request->setExtraInfo($extraInfo);
     $extraInfo["Name"] = 'IP';
     $extraInfo["Value"] = $this->getClientIp();
     $request->setExtraInfo($extraInfo);
     $sesId = Mage::getSingleton('checkout/session')->getData("byjuno_session_id");
     if (Mage::getStoreConfig('byjuno/api/tmxenabled', Mage::app()->getStore()) == 'enable' && !empty($sesId)) {
         $extraInfo["Name"] = 'DEVICE_FINGERPRINT_ID';
         $extraInfo["Value"] = Mage::getSingleton('checkout/session')->getData("byjuno_session_id");
         $request->setExtraInfo($extraInfo);
     }
     /* shipping information */
     if (!$quote->isVirtual()) {
         $extraInfo["Name"] = 'DELIVERY_FIRSTNAME';
         $extraInfo["Value"] = $quote->getShippingAddress()->getFirstname();
         if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && empty($_POST["shipping"]["same_as_billing"])) {
             if (!empty($_POST["shipping"]["firstname"])) {
                 $extraInfo["Value"] = $_POST["shipping"]["firstname"];
             }
         }
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_LASTNAME';
         $extraInfo["Value"] = $quote->getShippingAddress()->getLastname();
         if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && empty($_POST["shipping"]["same_as_billing"])) {
             if (!empty($_POST["shipping"]["lastname"])) {
                 $extraInfo["Value"] = $_POST["shipping"]["lastname"];
             }
         }
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_FIRSTLINE';
         $extraInfo["Value"] = trim($quote->getShippingAddress()->getStreetFull());
         if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && empty($_POST["shipping"]["same_as_billing"])) {
             $extraInfo["Value"] = '';
             if (!empty($_POST["shipping"]["street"][0])) {
                 $extraInfo["Value"] = $_POST["shipping"]["street"][0];
             }
             if (!empty($_POST["shipping"]["street"][1])) {
                 $extraInfo["Value"] .= ' ' . $_POST["shipping"]["street"][1];
             }
             $extraInfo["Value"] = trim($extraInfo["Value"]);
         }
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_HOUSENUMBER';
         $extraInfo["Value"] = '';
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_COUNTRYCODE';
         $extraInfo["Value"] = strtoupper($quote->getShippingAddress()->getCountry());
         if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && empty($_POST["shipping"]["same_as_billing"])) {
             if (!empty($_POST["shipping"]["country_id"])) {
                 $extraInfo["Value"] = $_POST["shipping"]["country_id"];
             }
         }
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_POSTCODE';
         $extraInfo["Value"] = $quote->getShippingAddress()->getPostcode();
         if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty' && empty($_POST["shipping"]["same_as_billing"])) {
             if (!empty($_POST["shipping"]["postcode"])) {
                 $extraInfo["Value"] = $_POST["shipping"]["postcode"];
             }
         }
         $request->setExtraInfo($extraInfo);
         $extraInfo["Name"] = 'DELIVERY_TOWN';
         $extraInfo["Value"] = $quote->getShippingAddress()->getCity();
         if (Mage::getStoreConfig('byjuno/api/plugincheckouttype', Mage::app()->getStore()) == 'amasty') {
             if (!empty($_POST["shipping"]["same_as_billing"]) && $_POST["shipping"]["same_as_billing"] == '1' && !empty($_POST["billing"]["city"])) {
                 $extraInfo["Value"] = $_POST["billing"]["city"];
             } else {
                 if (!empty($_POST["shipping"]["city"])) {
                     $extraInfo["Value"] = $_POST["shipping"]["city"];
                 }
             }
         }
         $request->setExtraInfo($extraInfo);
         if ($quote->getShippingAddress()->getCompany() != '' && Mage::getStoreConfig('byjuno/api/businesstobusiness', Mage::app()->getStore()) == 'enable') {
             $extraInfo["Name"] = 'DELIVERY_COMPANYNAME';
             $extraInfo["Value"] = $quote->getShippingAddress()->getCompany();
             $request->setExtraInfo($extraInfo);
         }
     }
     $extraInfo["Name"] = 'CONNECTIVTY_MODULE';
     $extraInfo["Value"] = 'Byjuno Magento module 4.0.0';
     $request->setExtraInfo($extraInfo);
     return $request;
 }