Ejemplo n.º 1
0
 /**
  * This overwritten function send after the mail to the admin an email to the customer as well
  * @author Manuel Neukum m.neukum@narf-studios.de
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     // Send first the email to the admin
     parent::sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage');
     // Load the HTML template from the Backend
     $template = Mage::getStoreConfig('checkout/payment_failed/template_customer', $checkout->getStoreId());
     // Check coupon configuration
     $isCoupon = Mage::getStoreConfig('checkout/payment_failed/coupon');
     Mage::log($isCoupon . '_' . Mage::getStoreConfig('checkout/payment_failed/coupon_value'), null, 'system.log');
     if ($isCoupon === 1 || $isCoupon === '1') {
         $isCoupon = 1;
         // Generate Groupon code
         $coupon = $this->generateCouponCode($checkout->getCustomerLastname());
     }
     // no coupon or valid coupon otherwise error
     if ($isCoupon !== 1 || is_object($coupon) && $coupon !== false) {
         // prepare variables for mail
         $array = array('reason' => $message, 'dateAndTime' => Mage::app()->getLocale()->date(), 'customer' => $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), 'billingAddress' => $checkout->getBillingAddress(), 'shippingAddress' => $checkout->getShippingAddress());
         // add the coupon variables
         if ($isCoupon === 1) {
             $array['couponValue'] = $coupon->getDiscountAmount();
             $array['couponCode'] = $coupon->getCouponCode();
             $array['currency'] = Mage::app()->getStore()->getCurrentCurrencyCode();
         }
         $mailTemplate = Mage::getModel('core/email_template');
         $mailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $checkout->getStoreId()))->sendTransactional($template, Mage::getStoreConfig('checkout/payment_failed/identity', $checkout->getStoreId()), $checkout->getCustomerEmail(), $checkout->getCustomerFirstname() . ' ' . $checkout->getCustomerLastname(), $array);
     } else {
         Mage::log($isCoupon, null, 'system.log');
         Mage::log('No mail send to customer because coupon could not be initialized', null, 'system.log');
     }
 }
Ejemplo n.º 2
0
 /**
  * Validate quote state to be integrated with obe page checkout process
  */
 public function validate()
 {
     $helper = Mage::helper('checkout');
     $quote = $this->getQuote();
     if ($quote->getIsMultiShipping()) {
         Mage::throwException($helper->__('Invalid checkout type.'));
     }
     if ($quote->getCheckoutMethod() == self::METHOD_GUEST && !$quote->isAllowedGuestCheckout()) {
         Mage::throwException($this->_helper->__('Sorry, guest checkout is not enabled. Please try again or contact store owner.'));
     }
 }
Ejemplo n.º 3
0
 /**
  * Get quote checkout method
  *
  * @return string
  */
 public function getCheckoutMethod()
 {
     if ($this->getCustomerSession()->isLoggedIn()) {
         return self::METHOD_CUSTOMER;
     }
     if (!$this->getQuote()->getCheckoutMethod()) {
         if ($this->_helper->isAllowedGuestCheckout($this->getQuote())) {
             $this->getQuote()->setCheckoutMethod(self::METHOD_GUEST);
         } else {
             $this->getQuote()->setCheckoutMethod(self::METHOD_REGISTER);
         }
     }
     return $this->getQuote()->getCheckoutMethod();
 }
 /**
  * Submit the order
  */
 public function placeOrderAction()
 {
     try {
         $requiredAgreements = $this->_checkoutHelper->getRequiredAgreementIds();
         if ($requiredAgreements) {
             $postedAgreements = array_keys($this->getRequest()->getPost('agreement', array()));
             if (array_diff($requiredAgreements, $postedAgreements)) {
                 Mage::throwException($this->_helper->__('Please agree to all the terms and conditions before placing the order.'));
             }
         }
         $this->_initCheckout();
         $this->_checkout->place($this->_initToken());
         // prepare session to success or cancellation page
         $session = $this->_getCheckoutSession();
         $session->clearHelperData();
         // last successful quote
         $quoteId = $this->_getQuote()->getId();
         $session->setLastQuoteId($quoteId)->setLastSuccessQuoteId($quoteId);
         // an order may be created
         $order = $this->_checkout->getOrder();
         if ($order) {
             $session->setLastOrderId($order->getId())->setLastRealOrderId($order->getIncrementId());
         }
         $this->_initToken(false);
         // no need in token anymore
         $this->_redirect('checkout/onepage/success');
         return;
     } catch (EbayEnterprise_PayPal_Exception $e) {
         $this->_checkoutHelper->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
         $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
         // If a PayPal exception is thrown while trying to place the order,
         // the PayPal transaction failed or was voided and customer needs to
         // begin PayPal flow again. Place error message in checkout session
         // so it will be displayed in the cart and redirect back to the cart
         // for the checkout flow to begin again.
         $this->_getCheckoutSession()->addError($e->getMessage());
         $this->_redirect('checkout/cart');
     } catch (Mage_Core_Exception $e) {
         $this->_checkoutHelper->sendPaymentFailedEmail($this->_getQuote(), $e->getMessage());
         $this->_getSession()->addError($e->getMessage());
         $this->_redirect('*/*/review');
     } catch (Exception $e) {
         $this->_checkoutHelper->sendPaymentFailedEmail($this->_getQuote(), $this->__('Unable to place the order.'));
         $this->_getSession()->addError($this->__('Unable to place the order.'));
         $this->_logger->logException($e, $this->_context->getMetaData(__CLASS__, [], $e));
         $this->_redirect('*/*/review');
     }
 }
Ejemplo n.º 5
0
 /**
  * Send email id payment was failed
  *
  * @param Mage_Sales_Model_Quote $checkout
  * @param string $message
  * @param string $checkoutType
  * @return Mage_Checkout_Helper_Data
  */
 public function sendPaymentFailedEmail($checkout, $message, $checkoutType = 'onepage')
 {
     parent::sendPaymentFailedEmail($checkout, $message, $checkoutType);
     $this->sendPaymentFailedEmailToCustomer($checkout, $message, $checkoutType);
 }
 /**
  * Localize and format the price
  *
  * @param float
  * @return string
  */
 protected function _formatPrice($amount)
 {
     return $this->_checkoutHelper->formatPrice($amount);
 }