home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgLangD.iso / VCAFE.3.0A / Sample.bin / PHOwner.java < prev    next >
Text File  |  1998-10-17  |  3KB  |  112 lines

  1. package symantec.sourcebook.servlet;
  2. import java.io.*;
  3. import java.net.*;
  4. import javax.servlet.*;
  5. import javax.servlet.http.*;
  6.  
  7. public class PHOwner extends PageHandler 
  8. {
  9.  
  10.    int    pagenumber = ESDServlet.DOWNLOAD_PAGE_NUM;
  11.    
  12.    private final static String PAGENAME = PAGEBASE + "owner.html";
  13.    
  14.    public PHOwner()
  15.    {
  16.    }
  17.    
  18.    public String pageName()
  19.    {
  20.         return PAGENAME;
  21.    }
  22.    
  23.    public int nextPage()
  24.    {
  25.         return pagenumber;
  26.    }
  27.    
  28.    
  29.     
  30.    protected void customize(Object pageDataObject) throws IOException
  31.    {
  32.         PageData ownerData = (PageData) pageDataObject;
  33.  
  34.         String fieldText = "<input type=\"hidden\" name=\"orderID\" value=\""+ ownerData.transaction.orderID +"\"> ";
  35.         fieldText +=   ownerData.transaction.name + "<br>" +
  36.                ownerData.transaction.company + "<br>" +
  37.                ownerData.transaction.email + "<br>" +
  38.                ownerData.transaction.address + "<br>" +
  39.                ownerData.transaction.city  + " " + ownerData.transaction.state + " " + ownerData.transaction.zip + "<br>" +
  40.                ownerData.transaction.country + " " + ownerData.transaction.phone +"<br>" ;
  41.                
  42.         
  43.         insert("fieldPosition",fieldText);       
  44.         insert("ownerIDPosition",ownerData.transaction.orderID);
  45.    }
  46.     
  47.  
  48.  
  49.     public Object validate(ServletConfig config,HttpServletRequest request,HttpServletResponse response) throws IOException
  50.     {
  51.         
  52.         Transaction t;
  53.         String name;
  54.         String orderId;
  55.         String total;
  56.         PageData pageData = new PageData(config,request,response);
  57.     
  58.         orderId = getParameter(request,"orderID","");
  59.  
  60.         if(orderId.length() ==0)
  61.         {
  62.             pagenumber = ESDServlet.ERROR_PAGE_NUM;
  63.             pageData.messageText = "Invalid order processing identification (1)";
  64.             return pageData;
  65.         }
  66.  
  67.         t = Transaction.findTransaction(orderId);
  68.         
  69.         if(t==null)
  70.         {
  71.             pagenumber = ESDServlet.ERROR_PAGE_NUM;
  72.             pageData.messageText = "Invalid order processing identification (2)";
  73.             return pageData;
  74.         }
  75.  
  76.         // check status of this transaction
  77.  
  78.         if( (t.verified && !t.accepted) || // credit was already declined on this order ID
  79.             (t.downloadCount > 12))               // excessive downloads... suspend
  80.         {
  81.             pagenumber = ESDServlet.ERROR_PAGE_NUM;
  82.             pageData.messageText = "This order has been suspended. Please contact the company.";
  83.             return pageData;
  84.            
  85.         }
  86.  
  87.  
  88.  
  89.         // if record has not yet been validated with web order, contact host
  90.  
  91.         if(!t.verified)
  92.         {
  93.             // NOTE: In a live system you should 
  94.             // contact host and verify order here!
  95.             // (to prevent hackers from bypassing the credit card screen)
  96.  
  97.             // Dummy verification
  98.             t.verified = true;
  99.             t.accepted = true;
  100.             
  101.             
  102.         }
  103.  
  104.         t.record();
  105.  
  106.         
  107.         pageData.transaction = t;
  108.         return pageData;
  109.     }
  110.  
  111.  
  112. }