Pages

Monday, September 13, 2010

Checkout Process of the Shopping Cart

User can provide all their payment options here on this page and submit to complete the transaction. User IP will be saved for security reasons.

Checkout.aspx:

//---------------------------------------------------------------------------------------------------||
// Members can checkout from the cart page for further formalities                ||
//This is the code of checkout                                                                          ||
//---------------------------------------------------------------------------------------------------||


checkout.aspx
<%@ Page Explicit="True" Language="VB" Debug="True"  %> // Page Directive
<%@ Import Namespace="System.Data" %>
<%@ Import Namespace="System.Data.sqlclient" %>
<!--#include file="config.aspx" -->
<!--#include file="scrollerdata.aspx" -->
<!--#include file="man_menu.aspx" -->
<!--#include file="checklogin.aspx" -->
<Script Runat="Server">
Sub Page_Load( s As Object, e As EventArgs )
call logincheck
call checkstatus
call dbcon
call fillmanu
call scrollphone
call Getamount
if session("useriD")="" then
btnlogin.text="login"
end if

If Not isPostBack Then
call dbcon
if session("useriD")="" then
    btnlogin.text="login"
    end if
End If
lblip.text=request.servervariables("REMOTE_ADDR")
End Sub
sub logincheck
if session("userID")="" or session("cartison")="" or session.sessionID<>request.QueryString("transID") or session("seccode")<>request.QueryString("seccode") or session("cartison")="" then
session("checklog")= true
response.redirect("requesterror.aspx")

end if
end sub
sub Getamount
dbcon
mcmd=new sqlcommand("select sum(totalamount) as finaltotal from temp_cart where transiD='"& session.SessionID &"' and secCode='"& request("secCode") & "' and userID='"& session("userID") & "' ",bcon)
bcon.open
objreader=mcmd.executereader
objreader.read
totalamount=objreader("finaltotal")
lblfinalprice.text=totalamount & " LKR"
objreader.close
bcon.close
end sub
sub savedata(sender As Object, e As System.Web.UI.ImageClickEventArgs)
call ordernumgen
orderID="ORD" & cstr(ord) & session("userID")
session("orderID")=cstr(orderID)
dim xdate as string

xdate= txtmm.text & "/" & txtYYYY.text
If Not IsDate(xdate) then
            lbldate.text="Invalid date"
            lbldate.visible=true
else if (DateDiff(DateInterval.Day, CDate(Now), CDate(xdate)))< 7 then
lbldate.text="card is expired or expires within 7 days"
lbldate.visible=true       

else if txtcardno.text.length< 15 then
lblcardVal.text="*card number should be atleast 15 digits"
lblcardval.visible=true
else
tcmd= new sqlcommand("insert into payments(orderID,userID,amount,card_type,card_holder,card_secno,card_no,exp_date,IP,Ord_date,TP,Deladdr,status)values(@orderID,@userID,@amount,@card_type,@card_holder,@card_secno,@card_no,@exp_date,@IP,@ord_date,@tp,@Deladdr,@status)",bcon)

TCmd.Parameters.Add(New sqlParameter("@orderID", sqlDbType.Varchar,50))
TCmd.Parameters.Add(New sqlParameter("@userID", sqlDbType.Varchar,50))
TCmd.Parameters.Add(New sqlParameter("@amount", sqlDbType.decimal))
TCmd.Parameters.Add(New sqlParameter("@card_type", sqlDbType.Varchar,50))
TCmd.Parameters.Add(New sqlParameter("@card_holder", sqlDbType.Varchar,100))
TCmd.Parameters.Add(New sqlParameter("@card_secno", sqlDbType.int))
TCmd.Parameters.Add(New sqlParameter("@card_no", sqlDbType.Varchar,100))
TCmd.Parameters.Add(New sqlParameter("@exp_date", sqlDbType.datetime))
TCmd.Parameters.Add(New sqlParameter("@IP", sqlDbType.char,200))
TCmd.Parameters.Add(New sqlParameter("@ord_date", sqlDbType.datetime))
TCmd.Parameters.Add(New sqlParameter("@TP", sqlDbType.varchar,50))
TCmd.Parameters.Add(New sqlParameter("@Deladdr", sqlDbType.Varchar,500))
TCmd.Parameters.Add(New sqlParameter("@Status", sqlDbType.Varchar,10))

TCmd.Parameters("@orderID").Value=orderID
TCmd.Parameters("@userID").Value=session("userID")
TCmd.Parameters("@amount").Value=totalamount
TCmd.Parameters("@card_type").Value=cboCardtyp.selecteditem.text
TCmd.Parameters("@card_holder").Value=txtCardhol.text
TCmd.Parameters("@card_secno").Value=cint(txtSeccode.text)
TCmd.Parameters("@card_no").Value=txtcardno.text
TCmd.Parameters("@exp_date").Value=cdate(xdate)
TCmd.Parameters("@IP").Value=request.ServerVariables("REMOTE_ADDR")
TCmd.Parameters("@ord_date").Value=cdate(now)
TCmd.Parameters("@TP").Value=txtPhnno.text
TCmd.Parameters("@Deladdr").Value=txtDeladd.text
TCmd.Parameters("@status").Value="No"
bcon.open
tcmd.executenonquery
bcon.close
bcon.open
mcmd=new sqlcommand("update ordGen set ordernumber=ordernumber+1",bcon)
mcmd.executenonquery
bcon.close
call dataTopermenent
call updateqty
call deltemp
call sendnotification
call checkreOrder
response.Redirect("paymentsuccess.aspx?transID=" &request.QueryString("transID") & "&secCode=" &cstr(session("secCode")))
end if
end sub
sub dataTopermenent
call dbcon
bcmd=new sqlcommand("select phoneId,qty,totalamount from temp_cart where transId='" & session.SessionID & "' and userID='" & session("userID") & "' and  secCode='" & request.QueryString("secCode") & "' ",bcon)
bcon.open
objreader = BCmd.ExecuteReader
while objreader.read
            



After the checking out, if all the validations are completed, the user will be shown the transaction details as given below:



The order ID is a code designed for the Online Mobile Store, which uses a 3 string value “ORD” and a numeric value continued by the user id who made the transaction.

Ex: ORD10024NCCEDU

The system will send a confirmation mail to the user about the transaction .