コード例 #1
0
 /**
  * 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']);
     }
 }
コード例 #2
0
ファイル: Create.php プロジェクト: romfr/payone-magento
 /**
  * @param Mage_Sales_Model_Order $order
  * @param Payone_Api_Response_Interface $response
  * @param Payone_Api_Request_Interface $request
  * @throws Payone_Core_Exception_TransactionAlreadyExists
  * @return null|Payone_Core_Model_Domain_Transaction
  */
 public function createByApiResponse(Mage_Sales_Model_Order $order, Payone_Api_Response_Interface $response, Payone_Api_Request_Interface $request)
 {
     $transaction = $this->getFactory()->getModelTransaction();
     $transaction->load($response->getTxid(), 'txid');
     // should not exist but to be sure load by txid
     if ($transaction->hasData()) {
         throw new Payone_Core_Exception_TransactionAlreadyExists($response->getTxid());
     }
     $transaction->setTxid($response->getTxid());
     $transaction->setLastTxaction($response->getStatus());
     $transaction->setUserid($response->getUserid());
     $transaction->setStoreId($order->getStoreId());
     $transaction->setOrderId($order->getId());
     $transaction->setReference($order->getIncrementId());
     $transaction->setCurrency($order->getOrderCurrencyCode());
     $transaction->setCustomerId($order->getCustomerId());
     $transaction->setClearingtype($request->getClearingtype());
     $transaction->setMode($request->getMode());
     $transaction->setMid($request->getMid());
     $transaction->setAid($request->getAid());
     $transaction->setPortalid($request->getPortalid());
     $transaction->setLastSequencenumber(0);
     $data = $response->toArray();
     $transaction->addData($data);
     $transaction->save();
     return $transaction;
 }
コード例 #3
0
ファイル: Order.php プロジェクト: arslbbt/mangentovies
 /**
  * Converting order object to quote object
  *
  * @param   Mage_Sales_Model_Order $order
  * @return  Mage_Sales_Model_Quote
  */
 public function toQuote(Mage_Sales_Model_Order $order, $quote = null)
 {
     if (!$quote instanceof Mage_Sales_Model_Quote) {
         $quote = Mage::getModel('sales/quote');
     }
     $quote->setStoreId($order->getStoreId())->setOrderId($order->getId())->setCustomerId($order->getCustomerId())->setCustomerEmail($order->getCustomerEmail())->setCustomerGroupId($order->getCustomerGroupId())->setCustomerTaxClassId($order->getCustomerTaxClassId())->setCustomerIsGuest($order->getCustomerIsGuest())->setBaseCurrencyCode($order->getBaseCurrencyCode())->setStoreCurrencyCode($order->getStoreCurrencyCode())->setQuoteCurrencyCode($order->getOrderCurrencyCode())->setStoreToBaseRate($order->getStoreToBaseRate())->setStoreToQuoteRate($order->getStoreToOrderRate())->setGrandTotal($order->getGrandTotal())->setBaseGrandTotal($order->getBaseGrandTotal())->setCouponCode($order->getCouponCode())->setGiftcertCode($order->getGiftcertCode())->setAppliedRuleIds($order->getAppliedRuleIds())->collectTotals();
     Mage::dispatchEvent('sales_convert_order_to_quote', array('order' => $order, 'quote' => $quote));
     return $quote;
 }
コード例 #4
0
 /**
  * @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;
 }
コード例 #5
0
 /**
  * Fill in the values the order create request requires.
  *
  * @return self
  */
 protected function _buildNewPayload()
 {
     $this->_payload->setBillingAddress($this->_getRomBillingAddress($this->_order->getBillingAddress()))->setCurrency($this->_order->getOrderCurrencyCode())->setLevelOfService($this->_config->levelOfService)->setLocale($this->_getLocale())->setOrderHistoryUrl($this->_helper->getOrderHistoryUrl($this->_order))->setOrderId($this->_order->getIncrementId())->setOrderTotal($this->_order->getBaseGrandTotal())->setOrderType($this->_config->orderType)->setRequestId($this->_coreHelper->generateRequestId('OCR-'));
     $createdAt = $this->_getAsDateTime($this->_order->getCreatedAt());
     if ($createdAt) {
         $this->_payload->setCreateTime($createdAt);
     }
     return $this->_setCustomerData($this->_order, $this->_payload)->_setOrderContext($this->_order, $this->_payload)->_setShipGroups($this->_order, $this->_payload)->_setPaymentData($this->_order, $this->_payload);
 }
