Ejemplo n.º 1
0
 public function cancelaPedido(Mage_Sales_Model_Order $order)
 {
     $paymentMethod = $order->getPayment()->getMethodInstance()->getCode();
     $listPaymentMethodsIdeasa = Mage::helper('base')->listPaymentMethods();
     $this->logger->info('Processando cancelamento do pedido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
     try {
         if ($order->getState() != Mage_Sales_Model_Order::STATE_CANCELED) {
             $order->cancel();
             //força o cancelamento
             if ($order->getStatus() != Mage_Sales_Model_Order::STATE_CANCELED) {
                 $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('Pedido cancelado'), $notified = false);
             } else {
                 $order->addStatusToHistory($order->getStatus(), Mage::helper('base')->__('Pedido cancelado.'));
             }
             if ($order->hasInvoices() != '') {
                 $order->setState(Mage_Sales_Model_Order::STATE_CANCELED, true, Mage::helper('base')->__('O pagamento e o pedido foram cancelados, mas não foi possível retornar os produtos ao estoque pois já havia uma fatura gerada para este pedido.'), $notified = false);
             }
             $order->save();
         }
         if (Mage::helper('base')->isIdeasaPaymentMethod($paymentMethod) && Mage::helper('base/module')->isPagSeguroDiretoExists() && $paymentMethod == $listPaymentMethodsIdeasa[0]) {
             Mage::getModel('pagsegurodireto/notification')->sendEmail($order);
         }
     } catch (Exception $e) {
         $this->logger->error("Erro ao cancelar pedido {$orderId} \n {$e->__toString}()");
     }
     $this->logger->info('Cancelamento do pedido foi concluido ' . $order->getRealOrderId() . ', do modulo: ' . $paymentMethod);
     return;
 }
Ejemplo n.º 2
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;
 }
 /**
  * Check order archiveablility for single archiving
  *
  * @param Mage_Sales_Model_Order $order
  * @param boolean $checkAge check order age for archive
  * @return boolean
  */
 public function isOrderArchiveable($order, $checkAge = false)
 {
     if (in_array($order->getStatus(), $this->getArchiveOrderStatuses())) {
         if ($checkAge) {
             $now = Mage::app()->getLocale()->storeDate();
             $updated = Mage::app()->getLocale()->storeDate($order->getUpdatedAt());
         }
         return true;
     }
     return false;
 }
Ejemplo n.º 4
0
 /**
  * Send the shop owner and subscribers to the debug-email an email with the message that there is a double transaction
  */
 protected function _sendDoubleTransactionEmail()
 {
     $helper = Mage::helper('buckaroo3extended');
     $orderId = $this->_order->getIncrementId();
     $currentOrderStatus = $this->_order->getStatus();
     $recipients = explode(',', Mage::getStoreConfig('buckaroo/buckaroo3extended_advanced/debug_email', $this->getStoreId()));
     $recipients[] = Mage::getStoreConfig('trans_email/ident_general/email');
     $mail = $helper->__('Status Success received for order %s while the order currently the status %s has.', $orderId, $currentOrderStatus);
     foreach ($recipients as $recipient) {
         mail(trim($recipient), 'Dubbele transactie voor dezelfde order', $mail);
     }
 }
Ejemplo n.º 5
0
 /**
  * Check if can make payment for order
  *
  * @param Mage_Sales_Model_Order $order
  * @return bool
  */
 public function canMakePayment($order)
 {
     if ($order->getPayment() && $order->getPayment()->getMethod() == 'purchaseorder' && $order->canShip()) {
         return false;
     }
     if ($order->getStatus() != 'purchaseorder_pending_payment') {
         return false;
     }
     if (!$order->canInvoice()) {
         return false;
     }
     return true;
 }
Ejemplo n.º 6
0
 public function flush(Mage_Sales_Model_Order $order, $historyEntity)
 {
     $collection = Mage::registry(DEG_OrderLifecycle_Model_Lifecycle_Event_Collection::REGISTRY_LIFECYCLE_EVENT_COLLECTION);
     //TODO wrap in a transaction
     if ($collection) {
         foreach ($collection->getEvents() as $event) {
             $comment = $this->formatEventData($event);
             $history = Mage::getModel('sales/order_status_history');
             $history->setParentId($order->getId());
             $history->setStatus($order->getStatus());
             $history->setComment($comment);
             $history->setIsCustomerNotified(0);
             $history->setIsVisibleOnFront(0);
             $history->setEntityName($historyEntity);
             $history->save();
         }
         Mage::unregister(DEG_OrderLifecycle_Model_Lifecycle_Event_Collection::REGISTRY_LIFECYCLE_EVENT_COLLECTION);
     }
 }
