#!/usr/local/bin/perl # billing.pl - web cgi routine to collect shopping cart payment info # # Dave Stoddard - 6/01/04 # dgs@accelix.com # # Copyright # --------- # Copyright(c) 2004, Accelix LLC. All Rights Reserved. # # Description # ----------- # This program handles the process of collecting billing info for the # shopping cart system. The steps in the checkout process, and their # associated modules, are as follows: # # checkout.pl - collect shipping information for the customer's order # billing.pl - show total and collect billing information # confirm.pl - show total and confirm or cancel the order # payment.pl - process payment and provide an invoice # # This routine creates the billto record. It assumes that the order master # record has already been created and FAILS (with a message) if that record # does not exist. # # RCS Information # --------------- # $Id$ # $Log$ # # package main; use strict 'vars'; use strict 'subs'; # use warnings; # use diagnostics; # load application modules use cart; # shopping cart support routines use Time::Local; # perl time functions # --------------------------- # DECLARATIONS AND PROTOTYPES # --------------------------- # local elements my %form = (); # data from form (name/value pairs) my %state = (); # state persistence data hash my %sess = (); # session id hash my %orders = (); # orders table record my %shipto = (); # shipto table record my %billto = (); # billto table record my %tax = (); # tax table hash my %pohash = (); # payment option hash my %mmhash = (); # expiration month hash my %yyhash = (); # expiration year hash my $itemtot = 0; # order total my $discount = 0; # order discount amount my $nettotal = 0; # net total (itemtot - discount) my $salestax = 0; # sales tax amount my $shipcost = 0; # shipping costs my $mintotal = 150.00; # minimum order amount my $i = ""; # current cart record in series my $prev = "/cgi-bin/checkout.pl"; # previous CGI program my $curr = "/cgi-bin/billing.pl"; # this CGI program my $next = "/cgi-bin/confirm.pl"; # next in the series of CGI programs # only states in this table have sales tax applied $tax{PA} = .06; # payment options (to deactivate option, simply comment out) $pohash{"V"} = "Visa"; $pohash{"M"} = "MasterCard"; $pohash{"D"} = "Discover"; $pohash{"A"} = "American Express"; # $pohash{"O"} = "Money Order"; # results in hold # $pohash{"C"} = "Cash"; # admin only # $pohash{"K"} = "Check"; # admin only # $pohash{"I"} = "Invoice"; # admin only # cc expiration months $mmhash{"01"} = "January"; $mmhash{"02"} = "February"; $mmhash{"03"} = "March"; $mmhash{"04"} = "April"; $mmhash{"05"} = "May"; $mmhash{"06"} = "June"; $mmhash{"07"} = "July"; $mmhash{"08"} = "August"; $mmhash{"09"} = "September"; $mmhash{"10"} = "October"; $mmhash{"11"} = "November"; $mmhash{"12"} = "December"; # cc expiration years $yyhash{"04"} = "2004"; $yyhash{"05"} = "2005"; $yyhash{"06"} = "2006"; $yyhash{"07"} = "2007"; $yyhash{"08"} = "2008"; $yyhash{"09"} = "2009"; $yyhash{"10"} = "2010"; $yyhash{"11"} = "2011"; $yyhash{"12"} = "2012"; $yyhash{"13"} = "2013"; $yyhash{"14"} = "2014"; # function prototypes sub CheckForOrders ($); # check for an existing order record sub CheckForBillto ($); # check for an existing billto record sub InitBilltoRecord (); # initialize a blank billto record sub EditBilltoData (\%\%\%); # edit form data for billto record sub DisplayBilltoPage (\%); # display the shipping info form sub GetOrdersRecord ($); # retrieve a orders record sub GetShiptoRecord ($); # retrieve a shipto record sub GetBilltoRecord ($); # retrieve a billto record sub AddBilltoRecord (\%); # add a billto record to the table sub ChangeBilltoRecord (\%); # change an existing billto record sub GetStates (); # load state code hash sub GenerateOptions (\%$$); # create