private function createTransactionContextFromContext(Customweb_Payment_ExternalCheckout_IContext $context)
 {
     if (!$context instanceof Customweb_SaferpayCw_Model_ExternalCheckoutContext) {
         throw new Customweb_Core_Exception_CastException('Customweb_SaferpayCw_Model_ExternalCheckoutContext');
     }
     $this->redirectOnEmptyBasket();
     $quote = $context->getQuote();
     $quote->collectTotals()->save();
     $isNewCustomer = false;
     switch ($context->getRegisterMethod()) {
         case 'guest':
             $this->prepareGuestQuote($context);
             break;
         case 'register':
             $this->prepareNewCustomerQuote($context);
             $isNewCustomer = true;
             break;
         default:
             $this->prepareCustomerQuote($context);
             break;
     }
     $quote->getBillingAddress()->setShouldIgnoreValidation(true);
     $quote->getShippingAddress()->setShouldIgnoreValidation(true);
     $service = Mage::getModel('sales/service_quote', $quote);
     $service->submitAll();
     if ($isNewCustomer) {
         try {
             $this->involveNewCustomer($context);
         } catch (Exception $e) {
             Mage::helper('SaferpayCw')->logException($e);
         }
     }
     Mage::getSingleton('checkout/session')->setLastQuoteId($quote->getId())->setLastSuccessQuoteId($quote->getId())->clearHelperData();
     $order = $service->getOrder();
     Mage::getSingleton('checkout/session')->setLastOrderId($order->getId())->setRedirectUrl(false)->setLastRealOrderId($order->getIncrementId());
     $transaction = Mage::getModel('saferpaycw/transaction');
     $transaction->setOrderId($order->getId());
     $transaction->setOrderPaymentId($order->getPayment()->getId());
     $transaction->save();
     return $context->getPaymentMethod()->getTransactionContext($order, $transaction);
 }