Ejemplo n.º 7
0
 /**
  * @param Mage_Sales_Model_Order $order
  * @param string                 $uri
  * @param string                 $method
  * @param string                 $body
  */
 public function logRequest(Mage_Sales_Model_Order $order = null, $uri, $method, $body)
 {
     if (!$this->isApiLogEnabled()) {
         return;
     }
     $message = $this->getDashHash();
     $message .= PHP_EOL;
     $message .= PHP_EOL . 'Starting Request';
     $message .= PHP_EOL . 'Request Data:';
     $message .= PHP_EOL;
     if ($order && $order->getId()) {
         $message .= PHP_EOL . sprintf('Order ID:      %s', $order->getId());
         $message .= PHP_EOL . sprintf('Order Real ID: %s', $order->getRealOrderId());
         $message .= PHP_EOL . sprintf('Order State:   %s', $order->getState());
         $message .= PHP_EOL . sprintf('Order Status:  %s', $order->getStatus());
     }
     $message .= PHP_EOL . sprintf('URI:           %s', $uri);
     $message .= PHP_EOL . sprintf('Method:        %s', $method);
     $message .= PHP_EOL . sprintf('Request Body:  %s', $body);
     $message .= PHP_EOL;
     $message .= $this->getShortDashHash();
     $this->log($message);
 }
Ejemplo n.º 8
0
 /**
  * checks if the order's state is valid for the according Barclaycard's status. If not the order's state is reset
  * to it's previous state
  *
  * @param Mage_Sales_Model_Order $order
  *
  * @return $this
  */
 public function checkForOpsStateOnStatusUpdate(Mage_Sales_Model_Order $order)
 {
     $opsStatus = $order->getPayment()->getAdditionalInformation('status');
     $opsOrderStates = $this->getStatusMappingModel()->getStatusForOpsStatus($opsStatus);
     $origData = $order->getOrigData();
     if (0 < count($opsOrderStates) && !in_array($order->getStatus(), $opsOrderStates)) {
         $comment = $this->getDataHelper()->__('revert state update to it\'s original one because of Barclaycard\'s state restriction');
         $order->addStatusHistoryComment($comment, $origData['status']);
     }
     return $this;
 }
 public function responseAction()
 {
     require_once 'Zend/Crypt/Hmac.php';
     $txnid = "";
     $txnrefno = "";
     $txnstatus = "";
     $txnmsg = "";
     $firstName = "";
     $lastName = "";
     $email = "";
     $street1 = "";
     $city = "";
     $state = "";
     $country = "";
     $pincode = "";
     $mobileNo = "";
     $signature = "";
     $reqsignature = "";
     $data = "";
     $txnGateway = "";
     $paymentMode = "";
     $maskedCardNumber = "";
     $cardType = "";
     $flag = "dataTampered";
     $order = $this->getOrder();
     $orderAmount = round($order->getData('grand_total'), 2);
     $config = Mage::getSingleton('citrus/config');
     $secretKey = $config->getSecretKey();
     $session = Mage::getSingleton('checkout/session');
     if ($_POST) {
         if (isset($_POST['TxId'])) {
             $txnid = $_POST['TxId'];
             $data .= $txnid;
         }
         if (isset($_POST['TxStatus'])) {
             $txnstatus = $_POST['TxStatus'];
             $data .= $txnstatus;
         }
         if (isset($_POST['amount'])) {
             $amount = $_POST['amount'];
             $data .= $amount;
         }
         if (isset($_POST['pgTxnNo'])) {
             $pgtxnno = $_POST['pgTxnNo'];
             $data .= $pgtxnno;
         }
         if (isset($_POST['issuerRefNo'])) {
             $issuerrefno = $_POST['issuerRefNo'];
             $data .= $issuerrefno;
         }
         if (isset($_POST['authIdCode'])) {
             $authidcode = $_POST['authIdCode'];
             $data .= $authidcode;
         }
         if (isset($_POST['firstName'])) {
             $firstName = $_POST['firstName'];
             $data .= $firstName;
         }
         if (isset($_POST['lastName'])) {
             $lastName = $_POST['lastName'];
             $data .= $lastName;
         }
         if (isset($_POST['pgRespCode'])) {
             $pgrespcode = $_POST['pgRespCode'];
             $data .= $pgrespcode;
         }
         if (isset($_POST['addressZip'])) {
             $pincode = $_POST['addressZip'];
             $data .= $pincode;
         }
         if (isset($_POST['signature'])) {
             $signature = $_POST['signature'];
         }
         /*signature data end*/
         $respSignature = $this->generateHmacKey($data, $secretKey);
         if ($signature != "" && strcmp($signature, $respSignature) != 0 || $orderAmount != $amount) {
             $flag = "dataTampered";
         } else {
             $flag = "dataValid";
         }
         if (strtoupper($txnstatus) != "SUCCESS") {
             $flag = "dataTampered";
         } else {
             $flag = "dataValid";
         }
     }
     $debug = Mage::getModel('citrus/api_debug')->load($TxnID, "transact_id");
     $debug->setResponseBody($data);
     $debug->save();
     if ($flag == "dataValid") {
         $_order = new Mage_Sales_Model_Order();
         $orderId = $session->getLastRealOrderId();
         $_order->loadByIncrementId($orderId);
         $_order->sendNewOrderEmail();
         try {
             $payment = $_order->getPayment();
             $payment->setTransactionId($TxnID)->capture(null);
             $_order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true);
             $_order->setStatus('created');
             $_order->addStatusToHistory($_order->getStatus(), Mage::helper('citrus')->__('Customer successfully returned from citrus'));
             $_order->save();
         } catch (Exception $e) {
             Mage::logException($e);
             //if we couldn't capture order, just leave it as NEW order.
         }
         $session->getQuote()->setIsActive(false)->save();
         $this->_redirect('checkout/onepage/successcitrus', array('_secure' => true));
     } else {
         if (strtoupper($txnstatus) == "CANCELED") {
             $cartURL = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_WEB) . "checkout/cart/";
             echo "<script language='javascript' type='text/javascript'>setTimeout('window.self.location=\\'" . $cartURL . "\\''); </script>";
             exit;
         } else {
             $this->_redirect('checkout/onepage/failure', array('_secure' => true));
         }
     }
 }