コード例 #6
0
ファイル: Event.php プロジェクト: chucky515/Magento-CE-Mirror
 /**
  * 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;
 }
コード例 #7
0
 /**
  * Returns the currency compliant to ISO 4217 (3 char code)
  * @return string 3 Character long currency code
  *
  * @param Mage_Sales_Model_Quote|Mage_Sales_Model_Order|Mage_Sales_Model_Order_Invoice|Mage_Sales_Model_Order_Creditmemo $object
  * @return string
  */
 public function getCurrency($object)
 {
     $currency = $object->getBaseCurrencyCode();
     if (!Mage::helper('paymill/optionHelper')->isBaseCurrency()) {
         if ($object instanceof Mage_Sales_Model_Quote) {
             $currency = $object->getQuoteCurrencyCode();
         } else {
             $currency = $object->getOrderCurrencyCode();
         }
     }
     return $currency;
 }
コード例 #8
0
ファイル: Order.php プロジェクト: aplazame/magento
 public static function crateFromOrder(Mage_Sales_Model_Order $order)
 {
     $aOrder = new self();
     $aOrder->id = $order->getIncrementId();
     $aOrder->currency = $order->getOrderCurrencyCode();
     $aOrder->total_amount = Aplazame_Sdk_Serializer_Decimal::fromFloat($order->getTotalDue());
     $aOrder->articles = array_map(array('Aplazame_Aplazame_BusinessModel_Article', 'crateFromOrderItem'), $order->getAllVisibleItems());
     if (($discounts = $order->getDiscountAmount()) !== null) {
         $aOrder->discount = Aplazame_Sdk_Serializer_Decimal::fromFloat(-$discounts);
     }
     return $aOrder;
 }
コード例 #9
0
ファイル: ApiController.php プロジェクト: Archipel/Magento
 /**
  * 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));
 }
コード例 #10
0
ファイル: Push.php プロジェクト: technomagegithub/olgo.nl
 /**
  * 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;
 }
コード例 #11
0
 /**
  * Returns the currency code of the current order.
  *
  * @return string
  */
 public function getCurrencyCode()
 {
     return $this->_order->getOrderCurrencyCode();
 }
コード例 #12
0
ファイル: Order.php プロジェクト: AndreKlang/Magento-Payex
 /**
  * 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());
 }
コード例 #13
0
 /**
  * Do Void Request/Response
  *
  * @param  Mage_Sales_Model_Order
  * @return array
  * @throws EbayEnterprise_PayPal_Exception when the operation cannot be completed or fails.
  */
 public function doVoidOrder(Mage_Sales_Model_Order $order)
 {
     return $this->doVoid($order->getIncrementId(), $order->getOrderCurrencyCode());
 }
