public function authenticate(Customweb_Payment_ExternalCheckout_IContext $context, $emailAddress, $successUrl) { if (!$context instanceof Customweb_SaferpayCw_Model_ExternalCheckoutContext) { throw new Customweb_Core_Exception_CastException('Customweb_SaferpayCw_Model_ExternalCheckoutContext'); } if ($context->getBillingAddress() === null) { throw new Exception("The authenticate method can not be called before the billing address is set on the context."); } $this->redirectOnEmptyBasket(); $quote = $context->getQuote(); if (Mage::getSingleton('customer/session')->isLoggedIn()) { $context->updateFromQuote($quote); $context->save(); return Customweb_Core_Http_Response::redirect($successUrl); } if ($quote->isAllowedGuestCheckout() && Mage::getStoreConfig('saferpaycw/general/external_checkout_account_creation') == 'skip_selection') { Mage::helper('SaferpayCw/externalCheckout')->validateCustomerData($quote, array('email' => $emailAddress, 'firstname' => $context->getBillingAddress()->getFirstName(), 'lastname' => $context->getBillingAddress()->getLastName()), 'guest'); $quote->collectTotals(); $quote->save(); $context->setRegisterMethod('guest'); $context->updateFromQuote($quote); $context->save(); return Customweb_Core_Http_Response::redirect($successUrl); } $context->setAuthenticationEmailAddress($emailAddress); $context->setAuthenticationSuccessUrl($successUrl); $context->save(); return Customweb_Core_Http_Response::redirect(Mage::getUrl('SaferpayCw/Externalcheckout/login', array('_secure' => true))); }