void btnCreateOrder_Click(object sender, EventArgs e)
        {
            if (cart.UserGuid == Guid.Empty)
            {
                SiteUser newUser = SiteUtils.CreateMinimalUser(siteSettings, cart.OrderInfo.CustomerEmail, true, WebStoreResources.UserCreatedForOrder);
                cart.UserGuid = newUser.UserGuid;
            }

            cart.LastUserActivity          = DateTime.UtcNow;
            cart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address();
            cart.OrderInfo.Completed       = DateTime.UtcNow;
            StoreHelper.EnsureUserForOrder(cart);
            cart.Save();

            Order order = Order.CreateOrder(
                store,
                cart,
                string.Empty,
                txtTransactionId.Text,
                txtAuthCode.Text,
                siteSettings.GetCurrency().Code,
                "OrderEntry",
                OrderStatus.OrderStatusFulfillableGuid);


            StoreHelper.ClearClerkCartCookie(cart.StoreGuid);

            // send confirmation email
            try
            {
                if (chkOrderEntrySendConfirmationEamil.Checked)
                {
                    StoreHelper.ConfirmOrder(store, order);
                }
                Module m = new Module(store.ModuleId);
                Order.EnsureSalesReportData(m.ModuleGuid, pageId, moduleId);
            }
            catch (Exception ex)
            {
                log.Error("error sending confirmation email", ex);
            }

            // redirect to order details
            string redirectUrl = SiteRoot +
                                 "/WebStore/AdminOrderDetail.aspx?pageid="
                                 + pageId.ToInvariantString()
                                 + "&mid=" + moduleId.ToInvariantString()
                                 + "&order=" + order.OrderGuid.ToString();

            WebUtils.SetupRedirect(this, redirectUrl);
        }
        void btnMakePayment_Click(object sender, EventArgs e)
        {
            if (
                (store != null) &&
                (cart != null)
                )
            {
                IPaymentGateway gateway = commerceConfig.GetDirectPaymentGateway();
                if (gateway == null)
                {
                    lblMessage.Text        = WebStoreResources.PaymentGatewayNotConfiguredForDirectCardProcessing;
                    btnMakePayment.Enabled = false;
                    return;
                }
                if (gateway is PlugNPayPaymentGateway)
                {
                    gateway.MerchantInvoiceNumber = cart.CartGuid.ToString("N");
                    string CartItems = "";
                    int    itemnum   = 0;
                    foreach (CartOffer coffer in cart.CartOffers)
                    {
                        itemnum++;
                        CartItems += string.Format("&item{1}={0}&cost{1}={2}&description{1}={3}&quantity{1}={4}", coffer.OfferGuid, itemnum, coffer.OfferPrice, coffer.Name, coffer.Quantity);
                    }
                    gateway.MerchantTransactionDescription = CartItems; //not sure if this is the intended purpose or not
                }

                gateway.CardType         = ddCardType.SelectedValue;
                gateway.CardNumber       = txtCardNumber.Text;
                gateway.CardExpiration   = ddExpireMonth.SelectedValue + ddExpireYear.SelectedValue;
                gateway.ChargeTotal      = cart.OrderTotal;
                gateway.CardSecurityCode = txtCardSecurityCode.Text;

                gateway.CardOwnerFirstName = txtCardOwnerFirstName.Text;
                gateway.CardOwnerLastName  = txtCardOwnerLastName.Text;

                gateway.CardOwnerCompanyName = cart.OrderInfo.BillingCompany;
                gateway.CardBillingAddress   = cart.OrderInfo.BillingAddress1
                                               + " " + cart.OrderInfo.BillingAddress2;

                gateway.CardBillingCity       = cart.OrderInfo.BillingCity;
                gateway.CardBillingState      = cart.OrderInfo.BillingState;
                gateway.CardBillingPostalCode = cart.OrderInfo.BillingPostalCode;
                gateway.CardBillingCountry    = cart.OrderInfo.BillingCountry;


                gateway.CardBillingCountryCode = cart.OrderInfo.BillingCountry;

                gateway.CardBillingPhone  = cart.OrderInfo.CustomerTelephoneDay;
                gateway.CustomerIPAddress = SiteUtils.GetIP4Address();

                // this is where the actual request is made, it can timeout here
                bool executed = false;
                try
                {
                    executed = gateway.ExecuteTransaction();
                }
                catch (WebException ex)
                {
                    if (commerceConfig.PaymentGatewayUseTestMode)
                    {
                        lblMessage.Text = ex.Message;
                    }
                    else
                    {
                        lblMessage.Text = WebStoreResources.PaymentGatewayCouldNotConnectMessage;
                    }
                    return;
                }

                string serializedCart = string.Empty;

                if (gateway is PayPalDirectPaymentGateway)
                {
                    // this is capturing of the serialized cart is not needed for other providers and I'm not sure its even needed for PayPal Direct
                    // it was needed for other paypal solutions. I just don't want to remove it until I'm sure
                    cart.SerializeCartOffers();
                    serializedCart = SerializationHelper.SerializeToString(cart);

                    gateway.LogTransaction(
                        siteSettings.SiteGuid,
                        store.ModuleGuid,
                        store.Guid,
                        cart.CartGuid,
                        cart.UserGuid,
                        "WebStorePayPalDirect",
                        "DirectPayment",
                        serializedCart);
                }
                else
                {
                    gateway.LogTransaction(
                        siteSettings.SiteGuid,
                        store.ModuleGuid,
                        store.Guid,
                        cart.CartGuid,
                        cart.UserGuid,
                        string.Empty,
                        "WebStoreCheckout",
                        serializedCart);
                }


                if (executed)
                {
                    switch (gateway.Response)
                    {
                    case PaymentGatewayResponse.Approved:
                        cart.LastUserActivity          = DateTime.UtcNow;
                        cart.OrderInfo.CompletedFromIP = SiteUtils.GetIP4Address();
                        cart.OrderInfo.Completed       = DateTime.UtcNow;
                        StoreHelper.EnsureUserForOrder(cart);
                        cart.Save();

                        //Order order = Order.CreateOrder(store, cart, gateway, store.DefaultCurrency, "CreditCard");
                        Order order = Order.CreateOrder(store, cart, gateway, siteSettings.GetCurrency().Code, "CreditCard");
                        StoreHelper.ClearClerkCartCookie(cart.StoreGuid);

                        // send confirmation email
                        try
                        {
                            if (chkSendConfirmationEmail.Checked)
                            {
                                StoreHelper.ConfirmOrder(store, order);
                            }
                            Module m = new Module(store.ModuleId);
                            Order.EnsureSalesReportData(m.ModuleGuid, pageId, moduleId);
                        }
                        catch (Exception ex)
                        {
                            log.Error("error sending confirmation email", ex);
                        }

                        // redirect to order details
                        string redirectUrl = SiteRoot +
                                             "/WebStore/AdminOrderDetail.aspx?pageid="
                                             + pageId.ToInvariantString()
                                             + "&mid=" + moduleId.ToInvariantString()
                                             + "&order=" + order.OrderGuid.ToString();

                        WebUtils.SetupRedirect(this, redirectUrl);
                        return;

                    case PaymentGatewayResponse.Declined:

                        lblMessage.Text = WebStoreResources.TransactionDeclinedMessage;

                        break;


                    case PaymentGatewayResponse.Error:

                        if (gateway.UseTestMode)
                        {
                            if (gateway.LastExecutionException != null)
                            {
                                lblMessage.Text = gateway.LastExecutionException.ToString();
                            }
                            else
                            {
                                // TODO: should not show user real messages? Mask CCNumber and login credentials in the gateways RawResponse property ... those shouldn't be logged either
                                lblMessage.Text = gateway.RawResponse;
                            }
                        }
                        else
                        {
                            lblMessage.Text = WebStoreResources.TransactionErrorMessage;
                        }

                        break;

                    case PaymentGatewayResponse.NoRequestInitiated:

                        lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage;
                        break;
                    }
                }
                else
                {
                    lblMessage.Text = WebStoreResources.TransactionNotInitiatedMessage;

                    if (gateway.LastExecutionException != null)
                    {
                        if (commerceConfig.PaymentGatewayUseTestMode)
                        {
                            lblMessage.Text = gateway.LastExecutionException.ToString();
                        }
                    }
                }
            }

            btnMakePayment.Text = WebStoreResources.PaymentButton;
        }