コード例 #14
0
 /**
  * Initializes the payment.
  * @param Mage_Sales_Model_Order
  * @param Mage_Shipping_Model_Shipping
  * @return array
  */
 public function orderCreateRequest(Mage_Sales_Model_Order $order, $allShippingRates)
 {
     $this->_order = $order;
     $orderCurrencyCode = $this->_order->getOrderCurrencyCode();
     $orderCountryCode = $this->_order->getBillingAddress()->getCountry();
     $shippingCostList = array();
     if (empty($allShippingRates) || Mage::getSingleton('customer/session')->isLoggedIn()) {
         if ($order->getShippingInclTax() > 0) {
             $shippingCostList['shippingMethods'][] = array('name' => $order->getShippingDescription(), 'country' => $orderCountryCode, 'price' => $this->toAmount($order->getShippingInclTax()));
         }
         $grandTotal = $this->_order->getGrandTotal() - $order->getShippingInclTax();
     } else {
         $firstPrice = 0;
         foreach ($allShippingRates as $key => $rate) {
             $gross = $this->toAmount($rate->getPrice());
             if ($key == 0) {
                 $firstPrice = $rate->getPrice();
             }
             $shippingCostList['shippingMethods'][] = array('name' => $rate->getMethodTitle(), 'country' => $orderCountryCode, 'price' => $gross);
         }
         $grandTotal = $this->_order->getGrandTotal() - $firstPrice;
     }
     $shippingCost = array('countryCode' => $orderCountryCode, 'shipToOtherCountry' => 'true', 'shippingCostList' => $shippingCostList);
     $orderItems = $this->_order->getAllVisibleItems();
     $items = array();
     $productsTotal = 0;
     $is_discount = false;
     foreach ($orderItems as $key => $item) {
         $itemInfo = $item->getData();
         if ($itemInfo['discount_amount'] > 0) {
             $itemInfo['price_incl_tax'] = $itemInfo['price_incl_tax'] - $itemInfo['discount_amount'];
             $is_discount = true;
         } else {
             if ($itemInfo['discount_percent'] > 0) {
                 $itemInfo['price_incl_tax'] = $itemInfo['price_incl_tax'] * (100 - $itemInfo['discount_percent']) / 100;
             }
         }
         // Check if the item is countable one
         if ($this->toAmount($itemInfo['price_incl_tax']) > 0) {
             $items['products'][] = array('quantity' => (int) $itemInfo['qty_ordered'], 'name' => $itemInfo['name'], 'unitPrice' => $this->toAmount($itemInfo['price_incl_tax']));
             $productsTotal += $itemInfo['price_incl_tax'] * $itemInfo['qty_ordered'];
         }
     }
     //if($this->_order->getShippingAmount () > 0 && !empty ( $shippingCostList['shippingMethods'][0] ) ){
     //        $items ['products'] ['products'] [] = array (
     //            'quantity' => 1 ,'name' => Mage::helper ( 'payu_account' )->__('Shipping costs') . " - " . $shippingCostList['shippingMethods'][0]['name'] ,'unitPrice' => $this->toAmount ( $this->_order->getShippingAmount () ));
     //}
     // assigning the shopping cart
     $shoppingCart = array('grandTotal' => $this->toAmount($grandTotal), 'CurrencyCode' => $orderCurrencyCode, 'ShoppingCartItems' => $items);
     $orderInfo = array('merchantPosId' => OpenPayU_Configuration::getMerchantPosId(), 'orderUrl' => Mage::getBaseUrl() . 'sales/order/view/order_id/' . $this->_order->getId() . '/', 'description' => 'Order no ' . $this->_order->getRealOrderId(), 'validityTime' => $this->_config->getOrderValidityTime());
     if ($is_discount) {
         $items['products'] = array();
         $items['products'][] = array('quantity' => 1, 'name' => Mage::helper('payu_account')->__('Order # ') . $this->_order->getId(), 'unitPrice' => $this->toAmount($grandTotal));
     }
     $OCReq = $orderInfo;
     $OCReq['products'] = $items['products'];
     $OCReq['customerIp'] = Mage::app()->getFrontController()->getRequest()->getClientIp();
     $OCReq['notifyUrl'] = $this->_myUrl . 'orderNotifyRequest';
     $OCReq['cancelUrl'] = $this->_myUrl . 'cancelPayment';
     $OCReq['continueUrl'] = $this->_myUrl . 'continuePayment';
     $OCReq['currencyCode'] = $orderCurrencyCode;
     $OCReq['totalAmount'] = $shoppingCart['grandTotal'];
     $OCReq['extOrderId'] = $this->_order->getId() . '-' . microtime();
     if (!empty($shippingCostList)) {
         $OCReq['shippingMethods'] = $shippingCostList['shippingMethods'];
     }
     unset($OCReq['shoppingCart']);
     $customer_sheet = array();
     $billingAddressId = $this->_order->getBillingAddressId();
     if (!empty($billingAddressId)) {
         $billingAddress = $this->_order->getBillingAddress();
         $customer_mail = $billingAddress->getEmail();
         if (!empty($customer_mail)) {
             $customer_sheet = array('email' => $billingAddress->getEmail(), 'phone' => $billingAddress->getTelephone(), 'firstName' => $billingAddress->getFirstname(), 'lastName' => $billingAddress->getLastname());
             $shippingAddressId = $this->_order->getShippingAddressId();
             if (!empty($shippingAddressId)) {
                 $shippingAddress = $this->_order->getShippingAddress();
             }
             if (!$this->_order->getIsVirtual()) {
                 $customer_sheet['delivery'] = array('street' => trim(implode(' ', $shippingAddress->getStreet())), 'postalCode' => $shippingAddress->getPostcode(), 'city' => $shippingAddress->getCity(), 'countryCode' => $shippingAddress->getCountry(), 'recipientName' => trim($shippingAddress->getFirstname() . ' ' . $shippingAddress->getLastname()), 'recipientPhone' => $shippingAddress->getTelephone(), 'recipientEmail' => $shippingAddress->getEmail());
             }
             $OCReq['buyer'] = $customer_sheet;
         }
     }
     $result = OpenPayU_Order::create($OCReq);
     if ($result->getStatus() == 'SUCCESS') {
         // store session identifier in session info
         Mage::getSingleton('core/session')->setPayUSessionId($result->getResponse()->orderId);
         // assign current transaction id
         $this->_transactionId = $result->getResponse()->orderId;
         $order->getPayment()->setLastTransId($this->_transactionId);
         $locale = Mage::getStoreConfig('general/locale/code', Mage::app()->getStore()->getId());
         $lang_code = explode('_', $locale, 2);
         $ret = array('redirectUri' => $result->getResponse()->redirectUri, 'url' => OpenPayu_Configuration::getSummaryUrl(), 'sessionId' => $result->getResponse()->orderId, 'lang' => strtolower($lang_code[1]));
         $customer = Mage::getModel('customer/customer');
         if ($this->_order->getCustomerIsGuest()) {
             $email = $billingAddress->getEmail();
             $customer->setWebsiteId(Mage::app()->getWebsite()->getId());
             $customer->loadByEmail($email);
         } else {
             $customer->load($this->_order->getCustomerId());
         }
         if (!$customer->getId()) {
             $this->_order->setCustomerEmail($email);
         }
         $this->_order->sendNewOrderEmail();
         $this->_order->save();
     } else {
         Mage::throwException(Mage::helper('payu_account')->__('There was a problem with initializing the payment, please contact the store administrator. ' . $result->getError()));
     }
     return $ret;
 }
