/**
  * Perform the final steps needed to finish an AIM web order
  *
  * @return array|bool
  * @throws Exception
  */
 public function executeCheckoutProcess()
 {
     $objCart = Yii::app()->shoppingcart;
     if ($objCart->payment_id === null) {
         throw new Exception('Cart must have an associated payment.');
     }
     self::executeCheckoutProcessInit();
     // save ids that we need for after finalization
     $cartlink = $objCart->linkid;
     $id = $objCart->id;
     // run payment and finalize order
     if ($this->runPayment($objCart->payment_id) === false) {
         return false;
     }
     // send emails
     Checkout::sendEmails($id);
     // awesome.
     return array('success' => true, 'cartlink' => $cartlink);
 }
Пример #2
0
 /**
  *
  * TODO: Remove this function and incorporate the one in the Checkout Component instead.
  * Also verify if the ecp variable is still necessary
  *
  * Final steps in completing cart and recalculating inventory numbers.
  *
  * @param null ShoppingCart $objCart
  *
  * @param bool $performInternalFinalizeSteps
  * if true, it's either an IPN-like transaction, an AIM payment, or a
  * an alternative payment method (ex. cash on delivery). So we can
  * handle the final steps within Web Store. If false, it's a SIM credit
  * card transaction and we ignore those steps which will allow for
  * the calling action to echo an html meta refresh which redirects the
  * customer to Web Store's receipt page. We have to do this since some
  * processors try to render the receipt page on their own domain and
  * we don't want that since the necessary CSS won't be available.
  *
  * @param bool $ecp
  * If ecp (executeCheckoutProcess, a function from the Checkout controller)
  * is true, do not redirect to receipt.
  *
  * @return void
  */
 public static function FinalizeCheckout($objCart = null, $performInternalFinalizeSteps = true, $ecp = false)
 {
     Yii::log("Finalizing checkout", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
     if (!$objCart) {
         $objCart = Yii::app()->shoppingcart;
     }
     unset(Yii::app()->session['checkout.cache']);
     self::PreFinalizeHooks($objCart);
     //Send receipt e-mails in the queue
     Checkout::sendEmails($objCart->id);
     // Mark as successful order, ready to download.
     Yii::log("Marking as " . OrderStatus::AwaitingProcessing, 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
     $objCart->cart_type = CartType::order;
     $objCart->status = OrderStatus::AwaitingProcessing;
     $objCart->UpdateWishList();
     //if we are supposed to delete anything
     $objCart->save();
     // Cart items get updated too.
     foreach ($objCart->cartItems as $item) {
         $item->cart_type = CartType::order;
         $item->save();
     }
     $objCart->RecalculateInventoryOnCartItems();
     $strLinkId = $objCart->linkid;
     $objCart->payment->markCompleted();
     self::PostFinalizeHooks($objCart);
     if ($performInternalFinalizeSteps === true) {
         //If we're behind a common SSL and we want to stay logged in
         if (Yii::app()->isCommonSSL && $objCart->customer->record_type != Customer::GUEST) {
             Yii::app()->user->setState('sharedssl', 1);
         }
         //If we were in as guest, immediately log out of guest account
         if ($objCart->customer->record_type == Customer::GUEST && Yii::app()->theme->info->advancedCheckout === false) {
             Yii::app()->user->logout();
         }
         //Redirect to our receipt, we're done
         Yii::app()->shoppingcart->releaseCart();
         Yii::log("Redirecting to receipt, thank you for coming, exit through the gift shop.", 'info', 'application.' . __CLASS__ . "." . __FUNCTION__);
         if (!$ecp) {
             self::redirectToReceipt($strLinkId);
         }
     }
 }