Ejemplo n.º 10
0
 /**
  * Add comment to order
  *
  * @param  Mage_Sales_Model_Order   		$order
  * @param  string                   		$comment
  * @param  boolean  						$isShipmentSuccessfullyCreated
  *
  * @return void
  */
 public function addCommentToOrder(Mage_Sales_Model_Order $order, $comment, $isShipmentSuccessfullyCreated = false)
 {
     /*
      * for Magento 1.4.x.x
      */
     if (true === $this->getConfig()->isVersionRecommendedOrLarger()) {
         $order->addStatusHistoryComment($comment)->setIsVisibleOnFront(false)->setIsCustomerNotified(false)->save();
         /*
          * for Magento 1.3.x.x
          */
     } else {
         //Get existing order status
         $status = $order->getStatus();
         //If shipment was created successfully
         if (true === $isShipmentSuccessfullyCreated) {
             $status = Mage_Sales_Model_Order::STATE_PROCESSING;
         }
         //Is status is empty, take state
         if ($status == "") {
             $status = $order->getState();
         }
         if (false === $isShipmentSuccessfullyCreated) {
             /*
              * reload the order to avoid that unwanted order data is saved | SEE DHLIS-181
              *  Order Items are set as shipped in CE 1.3 even if there was an exception
              */
             $order = Mage::getModel('sales/order')->load($order->getId());
         }
         $order->addStatusToHistory($status, $comment)->save();
     }
 }
Ejemplo n.º 11
0
 /**
  * Perform order state and status assertions depending on currency code
  *
  * @param Mage_Sales_Model_Order $order
  * @param string $currencyCode
  */
 protected function _assertOrder($order, $currencyCode)
 {
     if ($currencyCode == 'USD') {
         $this->assertEquals('complete', $order->getState());
         $this->assertEquals('complete', $order->getStatus());
     } else {
         $this->assertEquals('payment_review', $order->getState());
         $this->assertEquals('fraud', $order->getStatus());
     }
 }