コード例 #15
0
 /**
  * Do Void Request/Response
  *
  * @param  Mage_Sales_Model_Order
  * @return array
  *
  * @throws EbayEnterprise_PayPal_Exception when the operation cannot be completed or fails.
  */
 public function doVoid(Mage_Sales_Model_Order $order)
 {
     $sdk = $this->getSdk($this->config->apiOperationDoVoid);
     $payload = $sdk->getRequestBody();
     $payload->setOrderId($order->getIncrementId())->setRequestId($this->coreHelper->generateRequestId(self::PAYPAL_DOVOID_REQUEST_ID_PREFIX))->setCurrencyCode($order->getOrderCurrencyCode());
     $sdk->setRequestBody($payload);
     $this->logApiCall('do void', $sdk->getRequestBody()->serialize(), 'request');
     $reply = $this->sendRequest($sdk);
     $isVoided = $reply->isSuccess();
     if (!$reply->isSuccess()) {
         $logMessage = 'PayPal DoVoid failed. See exception log for details.';
         $this->logger->warning($logMessage, $this->logContext->getMetaData(__CLASS__));
         $e = Mage::exception('EbayEnterprise_PayPal', $this->helper->__(static::EBAYENTERPRISE_PAYPAL_API_FAILED));
         $this->logger->logException($e, $this->logContext->getMetaData(__CLASS__, [], $e));
         throw $e;
     }
     $this->logApiCall('do void', $reply->serialize(), 'response');
     return ['method' => EbayEnterprise_PayPal_Model_Method_Express::CODE, 'order_id' => $reply->getOrderId(), 'is_voided' => $isVoided];
 }
