Exemplo n.º 1
0
 protected function _updateQuote(Mage_Sales_Model_Quote $quote)
 {
     if (!Mage::helper('recapture')->isEnabled()) {
         return $this;
     }
     if (!$quote->getId()) {
         return;
     }
     //sales_quote_save_before gets called like 5 times on some page loads, we don't want to do 5 updates per page load
     if (Mage::registry('recapture_has_posted')) {
         return;
     }
     Mage::register('recapture_has_posted', true);
     $mediaConfig = Mage::getModel('catalog/product_media_config');
     $storeId = Mage::app()->getStore();
     $transportData = array('first_name' => $quote->getCustomerFirstname(), 'last_name' => $quote->getCustomerLastname(), 'email' => $quote->getCustomerEmail(), 'external_id' => $quote->getId(), 'grand_total' => $quote->getGrandTotal(), 'products' => array(), 'totals' => array());
     $cartItems = $quote->getAllVisibleItems();
     foreach ($cartItems as $item) {
         $productModel = $item->getProduct();
         $productImage = (string) Mage::helper('catalog/image')->init($productModel, 'thumbnail');
         //check configurable first
         if ($item->getProductType() == 'configurable') {
             if (Mage::getStoreConfig('checkout/cart/configurable_product_image') == 'itself') {
                 $child = $productModel->getIdBySku($item->getSku());
                 $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($child, 'thumbnail', $storeId);
                 if ($image) {
                     $productImage = $mediaConfig->getMediaUrl($image);
                 }
             }
         }
         //then check grouped
         if (Mage::getStoreConfig('checkout/cart/grouped_product_image') == 'parent') {
             $options = $productModel->getTypeInstance(true)->getOrderOptions($productModel);
             if (isset($options['super_product_config']) && $options['super_product_config']['product_type'] == 'grouped') {
                 $parent = $options['super_product_config']['product_id'];
                 $image = Mage::getResourceModel('catalog/product')->getAttributeRawValue($parent, 'thumbnail', $storeId);
                 $productImage = $mediaConfig->getMediaUrl($image);
             }
         }
         $optionsHelper = Mage::helper('catalog/product_configuration');
         if ($item->getProductType() == 'configurable') {
             $visibleOptions = $optionsHelper->getConfigurableOptions($item);
         } else {
             $visibleOptions = $optionsHelper->getCustomOptions($item);
         }
         $product = array('name' => $item->getName(), 'sku' => $item->getSku(), 'price' => $item->getPrice(), 'qty' => $item->getQty(), 'image' => $productImage, 'options' => $visibleOptions);
         $transportData['products'][] = $product;
     }
     $totals = $quote->getTotals();
     foreach ($totals as $total) {
         //we pass grand total on the top level
         if ($total->getCode() == 'grand_total') {
             continue;
         }
         $total = array('name' => $total->getTitle(), 'amount' => $total->getValue());
         $transportData['totals'][] = $total;
     }
     Mage::helper('recapture/transport')->dispatch('cart', $transportData);
     return $this;
 }
Exemplo n.º 2
0
 /**
  * Check whether method is available
  *
  * @param Mage_Sales_Model_Quote|null $quote
  * @return bool
  */
 public function isAvailable($quote = null)
 {
     /* custom code written to round price here as roundPrice function was changed */
     $_grand_price = Mage::app()->getStore()->roundPrice($quote->getGrandTotal());
     $_grand_price = round($_grand_price, 2);
     return parent::isAvailable($quote) && !empty($quote) && $_grand_price == 0;
 }