Ejemplo n.º 12
0
 /**
  * Return the order data in an array for easy processing 
  *
  * @param Mage_Sales_Model_Order $order
  * @return array
  */
 protected function getOrderData($order)
 {
     $data = array();
     $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
     $billingAddress = $order->getBillingAddress();
     $data['OrderNumber'] = $order->getRealOrderId();
     //$data['OrderCreated'] = Mage::helper('core')->formatDate($order->getCreatedAt(), 'medium', true);
     //$data['OrderUpdated'] = Mage::helper('core')->formatDate($order->getUpdatedAt(), 'medium', true);
     //$data['OrderCreated'] = $order->getCreatedAt();
     //$data['OrderUpdated'] = $order->getUpdatedAt();
     $dateCreated = Mage::app()->getLocale()->date(strtotime($order->getCreatedAt()), null, null);
     $dateCreated = $dateCreated->toString('yyyy-MM-dd HH:mm:ss');
     $dateUpdated = Mage::app()->getLocale()->date(strtotime($order->getUpdatedAt()), null, null);
     $dateUpdated = $dateUpdated->toString('yyyy-MM-dd HH:mm:ss');
     $data['OrderCreated'] = $dateCreated;
     $data['OrderUpdated'] = $dateUpdated;
     $data['Status'] = $order->getStatus();
     $data['PurchasedFrom'] = $this->getStoreName($order);
     if (strtolower($this->getPaymentMethod($order)) == 'paytm_cc') {
         $data['PaymentMethod'] = 'Paytm-wallet';
     } else {
         if (strtolower($this->getPaymentMethod($order)) == 'payumoney_shared') {
             $data['PaymentMethod'] = 'Payumoney-wallet';
         } else {
             $data['PaymentMethod'] = $this->getPaymentMethod($order) == "free" ? 'prepaid' : $this->getPaymentMethod($order);
         }
     }
     $data['ShippingMethod'] = $this->getShippingMethod($order);
     //Shipping Provider
     $data['ShippingProvider'] = $order->getData('blinkecarrier_id');
     //$data['ExpectedDeliveryDate'] = $order->getData('shipping_arrival_date');
     $expectedDelivery = $order->getData('shipping_arrival_date');
     if (is_null($expectedDelivery)) {
         $dateDelivery = "";
     } else {
         $dateDelivery = Mage::app()->getLocale()->date(strtotime($order->getData('shipping_arrival_date')), null, null);
         $dateDelivery = $dateDelivery->toString('yyyy-MM-dd 00:00:00');
     }
     $data['ExpectedDeliveryDate'] = $dateDelivery;
     $timeSlot = $order->getData('shipping_time_slot');
     if (is_null($timeSlot)) {
         $timeSlot = "";
     }
     $data['ExpectedTimeSlot'] = $timeSlot;
     $data['Currency'] = $order->getOrderCurrencyCode();
     $data['ExchangeRate'] = $order->getBaseToOrderRate();
     $data['Subtotal'] = $order->getData('subtotal');
     $data['Tax'] = $order->getData('tax_amount');
     //VAT is for Delhi and CST for other states
     if ($shippingAddress->getRegionCode() == 'IN-DL') {
         $data['TaxCategory'] = 'VAT';
     } else {
         $data['TaxCategory'] = 'CST';
     }
     $data['ShippingAmount'] = $order->getData('shipping_amount');
     $data['Discount'] = $order->getData('discount_amount');
     $data['ShippingDiscountAmount'] = $order->getData('shipping_discount_amount');
     $data['RewardsDiscountAmount'] = $order->getData('rewards_discount_amount');
     $data['GrandTotal'] = $order->getData('grand_total');
     $data['TotalPaid'] = $order->getData('total_paid');
     $data['TotalRefunded'] = $order->getData('total_refunded');
     $data['TotalDue'] = $order->getData('total_due');
     $data['TotalInvoiced'] = $this->getTotalQtyItemsOrdered($order);
     $data['TotalQtyItemsOrdered'] = $this->getTotalQtyItemsOrdered($order);
     $data['Weight'] = $order->getWeight();
     $data['CustomerName'] = $order->getCustomerName();
     $data['CustomerFirstName'] = $order->getCustomerFirstname();
     $data['CustomerLastName'] = $order->getCustomerLastname();
     $data['CustomerMiddleName'] = $order->getCustomerMiddlename();
     $data['CustomerEmail'] = $order->getCustomerEmail();
     //Billing Address
     $data['BillToTitle'] = $billingAddress->getPrefix();
     $data['BillToName'] = $billingAddress->getName();
     $data['BillToFirstName'] = $billingAddress->getFirstname();
     $data['BillToLastName'] = $billingAddress->getLastname();
     $data['BillToMiddleName'] = $billingAddress->getMiddlename();
     $data['BillToAddressStreet'] = $billingAddress->getData("street");
     $data['BillToCity'] = $billingAddress->getData("city");
     $data['BillToRegionCode'] = $billingAddress->getRegionCode();
     $data['BillToRegion'] = $billingAddress->getRegion();
     $data['BillToCountry'] = $billingAddress->getCountry();
     $data['BillToCountryName'] = $billingAddress->getCountryModel()->getName();
     $data['BillToPostalCode'] = $billingAddress->getData("postcode");
     $billPhoneNumber = $billingAddress->getData("telephone");
     $data['BillToCustomerPhoneNum'] = $billPhoneNumber;
     $data['BillToEmail'] = $billingAddress->getData("email");
     //Shipping Address
     $data['ShipToTitle'] = $shippingAddress ? $shippingAddress->getPrefix() : '';
     $data['ShipToName'] = $shippingAddress ? $shippingAddress->getName() : '';
     $data['ShipToFirstName'] = $shippingAddress ? $shippingAddress->getFirstname() : '';
     $data['ShipToLastName'] = $shippingAddress ? $shippingAddress->getLastname() : '';
     $data['ShipToMiddleName'] = $shippingAddress ? $shippingAddress->getMiddlename() : '';
     $data['ShipToAddressStreet'] = $shippingAddress ? $shippingAddress->getData("street") : '';
     $data['ShipToCity'] = $shippingAddress ? $shippingAddress->getData("city") : '';
     $data['ShipToRegionCode'] = $shippingAddress ? $shippingAddress->getRegionCode() : '';
     $data['ShipToRegion'] = $shippingAddress ? $shippingAddress->getRegion() : '';
     $data['ShipToCountry'] = $shippingAddress ? $shippingAddress->getCountry() : '';
     $data['ShipToCountryName'] = $shippingAddress ? $shippingAddress->getCountryModel()->getName() : '';
     $data['ShipToPostalCode'] = $shippingAddress ? $shippingAddress->getData("postcode") : '';
     $shipPhoneNumber = $shippingAddress ? $shippingAddress->getData("telephone") : '';
     if (!empty($shipPhoneNumber) and $shipPhoneNumber != '-') {
         $data['ShipToCustomerPhoneNum'] = $shipPhoneNumber;
     } else {
         $data['ShipToCustomerPhoneNum'] = $billPhoneNumber;
     }
     $data['ShipToEmail'] = $shippingAddress ? $shippingAddress->getData("email") : '';
     if ($this->getPaymentMethod($order) == 'free') {
         $orderDetails = $order->getData();
         //check for store credit or gv
         if (isset($orderDetails['customer_balance_amount']) && $orderDetails['customer_balance_amount'] > 0) {
             $data['PaymentType'] = 'StoreCredit';
         } else {
             if ($order->getGiftCardsAmount() > 0) {
                 $data['PaymentType'] = 'GiftVoucherCode';
             }
         }
     } else {
         if (strtolower($this->getPaymentMethod($order)) == 'paytm_cc') {
             $data['PaymentType'] = 'Paytm-wallet';
         } else {
             if (strtolower($this->getPaymentMethod($order)) == 'payumoney_shared') {
                 $data['PaymentType'] = 'Payumoney-wallet';
             } else {
                 $data['PaymentType'] = $this->getPaymentMethod($order) == 'cashondelivery' ? 'COD' : $this->getPaymentMethod($order);
             }
         }
     }
     return $data;
 }