コード例 #16
0
 /**
  * Builds a order items object form the Magento sales item.
  *
  * @param Mage_Sales_Model_Order_Item $item the sales item model.
  * @param Mage_Sales_Model_Order $order the order model.
  *
  * @return Nosto_Tagging_Model_Meta_Order_Item the built item.
  */
 protected function buildItem(Mage_Sales_Model_Order_Item $item, Mage_Sales_Model_Order $order)
 {
     return Mage::getModel('nosto_tagging/meta_order_item', array('productId' => (int) $this->buildItemProductId($item), 'quantity' => (int) $item->getQtyOrdered(), 'name' => $this->buildItemName($item), 'unitPrice' => $item->getPriceInclTax(), 'currencyCode' => $order->getOrderCurrencyCode()));
 }
コード例 #17
0
ファイル: Create.php プロジェクト: xiaoguizhidao/mydigibits
 /**
  * Initialize creation data from existing order
  *
  * @param Mage_Sales_Model_Order $order
  * @return unknown
  */
 public function initFromOrder(Mage_Sales_Model_Order $order)
 {
     if (!$order->getReordered()) {
         $this->getSession()->setOrderId($order->getId());
     } else {
         $this->getSession()->setReordered($order->getId());
     }
     /**
      * Check if we edit quest order
      */
     $this->getSession()->setCurrencyId($order->getOrderCurrencyCode());
     if ($order->getCustomerId()) {
         $this->getSession()->setCustomerId($order->getCustomerId());
     } else {
         $this->getSession()->setCustomerId(false);
     }
     $this->getSession()->setStoreId($order->getStoreId());
     $this->getSession()->getStore();
     //need for initializing store
     foreach ($order->getItemsCollection(Mage::helper('sarp')->getAllSubscriptionTypes(), true) as $orderItem) {
         /* @var $orderItem Mage_Sales_Model_Order_Item */
         if (!$this->hasSubscriptionOptions($orderItem)) {
             continue;
         }
         if (is_array($this->getItemIdFilter()) && sizeof($this->getItemIdFilter())) {
             // If itemId filter is set - ignore not matching entries
             if (array_search($orderItem->getId(), $this->getItemIdFilter()) === false) {
                 continue;
             }
         }
         if (!$orderItem->getParentItem()) {
             if ($order->getReordered()) {
                 $qty = $orderItem->getQtyOrdered();
             } else {
                 $qty = $orderItem->getQtyOrdered() - $orderItem->getQtyShipped() - $orderItem->getQtyInvoiced();
             }
             if ($qty > 0) {
                 $item = $this->initFromOrderItem($orderItem, $qty);
                 if (is_string($item)) {
                     Mage::throwException($item);
                 }
             }
         }
     }
     $this->_initBillingAddressFromOrder($order);
     $this->_initShippingAddressFromOrder($order);
     $this->setShippingMethod($order->getShippingMethod());
     $this->getQuote()->getShippingAddress()->setShippingDescription($order->getShippingDescription());
     $this->getQuote()->getBillingAddress()->setShippingDescription($order->getShippingDescription());
     $this->getQuote()->getPayment()->addData($order->getPayment()->getData());
     if ($order->getPayment()->getData('method') == 'ccsave') {
         $this->getQuote()->getPayment()->setAdditionalInformation('useccv', false);
     }
     $orderCouponCode = $order->getCouponCode();
     if ($orderCouponCode) {
         $this->getQuote()->setCouponCode($orderCouponCode);
     }
     if ($this->getQuote()->getCouponCode()) {
         //$this->getQuote()->collectTotals();
     }
     Mage::helper('core')->copyFieldset('sales_copy_order', 'to_edit', $order, $this->getQuote());
     Mage::dispatchEvent('sales_convert_order_to_quote', array('order' => $order, 'quote' => $this->getQuote()));
     if (!$order->getCustomerId()) {
         $this->getQuote()->setCustomerIsGuest(true);
     }
     if ($this->getSession()->getUseOldShippingMethod(true)) {
         /*
          * if we are making reorder or editing old order
          * we need to show old shipping as preselected
          * so for this we need to collect shipping rates
          */
         $this->collectShippingRates();
     } else {
         /*
          * if we are creating new order then we don't need to collect
          * shipping rates before customer hit appropriate button
          */
         $this->collectRates();
     }
     $this->saveQuote();
     // Make collect rates when user click "Get shipping methods and rates" in order creating
     // $this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
     // $this->getQuote()->getShippingAddress()->collectShippingRates();
     /** Check stock */
     foreach ($this->getQuote()->getItemsCollection() as $item) {
         $this->checkQuoteItemQty($item);
         if ($item->getProduct()->getStatus() == Mage_Catalog_Model_Product_Status::STATUS_DISABLED) {
             $item->setMessage(Mage::helper('adminhtml')->__('This product is currently disabled'));
             $item->setHasError(true);
         }
         if ($item->getHasError()) {
             throw new AW_Sarp_Exception($item->getMessage());
         }
     }
     return $this;
 }