Exemplo n.º 3
0
 /**
  * Reserve order ID for specified quote and start checkout on PayPal
  * @return string
  */
 public function start($returnUrl, $cancelUrl)
 {
     $this->_quote->collectTotals();
     if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
         Mage::throwException(Mage::helper('paypal')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
     }
     $this->_quote->reserveOrderId()->save();
     // prepare API
     $this->_getApi();
     $this->_api->setAmount($this->_quote->getBaseGrandTotal())->setCurrencyCode($this->_quote->getBaseCurrencyCode())->setInvNum($this->_quote->getReservedOrderId())->setReturnUrl($returnUrl)->setCancelUrl($cancelUrl)->setSolutionType($this->_config->solutionType)->setPaymentAction($this->_config->paymentAction);
     if ($this->_giropayUrls) {
         list($successUrl, $cancelUrl, $pendingUrl) = $this->_giropayUrls;
         $this->_api->addData(array('giropay_cancel_url' => $cancelUrl, 'giropay_success_url' => $successUrl, 'giropay_bank_txn_pending_url' => $pendingUrl));
     }
     $this->_setBillingAgreementRequest();
     // supress or export shipping address
     if ($this->_quote->getIsVirtual()) {
         $this->_api->setSuppressShipping(true);
     } else {
         $address = $this->_quote->getShippingAddress();
         $isOverriden = 0;
         if (true === $address->validate()) {
             $isOverriden = 1;
             $this->_api->setAddress($address);
         }
         $this->_quote->getPayment()->setAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_SHIPPING_OVERRIDEN, $isOverriden);
         $this->_quote->getPayment()->save();
     }
     // add line items
     $paypalCart = Mage::getModel('paypal/cart', array($this->_quote));
     $this->_api->setPaypalCart($paypalCart)->setIsLineItemsEnabled($this->_config->lineItemsEnabled);
     // add shipping options if needed and line items are available
     if ($this->_config->lineItemsEnabled && $this->_config->transferShippingOptions && $paypalCart->getItems()) {
         if (!$this->_quote->getIsVirtual() && !$this->_quote->hasNominalItems()) {
             if ($options = $this->_prepareShippingOptions($address, true)) {
                 $this->_api->setShippingOptionsCallbackUrl(Mage::getUrl('*/*/shippingOptionsCallback', array('quote_id' => $this->_quote->getId())))->setShippingOptions($options);
             }
         }
     }
     // add recurring payment profiles information
     if ($profiles = $this->_quote->prepareRecurringPaymentProfiles()) {
         foreach ($profiles as $profile) {
             $profile->setMethodCode(Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS);
             if (!$profile->isValid()) {
                 Mage::throwException($profile->getValidationErrors(true, true));
             }
         }
         $this->_api->addRecurringPaymentProfiles($profiles);
     }
     $this->_config->exportExpressCheckoutStyleSettings($this->_api);
     // call API and redirect with token
     $this->_api->callSetExpressCheckout();
     $token = $this->_api->getToken();
     $this->_redirectUrl = $this->_config->getExpressCheckoutStartUrl($token);
     $this->_quote->getPayment()->unsAdditionalInformation(self::PAYMENT_INFO_TRANSPORT_BILLING_AGREEMENT);
     $this->_quote->getPayment()->save();
     return $token;
 }
 /**
  * @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.º 5
0
 /**
  * @magentoDataFixture Mage/Catalog/_files/product_virtual.php
  * @magentoDataFixture Mage/Sales/_files/quote.php
  */
 public function testCollectTotalsWithVirtual()
 {
     $quote = new Mage_Sales_Model_Quote();
     $quote->load('test01', 'reserved_order_id');
     $product = new Mage_Catalog_Model_Product();
     $product->load(21);
     $quote->addProduct($product);
     $quote->collectTotals();
     $this->assertEquals(2, $quote->getItemsQty());
     $this->assertEquals(1, $quote->getVirtualItemsQty());
     $this->assertEquals(20, $quote->getGrandTotal());
     $this->assertEquals(20, $quote->getBaseGrandTotal());
 }