Ejemplo n.º 13
0
 /**
  * Process Configured Payment Action: Direct Sale, create invoce if state is Pending
  *
  * @param Mage_Sales_Model_Order $order  Order
  * @param array                  $params Request params
  */
 protected function _processDirectSale($order, $params, $instantCapture = 0)
 {
     Mage::register('postfinance_auto_capture', true);
     $status = $params['STATUS'];
     if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AWAIT_CUSTOMER_PAYMENT) {
         $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Waiting for the payment of the customer'));
         $order->save();
     } elseif ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED_WAITING) {
         $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('postfinance')->__('Authorization waiting from PostFinance'));
         $order->save();
     } elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) {
         if ($status == PostFinance_Payment_Model_Payment_Abstract::POSTFINANCE_AUTHORIZED) {
             if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
                 $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance'));
             }
         } else {
             $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('postfinance')->__('Processed by PostFinance'));
         }
         if (!$order->getInvoiceCollection()->getSize()) {
             $invoice = $order->prepareInvoice();
             $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
             $invoice->register();
             $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
             $invoice->getOrder()->setIsInProcess(true);
             $invoice->save();
             $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
             /*
              * If the payment method is a redirect-payment-method send the email
              * In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder
              */
             if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() !== '1') {
                 $order->sendNewOrderEmail();
             }
         }
     } else {
         $order->save();
     }
 }