コード例 #18
0
ファイル: Data.php プロジェクト: buttasg/cowgirlk
 /**
  * check if order total is correct
  *
  * @param ShopgateOrder          $order
  * @param Mage_Sales_Model_Order $oMageOrder
  * @param string                 $message
  *
  * @return bool
  */
 public function isOrderTotalCorrect(ShopgateOrder $order, Mage_Sales_Model_Order $oMageOrder, &$message = "")
 {
     $totalShopgate = $order->getAmountComplete();
     $totalMagento = $oMageOrder->getTotalDue() + $oMageOrder->getTotalPaid();
     ShopgateLogger::getInstance()->log("Total Shopgate: {$totalShopgate} {$order->getCurrency()} \n            Total Magento: {$totalMagento} {$order->getCurrency()}", ShopgateLogger::LOGTYPE_DEBUG);
     if (abs($totalShopgate - $totalMagento) > 0.02) {
         $msg = "differing total order amounts:\n";
         $msg .= "\tShopgate:\t{$totalShopgate} {$order->getCurrency()} \n";
         $msg .= "\tMagento:\t{$totalMagento} {$oMageOrder->getOrderCurrencyCode()}\n";
         $message = $msg;
         return false;
     }
     return true;
 }
コード例 #19
0
ファイル: Orders.php プロジェクト: buttasg/cowgirlk
 /**
  * @param Mage_Sales_Model_Order $order
  * @return array
  */
 protected function _getCouponsFormatted($order)
 {
     $result = array();
     if ($order->getCouponCode()) {
         if (Mage::helper("shopgate/config")->getIsMagentoVersionLower1410()) {
             $mageRule = Mage::getModel('salesrule/rule')->load($order->getCouponCode(), 'coupon_code');
             $mageCoupon = $mageRule;
         } else {
             $mageCoupon = Mage::getModel('salesrule/coupon')->load($order->getCouponCode(), 'code');
             $mageRule = Mage::getModel('salesrule/rule')->load($mageCoupon->getRuleId());
         }
         $externalCoupon = new ShopgateExternalCoupon();
         $couponInfo = array();
         $couponInfo["coupon_id"] = $mageCoupon->getId();
         $couponInfo["rule_id"] = $mageRule->getId();
         $externalCoupon->setCode($order->getCouponCode());
         $externalCoupon->setCurrency($order->getOrderCurrencyCode());
         $externalCoupon->setName($mageRule->getName());
         $externalCoupon->setDescription($mageRule->getDescription());
         $externalCoupon->setInternalInfo($this->_getConfig()->jsonEncode($couponInfo));
         $externalCoupon->setAmount($order->getDiscountAmount());
         array_push($result, $externalCoupon);
     }
     return $result;
 }
