Sunday, 25 March 2012

Checkout Page


<%@ Page Title="" Language="VB" MasterPageFile="~/resources/masterpages/MainMaster3.master" EnableEventValidation="false" AutoEventWireup="false" CodeFile="checkout.aspx.vb" Inherits="secure_checkout" %>
<%@ MasterType  virtualPath="~/resources/masterpages/MainMaster3.master"%>
<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="Server"></asp:Content>
<asp:Content ID="Content3" ContentPlaceHolderID="head2" runat="Server">
  <link rel="stylesheet" type="text/css" href="/resources/css/thickbox.css" />
  <link rel="stylesheet" type="text/css" href="/resources/css/checkout.css" />
  <script src="/resources/scripts/thickbox.js" type="text/javascript" language="javascript"></script>
  <script language="javascript" type="text/javascript">
        var currentStep = 1;  //<%= CurrentStep %>;
        var cartID = '<%= CartID %>';
        $(document).ready(function () {

            $("#checkout-page input").bind("keypress", function (e) {
                if (e.keyCode == 34 || e.keyCode == 13) return false;
            });

            //PAGE DEFAULTS
            if (currentStep == 2) {
                $("#step1Group").css("display", "none");
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-inactive.png");
                $("#step2Group").css("display", "block");
                $(".step2TopImg").attr("src", "/images/loc-payment-active.png");
                $("#step3Group").css("display", "none");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
            } else if (currentStep == 3) {
                $("#step1Group").css("display", "none");
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-inactive.png");
                $("#step2Group").css("display", "none");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $("#step3Group").css("display", "block");
                $(".step3TopImg").attr("src", "/images/loc-confirm-active.png");
            } else {
                $("#step1Group").css("display", "block");
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-active.png");
                $("#step2Group").css("display", "none");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $("#step3Group").css("display", "none");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
            }
            if ($("#<%=ddlShipCountryRegion.ClientID %>").val() != "-1") {
                getStatesProvince($("#<%=ddlShipCountryRegion.ClientID %>").val(), "<%=ddlShipStateProvince.ClientID %>", "<%=hidShipStateProvince.ClientID %>");
            }
            if ($("#<%=ddlBillCountryRegion.ClientID %>").val() != "-1") {
                getStatesProvince($("#<%=ddlBillCountryRegion.ClientID %>").val(), "<%=ddlBillStateProvince.ClientID %>", "<%=hidBillStateProvince.ClientID %>");
            }
            $(".paymentMethods").removeAttr("checked");
            $(".paymentMethods[value=" + $("#<%=hidPaymentMethod.ClientID%>").val() + "]").attr("checked", "checked");
            if ($(".paymentMethods:checked=checked").val() == "Credit") {
                $("#creditCard_Info").show();
            } else {
                $("#creditCard_Info").hide();
            }
            $(".shippingMethods").removeAttr("checked");
            $(".shippingMethods[value=" + $("#<%=hidShippingVia.ClientID%>").val() + "]").attr("checked", "checked");
            if ($(".shippingMethods:checked=checked").val() == "Hammond") {
                $("#shipOwn").hide();
                $("#shipHammond").show();
                $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                getCheckoutPricing();
            } else {
                $("#shipHammond").hide();
                $("#shipOwn").show();
                $("#<%=ddlOwnCarrier.ClientID %>").val($("#<%=hidShippingCarrier.ClientID%>").val());
                $("#<%=ddlOwnMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                getCheckoutPricing();
            }

            //PAGE EVENTS
            var options = {};
            var target_offset = $("#checkout-page").offset();
            var target_top = target_offset.top;
            $("#btnContinueToStep2").click(function () {
                //CHECK STEP 1 FOR ERRORS
                var step1Errors = false;
                var step1ErrorList = '';
                if (jQuery.trim($("#<%=txtShipFirstName.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Shipping first name is required.\n";
                }
                if (jQuery.trim($("#<%=txtShipLastName.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Shipping last name is required.\n";
                }
                if (jQuery.trim($("#<%=txtShipAddressLine1.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Shipping address is required.\n";
                }
                if (jQuery.trim($("#<%=txtShipCity.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Shipping city is required.\n";
                }
                if ($("#<%=ddlShipCountryRegion.ClientID %>").val() == "-1") {
                    step1Errors = true;
                    step1ErrorList += "Shipping county is required.\n";
                }
                if ($("#<%=ddlShipStateProvince.ClientID %>").val() == "-1") {
                    step1Errors = true;
                    step1ErrorList += "Shipping state/province is required.\n";
                }
                if (jQuery.trim($("#<%=txtShipPostalCode.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Shipping postal code is required.\n";
                }
                if (jQuery.trim($("#<%=txtPhone.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Phone number is required.\n";
                } else if (!validatePhone(jQuery.trim($("#<%=txtPhone.ClientID %>").val()))) {
                    step1Errors = true;
                    step1ErrorList += "Phone number is in an incorrect format.\n";
                }
                if (jQuery.trim($("#<%=txtEmail.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Email address is required.\n";
                }
                if (!validateEmail(jQuery.trim($("#<%=txtEmail.ClientID %>").val()))) {
                    step1Errors = true;
                    step1ErrorList += "Email address is in an incorrect format.\n";
                }
                //BILLING
                if (jQuery.trim($("#<%=txtBillFirstName.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Billing first name is required.\n";
                }
                if (jQuery.trim($("#<%=txtBillLastName.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Billing last name is required.\n";
                }
                if (jQuery.trim($("#<%=txtBillAddressLine1.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Billing address is required.\n";
                }
                if (jQuery.trim($("#<%=txtBillCity.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Billing city is required.\n";
                }
                if ($("#<%=ddlBillCountryRegion.ClientID %>").val() == "-1") {
                    step1Errors = true;
                    step1ErrorList += "Billing county is required.\n";
                }
                if ($("#<%=ddlBillStateProvince.ClientID %>").val() == "-1") {
                    step1Errors = true;
                    step1ErrorList += "Billing state/province is required.\n";
                }
                if (jQuery.trim($("#<%=txtBillPostalCode.ClientID %>").val()) == "") {
                    step1Errors = true;
                    step1ErrorList += "Billing postal code is required.\n";
                }
                if (step1Errors) {
                    alert(step1ErrorList);
                    return false;
                }

                //enable the billing interface
                billingInterface(false);

                //If We Made It This Far We Are Ok
                //Load The Values To The Final Page
                var myBill = '';
                var myShip = '';
                var myGeneral = '';
                myBill += $("#<%=txtBillFirstName.ClientID %>").val() + ' ' + $("#<%=txtBillLastName.ClientID %>").val() + '<br />';
                if (jQuery.trim($("#<%=txtBillCompanyName.ClientID %>").val()) != '') {
                    myBill += $("#<%=txtBillCompanyName.ClientID %>").val() + '<br />';
                }
                myBill += $("#<%=txtBillAddressLine1.ClientID %>").val() + '<br />';
                if (jQuery.trim($("#<%=txtBillAddressLine2.ClientID %>").val()) != '') {
                    myBill += $("#<%=txtBillAddressLine2.ClientID %>").val() + '<br />';
                }
                myBill += $("#<%=txtBillCity.ClientID %>").val() + ', ' + $("#<%=ddlBillStateProvince.ClientID %> option:selected").text() + ' ' + $("#<%=txtBillPostalCode.ClientID %>").val() + '<br />';
                myBill += $("#<%=ddlBillCountryRegion.ClientID %> option:selected").text() + '<br />';

                myShip += $("#<%=txtShipFirstName.ClientID %>").val() + ' ' + $("#<%=txtShipLastName.ClientID %>").val() + '<br />';
                if (jQuery.trim($("#<%=txtShipCompanyName.ClientID %>").val()) != '') {
                    myShip += $("#<%=txtShipCompanyName.ClientID %>").val() + '<br />';
                }
                myShip += $("#<%=txtShipAddressLine1.ClientID %>").val() + '<br />';
                if (jQuery.trim($("#<%=txtShipAddressLine2.ClientID %>").val()) != '') {
                    myShip += $("#<%=txtShipAddressLine2.ClientID %>").val() + '<br />';
                }
                myShip += $("#<%=txtShipCity.ClientID %>").val() + ', ' + $("#<%=ddlShipStateProvince.ClientID %> option:selected").text() + ' ' + $("#<%=txtShipPostalCode.ClientID %>").val() + '<br />';
                myShip += $("#<%=ddlShipCountryRegion.ClientID %> option:selected").text() + '<br />';

                myGeneral += $("#<%=txtPhone.ClientID %>").val() + '<br />';
                myGeneral += $("#<%=txtEmail.ClientID %>").val() + '<br />';

                $("#reviewShippingInfo").html(myShip);
                $("#reviewBillingInfo").html(myBill);
                $("#reviewGeneralInfo").html(myGeneral);

                //Update Prices
                if ($(".shippingMethods:checked=checked").val() == "Hammond") {
                    $("#shipOwn").hide();
                    $("#shipHammond").show();
                    LoadHammondCarrier();
                    if ($("#<%=ddlHammondMethod.ClientID %> option[value=" + $("#<%=hidShippingMethod.ClientID%>").val()).size() > 0) {
                        $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                    } else if ($("#<%=ddlShipCountryRegion.ClientID%> option:selected").text() == "Canada") {
                        $("#<%=hidShippingMethod.ClientID%>").val("CanadaGround");
                        $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                    } else {
                        $("#<%=hidShippingMethod.ClientID%>").val("Ground");
                        $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                    }
                } else {
                    $("#shipHammond").hide();
                    $("#shipOwn").show();
                    LoadOwnCarrier();
                    $("#<%=ddlOwnCarrier.ClientID %>").val($("#<%=hidShippingCarrier.ClientID%>").val());
                    $("#<%=ddlOwnMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                }
                getCheckoutPricing();
                $("#step1Group").fadeOut(500, function () {
                    $("#step2Group").fadeIn(300);
                    $(this).css("display", "none");
                });

                $(".step1TopImg").attr("src", "/images/loc-billingshipping-inactive.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-active.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);


            });
            $("#btnBackToStep1").click(function () {
                if ($("#<%=chkSame.ClientID %>").attr("checked")) {
                    billingInterface(true);
                } else {
                    billingInterface(false);
                }
                $("#step2Group").fadeOut(500, function () {
                    $("#step1Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-active.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });
            $("#btnContinueToStep3").click(function () {
                //CHECK STEP 2 FOR ERRORS
                var step2Errors = false;
                var step2ErrorList = '';
                if ($("#<%=hidPaymentMethod.ClientID%>").val() == "Credit") {
                    if ($("#<%=ddlCardType.ClientID%>").val() == "-1") {
                        step2ErrorList += 'You must select a credit card type.\n';
                        step2Errors = true;
                    }
                    if (jQuery.trim($("#<%=txtCardNumber.ClientID%>").val()) == "") {
                        step2ErrorList += 'You must select a credit card number.\n';
                        step2Errors = true;
                    }
                    if ($("#<%=ddlMonth.ClientID%>").val() == "-1") {
                        step2ErrorList += 'You must select an expiration month.\n';
                        step2Errors = true;
                    }
                    if ($("#<%=ddlYear.ClientID%>").val() == "-1") {
                        step2ErrorList += 'You must select an expiration year.\n';
                        step2Errors = true;
                    }
                    if (jQuery.trim($("#<%=txtSecurityCode.ClientID%>").val()) == "") {
                        step2ErrorList += 'You must enter a security code.\n';
                        step2Errors = true;
                    }
                }
                if ($("#<%=hidShippingVia.ClientID%>").val() == "Hammond") {
                    if ($("#<%=hidShippingMethod.ClientID%>").val() == "-1") {
                        step2ErrorList += 'You must select a shipping method.\n';
                        step2Errors = true;
                    }
                } else {
                    if ($("#<%=hidShippingCarrier.ClientID%>").val() == "-1") {
                        step2ErrorList += 'You must select a shipping carrier.\n';
                        step2Errors = true;
                    }
                    if ($("#<%=hidShippingMethod.ClientID%>").val() == "-1") {
                        step2ErrorList += 'You must select a shipping method.\n';
                        step2Errors = true;
                    }
                    if (jQuery.trim($("#<%=txtAccountNumber.ClientID%>").val()) == "") {
                        step2ErrorList += 'You must enter a shipping account number.\n';
                        step2Errors = true;
                    }
                }

                //WE ARE ALL GOOD LOAD VALUES TO REVIEW PAGE
                var myShipping = '';
                var myPayment = '';
                if ($("#<%=hidPaymentMethod.ClientID%>").val() == "Credit") {
                    myPayment += $("#<%=ddlCardType.ClientID %>").val() + '<br />';
                    myPayment += $("#<%=txtCardNumber.ClientID %>").val() + '<br />';
                    myPayment += $("#<%=txtSecurityCode.ClientID %>").val() + '<br />';
                    myPayment += $("#<%=ddlMonth.ClientID %>").val() + '/' + $("#<%=ddlYear.ClientID %>").val();
                } else {
                    myPayment += 'Check';
                }
                if ($(".shippingMethods:checked=checked").val() == "Hammond") {
                    myShipping += 'UPS<br />';
                    myShipping += $("#<%=ddlHammondMethod.ClientID %> option:selected").text();
                } else {
                    myShipping += $("#<%=ddlOwnCarrier.ClientID %> option:selected").text() + '<br />';
                    myShipping += $("#<%=ddlOwnMethod.ClientID %> option:selected").text() + '<br />';
                    myShipping += $("#<%=txtAccountNumber.ClientID %>").val();
                }
                $("#reviewPaymentInfo").html(myPayment);
                $("#reviewShippingMethod").html(myShipping);

                if (step2Errors) {
                    alert(step2ErrorList);
                    return false;
                }
                $("#step2Group").fadeOut(500, function () {
                    $("#step3Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                //Update Prices
                getCheckoutPricing();
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-inactive.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-active.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });
            $("#btnBackToStep2").click(function () {
                $("#step3Group").fadeOut(500, function () {
                    $("#step2Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                //Update Prices
                getCheckoutPricing();
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-inactive.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-active.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });

            $("#btnEditShipping").click(function () {
                if ($("#<%=chkSame.ClientID %>").attr("checked")) {
                    billingInterface(true);
                } else {
                    billingInterface(false);
                }
                $("#step3Group").fadeOut(500, function () {
                    $("#step1Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-active.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });
            $("#btnEditBilling").click(function () {
                if ($("#<%=chkSame.ClientID %>").attr("checked")) {
                    billingInterface(true);
                } else {
                    billingInterface(false);
                }
                $("#step3Group").fadeOut(500, function () {
                    $("#step1Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-active.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });
            $("#btnEditGeneral").click(function () {
                $("#step3Group").fadeOut(500, function () {
                    $("#step1Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-active.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-inactive.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });
            $("#btnEditPayment").click(function () {
                $("#step3Group").fadeOut(500, function () {
                    $("#step2Group").fadeIn(300);
                    $(this).css("display", "none");
                });
                $(".step1TopImg").attr("src", "/images/loc-billingshipping-inactive.png");
                $(".step2TopImg").attr("src", "/images/loc-payment-active.png");
                $(".step3TopImg").attr("src", "/images/loc-confirm-inactive.png");
                $('html, body').animate({ scrollTop: target_top }, 500);
            });
            $(".paymentMethods").click(function () {
                if ($(this).val() == "Credit") {
                    $("#creditCard_Info").show(300);
                } else {
                    $("#creditCard_Info").hide(300);
                }
                $("#<%=hidPaymentMethod.ClientID%>").val($(this).val());
            });
            $(".shippingMethods").click(function () {
                if ($(this).val() == "Hammond") {
                    $("#shipOwn").hide(300);
                    $("#shipHammond").show(300);
                    $("#<%=hidShippingCarrier.ClientID%>").val("UPS");
                    $("#<%=hidShippingMethod.ClientID%>").val("-1");
                    LoadHammondCarrier();
                    if ($("#<%=ddlHammondMethod.ClientID %> option[value=" + $("#<%=hidShippingMethod.ClientID%>").val()).size() > 0) {
                        $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                    } else if ($("#<%=ddlShipCountryRegion.ClientID%> option:selected").text() == "Canada") {
                        $("#<%=hidShippingMethod.ClientID%>").val("CanadaGround");
                        $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                    } else {
                        $("#<%=hidShippingMethod.ClientID%>").val("Ground");
                        $("#<%=ddlHammondMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
                    }
                } else {
                    $("#shipHammond").hide(300);
                    $("#shipOwn").show(300);
                    $("#<%=hidShippingCarrier.ClientID%>").val("-1");
                    $("#<%=hidShippingMethod.ClientID%>").val("-1");
                    $("#<%=ddlOwnCarrier.ClientID %>").val($("#<%=hidShippingCarrier.ClientID%>").val());
                    LoadOwnCarrier();
                }
                $("#<%=hidShippingVia.ClientID%>").val($(this).val());
                //Update Prices
                getCheckoutPricing();
            });
            $("#<%=ddlOwnCarrier.ClientID%>").change(function () {
                $("#<%=hidShippingCarrier.ClientID%>").val($(this).val());
                $("#<%=hidShippingMethod.ClientID%>").val("-1");
                LoadOwnCarrier();
                $("#<%=ddlOwnMethod.ClientID %>").val($("#<%=hidShippingMethod.ClientID%>").val());
            });
            $("#<%=ddlHammondMethod.ClientID%>").change(function () {
                $("#<%=hidShippingMethod.ClientID%>").val($(this).val());
                getCheckoutPricing();
            });
            $("#<%=ddlOwnMethod.ClientID%>").change(function () {
                $("#<%=hidShippingMethod.ClientID%>").val($(this).val());
            });
            $("#<%=ddlShipCountryRegion.ClientID %>").change(function () {
                if ($(this).val() == "0") {
                    $("#<%=ddlShipStateProvince.ClientID %>").html("<option value='0'>-Select-</option>");
                    alert("Hammond Greetings only offers web orders for United States and Canada customers. Please call (888) 553-2590 to place your order over the phone.");
                } else {
                    getStatesProvince($(this).val(), "<%=ddlShipStateProvince.ClientID %>");
                }
            });
            $("#<%=ddlBillCountryRegion.ClientID %>").change(function () {
                if ($(this).val() == "0") {
                    $("#<%=ddlBillStateProvince.ClientID %>").html("<option value='0'>-Select-</option>");
                    alert("Hammond Greetings only offers web orders for United States and Canada customers. Please call (888) 553-2590 to place your order over the phone.");
                } else {
                    getStatesProvince($(this).val(), "<%=ddlBillStateProvince.ClientID %>");
                }
            });
            $("#<%=ddlBillStateProvince.ClientID %>").change(function () {
                $("#<%=hidBillStateProvince.ClientID %>").val($("#<%=ddlBillStateProvince.ClientID %> :selected").text());
            });
            $("#<%=ddlShipStateProvince.ClientID %>").change(function () {
                $("#<%=hidShipStateProvince.ClientID %>").val($("#<%=ddlShipStateProvince.ClientID %> :selected").text());
            });
            $("#<%=chkSame.ClientID %>").click(function () {
                if ($(this).attr("checked")) {
                    $("#<%=txtBillFirstName.ClientID %>").val($("#<%=txtShipFirstName.ClientID %>").val());
                    $("#<%=txtBillLastName.ClientID %>").val($("#<%=txtShipLastName.ClientID %>").val());
                    $("#<%=txtBillCompanyName.ClientID %>").val($("#<%=txtShipCompanyName.ClientID %>").val());
                    $("#<%=txtBillAddressLine1.ClientID %>").val($("#<%=txtShipAddressLine1.ClientID %>").val());
                    $("#<%=txtBillAddressLine2.ClientID %>").val($("#<%=txtShipAddressLine2.ClientID %>").val());
                    $("#<%=txtBillCity.ClientID %>").val($("#<%=txtShipCity.ClientID %>").val());
                    $("#<%=ddlBillCountryRegion.ClientID %>").val($("#<%=ddlShipCountryRegion.ClientID %>").val());
                    $("#<%=ddlBillStateProvince.ClientID %>").html($("#<%=ddlShipStateProvince.ClientID %>").html());
                    $("#<%=ddlBillStateProvince.ClientID %>").val($("#<%=ddlShipStateProvince.ClientID %>").val());
                    $("#<%=hidBillStateProvince.ClientID %>").val($("#<%=ddlBillStateProvince.ClientID %> :selected").text());
                    $("#<%=txtBillPostalCode.ClientID %>").val($("#<%=txtShipPostalCode.ClientID %>").val());
                    billingInterface(true);
                } else {
                    billingInterface(false);
                }
            });
        });

        function billingInterface(disabled) {
            if (disabled) {
                $("#<%=txtBillFirstName.ClientID %>").attr("disabled", "true");
                $("#<%=txtBillLastName.ClientID %>").attr("disabled", "true");
                $("#<%=txtBillCompanyName.ClientID %>").attr("disabled", "true");
                $("#<%=txtBillAddressLine1.ClientID %>").attr("disabled", "true");
                $("#<%=txtBillAddressLine2.ClientID %>").attr("disabled", "true");
                $("#<%=txtBillCity.ClientID %>").attr("disabled", "true");
                $("#<%=ddlBillCountryRegion.ClientID %>").attr("disabled", "true");
                $("#<%=ddlBillStateProvince.ClientID %>").attr("disabled", "true");
                $("#<%=txtBillPostalCode.ClientID %>").attr("disabled", "true");
            } else {
                $("#<%=txtBillFirstName.ClientID %>").removeAttr("disabled");
                $("#<%=txtBillLastName.ClientID %>").removeAttr("disabled");
                $("#<%=txtBillCompanyName.ClientID %>").removeAttr("disabled");
                $("#<%=txtBillAddressLine1.ClientID %>").removeAttr("disabled");
                $("#<%=txtBillAddressLine2.ClientID %>").removeAttr("disabled");
                $("#<%=txtBillCity.ClientID %>").removeAttr("disabled");
                $("#<%=ddlBillStateProvince.ClientID %>").removeAttr("disabled");
                $("#<%=ddlBillCountryRegion.ClientID %>").removeAttr("disabled");
                $("#<%=txtBillPostalCode.ClientID %>").removeAttr("disabled");
            }
        }

        var getStates;
        function getStatesProvince(intCountRegionID, insertID, hidID) {
            var jsonText = JSON.stringify({ countryID: intCountRegionID });
            var statesOptions = '';
            getStates = $.ajax({
                type: "POST",
                url: "/WebServices/SiteWebService.asmx/GetStateProvince",
                data: jsonText,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    statesOptions += "<option value='0'>-Select-</option>";
                    for (var i = 0; i < msg.d.length; i++) {
                        statesOptions += "<option value='" + msg.d[i].ID + "'>" + msg.d[i].StateProvince + "</option>";
                    }
                    $("#" + insertID).html(statesOptions);
                    if (hidID != "") {
                        if ($("#" + hidID).val() != "-1") {
                            $("#" + insertID).val($("#" + hidID).val());
                        }
                    }
                },
                error: function(msg) {
                    alert("Error updating states/province.");
                }
            });
        }

        var getPrice;
        function getCheckoutPricing() {
            if (getPrice != undefined) {
                getPrice.abort();
            }
            var billingState = jQuery.trim($("#<%=ddlBillStateProvince.ClientID %> option:selected").text());
            var shippingVia = $("#<%=hidShippingVia.ClientID %>").val();
            var shippingMethod = $("#<%=hidShippingMethod.ClientID %>").val();
            var list = [cartID, billingState, shippingVia, shippingMethod];
            var jsonText = JSON.stringify({ list: list });
            getPrice = $.ajax({
                type: "POST",
                url: "/WebServices/SiteWebService.asmx/GetCheckOutPriceFormatted",
                data: jsonText,
                contentType: "application/json; charset=utf-8",
                dataType: "json",
                success: function(msg) {
                    var prices = msg.d;
                    $("#reviewSubtotal").html(prices[0]);
                    $("#reviewShipping").html(prices[1]);
                    $("#reviewTax").html(prices[2]);
                    $("#reviewGrandTotal").html(prices[3]);
                    $("#paymentSubtotal").text(prices[0]);
                    $("#paymentShipping").text(prices[1]);
                    $("#paymentTax").text(prices[2]);
                    $("#paymentGrandTotal").text(prices[3]);
                },
                error: function(msg) {
                    alert("Error updating checkout price.");
                }
            });
        }

        function LoadHammondCarrier() {
            if ($("#<%=ddlShipCountryRegion.ClientID%> option:selected").text() == "Canada") {
                var opts = '';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="CanadaGround">Canada - Ground</option>';
                opts += '<option value="CanadaExpedited">Canada - Expedited</option>';
                opts += '<option value="CanadaExpress">Canada - Express</option>';
                $("#<%=ddlHammondMethod.ClientID %>").html(opts);
            } else if (jQuery.trim($("#<%=ddlShipCountryRegion.ClientID%> option:selected").text()) == "United States" && jQuery.trim(($("#<%=ddlShipStateProvince.ClientID%>").val()) == "HI" || jQuery.trim($("#<%=ddlShipStateProvince.ClientID%>").val() == "AK"))) {
                var opts = '';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="Ship2Day">2-Day</option>';
                opts += '<option value="Overnight">Overnight</option>';
                $("#<%=ddlHammondMethod.ClientID %>").html(opts);
            } else if (jQuery.trim($("#<%=ddlShipCountryRegion.ClientID%> option:selected").text()) == "United States") {
                var opts = '';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="Ground">Ground</option>';
                opts += '<option value="Ship3Day">3-Day</option>';
                opts += '<option value="Ship2Day">2-Day</option>';
                opts += '<option value="Overnight">Overnight</option>';
                $("#<%=ddlHammondMethod.ClientID %>").html(opts);
            } else {
                var opts = '';
                opts += '<option value="-1">Select Method</option>';
                $("#<%=ddlHammondMethod.ClientID %>").html(opts);
            }
        }
        function LoadOwnCarrier() {
            if ($("#<%=ddlShipCountryRegion.ClientID%> option:selected").text() == "Canada") {
                var opts = '';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="CanadaGround">Canada - Ground</option>';
                opts += '<option value="CanadaExpedited">Canada - Expedited</option>';
                opts += '<option value="CanadaExpress">Canada - Express</option>';
                $("#<%=ddlOwnMethod.ClientID %>").html(opts);
            }else if ($("#<%=ddlOwnCarrier.ClientID%>").val() == "UPS" && ($("#<%=ddlShipStateProvince.ClientID%>").val() == "HI " || $("#<%=ddlShipStateProvince.ClientID%>").val() == "AK ")) {
                var opts ='';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="Ship2Day">2-Day</option>';
                opts += '<option value="Overnight">Overnight</option>';
                $("#<%=ddlOwnMethod.ClientID %>").html(opts);
            }else if($("#<%=ddlOwnCarrier.ClientID%>").val() == "UPS"){
                var opts ='';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="Ground">Ground (Continental U.S.)</option>';
                opts += '<option value="Ship3Day">3-Day (Continental U.S.)</option>';
                opts += '<option value="Ship2Day">2-Day</option>';
                opts += '<option value="Overnight">Overnight</option>';
                $("#<%=ddlOwnMethod.ClientID %>").html(opts);
            }else if($("#<%=ddlOwnCarrier.ClientID%>").val() == "FedEx"){
                var opts ='';
                opts += '<option value="-1">Select Method</option>';
                opts += '<option value="Ground">Ground</option>';
                opts += '<option value="Ship3Day">3-Day</option>';
                opts += '<option value="Ship2Day">2-Day</option>';
                opts += '<option value="Overnight">Overnight</option>';
                $("#<%=ddlOwnMethod.ClientID %>").html(opts);
            }else{
                var opts ='';
                opts += '<option value="-1">Select Method</option>';
                $("#<%=ddlOwnMethod.ClientID %>").html(opts);
            }
        }
        function validateEmail(elementValue) {
            var emailPattern = /^[a-zA-Z0-9._-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,4}$/;
            return emailPattern.test(elementValue);
        }
        function validatePhone(elementValue) {
            var phonePattern = /\d{3}-\d{3}-\d{4}$/;
            return phonePattern.test(elementValue);
        }
    </script>
</asp:Content>
<asp:Content ID="Content4" ContentPlaceHolderID="cphLeft" runat="Server"></asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="cphMain" runat="Server">
  <div id="singleColContent">
    <div id="checkout-page" style="padding-left:5px;">
      <div>
        <ol id="checkout-steps2">
          <li id="step1Top"><img class="step1TopImg" runat="server" src="~/images/loc-billingshipping-inactive.png" alt="Billing and Shipping" title="Billing and Shipping" width="196" height="32" /></li>
          <li id="step2Top"><img class="step2TopImg" runat="server" src="~/images/loc-payment-inactive.png" alt="Payment" title="Payment" width="118" height="32" /></li>
          <li id="step3Top"><img class="step3TopImg" runat="server" src="~/images/loc-confirm-inactive.png" alt="Confirm" title="Confirm" width="112" height="32" /></li>
        </ol>
        <div class="clear"><a style="display:none" name="topScroll"></a></div>
        <div id="step1Group">
          <div id="shipping-info">
            <div class="customizationHeaders">Shipping Information</div>
            <div class="customization-box">
              <table border="0" cellspacing="0" cellpadding="5" >
                <tr>
                  <td width="120"> Ship to Individual :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtShipFirstName" runat="server" Width="120px" CssClass="selected_box1" />
                    <asp:TextBox ID="txtShipLastName" runat="server" Width="120px" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> Company Name : </td>
                  <td><asp:TextBox ID="txtShipCompanyName" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td valign="top"> Address 1 :<span class="red_star">*</span><br />
                  </td>
                  <td valign="top"><asp:TextBox ID="txtShipAddressLine1" runat="server" CssClass="selected_box1" />
                    <br />
                    <span style="font-size: 10px">A street address is required.</span> </td>
                </tr>
                <tr>
                  <td> Address 2 : </td>
                  <td><asp:TextBox ID="txtShipAddressLine2" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> City :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtShipCity" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> Country :<span class="red_star">*</span> </td>
                  <td><asp:DropDownList ID="ddlShipCountryRegion" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> State/Province :<span class="red_star">*</span> </td>
                  <td><asp:DropDownList ID="ddlShipStateProvince" runat="server" Enabled="false" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> Zip Code :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtShipPostalCode" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> Phone :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtPhone" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
                <tr>
                  <td> Email :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtEmail" runat="server" CssClass="selected_box1" />
                  </td>
                </tr>
              </table>
            </div>
            <p><strong>Note:</strong> An order confirmation will be emailed to this address. We
              will never rent, sell trade or exchange your e-mail address... it’s strictly between
              us!</p>
            <p>Fields marked with an asterisk(<span class="red_star">*</span>) are required.</p>
          </div>
          <div id="billing-info">
            <div class="customizationHeaders">Billing Address</div>
            <div class="customization-box">
              <asp:CheckBox runat="server" ID="chkSame" Text="&nbsp;Same As Shipping" TextAlign="Right" />
              <table border="0" cellspacing="0" cellpadding="5">
                <tr>
                  <td width="120"> Bill to Individual :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtBillFirstName" runat="server" Width="120px" CssClass="billInput" />
                    <asp:TextBox ID="txtBillLastName" runat="server" Width="120px" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> Company Name : </td>
                  <td><asp:TextBox ID="txtBillCompanyName" runat="server" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> Address 1 :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtBillAddressLine1" runat="server" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> Address 2 : </td>
                  <td><asp:TextBox ID="txtBillAddressLine2" runat="server" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> City :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtBillCity" runat="server" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> Country :<span class="red_star">*</span> </td>
                  <td><asp:DropDownList ID="ddlBillCountryRegion" runat="server" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> State/Province :<span class="red_star">*</span> </td>
                  <td><asp:DropDownList ID="ddlBillStateProvince" runat="server" Enabled="false" CssClass="billInput" />
                  </td>
                </tr>
                <tr>
                  <td> Zip Code :<span class="red_star">*</span> </td>
                  <td><asp:TextBox ID="txtBillPostalCode" runat="server" CssClass="billInput" />
                  </td>
                </tr>
              </table>
            </div>
            <div style="text-align: center;">
            <asp:ImageButton ID="btnPreviousStep" runat="server" Text="" ToolTip="Continue Shopping" ImageURL="~/images/btn-continueshopping.png" />
            <a href="#" onclick="return false;" id="btnContinueToStep2"><img src="/images/btn-payment.png" alt="Payment" width="164" height="32" /></a>
            <div id="credit-cards"><img runat="server" src="~/images/credit-cards.jpg" alt="Credit Card icons" title="Credit Card icons" width="202" height="31" /></div>
              <div id="social-icons">
            For special offers and tips:<br />
            <a href="http://www.facebook.com/pages/Hammond-Greetings-Promotions/252451087531" target="_blank"><img runat="server" src="~/images/social-facebook.jpg" alt="Greeting Card Deals" title="Greeting Card Deals" width="31" height="31" /></a>
            <a href="http://www.linkedin.com/company/hammond-greetings-and-promotions" target="_blank"><img runat="server" src="~/images/social-linkedin.jpg" alt="Business Greeting Card Specials" title="Business Greeting Card Specials" width="31" height="31" /></a>
            <a href="http://www.twitter.com/corporatecards" target="_blank"><img runat="server" src="~/images/social-twitter.jpg" alt="Bulk Greeting Card Specials" title="Bulk Greeting Card Specials" width="31" height="31" /></a>
            <a href="http://www.youtube.com/user/hammondcards" target="_blank"><img runat="server" src="~/images/social-youtube.jpg" alt="Greeting Cards on YouTube" title="Greeting Cards on YouTube" width="31" height="31" /></a>
           
            <br />
            <a  runat="server" href="http://www.hammond.com/blog/"><img runat="server" src="~/images/blog.jpg" alt="Hammond Blog" title="Hammond Blog" width="157" height="30" /></a>
           
            </div>
           
            <div id="countries">
            We ship to the United States, Canada<br />
             
              <img runat="server" src="~/images/flags.jpg" alt="Flags" title="Flags" width="157" height="74" />
            </div>
           
            </div>
          </div>
         
       
       
           
        </div>
        <div class="clear"> </div>
      </div>
      <div id="step2Group">
        <!--start payment method -->
        <div id="payment-method">
          <div class="customizationHeaders">Payment Method</div>
          <div class="customization-box">
            <div class="visa_bg">
              <input type="radio" name="PaymentMethod" id="rbCredit" value="Credit" class="paymentMethods" />
            </div>
            <div class="payment_text"> Hammond.com secure checkout.</div>
            <br class="clear" />
            <div class="clear"></div>
            <div id="creditCard_Info">
              <table border="0" cellspacing="0" cellpadding="3">
                <tr>
                  <td width="30">&nbsp;</td>
                  <td><strong>Credit Card:</strong> </td>
                  <td><asp:DropDownList ID="ddlCardType" runat="server" CssClass="selected_box1">
                      <asp:ListItem Selected="True" Value="-1">-Select Card-</asp:ListItem>
                      <asp:ListItem Value="MasterCard">MasterCard</asp:ListItem>
                      <asp:ListItem Value="Visa">Visa</asp:ListItem>
                      <asp:ListItem Value="Amex">American Express</asp:ListItem>
                      <asp:ListItem Value="Discover">Discover</asp:ListItem>
                    </asp:DropDownList>
                    <asp:RequiredFieldValidator ID="rvPayment1" Display="Dynamic" InitialValue="-1" ValidationGroup="Payment" ControlToValidate="ddlCardType" runat="server"
                                         ErrorMessage="*" />
                  </td>
                </tr>
                <tr>
                  <td width="30">&nbsp;</td>
                  <td><strong>Credit Card Number:</strong> </td>
                  <td><asp:TextBox runat="server" MaxLength="16" ID="txtCardNumber" Width="140px" CssClass="selected_box1" />
                    <asp:RequiredFieldValidator ID="rvPayment2" Display="Dynamic" ValidationGroup="Payment" ControlToValidate="txtCardNumber" runat="server"
                                         ErrorMessage="*" />
                  </td>
                </tr>
                <tr>
                  <td width="30">&nbsp;</td>
                  <td><strong>Expiration Date:</strong> </td>
                  <td><asp:DropDownList ID="ddlMonth" runat="server" CssClass="selected_box1" Width="50px" />
                    &nbsp;
                    <asp:DropDownList ID="ddlYear" runat="server" CssClass="selected_box1" Width="60px" />
                    <asp:RequiredFieldValidator ID="rvPayment3" Display="Dynamic" ValidationGroup="Payment" InitialValue="-1" ControlToValidate="ddlMonth" runat="server"
                                         ErrorMessage="*" />
                    <asp:RequiredFieldValidator ID="rvPayment4" Display="Dynamic" ValidationGroup="Payment" InitialValue="-1" ControlToValidate="ddlYear" runat="server"
                                         ErrorMessage="*" />
                  </td>
                </tr>
                <tr>
                  <td width="30">&nbsp;</td>
                  <td><strong>Security Code:</strong> </td>
                  <td><asp:TextBox runat="server" ID="txtSecurityCode" Width="50px" MaxLength="4" CssClass="selected_box1" />
                    <asp:LinkButton runat="server" ID="btnWhatsThis" Text="What's This?" OnClientClick="window.open('CC.htm','CC','scrollbars=0,resizable=1,menubars=0,location=0,status=0,titlebar=0,toolbar=0,left=100,top=100,width=300,height=150');return false;" />
                    <asp:RequiredFieldValidator ID="rvPayment5" Display="Dynamic" ValidationGroup="Payment" ControlToValidate="txtSecurityCode" runat="server"
                                         ErrorMessage="*" />
                  </td>
                </tr>
              </table>
            </div>
            <div class="prepayment_bg">
              <input type="radio" name="PaymentMethod" id="rbCheck" value="Check" class="paymentMethods" />
            </div>
            <div class="payment_text"> Hammond.com prepayment by check.</div>
            <br class="clear" />
            <div class="clear"></div>
            <!--
                        <div class="paypal_bg">
                            <input type="radio" name="PaymentMethod" id="rbPayPal" value="PayPal" class="paymentMethods" />
                        </div>
                        <div class="payment_text">
                            The safer, easier way to pay</div>
                        <br class="clear" />
                        <div class="clear">
                        </div>-->
          </div>
        </div>
        <!--end payment method -->
        <div id="shipping-options2">
          <div class="customizationHeaders">Shipping Options</div>
          <div class="customization-box">
            <!--start shopping option part -->
            <div class="shippingOptions">
              <div style="padding:5px 2px">
                <input type="radio" id="rbShipHammond" name="ShippingMethod" class="shippingMethods" value="Hammond" />
                Add the shipping cost to the order. </div>
              <div style="padding:5px 2px">
                <input type="radio" id="rbShipOwn" name="ShippingMethod" class="shippingMethods" value="OwnCarrier" />
                Bill the shipping to my UPS or FedEx account. </div>
              <div id="shipOwn">
                <div style="padding:5px 2px"> Shipping Carrier:
                  <asp:DropDownList ID="ddlOwnCarrier" runat="server" CssClass="selected_box1">
                    <asp:ListItem Selected="True" Value="-1">Select Carrier</asp:ListItem>
                    <asp:ListItem Value="UPS">UPS</asp:ListItem>
                    <asp:ListItem Value="FedEx">FedEx</asp:ListItem>
                  </asp:DropDownList>
                  &nbsp;
                  <asp:DropDownList ID="ddlOwnMethod" runat="server" CssClass="selected_box1">
                    <asp:ListItem Value="-1">Select Method</asp:ListItem>
                  </asp:DropDownList>
                </div>
                <div style="padding:5px 2px"> Account #:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
                  <asp:TextBox ID="txtAccountNumber" runat="server" CssClass="selected_box1" />
                </div>
              </div>
              <div id="shipHammond">
                <div style="padding:5px 2px"> Shipping Method:
                  <asp:DropDownList ID="ddlHammondMethod" runat="server" CssClass="selected_box1"> </asp:DropDownList>
                </div>
              </div>
              <div>
                <div> <strong>Note :</strong><br />
                  All taxes, duties and customs fees are to be paid by the buyer. The rates for UPS
                  Customs Clearance into Canada can be reviewed by clicking on <a href="http://www.ups.com/content/ca/en/shipping/cost/zones/customs_clearance.html" target="_blank" class="link">this link</a>. </div>
              </div>
              </div>
             
              <!--end shopping option part -->
              <div class="clear"></div>
             
           
          </div>
         
          <div style="padding-top:5px;">
            <div>
              <asp:Label ID="lblCartTotal" runat="server" Visible="false"  />
              <div>
                <div class="orderTotalBox">
                  <div class="orderTotalLabel"> Subtotal</div>
                  <div id="paymentSubtotal" class="orderTotalValue"> </div>
                  <div class="clear"> </div>
                </div>
                <div class="orderTotalBox">
                  <div class="orderTotalLabel"> Tax</div>
                  <div id="paymentTax" class="orderTotalValue"> </div>
                  <div class="clear"> </div>
                </div>
                <div class="orderTotalBox">
                  <div class="orderTotalLabel"> Shipping Charges</div>
                  <div id="paymentShipping" class="orderTotalValue"> </div>
                  <div class="clear"> </div>
                </div>
                <div class="orderTotalBox" style="border: none;">
                  <div class="orderGrandTotalLabel"> <strong>Grand Total</strong></div>
                  <div id="paymentGrandTotal" class="orderGrandTotalValue"> </div>
                  <div class="clear"> </div>
                </div>
              </div>
              <div class="clear"> </div>
              <div style="margin: 30px 0;">Prices are in U.S. Dollars</div>
              <div class="clear"> </div>
            </div>
            <div class="clear"></div>
            <div style="text-align: center">
            <a href="#" id="btnBackToStep1" onclick="return false;"><img src="/images/btn-backtoshipping.png" alt="Back to Shipping" width="164" height="32" /></a>
                <a href="#" id="btnContinueToStep3" onclick="return false"><img src="/images/btn-reviewconfirm.png" alt="Review and Confirm" width="164" height="32" /></a>
               
                <div id="credit-cards"><img runat="server" src="~/images/credit-cards.jpg" alt="Credit Card icons" title="Credit Card icons" width="202" height="31" /></div>
              <div id="social-icons">
            For special offers and tips:<br />
            <a href="http://www.facebook.com/pages/Hammond-Greetings-Promotions/252451087531" target="_blank"><img runat="server" src="~/images/social-facebook.jpg" alt="Greeting Card Deals" title="Greeting Card Deals" width="31" height="31" /></a>
            <a href="http://www.linkedin.com/company/hammond-greetings-and-promotions" target="_blank"><img runat="server" src="~/images/social-linkedin.jpg" alt="Business Greeting Card Specials" title="Business Greeting Card Specials" width="31" height="31" /></a>
            <a href="http://www.twitter.com/corporatecards" target="_blank"><img runat="server" src="~/images/social-twitter.jpg" alt="Bulk Greeting Card Specials" title="Bulk Greeting Card Specials" width="31" height="31" /></a>
            <a href="http://www.youtube.com/user/hammondcards" target="_blank"><img runat="server" src="~/images/social-youtube.jpg" alt="Greeting Cards on YouTube" title="Greeting Cards on YouTube" width="31" height="31" /></a>
           
            <br />
            <a  runat="server" href="http://www.hammond.com/blog/"><img runat="server" src="~/images/blog.jpg" alt="Hammond Blog" title="Hammond Blog" width="157" height="30" /></a>
           
            </div>
           
            <div id="countries">
            We ship to the United States, Canada<br />
             
              <img runat="server" src="~/images/flags.jpg" alt="Flags" title="Flags" width="157" height="74" />
            </div>
              </div>
          </div>
          </div>
        </div>
        <div id="step3Group">
          <div class="page-title">
            <h1>Review and Submit Order</h1>
          </div>
          <asp:ListView ID="lvShoppingCart" runat="server" DataKeyNames="CartItemID">
            <LayoutTemplate>
              <table class="shoppingcart" width="100%" cellspacing="0" cellpadding="0" border="0">
                <tr>
                  <th align="left" style="border:solid 1px #C0C0C0;border-right:solid 1px #FFFFFF;padding:3px;"> Cart Item Description </th>
                  <th style="width:160px;border:solid 1px #C0C0C0;padding:3px;" align="right"> Total </th>
                </tr>
                <tr id="itemPlaceHolder" runat="server" />
                <tr>
                  <td colspan="2" style="border:solid 1px #FFFFFF;padding:3px;" align="right">&nbsp;</td>
                </tr>
              </table>
            </LayoutTemplate>
            <ItemTemplate>
              <tr>
                <td align="left" valign="top" style="border:solid 1px #C0C0C0;border-right:0px;border-top:0px;padding:3px;"><table style="border-collapse:collapse;width:100%;border:solid 0px #FFFFFF" cellpadding="0" cellspacing="0">
                    <tr>
                      <td align="left" valign="top" style="border-top:solid 0px #FFFFFF;width:190px"><asp:Image runat="server" ID="imgCard" />
                      </td>
                      <td align="left" valign="top" style="border-top:solid 0px #FFFFFF;"><asp:LinkButton ID="btnEdit" runat="server" CommandArgument='<%#Eval("CartItemID") %>' CommandName="EditCard" Text="<small>Edit Card Customizations</small><br />" ToolTip="Make changes to card customization" />
                        <p>
                          <asp:Literal runat="server" ID="litCardDetails" />
                        </p></td>
                    </tr>
                  </table></td>
                <td align="right" valign="top" style="border:solid 1px #C0C0C0;border-top:0px;padding:3px;"><asp:Label runat="server" ID="lblTotal" Text='<%#Eval("Total", "{0:C}") %>' />
                </td>
              </tr>
            </ItemTemplate>
            <EmptyDataTemplate>
              <table  width="100%"  class="shoppingcart" cellspacing="0" cellpadding="0" border="0">
                <tr>
                  <th align="left" style="border:solid 1px #C0C0C0;padding:3px;"> Item Description </th>
                  <th style="width:160px;border:solid 1px #C0C0C0;padding:3px;" align="right"> Total </th>
                </tr>
                <tr>
                  <td align="left" valign="top" style="border:solid 1px #C0C0C0;border-right:0px;border-top:0px;padding:3px;"> There are cards currently added to the cart. </td>
                  <td align="right" valign="top" style="border:solid 1px #C0C0C0;border-top:0px;padding:3px;">&nbsp;</td>
                </tr>
                <tr>
                  <td>&nbsp;</td>
                  <td>&nbsp;</td>
                </tr>
                <tr>
                  <td colspan="2" style="border:solid 1px #FFFFFF;padding:3px;">&nbsp;</td>
                </tr>
              </table>
            </EmptyDataTemplate>
          </asp:ListView>
          <table style="width:100%">
            <tr>
              <td align="right"><table class="shoppingcart" border="0" cellpadding="3" cellspacing="0" style="width: 500px;border-collapse: collapse;">
                  <tr>
                    <td align="right" style="width:340px;border:solid 1px #C0C0C0;border-right:0px;padding:3px;"><strong>Subtotal:</strong> </td>
                    <td align="right" style="width:160px;border:solid 1px #C0C0C0;padding:3px;"><div id="reviewSubtotal"></div></td>
                  </tr>
                  <tr>
                    <td align="right" style="border:solid 1px #C0C0C0;border-right:0px;padding:3px;"><strong>Tax:</strong> </td>
                    <td align="right" style="border:solid 1px #C0C0C0;padding:3px;"><div id="reviewTax"></div></td>
                  </tr>
                  <tr>
                    <td align="right" style="border:solid 1px #C0C0C0;border-right:0px;padding:3px;"><strong>Shipping:</strong> </td>
                    <td align="right" style="border:solid 1px #C0C0C0;padding:3px;"><div id="reviewShipping"></div></td>
                  </tr>
                  <tr>
                    <td align="right" style="border:solid 1px #C0C0C0;border-right:0px;padding:3px;"><strong>Grand Total:</strong> </td>
                    <td align="right" style="border:solid 1px #C0C0C0;padding:3px;"><div id="reviewGrandTotal"></div></td>
                  </tr>
                </table></td>
            </tr>
          </table>
          <br />
          <h2>Shipping Information</h2>
          <div class="clearDevider"></div>
          <table style="width:100%" cellspacing="3" cellpadding="2" border="0">
            <tr>
              <td style="width:33%;font-size:11px;" valign="top"><div id="reviewShippingMethod"></div></td>
            </tr>
          </table>
          <br />
          <h2>Your Information</h2>
          <div class="clearDevider"></div>
          <table style="width: 100%" cellspacing="3" cellpadding="2" border="0">
            <tr>
              <td class="checkoutProgress" style="width:33%" valign="top"> Shipping Information</td>
              <td class="checkoutProgress" style="width:33%" valign="top" > Billing Information </td>
              <td class="checkoutProgress" style="width:34%" valign="top" > General Information </td>
            </tr>
            <tr>
              <td style="width:33%;font-size:11px;" valign="top"><div id="reviewShippingInfo"></div></td>
              <td style="width:33%;font-size:11px;" valign="top" ><div id="reviewBillingInfo"></div></td>
              <td style="width:34%;font-size:11px;" valign="top" ><div id="reviewGeneralInfo"></div></td>
            </tr>
            <tr>
              <td style="width:33%" valign="top"><input type="button" class="button-edit" ID="btnEditShipping"  /></td>
              <td style="width:33%" valign="top" ><input type="button" class="button-edit" ID="btnEditBilling" />
              </td>
              <td style="width:34%" valign="top" ><input type="button" class="button-edit" ID="btnEditGeneral"  />
              </td>
            </tr>
          </table>
          <h2>Payment Information</h2>
          <div class="clearDevider"></div>
          <table style="width: 100%" cellspacing="3" cellpadding="2" border="0">
            <tr>
              <td class="checkoutProgress" style="width:100%" valign="top"> Payment Information</td>
            </tr>
            <tr>
              <td style="width:100%;font-size:11px;" valign="top"><div id="reviewPaymentInfo"></div></td>
            </tr>
            <tr>
              <td style="width:33%" valign="top"><input type="button" class="button-edit" ID="btnEditPayment" /></td>
            </tr>
          </table>
          <h2>Special Instructions</h2>
          <div class="clearDevider"></div>
          <table style="width: 100%" cellspacing="3" cellpadding="2" border="0">
            <tr>
              <td style="width:100%" valign="top"><asp:Textbox ID="txtSpecialInstructions" TextMode="MultiLine" Rows="4" Width="98%" runat="server" CssClass="cartInput" /></td>
            </tr>
          </table>
          <h2>Hammond Greetings & Promotions Payment Terms</h2>
          <div class="clearDevider"></div>
          <table style="width: 100%" cellspacing="3" cellpadding="2" border="0">
            <tr>
              <td style="width:100%;font-size:11px;" valign="top"><b>Payment Terms:</b> Once submitted to Hammond Greetings &amp; Promotions LLC, orders may not be cancelled
                or changed as outlined in the Return/Cancellation Policy.&nbsp;<br />
                <b>Prepayment by Credit Card:</b> Customer agrees to pay
                the Total according to the card holder agreement.&nbsp;<br />
                <b>Prepayment by Check:</b> An additional $20.00 will be
                charged for returned checks. A 1.5% monthly (18% annual) service fee will be charged
                on all unpaid balances resulting from returned checks. Unpaid balances more than
                30 days past due will be turned over to a collection agency. Customer agrees to
                pay collection costs up to 50% of the amount owed, all court costs, and reasonable
                attorneys' fees.<br />
                <b>Return/Cancellation Policy:</b><br />
                Orders that have been placed can only be canceled if the job has not yet been printed.
                Such orders are subject to a 20% cancellation fee. Once an order is printed as the
                customer ordered no return will be accepted and no refund will be given. If a customer
                orders unprinted merchandise, they may return the merchandise in the original packaging
                within 60 days for a 75% refund of the original purchase price.<br />
                <br />
                Questions can be sent to <a target="_blank" href="mailto:sales@hammond.com">sales@hammond.com</a>.
                By placing an order you indicate that you have read and understand these terms and
                policies. </td>
            </tr>
          </table>
          <div>
            <div style="float:right">
              <input type="button" ID="btnBackToStep2" title="Back To Payment" class="button-payment-back" />
              <asp:Button ID="btnFinalize" runat="server" Text="" OnClientClick="return enableBilling();" ToolTip="Finalize Order" CssClass="button-finalize-order" />
            </div>
          </div>
        </div>
      </div>
    </div>
  </div>
  <asp:HiddenField ID="hidPaymentMethod" runat="server" Value="Credit" />
  <asp:HiddenField ID="hidShippingMethod" runat="server" Value="Ground" />
  <asp:HiddenField ID="hidShippingCarrier" runat="server" Value="UPS" />
  <asp:HiddenField ID="hidShippingVia" runat="server" Value="Hammond" />
  <asp:HiddenField ID="hidShipStateProvince" runat="server" Value="-1" />
  <asp:HiddenField ID="hidBillStateProvince" runat="server" Value="-1" />
</asp:Content>




.cs  page ......................................................********************************

Partial Class secure_checkout
    Inherits System.Web.UI.Page

    Dim lk As New Lookups()
    Dim om As New OrderManager()
    Dim cardm As New CardManager
    Dim cartM As New CartManager

    Dim _TransactionID As String = String.Empty
    Dim _ReasonCode As String = String.Empty
    Dim _ReasonText As String = String.Empty
    Dim _TransError As String = String.Empty
    Dim _AVSADDR As String = String.Empty
    Dim _AVSZIP As String = String.Empty
    Dim _CVV2MATCH As String = String.Empty

    Public Property myCart() As Cart
        Get
            Return IIf(ViewState("myCart") Is Nothing, Nothing, ViewState("myCart"))
        End Get
        Set(ByVal value As Cart)
            ViewState("myCart") = value
        End Set
    End Property

    Public Property CartID() As String
        Get
            Return IIf(ViewState("CartID") Is Nothing, Nothing, ViewState("CartID"))
        End Get
        Set(ByVal value As String)
            ViewState("CartID") = value
        End Set
    End Property

    Public Property myOrder() As Order
        Get
            Return IIf(ViewState("myOrder") Is Nothing, New Order, ViewState("myOrder"))
        End Get
        Set(ByVal value As Order)
            ViewState("myOrder") = value
        End Set
    End Property

    Public Property CurrentStep() As Integer
        Get
            Return IIf(ViewState("CurrentStep") Is Nothing, 1, ViewState("CurrentStep"))
        End Get
        Set(ByVal value As Integer)
            ViewState("CurrentStep") = value
        End Set
    End Property

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Master.HideWriteUp()
            If Session("myOrder") Is Nothing Then
                myOrder = New Order(System.Guid.NewGuid.ToString())
            Else
                myOrder = CType(Session("myOrder"), Order)
            End If
            LoadDDls()
            LoadCart()
            LoadShippingBilling()
        End If
    End Sub

    Protected Sub btnPreviousStep_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnPreviousStep.Click
        Response.Redirect(SiteConfigs.RegularDomain & "/order/viewcart.aspx", True)
    End Sub

    Private Sub LoadCart()
        'PayPal Coming In
        If Request.QueryString("CartID") IsNot Nothing AndAlso Request.QueryString("Token") IsNot Nothing Then
            myCart = (New CartManager).GetCartByCartID(Request.QueryString("CartID"))
            'SetPageSessionsEC()
        Else
            myCart = (New CartManager).GetCartBySessionID(HttpContext.Current.Session.SessionID)
        End If
        Session("CartID") = myCart.CartID
        CartID = myCart.CartID
        Me.lvShoppingCart.DataSource = myCart.CartItems
        Me.lvShoppingCart.DataBind()
    End Sub

    Private Sub LoadDDls()
        ''SHIPPING BILLING ADDRESSES
        lk.GetCountryRegionDDL(Me.ddlShipCountryRegion)
        lk.GetCountryRegionDDL(Me.ddlBillCountryRegion)

        ''PAYMENT
        Me.ddlMonth.Items.Clear()
        Me.ddlYear.Items.Clear()
        For i As Integer = 1 To 12
            Me.ddlMonth.Items.Add(New ListItem(i.ToString, i.ToString))
        Next
        Me.ddlMonth.Items.Insert(0, New ListItem("_", "-1"))
        For y As Integer = System.DateTime.Now.Year To (System.DateTime.Now.Year + 10)
            Me.ddlYear.Items.Add(New ListItem(y.ToString, y.ToString))
        Next
        Me.ddlYear.Items.Insert(0, New ListItem("_", "-1"))

    End Sub

    Private Sub LoadOrderWithPage()
        'Save Into Billing Session
        With myOrder
            .Email = Me.txtEmail.Text
            .Phone = Me.txtPhone.Text

            .ShipFirstName = Me.txtShipFirstName.Text
            .ShipLastName = Me.txtShipLastName.Text
            .ShipCompanyName = Me.txtShipCompanyName.Text
            .ShipAddressLine1 = Me.txtShipAddressLine1.Text
            .ShipAddressLine2 = Me.txtShipAddressLine2.Text
            .ShipCity = Me.txtShipCity.Text
            .ShipState = Me.hidShipStateProvince.Value
            .ShipPostalCode = Me.txtShipPostalCode.Text
            .ShipCountry = Me.ddlShipCountryRegion.SelectedItem.Text

            .BillFirstName = Me.txtBillFirstName.Text
            .BillLastName = Me.txtBillLastName.Text
            .BillCompanyName = Me.txtBillCompanyName.Text
            .BillAddressLine1 = Me.txtBillAddressLine1.Text
            .BillAddressLine2 = Me.txtBillAddressLine2.Text
            .BillCity = Me.txtBillCity.Text
            .BillStateProvince = Me.hidBillStateProvince.Value
            .BillPostalCode = Me.txtBillPostalCode.Text
            .BillCountry = Me.ddlBillCountryRegion.SelectedItem.Text

            .PaymentMethod = Me.hidPaymentMethod.Value
            If Me.hidPaymentMethod.Value = "Credit" Then
                .CardNumber = Me.txtCardNumber.Text
                .Month = Me.ddlMonth.SelectedValue
                .Year = Me.ddlYear.SelectedValue
                .SecurityCode = Me.txtSecurityCode.Text
                .CardType = Me.ddlCardType.SelectedValue
            End If

            .PromoCode = IIf(Session("PromoCode") Is Nothing, "", Session("PromoCode"))

            .ShippingVia = IIf(Me.hidShippingVia.Value = "Hammond", SiteEnums.ShippingVia.Hammond, SiteEnums.ShippingVia.OwnCarrier)
            .ShippingAccount = IIf(.ShippingVia = SiteEnums.ShippingVia.Hammond, "", Me.txtAccountNumber.Text)
            .ShippingCarrier = SiteEnums.StringToShippingCarrier(Me.hidShippingCarrier.Value)
            .ShippingMethod = SiteEnums.StringToShippingMethod(Me.hidShippingMethod.Value)

            .SpecialInstructions = Me.txtSpecialInstructions.Text
            om.LoadCartItemsToOrderItems(myCart.CartItems, myOrder)

        End With
        Session("myOrder") = myOrder
    End Sub

    Private Sub LoadShippingBilling()
        With myOrder
            Me.txtEmail.Text = .Email
            Me.txtPhone.Text = .Phone

            Me.txtShipFirstName.Text = .ShipFirstName
            Me.txtShipLastName.Text = .ShipLastName
            Me.txtShipCompanyName.Text = .ShipCompanyName
            Me.txtShipAddressLine1.Text = .ShipAddressLine1
            Me.txtShipAddressLine2.Text = .ShipAddressLine2
            Me.txtShipCity.Text = .ShipCity
            If Me.ddlShipCountryRegion.Items.Contains(Me.ddlShipCountryRegion.Items.FindByText(.ShipCountry)) Then
                Me.ddlShipCountryRegion.SelectedIndex = -1
                Me.ddlShipCountryRegion.Items.FindByText(.ShipCountry).Selected = True
            End If
            lk.GetStateProvinceByCountryRegionIDDDL(Me.ddlShipStateProvince, Me.ddlShipCountryRegion.SelectedValue)
            If Me.ddlShipStateProvince.Items.Contains(Me.ddlShipStateProvince.Items.FindByText(.ShipState)) Then
                Me.ddlShipStateProvince.SelectedIndex = -1
                Me.ddlShipStateProvince.Items.FindByText(.ShipState).Selected = True
            End If
            Me.txtShipPostalCode.Text = .ShipPostalCode
            If Me.ddlShipCountryRegion.SelectedValue <> 0 Then
                Me.ddlShipStateProvince.Enabled = True
            End If

            Me.txtBillFirstName.Text = .BillFirstName
            Me.txtBillLastName.Text = .BillFirstName
            Me.txtBillCompanyName.Text = .BillCompanyName
            Me.txtBillAddressLine1.Text = .BillAddressLine1
            Me.txtBillAddressLine2.Text = .BillAddressLine2
            Me.txtBillCity.Text = .BillCity
            lk.GetStateProvinceByCountryRegionIDDDL(Me.ddlBillStateProvince, Me.ddlBillCountryRegion.SelectedValue)
            If Me.ddlBillCountryRegion.Items.Contains(Me.ddlBillCountryRegion.Items.FindByText(.BillCountry)) Then
                Me.ddlBillCountryRegion.SelectedIndex = -1
                Me.ddlBillCountryRegion.Items.FindByText(.BillCountry).Selected = True
            End If
            If Me.ddlBillStateProvince.Items.Contains(Me.ddlBillStateProvince.Items.FindByText(.BillStateProvince)) Then
                Me.ddlBillStateProvince.SelectedIndex = -1
                Me.ddlBillStateProvince.Items.FindByText(.BillStateProvince).Selected = True
            End If
            Me.txtBillPostalCode.Text = .BillPostalCode
            If Me.ddlBillCountryRegion.SelectedValue <> 0 Then
                Me.ddlBillStateProvince.Enabled = True
            End If

            If myCart.ShippingVia = SiteEnums.ShippingVia.OwnCarrier Then
                Me.txtAccountNumber.Text = myCart.ShippingAccount
            End If

            Me.hidBillStateProvince.Value = .BillStateProvince
            Me.hidShipStateProvince.Value = .ShipState
            Me.hidShippingMethod.Value = myCart.ShippingMethod.ToString()
            Me.hidShippingCarrier.Value = myCart.ShippingCarrier.ToString()
            Me.hidShippingVia.Value = myCart.ShippingVia.ToString()
            Me.hidPaymentMethod.Value = "Credit"

        End With
    End Sub

    Protected Sub btnFinalize_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnFinalize.Click
        LoadOrderWithPage()
        SubmitOrder()
    End Sub

    Protected Sub lvShoppingCart_ItemCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewCommandEventArgs) Handles lvShoppingCart.ItemCommand
        If e.CommandName = "EditCard" Then
            Dim ci As CartItem = New CartManager().GetCartItemByCartItemID(e.CommandArgument)
            'ended successfully..*
            Response.Redirect(SiteConfigs.RegularDomain & String.Format("/order/customizecard.aspx?CartItemID={0}&CardID={1}", e.CommandArgument, ci.CardID))
            'ended successfully..*
        End If
    End Sub

    Protected Sub lvShoppingCart_ItemDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.ListViewItemEventArgs) Handles lvShoppingCart.ItemDataBound
        If e.Item.ItemType = ListViewItemType.DataItem Then
            Dim imgCard As Image = CType(e.Item.FindControl("imgCard"), Image)
            Dim cartItem As CartItem = CType(CType(e.Item, ListViewDataItem).DataItem, CartItem)
            If cartItem.Assortment Then
                CType(e.Item.FindControl("btnEdit"), LinkButton).Visible = False
                imgCard.ImageUrl = String.Format("~/imagescards/thumbnail/{0}.jpg", (New CardManager).GetAssortment(cartItem.AssortmentID).CompanyCardID)
                Dim litCardDetails As Literal = CType(e.Item.FindControl("litCardDetails"), Literal)
                litCardDetails.Text = (New CartManager).DisplayCartItemAssortment(cartItem)
            Else
                imgCard.ImageUrl = String.Format("~/imagescards/thumbnail/{0}.jpg", (New CardManager).GetCard(cartItem.CardID).CardTitlePath)
                Dim litCardDetails As Literal = CType(e.Item.FindControl("litCardDetails"), Literal)
                litCardDetails.Text = (New CartManager).DisplayCartItem(cartItem)
            End If
        End If
    End Sub

    ''' <summary>
    ''' PAYPAL
    ''' </summary>
    ''' <remarks></remarks>
    Sub SetPageSessionsEC()
        Dim pEC As New PayPalExpress()
        pEC.Token = Request.QueryString("Token")
        pEC.PayerID = Request.QueryString("PayerID")
        If pEC.GetExpress() Then
            Dim myOrder As Order = New Order(myCart.CartID.ToString())
            myOrder.ShipCompanyName = pEC.Name
            myOrder.ShipFirstName = pEC.Name
            myOrder.ShipAddressLine1 = pEC.Street & " " & pEC.Street2
            myOrder.ShipCity = pEC.City
            myOrder.ShipState = pEC.State
            myOrder.ShipPostalCode = pEC.Zip
            myOrder.ShipCountry = pEC.Country
            myOrder.PaymentMethod = "PayPal"
        Else
            Response.Write(pEC.Message & pEC.MessageError)
        End If
    End Sub

    Private Sub SubmitOrder()
        Dim oManager As New OrderManager
        Dim blSendMail As Boolean = False

        Dim dblSubTotal As Double = 0
        Dim dblTax As Double = 0
        Dim dblShipping As Double = SiteConfigs.HammondShipping
        Dim dblTotalAmount As Double = 0
        With myOrder
            .SpecialInstructions = .SpecialInstructions
            .DateOrdered = System.DateTime.Now
            .IsProcessed = False
            .OrderShippingCost = .ShippingCost
            .OrderSubTotal = .SubTotal
            .OrderTax = .Tax
        End With

        If myOrder.PaymentMethod <> "Check" And myOrder.PaymentMethod <> "PayPal" Then 'CreditCard Order
            '9June:Removed (Payment details entered in NetSuite)
            'Dim creditProcess As PayFlowPro = New PayFlowPro()
            'With creditProcess
            '    .CardMonth = myOrder.Month
            '    .CardYear = myOrder.Year
            '    .CardNumber = myOrder.CardNumber
            '    .FirstName = myOrder.BillFirstName
            '    .LastName = myOrder.BillLastName
            '    .SecurityCode = myOrder.SecurityCode
            '    .OrderDescription = "Hammond.com Secure Checkout"
            '    .Comment1 = "Hammond.com Secure Checkout"
            '    .Comment2 = ""
            '    .PONum = ""
            '    .INVNum = oManager.NextAvailableOrderNumber() 'myCart.CartID.Replace("-", "").ToString()
            '    .Amount = myOrder.OrderOrderTotal
            '    .Street = myOrder.BillAddressLine1
            '    .City = myOrder.BillCity
            '    .State = myOrder.BillStateProvince
            '    .Country = myOrder.BillCountry
            '    .Zip = myOrder.BillPostalCode
            'End With
            'Dim blProcessed As Boolean = True 'creditProcess.Process()
            Dim blProcessed As Boolean = True
            If blProcessed Then
                myOrder.TransactionID = "" 'creditProcess.PnRef
                '_ReasonCode = creditProcess.RespMsg ' String.Format("{0} : {1}", creditProcess.Result, creditProcess.RespMsg)
                '_TransError = creditProcess.RespMsg
                '_AVSADDR = creditProcess.AVSAddr
                '_AVSZIP = creditProcess.AVSZip
                '_CVV2MATCH = creditProcess.CVV2Match

                myOrder.ResponseCode = "" 'creditProcess.FullResponse

                'Add To Orders Table
                oManager.InsertOrder(myOrder, myCart.CartID.ToString())

                'IF My Account Stuff
                If Not Session("Customer") Is Nothing Then
                    Dim cm As New CustomerManager
                    Dim myCustomer As Customer = CType(Session("Customer"), Customer)
                    cm.UpdateCustomer(myCustomer)
                    'Add The Order To This Customer
                    Try
                        cm.AddOrderToCustomer(myCart.CartID.ToString(), Session("CustomerID").ToString())
                        myCustomer.CustomerOrders.Insert(0, oManager.GetOrder(myCart.CartID.ToString()))
                        Session("Customer") = myCustomer
                    Catch ex As Exception

                    End Try
                End If

                'NSINTEGRATION: Add To NS Order
                CreateNSSalesOrder(myOrder, myCart)
                blSendMail = oManager.SendOrderEmail(myCart.CartID.ToString(), SiteEnums.EmailType.Order)
                Response.Redirect("~/Secure/confirmation.aspx?MailSent=" & blSendMail & "&OrderID=" & myCart.CartID.ToString(), True)
            Else
                'Stay Put
                'Display Credit Card Errors
                ClientScript.RegisterStartupScript(Page.GetType(), "ErrorCC", "alert('" & _TransError & "');", True)
            End If
        ElseIf myOrder.PaymentMethod = "Check" Then 'Payment By Check
            'Add To Orders Table
            oManager.InsertOrder(myOrder, myCart.CartID.ToString())
            'NSINTEGRATION: Add To NS Order
            CreateNSSalesOrder(myOrder, myCart)
            'Send Emails
            blSendMail = oManager.SendOrderEmail(myCart.CartID.ToString(), SiteEnums.EmailType.Order)

            'Redirect To Thank You
            Response.Redirect("~/Secure/confirmation.aspx?MailSent=" & blSendMail & "&OrderID=" & myCart.CartID.ToString(), True)
        ElseIf myOrder.PaymentMethod = "PayPal" Then
            'FINALIZE AT PAYPAL
            Dim pEC As New PayPalExpress()
            pEC.Token = Request.QueryString("Token")
            pEC.PayerID = Request.QueryString("PayerID")
            Session("PayerID") = Request.QueryString("PayerID")
            pEC.CartID = myCart.CartID
            pEC.Amount = dblTotalAmount
            'JUST SET IT FINAL
            pEC.SetExpress()
            If True Then
                oManager.InsertOrder(myOrder, myCart.CartID.ToString())

                'Send Emails
                Dim blMailSent As Boolean = oManager.SendOrderEmail(myCart.CartID.ToString(), SiteEnums.EmailType.Order)

                Session("CartID") = Nothing
                Session("myOrder") = Nothing
                Session("CheckOutMethod") = Nothing
                Session("CartID") = Nothing
                'Redirect To Thank You
                Response.Redirect(String.Format("~/Secure/confirmation.aspx?MailSent={0}&OrderID={1}", blMailSent.ToString(), myCart.CartID.ToString()), True)
            End If
        End If

    End Sub

    'NSINTEGRATION: Add To NS Order
    Private Function CreateNSSalesOrder(ByRef myOrder As Order, ByRef myCart As Cart) As Integer
        Dim objNSSalesOrderManager As NSSalesOrderManager = New NSSalesOrderManager(myOrder, myCart)
        objNSSalesOrderManager.CreateSalesOrderInNS()
    End Function

End Class

No comments:

Post a Comment