Ejemplo n.º 14
0
 /**
  * Returns the values which are identical for each row of the given order. These are
  * all the values which are not item specific: order data, shipping address, billing
  * address and order totals.
  * 
  * @param Mage_Sales_Model_Order $order The order to get values from
  * @return Array The array containing the non item specific values
  */
 protected function getCommonOrderValues($order)
 {
     $shippingAddress = !$order->getIsVirtual() ? $order->getShippingAddress() : null;
     $billingAddress = $order->getBillingAddress();
     return array($order->getRealOrderId(), Mage::helper('core')->formatDate($order->getCreatedAt(), 'medium', true), $order->getStatus(), $this->getStoreName($order), $this->getPaymentMethod($order), $this->getShippingMethod($order), $this->formatPrice($order->getData('subtotal'), $order), $this->formatPrice($order->getData('tax_amount'), $order), $this->formatPrice($order->getData('shipping_amount'), $order), $this->formatPrice($order->getData('discount_amount'), $order), $this->formatPrice($order->getData('grand_total'), $order), $this->formatPrice($order->getData('base_grand_total'), $order), $this->formatPrice($order->getData('total_paid'), $order), $this->formatPrice($order->getData('total_refunded'), $order), $this->formatPrice($order->getData('total_due'), $order), $this->getTotalQtyItemsOrdered($order), $order->getCustomerName(), $order->getCustomerEmail(), $shippingAddress ? $shippingAddress->getName() : '', $shippingAddress ? $shippingAddress->getData("company") : '', $shippingAddress ? $shippingAddress->getData("street") : '', $shippingAddress ? $shippingAddress->getData("postcode") : '', $shippingAddress ? $shippingAddress->getData("city") : '', $shippingAddress ? $shippingAddress->getRegionCode() : '', $shippingAddress ? $shippingAddress->getRegion() : '', $shippingAddress ? $shippingAddress->getCountry() : '', $shippingAddress ? $shippingAddress->getCountryModel()->getName() : '', $shippingAddress ? $shippingAddress->getData("telephone") : '', $billingAddress->getName(), $billingAddress->getData("company"), $billingAddress->getData("street"), $billingAddress->getData("postcode"), $billingAddress->getData("city"), $billingAddress->getRegionCode(), $billingAddress->getRegion(), $billingAddress->getCountry(), $billingAddress->getCountryModel()->getName(), $billingAddress->getData("telephone"));
 }
Ejemplo n.º 15
0
 /**
  * @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;
 }
Ejemplo n.º 16
0
 /**
  * @param PagSeguroSummaryItem $PagSeguroSummaryItem
  * @param Mage_Sales_Model_Order $order
  * @return multitype:date string NULL Ambigous <boolean, string, string, multitype:>
  */
 public function build($payment, $order)
 {
     $config = $order->getId() . '/' . $payment->getCode() . '/' . $this->getPaymentStatusFromKey($payment->getStatus()->getValue(), true);
     $checkbox = "<label class='chk_email'>";
     $checkbox .= "<input type='checkbox' name='conciliation_orders[]' class='checkbox' data-config='" . $config . "' />";
     $checkbox .= "</label>";
     // Receives the full html link to edit an order
     $editOrder = "<a class='edit' target='_blank' href='" . $this->getEditOrderUrl($order->getEntityId()) . "'>";
     $editOrder .= $this->__('Ver detalhes') . "</a>";
     return array('checkbox' => $checkbox, 'date' => $this->getOrderMagetoDateConvert($order->getCreatedAt()), 'id_magento' => "#" . $order->getIncrementId(), 'id_pagseguro' => $payment->getCode(), 'status_magento' => $this->getPaymentStatusToString($this->getPaymentStatusFromValue($order->getStatus())), 'status_pagseguro' => $this->getPaymentStatusToString($payment->getStatus()->getValue()), 'edit' => $editOrder);
 }
Ejemplo n.º 17
0
 /**
  * Loads the status info from a Magento order model.
  *
  * @param Mage_Sales_Model_Order $order the order model.
  */
 public function loadData(Mage_Sales_Model_Order $order)
 {
     $this->_code = $order->getStatus();
     $this->_label = $order->getStatusLabel();
 }