コード例 #20
0
ファイル: Order.php プロジェクト: nosto/nosto-magento-nodeps
 /**
  * Builds a order items object form the Magento sales item.
  *
  * @param Mage_Sales_Model_Order_Item $item the sales item model.
  * @param Mage_Sales_Model_Order $order the order model.
  *
  * @return Nosto_Tagging_Model_Meta_Order_Item the built item.
  */
 protected function buildItem(Mage_Sales_Model_Order_Item $item, Mage_Sales_Model_Order $order)
 {
     /* @var Nosto_Tagging_Helper_Price */
     $nostoPriceHelper = Mage::helper('nosto_tagging/price');
     return Mage::getModel('nosto_tagging/meta_order_item', array('productId' => $this->buildItemProductId($item), 'quantity' => (int) $item->getQtyOrdered(), 'name' => $this->buildItemName($item), 'unitPrice' => $nostoPriceHelper->getItemFinalPriceInclTax($item), 'currencyCode' => $order->getOrderCurrencyCode()));
 }
コード例 #21
0
ファイル: Mapping.php プロジェクト: ratepay/magento-module
 /**
  * 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;
 }
コード例 #22
0
ファイル: Create.php プロジェクト: beejhuff/magento-1.13.0.2
 /**
  * Initialize creation data from existing order
  *
  * @param Mage_Sales_Model_Order $order
  * @return unknown
  */
 public function initFromOrder(Mage_Sales_Model_Order $order)
 {
     if (!$order->getReordered()) {
         $this->getSession()->setOrderId($order->getId());
     } else {
         $this->getSession()->setReordered($order->getId());
     }
     /**
      * Check if we edit quest order
      */
     $this->getSession()->setCurrencyId($order->getOrderCurrencyCode());
     if ($order->getCustomerId()) {
         $this->getSession()->setCustomerId($order->getCustomerId());
     } else {
         $this->getSession()->setCustomerId(false);
     }
     $this->getSession()->setStoreId($order->getStoreId());
     /**
      * Initialize catalog rule data with new session values
      */
     $this->initRuleData();
     foreach ($order->getItemsCollection(array_keys(Mage::getConfig()->getNode('adminhtml/sales/order/create/available_product_types')->asArray()), true) as $orderItem) {
         /* @var $orderItem Mage_Sales_Model_Order_Item */
         if (!$orderItem->getParentItem()) {
             if ($order->getReordered()) {
                 $qty = $orderItem->getQtyOrdered();
             } else {
                 $qty = $orderItem->getQtyOrdered() - $orderItem->getQtyShipped() - $orderItem->getQtyInvoiced();
             }
             if ($qty > 0) {
                 $item = $this->initFromOrderItem($orderItem, $qty);
                 if (is_string($item)) {
                     Mage::throwException($item);
                 }
             }
         }
     }
     $shippingAddress = $order->getShippingAddress();
     if ($shippingAddress) {
         $addressDiff = array_diff_assoc($shippingAddress->getData(), $order->getBillingAddress()->getData());
         unset($addressDiff['address_type'], $addressDiff['entity_id']);
         $shippingAddress->setSameAsBilling(empty($addressDiff));
     }
     $this->_initBillingAddressFromOrder($order);
     $this->_initShippingAddressFromOrder($order);
     if (!$this->getQuote()->isVirtual() && $this->getShippingAddress()->getSameAsBilling()) {
         $this->setShippingAsBilling(1);
     }
     $this->setShippingMethod($order->getShippingMethod());
     $this->getQuote()->getShippingAddress()->setShippingDescription($order->getShippingDescription());
     $this->getQuote()->getPayment()->addData($order->getPayment()->getData());
     $orderCouponCode = $order->getCouponCode();
     if ($orderCouponCode) {
         $this->getQuote()->setCouponCode($orderCouponCode);
     }
     if ($this->getQuote()->getCouponCode()) {
         $this->getQuote()->collectTotals();
     }
     Mage::helper('core')->copyFieldset('sales_copy_order', 'to_edit', $order, $this->getQuote());
     Mage::dispatchEvent('sales_convert_order_to_quote', array('order' => $order, 'quote' => $this->getQuote()));
     if (!$order->getCustomerId()) {
         $this->getQuote()->setCustomerIsGuest(true);
     }
     if ($this->getSession()->getUseOldShippingMethod(true)) {
         /*
          * if we are making reorder or editing old order
          * we need to show old shipping as preselected
          * so for this we need to collect shipping rates
          */
         $this->collectShippingRates();
     } else {
         /*
          * if we are creating new order then we don't need to collect
          * shipping rates before customer hit appropriate button
          */
         $this->collectRates();
     }
     // Make collect rates when user click "Get shipping methods and rates" in order creating
     // $this->getQuote()->getShippingAddress()->setCollectShippingRates(true);
     // $this->getQuote()->getShippingAddress()->collectShippingRates();
     $this->getQuote()->save();
     return $this;
 }
