/**
  * Process a new service purchase
  */
 protected function process()
 {
     // Verify that the user entered a domain name and TLD
     if (!isset($this->post['domainname'])) {
         throw new FieldMissingException("domainname");
     }
     // Build an order item for the domain purchase
     $domainItem = new OrderDomainDBO();
     $domainItem->setPurchasable($this->post['domaintld']);
     $domainItem->setTerm($this->post['domainterm']->getTermLength());
     $domainItem->setDomainName($this->post['domainname']);
     $fqdn = sprintf("%s.%s", $this->post['domainname'], $this->post['domaintld']->getTLD());
     // Access the registrar module for the selected TLD
     $moduleName = $this->post['domaintld']->getModuleName();
     $registrar = ModuleRegistry::getModuleRegistry()->getModule($moduleName);
     switch ($this->post['domainoption']) {
         case "New":
             // Register a new domain
             // Check the domain availability
             if (!$registrar->checkAvailability($fqdn)) {
                 throw new SWUserException("[ERROR_DOMAIN_NOT_AVAILABLE]", array($fqdn));
             }
             $domainItem->setType("New");
             break;
         case "Transfer":
             // Transfer a domain
             // Check the domain transfer-ability
             if (!$registrar->isTransferable($fqdn)) {
                 throw new SWUserException("[ERROR_DOMAIN_TRANSFER_NO_DOMAIN]");
             }
             $domainItem->setType("Transfer");
             break;
     }
     // Add the domain item to the order
     $_SESSION['order']->addItem($domainItem);
     // Proceed to the cart page
     $this->gotoPage("cart");
 }
 /**
  * Process a new service purchase
  */
 protected function process()
 {
     // Build an order item for the hosting service
     $hostingItem = new OrderHostingDBO();
     $hostingItem->setPurchasable($this->post['hostingservice']);
     $hostingItem->setTerm($this->post['hostingterm']->getTermLength());
     switch ($this->post['domainoption']) {
         case "New":
             // Register a new domain for use with this hosting service
             // Verify that the user entered a domain name and TLD
             if (!isset($this->post['registerdomainname'])) {
                 throw new FieldMissingException("registerdomainname");
             }
             if (!isset($this->post['registerdomaintld'])) {
                 throw new FieldMissingException("registerdomaintld");
             }
             $fqdn = sprintf("%s.%s", $this->post['registerdomainname'], $this->post['registerdomaintld']->getTLD());
             // Check the domain availability
             $moduleName = $this->post['registerdomaintld']->getModuleName();
             $registrar = ModuleRegistry::getModuleRegistry()->getModule($moduleName);
             if (!$registrar->checkAvailability($fqdn)) {
                 throw new SWUserException("[ERROR_DOMAIN_NOT_AVAILABLE]");
             }
             // Place the domain name in the hosting item
             $hostingItem->setDomainName($fqdn);
             // Create another order item for the domain purchase
             $domainItem = new OrderDomainDBO();
             $domainItem->setType("New");
             $domainItem->setDomainName($this->post['registerdomainname']);
             $domainItem->setPurchasable($this->post['registerdomaintld']);
             $domainItem->setTerm($this->post['registerdomainterm']->getTermLength());
             break;
         case "Transfer":
             // Transfer a domain for use with this hosting service
             // Verify that the user entered a domain name and TLD
             if (!isset($this->post['transferdomainname'])) {
                 throw new FieldMissingException("transferdomainname");
             }
             if (!isset($this->post['transferdomaintld'])) {
                 throw new FieldMissingException("transferdomaintld");
             }
             $fqdn = sprintf("%s.%s", $this->post['transferdomainname'], $this->post['transferdomaintld']->getTLD());
             // Check the domain transfer-ability
             $moduleName = $this->post['registerdomaintld']->getModuleName();
             $registrar = ModuleRegistry::getModuleRegistry()->getModule($moduleName);
             if (!$registrar->isTransferable($fqdn)) {
                 throw new SWUserException("[ERROR_DOMAIN_TRANSFER_NO_DOMAIN]");
             }
             // Place the domain name in the hosting item
             $hostingItem->setDomainName($fqdn);
             // Create another order item for the domain purchase
             $domainItem = new OrderDomainDBO();
             $domainItem->setType("Transfer");
             $domainItem->setDomainName($this->post['transferdomainname']);
             $domainItem->setPurchasable($this->post['transferdomaintld']);
             $domainItem->setTerm($this->post['transferdomainterm']->getTermLength());
             break;
         case "InCart":
             // Use a domain that is in the customer's cart
             // Verify that the user selected a domain
             if (!isset($this->post['incartdomain'])) {
                 throw new FieldMissingException("incartdomain");
             }
             $hostingItem->setDomainName($this->post['incartdomain']);
             break;
         case "Existing":
             // Use an existing domain for this hosting service
             // Verify that the user entered a domain name
             if (!isset($this->post['existingdomainname'])) {
                 throw new FieldMissingException("existingdomainname");
             }
             $hostingItem->setDomainName($this->post['existingdomainname']);
             break;
         default:
             if ($this->post['hostingservice']->isDomainRequired()) {
                 throw new FieldMissingException("domainoption");
             }
             break;
     }
     // Add the item(s) to the order
     $_SESSION['order']->addItem($hostingItem);
     if (isset($domainItem)) {
         $_SESSION['order']->addItem($domainItem);
     }
     // Proceed to the cart page
     $this->gotoPage("cart");
 }