<!--- Show header images, etc., for Online Store --->
<CFINCLUDE TEMPLATE="StoreHeader.cfm">

<!--- Get current cart contents, via Custom Tag --->
<CF_ShoppingCart
  Action="List"
  ReturnVariable="GetCart">
  
<!--- Stop here if user's cart is empty --->
<CFIF GetCart.RecordCount EQ 0>
  There is nothing in your cart.
  <CFABORT>
</CFIF>

<!--- If user is not logged in, force them to now --->  
<CFIF NOT IsDefined("SESSION.Auth.IsLoggedIn")>
  <CFINCLUDE TEMPLATE="LoginForm.cfm">
  <CFABORT>
</CFIF> 

<!--- If user is attempting to place order --->
<CFIF IsDefined("FORM.IsPlacingOrder")>
  
  <!--- Attempt to process the transaction  --->
  <CF_PlaceOrder
    ContactID="#SESSION.Auth.ContactID#"
    MerchList="#ValueList(GetCart.MerchID)#"
    QuantList="#ValueList(GetCart.Quantity)#"
  	CreditCard="#FORM.CreditCard#"
  	CreditExpM="#FORM.CreditExpM#"
    CreditExpY="#FORM.CreditExpY#"
  	CreditName="#FORM.CreditName#"
    ShipAddress="#FORM.ShipAddress#"
    ShipState="#FORM.ShipState#"
    ShipCity="#FORM.ShipCity#"
    ShipZIP="#FORM.ShipZIP#"
    ShipCountry="#FORM.ShipCountry#"
    HTMLMail="#FORM.HTMLMail#"
    ReturnVariable="OrderInfo">
      
  <!--- If the order was processed successfully --->
  <CFIF OrderInfo.IsSuccessful>

    <!--- Empty user's shopping cart, via custom tag --->
    <CF_ShoppingCart
      ACTION="Empty">
    
    <!--- Display Success Message --->
    <CFOUTPUT>
      <H2>Thanks For Your Order</H2>
      <P><B>Your Order Has Been Placed.</B><BR>
      Your order number is: #OrderInfo.OrderID#<BR>
      Your credit card has been charged:
      #LSCurrencyFormat(OrderInfo.OrderAmount)#<BR>
      <P>A confirmation is being E-mailed to you.<BR>
    </CFOUTPUT>
    
    <!--- Stop here. --->
    <CFABORT>
  <CFELSE>
    <!--- Display "Error" message --->
    <FONT COLOR="Red">
      <STRONG>Your credit card could not be processed.</STRONG><BR>
      Please verify the credit card number, expiration date, and 
      name on the card.<BR>
    </FONT>
    
    <!--- Show debug info if viewing page on server --->
    <CFIF CGI.REMOTE_ADDR EQ "127.0.0.1">
      <CFOUTPUT>
        Status:  #OrderInfo.Status#<BR>
        Error:   #OrderInfo.ErrorCode#<BR>
        Message: #OrderInfo.ErrorMessage#<BR>
      </CFOUTPUT>
    </CFIF>
  </CFIF>  
</CFIF>


<!--- Show Checkout Form (Ship Address/Credit Card) --->
<CFINCLUDE TEMPLATE="StoreCheckoutForm.cfm">
