/** * Check the line items and totals according to PayPal business logic limitations */ protected function _validate() { $this->_areItemsValid = false; $this->_areTotalsValid = false; $referenceAmount = $this->_salesEntity->getGrandTotal(); $itemsSubtotal = 0; foreach ($this->_items as $i) { $itemsSubtotal = $itemsSubtotal + $i['qty'] * $i['amount']; } $sum = $itemsSubtotal + $this->_totals[self::TOTAL_TAX]; if (!$this->_isShippingAsItem) { $sum += $this->_totals[self::TOTAL_SHIPPING]; } if (!$this->_isDiscountAsItem) { $sum -= $this->_totals[self::TOTAL_DISCOUNT]; } /** * numbers are intentionally converted to strings because of possible comparison error * see http://php.net/float */ // match sum of all the items and totals to the reference amount if (sprintf('%.4F', $sum) == sprintf('%.4F', $referenceAmount)) { $this->_areItemsValid = true; } // PayPal requires to have discount less than items subtotal if (!$this->_isDiscountAsItem) { $this->_areTotalsValid = round($this->_totals[self::TOTAL_DISCOUNT], 4) < round($itemsSubtotal, 4); } else { $this->_areTotalsValid = $itemsSubtotal > 1.0E-5; } $this->_areItemsValid = $this->_areItemsValid && $this->_areTotalsValid; }
/** * * Update shipping info after notifyRequest * @param array $data */ protected function updateShippingInfo($data) { try { $typeChosen = $data['Shipping']['ShippingType']; $cost = $data['Shipping']['ShippingCost']['Gross']; if (!empty($typeChosen)) { $quote = Mage::getModel('sales/quote')->load($this->_order->getQuoteId()); $address = $quote->getShippingAddress(); $shipping = Mage::getModel('shipping/shipping'); $shippingRates = $shipping->collectRatesByAddress($address)->getResult(); $shippingCostList = array(); foreach ($shippingRates->getAllRates() as $rate) { $type = $rate->getCarrierTitle() . ' - ' . $rate->getMethodTitle(); if ($type == $typeChosen) { $this->_order->setShippingDescription($typeChosen); $this->_order->setShippingMethod($rate->getCarrier() . "_" . $rate->getMethod()); $current = $this->_order->getShippingAmount(); $this->_order->setShippingAmount($cost / 100); $this->_order->setGrandTotal($this->_order->getGrandTotal() + $this->_order->getShippingAmount() - $current); $this->_order->save(); } } } } catch (Exception $e) { Mage::logException("shipping info error: " . $e); } }
/** * Processes payment for specified order * @param Mage_Sales_Model_Order $Order * @return */ public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null) { $amount = $Order->getGrandTotal(); $increment = $Order->getIncrementId(); $VendorTxCode = $increment . "-" . date("y-m-d-H-i-s", time()) . "-" . rand(0, 1000000); $model = Mage::getModel('sarp/protxDirect')->load($this->getSubscription()->getId(), 'subscription_id'); $data = array('VPSProtocol' => self::PROTOCOL_VERSION, 'TxType' => self::REPEAT, 'Vendor' => Mage::getStoreConfig(self::VENDOR), 'VendorTxCode' => $VendorTxCode, 'Amount' => $amount, 'Currency' => $Order->getOrderCurrencyCode(), 'Description' => 'Order', 'RelatedVPSTxId' => $model->getVpsTxId(), 'RelatedVendorTxCode' => $model->getVendorTxCode(), 'RelatedSecurityKey' => $model->getSecurityKey(), 'RelatedTxAuthNo' => $model->getTxAuthNo()); $ready = array(); foreach ($data as $key => $value) { $ready[] = $key . '=' . $value; } $str = implode('&', $ready); switch (Mage::getStoreConfig(self::MODE)) { case 'test': $url = self::TEST_REPEAT_URL; break; case 'live': $url = self::LIVE_REPEAT_URL; break; default: $url = self::SIMULATOR_REPEAT_URL; } $ready = $this->requestPost($url, $str); if (empty($ready)) { throw new AW_Sarp_Exception($this->__("Order cannot be completed. Unknown error")); } if ($ready['Status'] != 'OK') { throw new AW_Sarp_Exception($ready['Status'] . " - " . $ready['StatusDetail']); } }
/** * Retrieve order item value by key * * @param Mage_Sales_Model_Order $order * @param string $key * @return string */ public function getOrderItemValue(Mage_Sales_Model_Order $order, $key) { $escape = true; switch ($key) { case 'order_increment_id': $value = $order->getIncrementId(); break; case 'created_at': $value = $this->helper('core')->formatDate($order->getCreatedAt(), 'short', true); break; case 'shipping_address': $value = $order->getShippingAddress() ? $this->htmlEscape($order->getShippingAddress()->getName()) : $this->__('N/A'); break; case 'order_total': $value = $order->formatPrice($order->getGrandTotal()); $escape = false; break; case 'status_label': $value = $order->getStatusLabel(); break; case 'view_url': $value = $this->getUrl('*/order/view', array('order_id' => $order->getId())); break; default: $value = $order->getData($key) ? $order->getData($key) : $this->__('N/A'); } return $escape ? $this->escapeHtml($value) : $value; }
/** * Checking returned parameters * Thorws Mage_Core_Exception if error * @param bool $fullCheck Whether to make additional validations such as payment status, transaction signature etc. * * @return array $params request params */ protected function _validateEventData($fullCheck = true) { // get request variables $params = $this->_eventData; if (empty($params)) { Mage::throwException('Request does not contain any elements.'); } // check order ID if (empty($params['transaction_id']) || $fullCheck == false && $this->_getCheckout()->getMoneybookersRealOrderId() != $params['transaction_id']) { Mage::throwException('Missing or invalid order ID.'); } // load order for further validation $this->_order = Mage::getModel('sales/order')->loadByIncrementId($params['transaction_id']); if (!$this->_order->getId()) { Mage::throwException('Order not found.'); } if (0 !== strpos($this->_order->getPayment()->getMethodInstance()->getCode(), 'moneybookers_')) { Mage::throwException('Unknown payment method.'); } // make additional validation if ($fullCheck) { // check payment status if (empty($params['status'])) { Mage::throwException('Unknown payment status.'); } // check transaction signature if (empty($params['md5sig'])) { Mage::throwException('Invalid transaction signature.'); } $checkParams = array('merchant_id', 'transaction_id', 'secret', 'mb_amount', 'mb_currency', 'status'); $md5String = ''; foreach ($checkParams as $key) { if ($key == 'merchant_id') { $md5String .= Mage::getStoreConfig(Phoenix_Moneybookers_Helper_Data::XML_PATH_CUSTOMER_ID, $this->_order->getStoreId()); } elseif ($key == 'secret') { $secretKey = Mage::getStoreConfig(Phoenix_Moneybookers_Helper_Data::XML_PATH_SECRET_KEY, $this->_order->getStoreId()); if (empty($secretKey)) { Mage::throwException('Secret key is empty.'); } $md5String .= strtoupper(md5($secretKey)); } elseif (isset($params[$key])) { $md5String .= $params[$key]; } } $md5String = strtoupper(md5($md5String)); if ($md5String != $params['md5sig']) { Mage::throwException('Hash is not valid.'); } // check transaction amount if currency matches if ($this->_order->getOrderCurrencyCode() == $params['mb_currency']) { if (round($this->_order->getGrandTotal(), 2) != $params['mb_amount']) { Mage::throwException('Transaction amount does not match.'); } } } return $params; }
/** * @return array */ protected function _prepareOrderData() { // magento 1.5 compat $shipping_method_c = $this->_order->getShippingMethod(true); $shipping_method = $this->_order->getData('shipping_method'); $shipping_method_code = $shipping_method_c ? $shipping_method_c->getData('carrier_code') : $shipping_method; $data = array_filter(array('currency_code' => $this->_order->getOrderCurrencyCode(), 'shipping_method_code' => $shipping_method_code, 'shipping_method_title' => $this->_order->getShippingDescription(), 'created_on' => $this->_order->getCreatedAt(), 'updated_on' => $this->_order->getUpdatedAt(), 'state' => $this->_order->getState(), 'status' => $this->_order->getStatus(), 'is_gift' => $this->_order->getGiftMessageId() != null, 'ref_quote_id' => $this->_order->getQuoteId(), 'order_subtotal_with_tax' => $this->_order->getSubtotalInclTax(), 'order_subtotal' => $this->_order->getSubtotal(), 'order_tax' => $this->_order->getTaxAmount(), 'order_hidden_tax' => $this->_order->getHiddenTaxAmount(), 'order_shipping_with_tax' => $this->_order->getShippingInclTax(), 'order_shipping' => $this->_order->getShippingAmount(), 'order_discount' => $this->_order->getDiscountAmount(), 'order_shipping_discount' => $this->_order->getShippingDiscountAmount(), 'order_total' => $this->_order->getGrandTotal(), 'order_total_items' => $this->_order->getTotalItemCount())); return $data; }
/** * Return an array with installment information to be used with API * @param Mage_Sales_Model_Order $order * @param $payment Mage_Sales_Model_Order_Payment * @return array */ public function getCreditCardInstallmentsParams(Mage_Sales_Model_Order $order, $payment) { $return = array(); if ($payment->getAdditionalInformation('installment_quantity') && $payment->getAdditionalInformation('installment_value')) { $return = array('installmentQuantity' => $payment->getAdditionalInformation('installment_quantity'), 'installmentValue' => number_format($payment->getAdditionalInformation('installment_value'), 2, '.', '')); } else { $return = array('installmentQuantity' => '1', 'installmentValue' => number_format($order->getGrandTotal(), 2, '.', '')); } return $return; }
public function collect(Mage_Sales_Model_Order $order) { $order->setData('zitec_dpd_cashondelivery_surcharge', 0); $order->setData('base_zitec_dpd_cashondelivery_surcharge', 0); $amount = $order->getOrder()->getData('zitec_dpd_cashondelivery_surcharge'); $order->setData('zitec_dpd_cashondelivery_surcharge', $amount); $amount = $order->getOrder()->getData('base_zitec_dpd_cashondelivery_surcharge'); $order->setData('base_zitec_dpd_cashondelivery_surcharge', $amount); $order->setGrandTotal($order->getGrandTotal() + $order->getData('zitec_dpd_cashondelivery_surcharge')); $order->setBaseGrandTotal($order->getBaseGrandTotal() + $order->getData('base_zitec_dpd_cashondelivery_surcharge')); return $this; }
public function getScript() { $request = Mage::app()->getRequest(); $module = $request->getModuleName(); $controller = $request->getControllerName(); $action = $request->getActionName(); $flag = false; $currency = Mage::app()->getStore()->getCurrentCurrencyCode(); $script = "<script>var apiKey = '" . $this->getKey() . "';</script>" . "\n"; if ($module == 'checkout' && $controller == 'onestep' && $action == 'success' || $module == 'checkout' && $controller == 'onepage' && $action == 'success' || $module == 'securecheckout' && $controller == 'index' && $action == 'success' || $module == 'customdownloadable' && $controller == 'onepage' && $action == 'success' || $module == 'onepagecheckout' && $controller == 'index' && $action == 'success' || $module == 'onestepcheckout' && $controller == 'index' && $action == 'success') { $order = new Mage_Sales_Model_Order(); $orderId = Mage::getSingleton('checkout/session')->getLastRealOrderId(); $order->loadByIncrementId($orderId); // Load order details $order_total = round($order->getGrandTotal(), 2); // Get grand total $order_coupon = $order->getCouponCode(); // Get coupon used $items = $order->getAllItems(); // Get items info $cartInfo = array(); // Convert object to string foreach ($items as $item) { $product = Mage::getModel('catalog/product')->load($item->getProductId()); $name = $item->getName(); $qty = $item->getQtyToInvoice(); $cartInfo[] = array('id' => $item->getProductId(), 'name' => $name, 'quantity' => $qty); } $cartInfoString = serialize($cartInfo); $cartInfoString = addcslashes($cartInfoString, "'"); $order_name = $order->getCustomerName(); // Get customer's name $order_email = $order->getCustomerEmail(); // Get customer's email id // Call invoiceRefiral function $scriptAppend = "<script>whenAvailable('invoiceRefiral',function(){invoiceRefiral('{$order_total}','{$order_total}','{$order_coupon}','{$cartInfoString}','{$order_name}','{$order_email}','{$orderId}', '{$currency}')});</script>" . "\n"; if ($this->debug()) { $scriptAppend .= "<script>console.log('Module: " . $module . ", Controller: " . $controller . ", Action: " . $action . "');</script>"; $scriptAppend .= "<script>console.log('Total: " . $order_total . ", Coupon: " . $order_coupon . ", Cart: " . $cartInfoString . ", Name: " . $order_name . ", Email: " . $order_email . ", Id: " . $orderId . ", Currency: " . $currency . "');</script>"; } $script .= '<script>var showButton = false;</script>' . "\n"; } else { if ($this->debug()) { $scriptAppend = "<script>console.log('Module: " . $module . ", Controller: " . $controller . ", Action: " . $action . "');</script>"; } else { $scriptAppend = ''; } $script .= '<script>var showButton = true;</script>' . "\n"; } $script .= '<script type="text/javascript">(function e(){var e=document.createElement("script");e.type="text/javascript",e.async=true,e.src="//rfer.co/api/v1/js/all.js";var t=document.getElementsByTagName("script")[0];t.parentNode.insertBefore(e,t)})();</script>' . "\n"; return $script . $scriptAppend; }
/** * Processes payment for specified order * @param Mage_Sales_Model_Order $Order * @return */ public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null) { $pnref = $this->getSubscription()->getRealId(); $amt = $Order->getGrandTotal(); $this->getWebService()->setStoreId($this->getSubscription()->getStoreId())->getRequest()->reset()->setData(array('ORIGID' => $pnref, 'AMT' => floatval($amt))); if (strtolower(Mage::getStoreConfig(self::XML_PATH_PPUK_PAYMENT_ACTION) == 'sale')) { $result = $this->getWebService()->referenceCaptureAction(); } else { $result = $this->getWebService()->referenceAuthAction(); } if ($result->getResult() . '' == '0') { // Payment Succeded } else { throw new Mage_Core_Exception(Mage::helper('sarp')->__("PayFlow " . Mage::getStoreConfig(self::XML_PATH_PPUK_PAYMENT_ACTION) . " failed:[%s] %s", $result->getResult(), $result->getRespmsg())); } }
/** * Make prepaid credit card payloads for any payments * remaining in the list * @param Mage_Sales_Model_Order $order * @param IPaymentContainer $paymentContainer * @param SplObjectStorage $processedPayments */ public function addPaymentsToPayload(Mage_Sales_Model_Order $order, IPaymentContainer $paymentContainer, SplObjectStorage $processedPayments) { foreach ($order->getAllPayments() as $payment) { if ($this->_shouldIgnorePayment($payment, $processedPayments)) { continue; } $iterable = $paymentContainer->getPayments(); $payload = $iterable->getEmptyPayPalPayment(); $additionalInfo = new Varien_Object($payment->getAdditionalInformation()); // use the grand total since it has already been adjusted for redeemed giftcards // by the the giftcard module's total collector. $amount = $order->getGrandTotal(); $payload->setAmount($amount)->setAmountAuthorized($amount)->setCreateTimestamp($this->_getAsDateTime($payment->getCreatedAt()))->setAuthorizationResponseCode(self::AUTH_RESPONSE_CODE)->setOrderId($order->getIncrementId())->setTenderType(self::TENDER_TYPE)->setPanIsToken(true)->setAccountUniqueId(self::ACCOUNT_UNIQUE_ID)->setPaymentRequestId($additionalInfo->getAuthRequestId()); // add the new payload $iterable->OffsetSet($payload, $payload); // put the payment in the processed payments set $processedPayments->attach($payment); } }
/** * Get the amount of the order in cents, make sure that we return the right value even if the locale is set to * something different than the default (e.g. nl_NL). * * @param Mage_Sales_Model_Order $order * @return int */ protected function getAmount(Mage_Sales_Model_Order $order) { if ($order->getBaseCurrencyCode() === 'EUR') { $grand_total = $order->getBaseGrandTotal(); } elseif ($order->getOrderCurrencyCode() === 'EUR') { $grand_total = $order->getGrandTotal(); } else { Mage::log(__METHOD__ . ' said: Neither Base nor Order currency is in Euros.'); Mage::throwException(__METHOD__ . ' said: Neither Base nor Order currency is in Euros.'); } if (is_string($grand_total)) { $locale_info = localeconv(); if ($locale_info['decimal_point'] !== '.') { $grand_total = strtr($grand_total, array($locale_info['thousands_sep'] => '', $locale_info['decimal_point'] => '.')); } $grand_total = floatval($grand_total); // Why U NO work with locales? } return floatval(round($grand_total, 2)); }
/** * Processes an order for which an incorrect amount has been paid (can only happen with Transfer) * * @param $newStates * @return bool */ protected function _processIncorrectPayment($newStates) { //determine whether too much or not enough has been paid and determine the status history copmment accordingly $amount = round($this->_order->getBaseGrandTotal() * 100, 0); $setStatus = $newStates[1]; if ($this->_postArray['brq_currency'] == $this->_order->getBaseCurrencyCode()) { $currencyCode = $this->_order->getBaseCurrencyCode(); $orderAmount = $this->_order->getBaseGrandTotal(); } else { $currencyCode = $this->_order->getOrderCurrencyCode(); $orderAmount = $this->_order->getGrandTotal(); } if ($amount > $this->_postArray['brq_amount']) { $description = Mage::helper('buckaroo3extended')->__('Not enough paid: %s has been transfered. Order grand total was: %s.', Mage::app()->getLocale()->currency($currencyCode)->toCurrency($this->_postArray['brq_amount']), Mage::app()->getLocale()->currency($currencyCode)->toCurrency($orderAmount)); } elseif ($amount < $this->_postArray['brq_amount']) { $description = Mage::helper('buckaroo3extended')->__('Too much paid: %s has been transfered. Order grand total was: %s.', Mage::app()->getLocale()->currency($currencyCode)->toCurrency($this->_postArray['brq_amount']), Mage::app()->getLocale()->currency($currencyCode)->toCurrency($orderAmount)); } else { //the correct amount was actually paid, so return false return false; } //hold the order $this->_order->hold()->save()->setStatus($setStatus)->save()->addStatusHistoryComment(Mage::helper('buckaroo3extended')->__($description), $setStatus)->save(); return true; }
/** * Add interest to order */ protected function addInterestToOrder(Mage_Sales_Model_Order $order, $interest) { $mundipaggInterest = $order->getMundipaggInterest(); $setInterest = (double) ($mundipaggInterest + $interest); $order->setMundipaggInterest($setInterest ? $setInterest : 0); $order->setMundipaggBaseInterest($setInterest ? $setInterest : 0); $order->setGrandTotal($order->getGrandTotal() + $interest); $order->setBaseGrandTotal($order->getBaseGrandTotal() + $interest); $order->save(); // $info = $this->getInfoInstance(); // $info->setPaymentInterest(($info->getPaymentInterest()+$setInterest)); // $info->save(); }
function CreateMagentoShopRequestOrder(Mage_Sales_Model_Order $order, $paymentmethod) { $request = new Byjuno_Cdp_Helper_Api_Classes_ByjunoRequest(); $request->setClientId(Mage::getStoreConfig('payment/cdp/clientid', Mage::app()->getStore())); $request->setUserID(Mage::getStoreConfig('payment/cdp/userid', Mage::app()->getStore())); $request->setPassword(Mage::getStoreConfig('payment/cdp/password', Mage::app()->getStore())); $request->setVersion("1.00"); try { $request->setRequestEmail(Mage::getStoreConfig('payment/cdp/mail', Mage::app()->getStore())); } catch (Exception $e) { } $b = $order->getCustomerDob(); if (!empty($b)) { $request->setDateOfBirth(Mage::getModel('core/date')->date('Y-m-d', strtotime($b))); } $g = $order->getCustomerGender(); if (!empty($g)) { if ($g == '1') { $request->setGender('1'); } else { if ($g == '2') { $request->setGender('2'); } } } $requestId = uniqid((string) $order->getBillingAddress()->getId() . "_"); $request->setRequestId($requestId); $reference = $order->getCustomerId(); if (empty($reference)) { $request->setCustomerReference("guest_" . $order->getBillingAddress()->getId()); } else { $request->setCustomerReference($order->getCustomerId()); } $request->setFirstName((string) $order->getBillingAddress()->getFirstname()); $request->setLastName((string) $order->getBillingAddress()->getLastname()); $request->setFirstLine(trim((string) $order->getBillingAddress()->getStreetFull())); $request->setCountryCode(strtoupper((string) $order->getBillingAddress()->getCountry())); $request->setPostCode((string) $order->getBillingAddress()->getPostcode()); $request->setTown((string) $order->getBillingAddress()->getCity()); $request->setFax((string) trim($order->getBillingAddress()->getFax(), '-')); $request->setLanguage((string) substr(Mage::app()->getLocale()->getLocaleCode(), 0, 2)); if ($order->getBillingAddress()->getCompany()) { $request->setCompanyName1($order->getBillingAddress()->getCompany()); } $request->setTelephonePrivate((string) trim($order->getBillingAddress()->getTelephone(), '-')); $request->setEmail((string) $order->getBillingAddress()->getEmail()); $extraInfo["Name"] = 'ORDERCLOSED'; $extraInfo["Value"] = 'NO'; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'ORDERAMOUNT'; $extraInfo["Value"] = number_format($order->getGrandTotal(), 2, '.', ''); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'ORDERCURRENCY'; $extraInfo["Value"] = $order->getBaseCurrencyCode(); $request->setExtraInfo($extraInfo); /* shipping information */ if ($order->canShip()) { $extraInfo["Name"] = 'DELIVERY_FIRSTNAME'; $extraInfo["Value"] = $order->getShippingAddress()->getFirstname(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_LASTNAME'; $extraInfo["Value"] = $order->getShippingAddress()->getLastname(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_FIRSTLINE'; $extraInfo["Value"] = trim($order->getShippingAddress()->getStreetFull()); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_HOUSENUMBER'; $extraInfo["Value"] = ''; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_COUNTRYCODE'; $extraInfo["Value"] = strtoupper($order->getShippingAddress()->getCountry()); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_POSTCODE'; $extraInfo["Value"] = $order->getShippingAddress()->getPostcode(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'DELIVERY_TOWN'; $extraInfo["Value"] = $order->getShippingAddress()->getCity(); $request->setExtraInfo($extraInfo); if ($order->getShippingAddress()->getCompany() != '' && Mage::getStoreConfig('payment/api/businesstobusiness', Mage::app()->getStore()) == 'enable') { $extraInfo["Name"] = 'DELIVERY_COMPANYNAME'; $extraInfo["Value"] = $order->getShippingAddress()->getCompany(); $request->setExtraInfo($extraInfo); } } $extraInfo["Name"] = 'PP_TRANSACTION_NUMBER'; $extraInfo["Value"] = $requestId; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'ORDERID'; $extraInfo["Value"] = $order->getIncrementId(); $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'PAYMENTMETHOD'; $extraInfo["Value"] = 'BYJUNO-INVOICE'; $request->setExtraInfo($extraInfo); $extraInfo["Name"] = 'CONNECTIVTY_MODULE'; $extraInfo["Value"] = 'Byjuno Magento module 1.0.0'; $request->setExtraInfo($extraInfo); return $request; }
/** * Get Order Amount * With Using Rounding Issue Fix * @param Mage_Sales_Model_Order $order * @return float */ public function getOrderAmount($order) { // At moment this function don't support discounts if (abs($order->getDiscountAmount()) > 0) { return $order->getGrandTotal(); } $amount = 0; // add Order Items $items = $order->getAllVisibleItems(); /** @var $item Mage_Sales_Model_Order_Item */ foreach ($items as $item) { if ($item->getParentItem()) { continue; } $itemQty = (int) $item->getQtyOrdered(); $priceWithTax = $item->getPriceInclTax(); $amount += round(100 * Mage::app()->getStore()->roundPrice($itemQty * $priceWithTax)); } // add Discount $discount = $order->getDiscountAmount(); $discount += $order->getShippingDiscountAmount(); $amount += round(100 * $discount); // Add reward points $amount += -1 * $order->getBaseRewardCurrencyAmount(); // add Shipping if (!$order->getIsVirtual()) { $shippingIncTax = $order->getShippingInclTax(); $amount += round(100 * $shippingIncTax); } $grand_total = $order->getGrandTotal(); $amount = $amount / 100; $abs = abs(Mage::app()->getStore()->roundPrice($amount) - Mage::app()->getStore()->roundPrice($grand_total)); // Is ~0.010000000002037 if ($abs > 0 && $abs < 0.011) { Mage::helper('payexinvoice/tools')->addToDebug('Warning: Price rounding issue. ' . $grand_total . ' vs ' . $amount); return $amount; } else { return $grand_total; } }
/** * Processes payment for specified order * @param Mage_Sales_Model_Order $Order * @return */ public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null) { $amt = $Order->getGrandTotal(); $inv = $Order->getIncrementId(); $this->getWebService()->getRequest()->reset()->setData(array('CcInfoKey' => $this->getSubscription()->getRealPaymentId(), 'Amount' => $amt, 'InvNum' => $inv, 'ExtData' => '')); $result = $this->getWebService()->processCreditCard(); }
/** * Returns the total sum of the current order. * * @return float */ public function getTotalSum() { return $this->_order->getGrandTotal(); }
/** * @param Mage_Payment_Model_Method_Abstract $payment * @param Mage_Sales_Model_Order $order * @param int $customerId * * @return bool * @throws \Mage_Core_Exception */ protected function processSinglePayment($payment, $order, $customerId) { $uniquePaymentProduct = $this->api()->findOrCreateUniquePaymentProduct(); $this->log(sprintf('Produto para pagamento único: %d.', $uniquePaymentProduct)); $body = ['customer_id' => $customerId, 'payment_method_code' => $this->getPaymentMethodCode(), 'bill_items' => [['product_id' => $uniquePaymentProduct, 'amount' => $order->getGrandTotal()]]]; if ($installments = $payment->getAdditionalInformation('installments')) { $body['installments'] = (int) $installments; } $billId = $this->api()->createBill($body); if (!$billId) { $this->log(sprintf('Erro no pagamento do pedido %d.', $order->getId())); $message = sprintf('Pagamento Falhou. (%s)', $this->api()->lastError); $payment->setStatus(Mage_Sales_Model_Order::STATE_CANCELED, Mage_Sales_Model_Order::STATE_CANCELED, $message, true); Mage::throwException($message); return false; } $order->setVindiBillId($billId); $order->save(); return $billId; }
public function init(Mage_Sales_Model_Order $order) { $this->setLiczOd("BRT"); $this->setDataWystawienia(date('Y-m-d')); $this->setDataSprzedazy(date('Y-m-d')); $this->setFormatDatySprzedazy("DZN"); $this->setRodzajPodpisuOdbiorcy("BPO"); $this->setWidocznyNumerGios(true); $this->setZaplacono($order->getGrandTotal()); $this->setSpozobZaplaty("PRZ"); $this->setTerminPlatnosci(''); $items = $order->getAllVisibleItems(); $positions = array(); foreach ($items as $item) { /* @var $item Mage_Sales_Model_Order_Item */ $invoice_position = new PowerMedia_Ifirma_Model_InvoicePosition(); $tax = sprintf('%.2f', $item->getTaxPercent() / 100); $invoice_position->setStawkaVat((string) $tax); $invoice_position->setIlosc($item->getQtyOrdered()); $invoice_position->setNazwaPelna($item->getName()); $invoice_position->setJednostka("sztuk"); $invoice_position->setTypStawkiVat("PRC"); $invoice_position->setCenaJednostkowa($item->getPriceInclTax()); $invoice_position->setPKWiU(""); $positions[] = $invoice_position->getProperties(); } $shipping = $order->getShippingInclTax(); if ($shipping >= 0) { /* @var $item Mage_Sales_Model_Order_Item */ $invoice_position = new PowerMedia_Ifirma_Model_InvoicePosition(); $tax = sprintf('%.2f', $item->getTaxPercent() / 100); $invoice_position->setStawkaVat((string) $tax); $invoice_position->setIlosc(1); $invoice_position->setNazwaPelna('Koszty dostawy'); $invoice_position->setJednostka("sztuk"); $invoice_position->setTypStawkiVat("PRC"); $invoice_position->setCenaJednostkowa($shipping); $invoice_position->setPKWiU(""); $positions[] = $invoice_position->getProperties(); } $this->setPozycje($positions); $invoice_contractor = new PowerMedia_Ifirma_Model_InvoiceContractor(); $invoice_contractor->setNazwa($order->getBillingAddress()->getName()); $invoice_contractor->setUlica($order->getBillingAddress()->getStreetFull()); $invoice_contractor->setKodPocztowy($order->getBillingAddress()->getPostcode()); $invoice_contractor->setMiejscowosc($order->getBillingAddress()->getCity()); $invoice_contractor->setKraj($order->getBillingAddress()->getCountry()); $this->setKontrahent($invoice_contractor->getProperties()); }
public function prepareValues(Mage_Sales_Model_Order $order) { $billing_address = $order->getBillingAddress(); $additional_data = unserialize($order->getPayment()->getAdditionalData()); $code_banco = $additional_data['code_banco']; $data_vencimento = $additional_data['data_vencimento']; $numero_boleto = str_replace('-', '', $order->getIncrementId()); $strtotime = strtotime($order->getCreatedAt()); $data = array('logoempresa' => $this->getConfig('logoempresa'), 'nosso_numero' => $numero_boleto, 'numero_documento' => $numero_boleto, 'data_vencimento' => $data_vencimento, 'data_documento' => date('d/m/Y', $strtotime), 'data_processamento' => date('d/m/Y', $strtotime), 'valor_boleto' => number_format($order->getGrandTotal() + $this->getLayoutConfig($code_banco, 'valor_adicional'), 2, ',', ''), 'valor_unitario' => number_format($order->getGrandTotal() + $this->getLayoutConfig($code_banco, 'valor_adicional'), 2, ',', ''), 'sacado' => $billing_address->getFirstname() . ' ' . $billing_address->getLastname(), 'sacadocpf' => $order->getCustomerTaxvat(), 'endereco1' => implode(' ', $billing_address->getStreet()), 'endereco2' => $billing_address->getCity() . ' - ' . $billing_address->getRegion() . ' - CEP: ' . $billing_address->getPostcode(), 'identificacao' => $this->getLayoutConfig($code_banco, 'identificacao'), 'cpf_cnpj' => $this->getLayoutConfig($code_banco, 'cpf_cnpj'), 'endereco' => $this->getLayoutConfig($code_banco, 'endereco'), 'cidade_uf' => $this->getLayoutConfig($code_banco, 'cidade_uf'), 'cedente' => $this->getLayoutConfig($code_banco, 'cedente'), 'agencia' => $this->getLayoutConfig($code_banco, 'agencia'), 'agencia_dv' => $this->getLayoutConfig($code_banco, 'agencia_dv'), 'conta' => $this->getLayoutConfig($code_banco, 'conta'), 'conta_dv' => $this->getLayoutConfig($code_banco, 'conta_dv'), 'carteira' => $this->getLayoutConfig($code_banco, 'carteira'), 'especie' => $this->getLayoutConfig($code_banco, 'especie'), 'especie_doc' => $this->getLayoutConfig($code_banco, 'especie_doc'), 'aceite' => $this->getLayoutConfig($code_banco, 'aceite'), 'quantidade' => $this->getLayoutConfig($code_banco, 'quantidade')); if ($code_banco == 'santander_banespa') { $data['ponto_venda'] = $this->getLayoutConfig($code_banco, 'ponto_venda'); $data['carteira_descricao'] = $this->getLayoutConfig($code_banco, 'carteira_descricao'); $data['codigo_cliente'] = $this->getLayoutConfig($code_banco, 'codigo_cliente'); } if ($code_banco == 'bradesco') { $data['conta_cedente'] = $this->getLayoutConfig($code_banco, 'conta_cedente'); $data['conta_cedente_dv'] = $this->getLayoutConfig($code_banco, 'conta_cedente_dv'); } if ($code_banco == 'cef' || $code_banco == 'cef_sinco' || $code_banco == 'cef_sigcb') { $data['conta_cedente_caixa'] = $this->getLayoutConfig($code_banco, 'conta_cedente_caixa'); $data['conta_cedente_dv_caixa'] = $this->getLayoutConfig($code_banco, 'conta_cedente_dv_caixa'); $data['inicio_nosso_numero'] = $this->getLayoutConfig($code_banco, 'inicio_nosso_numero'); } if ($code_banco == 'bb') { $data['convenio'] = $this->getLayoutConfig($code_banco, 'convenio'); $data['contrato'] = $this->getLayoutConfig($code_banco, 'contrato'); $data['variacao_carteira'] = $this->getLayoutConfig($code_banco, 'variacao_carteira'); $data['formatacao_convenio'] = $this->getLayoutConfig($code_banco, 'formatacao_convenio'); $data['formatacao_nosso_numero'] = $this->getLayoutConfig($code_banco, 'formatacao_nosso_numero'); } if ($code_banco == 'hsbc') { $data['codigo_cedente'] = $this->getLayoutConfig($code_banco, 'codigo_cedente'); } if ($code_banco == 'cef_sinco') { $data['campo_fixo_obrigatorio'] = $this->getLayoutConfig($code_banco, 'campo_fixo_obrigatorio'); } if ($code_banco == 'cef_sigcb') { $data['nosso_numero1'] = $this->getLayoutConfig($code_banco, 'nosso_numero1'); $data['nosso_numero_const1'] = $this->getLayoutConfig($code_banco, 'nosso_numero_const1'); $data['nosso_numero2'] = $this->getLayoutConfig($code_banco, 'nosso_numero2'); $data['nosso_numero_const2'] = $this->getLayoutConfig($code_banco, 'nosso_numero_const2'); $data['nosso_numero3'] = $numero_boleto; } if ($code_banco == 'sicoob') { $data['convenio'] = $this->getLayoutConfig($code_banco, 'codigo_cedente'); $data["numero_parcela"] = '001'; } $instrucoes = explode("\n", $this->getLayoutConfig($code_banco, 'instrucoes_boleto')); for ($i = 0; $i < 4; $i++) { $instrucao = isset($instrucoes[$i]) ? $instrucoes[$i] : ''; $data['instrucoes' . ($i + 1)] = $instrucao; } $info = sprintf($this->getLayoutConfig($code_banco, 'informacoes'), $order->getIncrementId()); $informacoes = explode("\n", $info); for ($i = 0; $i < 3; $i++) { $informacao = isset($informacoes[$i]) ? $informacoes[$i] : ''; $data['demonstrativo' . ($i + 1)] = $informacao; } return $data; }
/** * @param Mage_Sales_Model_Order $order * * @return array */ public static function createFromOrder(Mage_Sales_Model_Order $order) { $serialized = array('id' => $order->getIncrementId(), 'amount' => Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getGrandTotal()), 'due' => Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getTotalDue()), 'status' => $order->getStatus(), 'type' => $order->getPayment()->getMethodInstance()->getCode(), 'order_date' => date(DATE_ISO8601, strtotime($order->getCreatedAt())), 'currency' => $order->getOrderCurrencyCode(), 'billing' => Aplazame_Aplazame_BusinessModel_Address::createFromAddress($order->getBillingAddress()), 'shipping' => Aplazame_Aplazame_BusinessModel_ShippingInfo::createFromOrder($order)); return $serialized; }
/** * Convert order to shipping address * * @param Mage_Sales_Model_Order $order * @return Mage_Sales_Model_Quote_Address */ public function toQuoteShippingAddress(Mage_Sales_Model_Order $order) { $address = $this->addressToQuoteAddress($order->getShippingAddress()); $address->setWeight($order->getWeight())->setShippingMethod($order->getShippingMethod())->setShippingDescription($order->getShippingDescription())->setShippingRate($order->getShippingRate())->setSubtotal($order->getSubtotal())->setTaxAmount($order->getTaxAmount())->setDiscountAmount($order->getDiscountAmount())->setShippingAmount($order->getShippingAmount())->setGiftcertAmount($order->getGiftcertAmount())->setCustbalanceAmount($order->getCustbalanceAmount())->setGrandTotal($order->getGrandTotal())->setBaseSubtotal($order->getBaseSubtotal())->setBaseTaxAmount($order->getBaseTaxAmount())->setBaseDiscountAmount($order->getBaseDiscountAmount())->setBaseShippingAmount($order->getBaseShippingAmount())->setBaseGiftcertAmount($order->getBaseGiftcertAmount())->setBaseCustbalanceAmount($order->getBaseCustbalanceAmount())->setBaseGrandTotal($order->getBaseGrandTotal()); return $address; }
/** * Retrieve the actual grand total of the order * * @param Mage_Sales_Model_Order $order * @param Mage_Sales_Model_Order_Invoice $tempCancelInvoice * @param Mage_Sales_Model_Order_Creditmemo $tempCreditmemo * * @return float */ public function getShoppingBasketAmount(Mage_Sales_Model_Order $order, Mage_Sales_Model_Order_Creditmemo $tempCreditmemo = null) { $grandTotal = Mage::app()->getStore()->roundPrice($order->getGrandTotal()); if ($this->isOrderCanceled($order)) { $invoices = $order->getInvoiceCollection(); $grandTotal = 0; foreach ($invoices as $invoice) { $grandTotal = $grandTotal + Mage::app()->getStore()->roundPrice($invoice->getGrandTotal()); } } if (isset($tempCreditmemo)) { $grandTotal = $grandTotal - Mage::app()->getStore()->roundPrice($tempCreditmemo->getGrandTotal()); } $creditmemos = $order->getCreditmemosCollection(); foreach ($creditmemos as $creditmemo) { $grandTotal = $grandTotal - Mage::app()->getStore()->roundPrice($creditmemo->getGrandTotal()); } return $grandTotal; }
/** * Get Shopping Cart XML for MasterPass * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order $quote * @return string */ public function getShoppingCartXML($quote) { $dom = new DOMDocument('1.0', 'utf-8'); $ShoppingCart = $dom->createElement('ShoppingCart'); $dom->appendChild($ShoppingCart); if ($quote instanceof Mage_Sales_Model_Order) { $currency = $quote->getOrderCurrencyCode(); } else { $currency = $quote->getQuoteCurrencyCode(); } $ShoppingCart->appendChild($dom->createElement('CurrencyCode', $currency)); $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(); if ($quote instanceof Mage_Sales_Model_Order) { $qty = $item->getQtyOrdered(); } else { $qty = $item->getQty(); } $ShoppingCartItem = $dom->createElement('ShoppingCartItem'); $ShoppingCartItem->appendChild($dom->createElement('Description', $item->getName())); $ShoppingCartItem->appendChild($dom->createElement('Quantity', (double) $qty)); $ShoppingCartItem->appendChild($dom->createElement('Value', (int) bcmul($product->getFinalPrice(), 100))); $ShoppingCartItem->appendChild($dom->createElement('ImageURL', $product->getThumbnailUrl())); $ShoppingCart->appendChild($ShoppingCartItem); } return str_replace("\n", '', $dom->saveXML()); }
/** * Processes payment for specified order * @param Mage_Sales_Model_Order $Order * @return */ public function processOrder(Mage_Sales_Model_Order $PrimaryOrder, Mage_Sales_Model_Order $Order = null) { $sId = $this->getSubscriptionId($PrimaryOrder); $this->getWebService()->getRequest()->reset()->setSubscriptionid($sId)->setOrderid($Order->getIncrementId())->setAmount($Order->getGrandTotal() * 100)->setCurrency($this->getCurrencyCode($PrimaryOrder))->setGroup(''); $result = $this->getWebService()->authorizeSubscription(); // Include record to epay_orders_status $this->_saveOrderStatus($PrimaryOrder, $Order, 1); }
/** * Build a hash over some unmodifiable(!) order properties. * * @param Mage_Sales_Model_Order $order * @return string */ public function createHashForOrder(Mage_Sales_Model_Order $order) { $orderHash = $order->getId(); $orderHash .= $order->getIncrementId(); $orderHash .= $order->getQuoteId(); $orderHash .= $order->getCustomerEmail(); $orderHash .= $order->getCustomerFirstname(); $orderHash .= $order->getCustomerLastname(); $orderHash .= $order->getShippingMethod(); $orderHash .= $order->getStoreName(); $orderHash .= $order->getGrandTotal(); return hash("sha512", $orderHash); }
/** * edit order if something changed * * @param SofortLib_TransactionData $transData * @param Mage_Sales_Model_Order $order * @return boolean */ public function updateOrderFromTransactionData($transData, $order) { // total amount without refunded $amount = number_format($order->getGrandTotal() - $order->getBaseTotalRefunded(), 2, '.', ''); // if amount still the same, there was nothing edit if ($amount == $transData->getAmount()) { return false; } // transaction was cancel, nothing change, order will cancel full if ($transData->isLoss()) { return false; } // store items get from remote $checkItems = array(); foreach ($transData->getItems() as $item) { $checkItems[$item['item_id']] = $item; } // order already invoice => create creditmemo if ($order->hasInvoices()) { return $this->_createCreditMemo($transData, $order, $checkItems); } // update total $order->setGrandTotal($transData->getAmount()); $order->setBaseGrandTotal($transData->getAmount()); $subTotal = 0; $taxAmount = array(); // if discount value change the discount store on each row is broken // so we just remove it $removeDiscount = false; // edit discount amount if (empty($checkItems[2])) { $order->setDiscountAmount(0); $removeDiscount = true; } else { $order->setDiscountAmount($checkItems[2]['quantity'] * $checkItems[2]['unit_price']); $removeDiscount = true; } // check all items in the current order foreach ($order->getAllVisibleItems() as $item) { $uid = md5($item->getSku() . "-" . $item->getItemId()); // if not exist it should removed if (empty($checkItems[$uid])) { // item was cancel $this->_cancelItem($item); unset($checkItems[$uid]); continue; } // quantity or price change, new row values will be calculated if ($checkItems[$uid]['quantity'] != $item->getQtyOrdered() || $item->getPrice() != $checkItems[$uid]['unit_price']) { $item->setQtyCanceled($item->getQtyOrdered() - $checkItems[$uid]['quantity']); $singleTax = $checkItems[$uid]['unit_price'] - $checkItems[$uid]['unit_price'] * (100 / ($checkItems[$uid]['tax'] + 100)); $item->setPrice($checkItems[$uid]['unit_price'] - $singleTax); $item->setBasePrice($checkItems[$uid]['unit_price'] - $singleTax); $item->setPriceInclTax($checkItems[$uid]['unit_price']); $item->setBasePriceInclTax($checkItems[$uid]['unit_price']); $rowTotalInclTag = $checkItems[$uid]['quantity'] * $checkItems[$uid]['unit_price']; $rowTax = $rowTotalInclTag - $rowTotalInclTag * (100 / ($checkItems[$uid]['tax'] + 100)); $rowTotal = $rowTotalInclTag - $rowTax; $item->setRowTotalInclTax($rowTotalInclTag); $item->setBaseRowTotalInclTax($rowTotalInclTag); $item->setRowTotal($rowTotal); $item->setBaseRowTotal($rowTotal); $item->setTaxAmount($rowTax); $item->setBaseTaxAmount($rowTax); } // add to subtotal $subTotal += $checkItems[$uid]['quantity'] * $checkItems[$uid]['unit_price']; // appent to tax group if (empty($taxAmount[$checkItems[$uid]['tax']])) { $taxAmount[$checkItems[$uid]['tax']] = 0; } $taxAmount[$checkItems[$uid]['tax']] += $item->getRowTotalInclTax(); // remove discount from order row if ($removeDiscount) { $item->setDiscountPercent(0); $item->setDiscountAmount(0); $item->setBaseDiscountAmount(0); } unset($checkItems[$uid]); } // edit shipment amount if it was removed if (empty($checkItems[1]) && $order->getShippingAmount()) { $order->setShippingAmount(0); $order->setBaseShippingAmount(0); $order->setShippingTaxAmount(0); $order->setBaseShippingTaxAmount(0); $order->setShippingInclTax(0); $order->setBaseShippingInclTax(0); } else { $shippingWithTax = $checkItems[1]['quantity'] * $checkItems[1]['unit_price']; $shippingTax = $shippingWithTax - $shippingWithTax * (100 / ($checkItems[1]['tax'] + 100)); $shippingAmount = $shippingWithTax - $shippingTax; $order->setShippingAmount($shippingAmount); $order->setBaseShippingAmount($shippingAmount); $order->setShippingTaxAmount($shippingTax); $order->setBaseShippingTaxAmount($shippingTax); $order->setShippingInclTax($shippingWithTax); $order->setBaseShippingInclTax($shippingWithTax); } // fix tax from discount and shipping foreach ($checkItems as $item) { if (empty($taxAmount[$item['tax']])) { $taxAmount[$item['tax']] = 0; } $taxAmount[$item['tax']] += $item['unit_price'] * $item['quantity']; } // update subtotal $order->setBaseSubtotalInclTax($subTotal); $order->setSubtotalInclTax($subTotal); // sum for all tax amount $totalTaxAmount = 0; // update all tax rate items $rates = Mage::getModel('tax/sales_order_tax')->getCollection()->loadByOrder($order); foreach ($rates as $rate) { // format rate $tRate = sprintf("%01.2f", $rate->getPercent()); if (!empty($taxAmount[$tRate])) { // calc new tax value $tAmount = $taxAmount[$tRate] - $taxAmount[$tRate] * (100 / ($tRate + 100)); $totalTaxAmount += $tAmount; $rate->setAmount($tAmount); $rate->setBaseAmount($tAmount); $rate->setBaseRealAmount($tAmount); $rate->save(); } } // update total tax amount $order->setTaxAmount($totalTaxAmount); $order->setBaseTaxAmount($totalTaxAmount); // update subtotal without tax $order->setBaseSubtotal($subTotal - $totalTaxAmount + $order->getShippingTaxAmount()); $order->setSubtotal($subTotal - $totalTaxAmount + $order->getShippingTaxAmount()); $order->save(); return true; }
/** * Send email id payment is in Fraud status * @param Mage_Customer_Model_Customer $receiver * @param Mage_Sales_Model_Order $order * @param string $message * @return Mage_Checkout_Helper_Data */ public function sendFraudPaymentEmail($receiver, $order, $message, $email_key = 'fraud_payment') { $translate = Mage::getSingleton('core/translate'); /* @var $translate Mage_Core_Model_Translate */ $translate->setTranslateInline(false); $mailTemplate = Mage::getModel('core/email_template'); /* @var $mailTemplate Mage_Core_Model_Email_Template */ $template = Mage::getStoreConfig('hipay/' . $email_key . '/template', $order->getStoreId()); $copyTo = $this->_getEmails('hipay/' . $email_key . '/copy_to', $order->getStoreId()); $copyMethod = Mage::getStoreConfig('hipay/' . $email_key . '/copy_method', $order->getStoreId()); if ($copyTo && $copyMethod == 'bcc') { $mailTemplate->addBcc($copyTo); } $sendTo = array(array('email' => $receiver->getEmail(), 'name' => $receiver->getName())); if ($copyTo && $copyMethod == 'copy') { foreach ($copyTo as $email) { $sendTo[] = array('email' => $email, 'name' => null); } } $shippingMethod = ''; if ($shippingInfo = $order->getShippingAddress()->getShippingMethod()) { $data = explode('_', $shippingInfo); $shippingMethod = $data[0]; } $paymentMethod = ''; if ($paymentInfo = $order->getPayment()) { $paymentMethod = $paymentInfo->getMethod(); } $items = ''; foreach ($order->getAllVisibleItems() as $_item) { /* @var $_item Mage_Sales_Model_Quote_Item */ $items .= $_item->getProduct()->getName() . ' x ' . $_item->getQty() . ' ' . $order->getStoreCurrencyCode() . ' ' . $_item->getProduct()->getFinalPrice($_item->getQty()) . "\n"; } $total = $order->getStoreCurrencyCode() . ' ' . $order->getGrandTotal(); foreach ($sendTo as $recipient) { $mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $order->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('hipay/' . $email_key . '/identity', $order->getStoreId()), $recipient['email'], $recipient['name'], array('reason' => $message, 'dateAndTime' => Mage::app()->getLocale()->date(), 'customer' => $order->getCustomerFirstname() . ' ' . $order->getCustomerLastname(), 'customerEmail' => $order->getCustomerEmail(), 'billingAddress' => $order->getBillingAddress(), 'shippingAddress' => $order->getShippingAddress(), 'shippingMethod' => Mage::getStoreConfig('carriers/' . $shippingMethod . '/title'), 'paymentMethod' => Mage::getStoreConfig('payment/' . $paymentMethod . '/title'), 'items' => nl2br($items), 'total' => $total)); } $translate->setTranslateInline(true); return $this; }
/** * Retrieve Basket data * * @param Mage_Sales_Model_Order $order * @return array */ public function getBasketData(Mage_Sales_Model_Order $order) { if ($order instanceof Mage_Sales_Model_Order) { $basket = array('amount' => $order->getGrandTotal(), 'currency' => $order->getOrderCurrencyCode(), 'baseCurrency' => $order->getBaseCurrencyCode(), 'baseAmount' => $order->getBaseGrandTotal()); } else { if ($order instanceof Mage_Sales_Model_Quote) { $basket = array('amount' => $order->getGrandTotal(), 'currency' => $order->getQuoteCurrencyCode(), 'baseCurrency' => $order->getBaseCurrencyCode(), 'baseAmount' => $order->getBaseGrandTotal()); } } return $basket; }