Ejemplo n.º 18
0
 /**
  * Loads the order info from a Magento order model.
  *
  * @param Mage_Sales_Model_Order $order the order model.
  */
 public function loadData(Mage_Sales_Model_Order $order)
 {
     $this->_orderNumber = $order->getId();
     $this->_externalOrderRef = $order->getRealOrderId();
     $this->_createdDate = $order->getCreatedAt();
     $this->_paymentProvider = $order->getPayment()->getMethod();
     $this->_orderStatus = Mage::getModel('nosto_tagging/meta_order_status', array('code' => $order->getStatus(), 'label' => $order->getStatusLabel()));
     foreach ($order->getAllStatusHistory() as $item) {
         /** @var Mage_Sales_Model_Order_Status_History $item */
         $this->_orderStatuses[] = Mage::getModel('nosto_tagging/meta_order_status', array('code' => $item->getStatus(), 'label' => $item->getStatusLabel(), 'createdAt' => $item->getCreatedAt()));
     }
     $this->_buyer = Mage::getModel('nosto_tagging/meta_order_buyer', array('firstName' => $order->getCustomerFirstname(), 'lastName' => $order->getCustomerLastname(), 'email' => $order->getCustomerEmail()));
     foreach ($order->getAllVisibleItems() as $item) {
         /** @var $item Mage_Sales_Model_Order_Item */
         $this->_items[] = $this->buildItem($item, $order);
     }
     if ($this->includeSpecialItems) {
         if (($discount = $order->getDiscountAmount()) > 0) {
             /** @var Nosto_Tagging_Model_Meta_Order_Item $orderItem */
             $this->_items[] = Mage::getModel('nosto_tagging/meta_order_item', array('productId' => -1, 'quantity' => 1, 'name' => 'Discount', 'unitPrice' => $discount, 'currencyCode' => $order->getOrderCurrencyCode()));
         }
         if (($shippingInclTax = $order->getShippingInclTax()) > 0) {
             /** @var Nosto_Tagging_Model_Meta_Order_Item $orderItem */
             $this->_items[] = Mage::getModel('nosto_tagging/meta_order_item', array('productId' => -1, 'quantity' => 1, 'name' => 'Shipping and handling', 'unitPrice' => $shippingInclTax, 'currencyCode' => $order->getOrderCurrencyCode()));
         }
     }
 }
 public function SFAResponseAction()
 {
     include "Sfa/EncryptionUtil.php";
     $config = Mage::getSingleton('payseal/config');
     $merchantId = trim($config->getMerchantId());
     $keyPath = str_replace("/", "//", $config->getKeyPath()) . $merchantId . ".key";
     $strMerchantId = $merchantId;
     $astrFileName = $keyPath;
     $astrClearData;
     $ResponseCode = "";
     $Message = "";
     $TxnID = "";
     $ePGTxnID = "";
     $AuthIdCode = "";
     $RRN = "";
     $CVRespCode = "";
     $session = Mage::getSingleton('checkout/session');
     $session->setData("redirected", "false");
     if ($_POST) {
         if ($_POST['DATA'] == null) {
             print "null is the value";
         }
         $astrResponseData = $_POST['DATA'];
         $astrDigest = $_POST['EncryptedData'];
         $oEncryptionUtilenc = new EncryptionUtil();
         $astrsfaDigest = $oEncryptionUtilenc->getHMAC($astrResponseData, $astrFileName, $strMerchantId);
         if (strcasecmp($astrDigest, $astrsfaDigest) == 0) {
             parse_str($astrResponseData, $output);
             if (array_key_exists('RespCode', $output) == 1) {
                 $ResponseCode = $output['RespCode'];
             }
             if (array_key_exists('Message', $output) == 1) {
                 $Message = $output['Message'];
             }
             if (array_key_exists('TxnID', $output) == 1) {
                 $TxnID = $output['TxnID'];
             }
             if (array_key_exists('ePGTxnID', $output) == 1) {
                 $ePGTxnID = $output['ePGTxnID'];
             }
             if (array_key_exists('AuthIdCode', $output) == 1) {
                 $AuthIdCode = $output['AuthIdCode'];
             }
             if (array_key_exists('RRN', $output) == 1) {
                 $RRN = $output['RRN'];
             }
             if (array_key_exists('CVRespCode', $output) == 1) {
                 $CVRespCode = $output['CVRespCode'];
             }
         }
     }
     $debug = Mage::getModel('payseal/api_debug')->load($TxnID, "transact_id");
     $debug->setResponseBody(print_r($output, 1));
     $debug->save();
     if ($output['RespCode'] == 2 && $Message == "No Suitable Acquirer Found" || $output['RespCode'] == 0) {
         $_order = new Mage_Sales_Model_Order();
         $orderId = $session->getLastRealOrderId();
         $_order->loadByIncrementId($orderId);
         $_order->sendNewOrderEmail();
         try {
             $payment = $_order->getPayment();
             $payment->setTransactionId($TxnID)->capture(null);
             $_order->setStatus('created');
             $_order->addStatusToHistory($_order->getStatus(), Mage::helper('payseal')->__('Customer successfully returned from payseal'));
             $_order->save();
         } catch (Exception $e) {
             Mage::logException($e);
             //if we couldn't capture order, just leave it as NEW order.
         }
         $session->getQuote()->setIsActive(false)->save();
         $this->_redirect('checkout/onepage/success', array('_secure' => true));
     } else {
         $this->_redirect('checkout/onepage/failure', array('_secure' => true));
     }
 }
Ejemplo n.º 20
0
 /**
  * @param PagSeguroSummaryItem $PagSeguroSummaryItem
  * @param Mage_Sales_Model_Order $order
  * @return multitype:date string NULL Ambigous <boolean, string, string, multitype:>
  */
 public function build($PagSeguroSummaryItem, $order)
 {
     $PagSeguroStatusValue = $this->getPaymentStatusFromKey($PagSeguroSummaryItem->getStatus()->getValue());
     if ($order->getStatus() == $PagSeguroStatusValue) {
         $config = "class='action' data-config='" . $order->getId() . '/' . $PagSeguroSummaryItem->getCode() . '/' . $this->getPaymentStatusFromKey($PagSeguroSummaryItem->getStatus()) . "'";
     } else {
         $config = " onclick='Modal.alertConciliation(&#34;" . $this->alertConciliation($this->__('estornar')) . "&#34;)'";
     }
     $actionOrder = "<a class='edit' target='_blank' href='" . $this->getEditOrderUrl($order->getId()) . "'>";
     $actionOrder .= $this->__('Ver detalhes') . "</a>";
     $actionOrder .= "<a " . $config . " href='javascript:void(0)'>";
     $actionOrder .= $this->__('Estornar') . "</a>";
     return array('date' => $this->getOrderMagetoDateConvert($order->getCreatedAt()), 'id_magento' => $order->getIncrementId(), 'id_pagseguro' => $PagSeguroSummaryItem->getCode(), 'status_magento' => $this->getPaymentStatusToString($this->getPaymentStatusFromValue($order->getStatus())), 'action' => $actionOrder);
 }