Exemplo n.º 6
0
 /**
  * Reserve order ID for specified quote and start checkout on PayPal
  *
  * @return mixed
  */
 public function start()
 {
     $this->_quote->collectTotals();
     if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
         Mage::throwException(Mage::helper('payone_core')->__('PayPal does not support processing orders with zero amount. To complete your purchase, proceed to the standard checkout process.'));
     }
     $this->_quote->reserveOrderId()->save();
     $service = $this->getFactory()->getServicePaymentGenericpayment($this->_config);
     $mapper = $service->getMapper();
     $request = $mapper->mapExpressCheckoutParameters($this->_quote);
     $response = $this->getFactory()->getServiceApiPaymentGenericpayment()->request($request);
     if ($response instanceof Payone_Api_Response_Genericpayment_Redirect) {
         $this->_redirectUrl = $response->getRedirecturl();
         $this->_workorderid = $response->getWorkorderId();
     }
 }
 /**
  * @param Mage_Sales_Model_Quote $quote
  */
 public function mapExpressCheckoutParameters($quote, $workOrderId = null)
 {
     $request = $this->getRequest();
     $this->mapDefaultParameters($request);
     $paydata = new Payone_Api_Request_Parameter_Paydata_Paydata();
     if (null === $workOrderId) {
         $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYPAL_ECS_SET_EXPRESSCHECKOUT)));
     } else {
         $paydata->addItem(new Payone_Api_Request_Parameter_Paydata_DataItem(array('key' => 'action', 'data' => Payone_Api_Enum_GenericpaymentAction::PAYPAL_ECS_GET_EXPRESSCHECKOUTDETAILS)));
         $request->setWorkorderId($workOrderId);
     }
     $request->setPaydata($paydata);
     $request->setAid($this->getConfigPayment()->getAid());
     $request->setClearingtype(Payone_Enum_ClearingType::WALLET);
     $request->setAmount($quote->getGrandTotal());
     $request->setCurrency($quote->getQuoteCurrencyCode());
     $request->setWallet(new Payone_Api_Request_Parameter_Authorization_PaymentMethod_Wallet(array('wallettype' => Payone_Api_Enum_WalletType::PAYPAL_EXPRESS, 'successurl' => Mage::helper('payone_core/url')->getMagentoUrl('*/*/return'), 'errorurl' => Mage::helper('payone_core/url')->getMagentoUrl('*/*/error'), 'backurl' => Mage::helper('payone_core/url')->getMagentoUrl('*/*/cancel'))));
     return $request;
 }
 /**
  * Reserve order ID for specified quote and start checkout on PayPal
  *
  * @param string
  * @param string
  * @param bool|null $button specifies if we came from Checkout Stream or from Product/Cart directly
  * @return mixed
  */
 public function start($returnUrl, $cancelUrl, $button = null)
 {
     $this->_quote->collectTotals();
     if (!$this->_quote->getGrandTotal() && !$this->_quote->hasNominalItems()) {
         Mage::throwException($this->_helper->__(self::EBAYENTERPRISE_PAYPAL_ZERO_CHECKOUT_NOT_SUPPORTED));
     }
     $this->_quote->reserveOrderId()->save();
     $this->_getApi();
     $setExpressCheckoutReply = $this->_api->setExpressCheckout($returnUrl, $cancelUrl, $this->_quote);
     if ($button) {
         // mark the payment to indicate express checkout was initiated from
         // outside the normal checkout flow
         // (e.g. clicked paypal checkout button from product page)
         $setExpressCheckoutReply[self::PAYMENT_INFO_BUTTON] = 1;
     }
     $this->_quote->getPayment()->importData($setExpressCheckoutReply);
     $this->_quote->getPayment()->save();
     return $setExpressCheckoutReply;
 }