コード例 #23
0
ファイル: HistoricalOrder.php プロジェクト: aplazame/magento
 /**
  * @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;
 }
コード例 #24
0
ファイル: Data.php プロジェクト: Aya-Mousa/HyperpayMagentoo
 /**
  * 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;
 }
コード例 #25
0
ファイル: Bitcoin.php プロジェクト: keramist/magento-plugin
 /**
  * Adds currency information to the invoice
  *
  * @param Bitpay\Invoice         $invoice
  * @param Mage_Sales_Model_Order $order
  * @return Bitpay\Invoice
  */
 private function addCurrencyInfo($invoice, $order)
 {
     if (false === isset($invoice) || true === empty($invoice) || false === isset($order) || true === empty($order)) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::addCurrencyInfo(): missing or invalid invoice or order parameter.');
         throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::addCurrencyInfo(): missing or invalid invoice or order parameter.');
     } else {
         $this->debugData('[INFO] In Bitpay_Core_Model_Method_Bitcoin::addCurrencyInfo(): function called with good invoice and order parameters.');
     }
     $currency = new Bitpay\Currency();
     if (false === isset($currency) || true === empty($currency)) {
         $this->debugData('[ERROR] In Bitpay_Core_Model_Method_Bitcoin::addCurrencyInfo(): could not construct new BitPay currency object.');
         throw new \Exception('In Bitpay_Core_Model_Method_Bitcoin::addCurrencyInfo(): could not construct new BitPay currency object.');
     }
     $currency->setCode($order->getOrderCurrencyCode());
     $invoice->setCurrency($currency);
     return $invoice;
 }
コード例 #26
0
ファイル: Create.php プロジェクト: arslbbt/mangentovies
 /**
  * Initialize creation data from existing order
  *
  * @param Mage_Sales_Model_Order $order
  * @return unknown
  */
 public function initFromOrder(Mage_Sales_Model_Order $order)
 {
     if (!$order->getReordered()) {
         $this->getSession()->setOrderId($order->getId());
     }
     $this->getSession()->setCurrencyId($order->getOrderCurrencyCode());
     $this->getSession()->setCustomerId($order->getCustomerId());
     $this->getSession()->setStoreId($order->getStoreId());
     $convertModel = Mage::getModel('sales/convert_order');
     /*@var $quote Mage_Sales_Model_Quote*/
     $quote = $convertModel->toQuote($order, $this->getQuote());
     $quote->setShippingAddress($convertModel->toQuoteShippingAddress($order));
     $quote->setBillingAddress($convertModel->addressToQuoteAddress($order->getBillingAddress()));
     if ($order->getReordered()) {
         $quote->getPayment()->setMethod($order->getPayment()->getMethod());
     } else {
         $convertModel->paymentToQuotePayment($order->getPayment(), $quote->getPayment());
     }
     foreach ($order->getItemsCollection() as $item) {
         if ($order->getReordered()) {
             $qty = $item->getQtyOrdered();
         } else {
             $qty = min($item->getQtyToInvoice(), $item->getQtyToShip());
         }
         if ($qty) {
             $quoteItem = $convertModel->itemToQuoteItem($item)->setQty($qty);
             $quote->addItem($quoteItem);
         }
     }
     $quote->getShippingAddress()->setCollectShippingRates(true);
     $quote->getShippingAddress()->collectShippingRates();
     $quote->collectTotals();
     $quote->save();
     return $this;
 }