Ejemplo n.º 21
0
 /**
  * Process Configured Payment Action: Direct Sale, create invoice if state is Pending
  *
  * @param Mage_Sales_Model_Order $order Order
  * @param array $params Request params
  */
 protected function _processDirectSale($order, $params, $instantCapture = 0)
 {
     Mage::register('ops_auto_capture', true);
     $status = $params['STATUS'];
     if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AWAIT_CUSTOMER_PAYMENT) {
         $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Waiting for the payment of the customer'));
         // send new order mail for bank transfer, since it is 'successfully' authorized at this point
         if ($order->getPayment()->getMethodInstance() instanceof Netresearch_OPS_Model_Payment_BankTransfer && $order->getEmailSent() != 1) {
             $order->sendNewOrderEmail();
         }
         $order->save();
     } elseif ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED_WAITING) {
         $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PENDING_PAYMENT, Mage::helper('ops')->__('Authorization waiting from Barclaycard'));
         $order->save();
     } elseif ($order->getState() == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT || $instantCapture) {
         if ($status == Netresearch_OPS_Model_Payment_Abstract::OPS_AUTHORIZED) {
             if ($order->getStatus() != Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
                 $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, Mage_Sales_Model_Order::STATE_PROCESSING, Mage::helper('ops')->__('Processed by Barclaycard'));
             }
         } else {
             $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true, Mage::helper('ops')->__('Processed by Barclaycard'));
             $order->save();
         }
         if (!$order->getInvoiceCollection()->getSize() && $order->getState() == Mage_Sales_Model_Order::STATE_PROCESSING && $order->canInvoice()) {
             $invoice = $order->prepareInvoice();
             $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
             $invoice->register();
             $invoice->setState(Mage_Sales_Model_Order_Invoice::STATE_PAID);
             $invoice->getOrder()->setIsInProcess(true);
             $invoice->save();
             $this->sendInvoiceToCustomer($invoice);
             $transactionSave = Mage::getModel('core/resource_transaction')->addObject($invoice)->addObject($invoice->getOrder())->save();
             /*
              * If the payment method is a redirect-payment-method send the email
              * In any other case Magento sends an email automatically in Mage_Checkout_Model_Type_Onepage::saveOrder
              */
             if ($this->isRedirectPaymentMethod($order) === true && $order->getEmailSent() != 1) {
                 $order->sendNewOrderEmail();
             }
             $eventData = array('data_object' => $order, 'order' => $order);
             Mage::dispatchEvent('ops_sales_order_save_commit_after', $eventData);
         }
         if ($this->isInlinePayment($order->getPayment()) && 0 < strlen(trim($order->getPayment()->getAdditionalInformation('HTML_ANSWER'))) && $order->getPayment()->getAdditionalInformation('status') == Netresearch_OPS_Model_Payment_Abstract::OPS_PAYMENT_REQUESTED) {
             $order->getPayment()->setIsTransactionApproved(true)->registerPaymentReviewAction(Mage_Sales_Model_Order_Payment::REVIEW_ACTION_UPDATE, true)->save();
             $this->setInvoicesToPaid($order);
             $order->getPayment()->getAuthorizationTransaction()->setIsClosed(true)->save();
             $order->getPayment()->addTransaction(Mage_Sales_Model_Order_Payment_Transaction::TYPE_CAPTURE, $order->getPayment())->setIsClosed(true)->save();
             $order->sendNewOrderEmail();
             $order->save();
         }
         if ($this->isInlinePayment($order->getPayment()) && Mage::getModel('ops/config')->getSendInvoice() && Mage::getModel('ops/config')->getPaymentAction($order->getStoreId()) === Mage_Payment_Model_Method_Abstract::ACTION_AUTHORIZE_CAPTURE) {
             foreach ($order->getInvoiceCollection() as $invoice) {
                 $this->sendInvoiceToCustomer($invoice);
             }
         }
     } else {
         $order->save();
     }
 }