Exemplo n.º 9
0
 /**
  * Get Shopping Cart XML
  * @param Mage_Sales_Model_Quote $quote
  * @return string
  */
 public function getShoppingCartXML($quote)
 {
     $dom = new DOMDocument('1.0', 'utf-8');
     $ShoppingCart = $dom->createElement('ShoppingCart');
     $dom->appendChild($ShoppingCart);
     $ShoppingCart->appendChild($dom->createElement('CurrencyCode', $quote->getQuoteCurrencyCode()));
     $ShoppingCart->appendChild($dom->createElement('Subtotal', (int) (100 * $quote->getGrandTotal())));
     // Add Order Lines
     $items = $quote->getAllVisibleItems();
     /** @var $item Mage_Sales_Model_Quote_Item */
     foreach ($items as $item) {
         $product = $item->getProduct();
         $ShoppingCartItem = $dom->createElement('ShoppingCartItem');
         $ShoppingCartItem->appendChild($dom->createElement('Description', $item->getName()));
         $ShoppingCartItem->appendChild($dom->createElement('Quantity', (int) $item->getQty()));
         $ShoppingCartItem->appendChild($dom->createElement('Value', (int) bcmul($product->getFinalPrice(), 100)));
         $ShoppingCartItem->appendChild($dom->createElement('ImageURL', $product->getThumbnailUrl()));
         // NOTE: getThumbnailUrl is DEPRECATED!
         $ShoppingCart->appendChild($ShoppingCartItem);
     }
     return str_replace("\n", '', $dom->saveXML());
 }
Exemplo n.º 10
0
 /**
  * Send email id payment was failed
  *
  * @param Mage_Sales_Model_Quote $checkout
  * @param string $message
  * @param string $checkoutType
  * @return Mage_Checkout_Helper_Data
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     $translate = Mage::getSingleton('Mage_Core_Model_Translate');
     /* @var $translate Mage_Core_Model_Translate */
     $translate->setTranslateInline(false);
     $mailTemplate = Mage::getModel('Mage_Core_Model_Email_Template');
     /* @var $mailTemplate Mage_Core_Model_Email_Template */
     $template = Mage::getStoreConfig('checkout/payment_failed/template', $checkout->getStoreId());
     $copyTo = $this->_getEmails('checkout/payment_failed/copy_to', $checkout->getStoreId());
     $copyMethod = Mage::getStoreConfig('checkout/payment_failed/copy_method', $checkout->getStoreId());
     if ($copyTo && $copyMethod == 'bcc') {
         $mailTemplate->addBcc($copyTo);
     }
     $_reciever = Mage::getStoreConfig('checkout/payment_failed/reciever', $checkout->getStoreId());
     $sendTo = array(array('email' => Mage::getStoreConfig('trans_email/ident_' . $_reciever . '/email', $checkout->getStoreId()), 'name' => Mage::getStoreConfig('trans_email/ident_' . $_reciever . '/name', $checkout->getStoreId())));
     if ($copyTo && $copyMethod == 'copy') {
         foreach ($copyTo as $email) {
             $sendTo[] = array('email' => $email, 'name' => null);
         }
     }
     $shippingMethod = '';
     if ($shippingInfo = $checkout->getShippingAddress()->getShippingMethod()) {
         $data = explode('_', $shippingInfo);
         $shippingMethod = $data[0];
     }
     $paymentMethod = '';
     if ($paymentInfo = $checkout->getPayment()) {
         $paymentMethod = $paymentInfo->getMethod();
     }
     $items = '';
     foreach ($checkout->getAllVisibleItems() as $_item) {
         /* @var $_item Mage_Sales_Model_Quote_Item */
         $items .= $_item->getProduct()->getName() . '  x ' . $_item->getQty() . '  ' . $checkout->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n";
     }
     $total = $checkout->getStoreCurrencyCode() . ' ' . $checkout->getGrandTotal();
     foreach ($sendTo as $recipient) {
         $mailTemplate->setDesignConfig(array('area' => Mage_Core_Model_App_Area::AREA_FRONTEND, 'store' => $checkout->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()), $recipient['email'], $recipient['name'], array('reason' => $message, 'checkoutType' => $checkoutType, 'dateAndTime' => Mage::app()->getLocale()->date(), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'customerEmail' => $checkout->getCustomerEmail(), 'billingAddress' => $checkout->getBillingAddress(), 'shippingAddress' => $checkout->getShippingAddress(), 'shippingMethod' => Mage::getStoreConfig('carriers/' . $shippingMethod . '/title'), 'paymentMethod' => Mage::getStoreConfig('payment/' . $paymentMethod . '/title'), 'items' => nl2br($items), 'total' => $total));
     }
     $translate->setTranslateInline(true);
     return $this;
 }
Exemplo n.º 11
0
 /**
  * Gets all needed Informations for payment Block of the Request
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $object
  * @param float amount
  * @param string $request
  * @return array
  */
 public function getRequestPayment($object, $amount = '', $request = '')
 {
     $paymentMethod = $object->getPayment()->getMethod();
     $payment = array();
     switch ($paymentMethod) {
         case 'ratepay_rechnung':
             $payment['method'] = 'INVOICE';
             break;
         case 'ratepay_rate0':
         case 'ratepay_rate':
             if ($request == 'PAYMENT_REQUEST') {
                 $payment['installmentNumber'] = Mage::getSingleton('ratepaypayment/session')->{'get' . Mage::helper('ratepaypayment')->convertUnderlineToCamelCase($paymentMethod) . 'NumberOfRatesFull'}();
                 $payment['installmentAmount'] = Mage::getSingleton('ratepaypayment/session')->{'get' . Mage::helper('ratepaypayment')->convertUnderlineToCamelCase($paymentMethod) . 'Rate'}();
                 $payment['lastInstallmentAmount'] = Mage::getSingleton('ratepaypayment/session')->{'get' . Mage::helper('ratepaypayment')->convertUnderlineToCamelCase($paymentMethod) . 'LastRate'}();
                 $payment['interestRate'] = Mage::getSingleton('ratepaypayment/session')->{'get' . Mage::helper('ratepaypayment')->convertUnderlineToCamelCase($paymentMethod) . 'InterestRate'}();
                 if ($this->isDynamicDue()) {
                     $payment['paymentFirstDay'] = Mage::getSingleton('ratepaypayment/session')->getRatepayPaymentFirstDay();
                 } else {
                     $payment['paymentFirstDay'] = '28';
                 }
             }
             $payment['method'] = 'INSTALLMENT';
             if (Mage::getSingleton('ratepaypayment/session')->getDirectDebitFlag()) {
                 $payment['debitType'] = 'DIRECT-DEBIT';
             } else {
                 $payment['debitType'] = 'BANK-TRANSFER';
             }
             break;
         case 'ratepay_directdebit':
             $payment['method'] = 'ELV';
             break;
     }
     if ($object instanceof Mage_Sales_Model_Order) {
         $payment['currency'] = $object->getOrderCurrencyCode();
     } else {
         $payment['currency'] = $object->getQuoteCurrencyCode();
     }
     if (is_numeric($amount)) {
         $payment['amount'] = $amount;
     } else {
         $payment['amount'] = $object->getGrandTotal();
     }
     // Ensure that the basket amout is never less than zero
     // In certain cases (i.e. in case of maloperation) the amount can become < 0
     if ($payment['amount'] < 0) {
         $payment['amount'] = 0;
     }
     return $payment;
 }
Exemplo n.º 12
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;
 }
Exemplo n.º 13
0
 /**
  * Get Available Methods for Type by Quote
  *
  * @param $type
  * @param Mage_Sales_Model_Quote $quote
  * @return array
  */
 public function getMethodsForQuote($type, Mage_Sales_Model_Quote $quote)
 {
     $country = $quote->getBillingAddress()->getCountry();
     $quoteTotal = $quote->getGrandTotal();
     $methodsForCountry = $this->getMethodsForCountry($type, $country);
     $methods = array();
     foreach ($methodsForCountry as $key => $method) {
         /** @var $method Payone_Core_Model_Config_Payment_Method_Interface */
         $maxOrderTotal = $method->getMaxOrderTotal();
         $minOrderTotal = $method->getMinOrderTotal();
         if (!empty($maxOrderTotal) and $maxOrderTotal < $quoteTotal) {
             continue;
             // quote total too high.
         }
         if (!empty($minOrderTotal) and $minOrderTotal > $quoteTotal) {
             continue;
             // quote total is too low.
         }
         $methods[] = $method;
     }
     return $methods;
 }
Exemplo n.º 14
0
 /**
  * Build Amount
  *
  * @param Mage_Sales_Model_Quote $quote
  * @return Amount
  */
 protected function buildAmount($quote)
 {
     $details = new Details();
     $details->setShipping($quote->getShippingAddress()->getShippingAmount())->setTax($quote->getShippingAddress()->getTaxAmount())->setSubtotal($quote->getSubtotalWithDiscount() + $quote->getShippingAddress()->getHiddenTaxAmount());
     /*- $quote->getShippingAddress()->getBaseGiftcertAmount()*/
     $amount = new Amount();
     $amount->setCurrency(Mage::app()->getStore()->getCurrentCurrencyCode())->setDetails($details)->setTotal($quote->getGrandTotal());
     return $amount;
 }
 /**
  * Check if the quote has zero grandtotal.
  * @param  Mage_Sales_Model_Quote $quote
  * @return bool
  */
 protected function _hasZeroGrandTotal(Mage_Sales_Model_Quote $quote)
 {
     return !$quote->validateMinimumAmount() || !$quote->getGrandTotal() && !$quote->hasNominalItems();
 }
Exemplo n.º 16
0
 /**
  * @param Mage_Sales_Model_Quote $quote
  *
  * @return Bronto_Common_Model_Email_Template_Filter
  */
 protected function _filterQuote(Mage_Sales_Model_Quote $quote)
 {
     if (!in_array('quote', $this->_filteredObjects)) {
         $this->setStoreId($quote->getStoreId());
         $currencyCode = $quote->getQuoteCurrencyCode();
         if (Mage::helper('bronto_common')->displayPriceIncTax($quote->getStoreId())) {
             $totals = $quote->getTotals();
             $this->setField('subtotal', $this->formatPrice($totals['subtotal']->getValue(), $currencyCode));
             $this->setField('grandTotal', $this->formatPrice($totals['grand_total']->getValue(), $currencyCode));
         } else {
             $this->setField('subtotal', $this->formatPrice($quote->getSubtotal(), $currencyCode));
             $this->setField('grandTotal', $this->formatPrice($quote->getGrandTotal(), $currencyCode));
         }
         $index = 1;
         foreach ($quote->getAllItems() as $item) {
             if (!$item->getParentItem()) {
                 $this->_filterQuoteItem($item, $index);
                 $index++;
             }
         }
         // Add Related Content
         $this->_items = $quote->getAllItems();
         $queryParams = $this->getQueryParams();
         $queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
         if ($store = $this->getStore()) {
             $this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
         } else {
             $this->setField('quoteURL', Mage::getUrl('reminder/load/index', $queryParams));
         }
         // Setup quote items as a template
         if (class_exists('Bronto_Reminder_Block_Cart_Items', false)) {
             $layout = Mage::getSingleton('core/layout');
             /* @var $items Mage_Sales_Block_Items_Abstract */
             $items = $layout->createBlock('bronto/bronto_reminder_cart_items', 'items');
             $items->setTemplate('bronto/reminder/items.phtml');
             $items->setQuote($item->getQuote());
             $this->_respectDesignTheme();
             $this->setField("cartItems", $items->toHtml());
         }
         $this->_filteredObjects[] = 'quote';
     }
     return $this;
 }
Exemplo n.º 17
0
 /**
  * Check max amount on cart
  *
  * @param Mage_Sales_Model_Quote $quote
  */
 public function checkCartMaxAmount($quote)
 {
     $quoteStore = $quote->getStore();
     if ($this->isCartEnable($quoteStore)) {
         $maxAmount = $this->getCartMaxAmount($quoteStore);
         $grandTotal = $quote->getGrandTotal();
         if ($grandTotal > $maxAmount) {
             $formater = new Varien_Filter_Template();
             $formater->setVariables(array('amount' => Mage::helper('core')->currency($maxAmount, true, false)));
             $format = $this->getCartMessage($quoteStore);
             //	hold checkout
             $quote->setHasError(true)->addMessage($formater->filter($format));
         }
     }
 }