Esempio n. 1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            try
            {
                if (!Page.IsPostBack)
                {
                    btnConfirmOrder.Attributes.Add("OnClick", ScriptAvoidDoubleClick(btnConfirmOrder, Localization.GetString("Processing", LocalResourceFile)));
                    lblError.Text    = string.Empty;
                    lblError.Visible = false;
                    string message = Localization.GetString("lblConfirmMessage", LocalResourceFile);
                    lblConfirmMessage.Text = string.Format(message, PortalSettings.PortalName);
                }

                EmailNavigation nav = new EmailNavigation(Request.QueryString);
                if (nav.GatewayExit.ToUpper() == "RETURN")
                {
                    CheckoutControl.Hide();
                    pnlProceedToEmail.Visible = false;
                    InvokeAwaitingPayment();
                }
            }
            catch (Exception ex)
            {
                Exceptions.ProcessModuleLoadException(this, ex);
            }
        }
Esempio n. 2
0
        protected void btnProcess_Click(object sender, EventArgs e)
        {
            Page.Validate();
            if (!Page.IsValid)
            {
                return;
            }

            PortalSecurity security = new PortalSecurity();

            TransactionDetails transaction = new TransactionDetails
            {
                CardNumber       = security.InputFilter(txtNumber.Text, PortalSecurity.FilterFlag.NoMarkup),
                VerificationCode = security.InputFilter(txtVer.Text, PortalSecurity.FilterFlag.NoMarkup),
                ExpirationMonth  = int.Parse(ddlMonth.SelectedValue),
                ExpirationYear   = int.Parse(ddlYear.SelectedValue)
            };

            if (transaction.IsValid())
            {
                IAddressInfo shippingAddress = CheckoutControl.ShippingAddress;
                IAddressInfo billingAddress  = CheckoutControl.BillingAddress;
                //Adds order to db...
                OrderInfo order = CheckoutControl.GetFinalizedOrderInfo();

                GenerateOrderConfirmation();

                //Process transaction
                AuthNetGatewayProvider provider    = new AuthNetGatewayProvider(StoreSettings.GatewaySettings);
                TransactionResult      orderResult = provider.ProcessTransaction(shippingAddress, billingAddress, order, transaction);
                if (!orderResult.Succeeded)
                {
                    string errorMessage    = string.Empty;
                    string localizedReason = string.Empty;
                    // Try to get the corresponding localized reason message
                    localizedReason = Localization.GetString("ReasonCode" + orderResult.ReasonCode, LocalResourceFile);
                    // If a localized message do not exist use the original message
                    if (localizedReason == string.Empty | localizedReason == null)
                    {
                        localizedReason = orderResult.Message.ToString();
                    }
                    switch (orderResult.ResultCode)
                    {
                    case -5:
                        errorMessage = Localization.GetString("ErrorCardInformation", LocalResourceFile);
                        break;

                    case -4:
                        errorMessage = Localization.GetString("ErrorBillingAddress", LocalResourceFile);
                        break;

                    case -3:
                        errorMessage = Localization.GetString("ErrorPaymentOption", LocalResourceFile);
                        break;

                    case -2:
                        errorMessage = Localization.GetString("ErrorConnection", LocalResourceFile);
                        break;

                    case -1:
                        errorMessage = Localization.GetString("ErrorUnexpected", LocalResourceFile);
                        break;

                    case 2:
                        errorMessage          = string.Format(Localization.GetString("ReasonMessage", LocalResourceFile), Localization.GetString("ResponseCode2", LocalResourceFile), orderResult.ReasonCode, "");
                        CheckoutControl.Order = UpdateOrderStatus(order, OrderInfo.OrderStatusList.AwaitingPayment);
                        CheckoutControl.Hide();
                        pnlProceedToAuthorize.Visible = false;
                        InvokePaymentFailed();
                        CurrentCart.DeleteCart(PortalId, StoreSettings.SecureCookie);
                        ClearOrderIdCookie();
                        break;

                    case 3:
                        errorMessage = string.Format(Localization.GetString("ReasonMessage", LocalResourceFile), Localization.GetString("ResponseCode3", LocalResourceFile), orderResult.ReasonCode, localizedReason);
                        break;

                    case 4:
                        errorMessage          = string.Format(Localization.GetString("ReasonMessage", LocalResourceFile), Localization.GetString("ResponseCode4", LocalResourceFile), orderResult.ReasonCode, localizedReason);
                        CheckoutControl.Order = UpdateOrderStatus(order, OrderInfo.OrderStatusList.AwaitingPayment);
                        CheckoutControl.Hide();
                        pnlProceedToAuthorize.Visible = false;
                        InvokePaymentRequiresConfirmation();
                        CurrentCart.DeleteCart(PortalId, StoreSettings.SecureCookie);
                        ClearOrderIdCookie();
                        break;

                    default:
                        errorMessage = string.Format(Localization.GetString("ReasonMessage", LocalResourceFile), Localization.GetString("ErrorUnexpected", LocalResourceFile), orderResult.ReasonCode, localizedReason);
                        break;
                    }
                    lblError.Visible = true;
                    lblError.Text    = errorMessage;
                }
                else
                {
                    int portalId = PortalSettings.PortalId;
                    // Set order status to "Paid"...
                    CheckoutControl.Order = UpdateOrderStatus(order, OrderInfo.OrderStatusList.Paid);
                    // Add User to Product Roles
                    OrderController orderController = new OrderController();
                    orderController.AddUserToRoles(PortalId, order);
                    // Add User to Order Role
                    StoreInfo storeSetting = StoreController.GetStoreInfo(PortalSettings.PortalId);
                    if (storeSetting.OnOrderPaidRoleID != Null.NullInteger)
                    {
                        orderController.AddUserToPaidOrderRole(portalId, order.CustomerID, storeSetting.OnOrderPaidRoleID);
                    }
                    CheckoutControl.Hide();
                    pnlProceedToAuthorize.Visible = false;
                    lblError.Visible = false;
                    InvokePaymentSucceeded();
                    CurrentCart.DeleteCart(PortalId, StoreSettings.SecureCookie);
                    ClearOrderIdCookie();
                }
            }
            else
            {
                lblError.Visible = true;
                lblError.Text    = Localization.GetString("ErrorCardNotValid", LocalResourceFile);
            }
            btnProcess.Enabled = true;
        }
Esempio n. 3
0
        protected void Page_Load(object sender, EventArgs e)
        {
            // Do we have any special handling?
            SystempayNavigation nav = new SystempayNavigation(Request.QueryString);

            switch (nav.GatewayExit.ToUpper())
            {
            case "CANCEL":
            {
                InvokePaymentCancelled();
                CheckoutControl.Hide();
                pnlProceedToSystempay.Visible = false;
                return;
            }

            case "ERROR":
            case "REFUSED":
            {
                InvokePaymentFailed();
                CheckoutControl.Hide();
                pnlProceedToSystempay.Visible = false;
                return;
            }

            case "RETURN":
            {
                SystempaySettings      settings = new SystempaySettings(StoreSettings.GatewaySettings);
                SystempayIPNParameters ipn      = new SystempayIPNParameters(Request.QueryString, settings.Certificate);
                // Here there is no check about the validity of the Systempay response (IPN),
                // because it's just a message displayed to the customer.
                // Everything is checked in the NOTIFY case received from Systempay in the SystempayIPN.aspx page.
                switch (ipn.vads_trans_status.ToLower())
                {
                case "authorised":
                case "authorised_to_validate":
                    InvokePaymentSucceeded();
                    break;

                default:
                    InvokePaymentRequiresConfirmation();
                    break;
                }
                CheckoutControl.Hide();
                pnlProceedToSystempay.Visible = false;
                return;
            }
            }

            if (nav.GatewayExit.Length > 0)
            {
                //If the SystempayExit is anything else with length > 0, then don't do any processing
                HttpContext.Current.Response.Redirect(Common.Globals.NavigateURL(PortalSettings.ActiveTab.TabID), false);
                return;
            }

            // Continue with display of payment control...
            if (Page.IsPostBack == false)
            {
                SystempaySettings settings = new SystempaySettings(StoreSettings.GatewaySettings);
                if (!settings.IsValid())
                {
                    lblError.Text    = Localization.GetString("GatewayNotConfigured", LocalResourceFile);
                    lblError.Visible = true;
                    pnlProceedToSystempay.Visible = false;
                    return;
                }

                btnConfirmOrder.Attributes.Add("OnClick", ScriptAvoidDoubleClick(btnConfirmOrder, Localization.GetString("Processing", this.LocalResourceFile)));
                string message = Localization.GetString("lblConfirmMessage", LocalResourceFile);
                lblConfirmMessage.Text = string.Format(message, PortalSettings.PortalName);
                message = Localization.GetString("systempayimage", LocalResourceFile);
                systempayimage.AlternateText = message;
                systempayimage.ImageUrl      = settings.ButtonURL;

                lblError.Text    = string.Empty;
                lblError.Visible = false;
            }
        }
Esempio n. 4
0
        private void ConfirmOrder()
        {
            Page.Validate();
            if (Page.IsValid == false)
            {
                return;
            }

            // Adds order to db...
            OrderInfo    order          = CheckoutControl.GetFinalizedOrderInfo();
            IAddressInfo billingAddress = CheckoutControl.BillingAddress;

            GenerateOrderConfirmation();

            CheckoutControl.Hide();
            pnlProceedToSystempay.Visible = false;

            // Set order status to "Awaiting Payment"...
            CheckoutControl.Order = UpdateOrderStatus(order, OrderInfo.OrderStatusList.AwaitingPayment);

            // Clear basket
            CurrentCart.DeleteCart(PortalId, StoreSettings.SecureCookie);

            // Clear cookies
            ClearOrderIdCookie();

            // Process transaction
            string              urlAuthority = Request.Url.GetLeftPart(UriPartial.Authority);
            TransactionDetails  transaction  = new TransactionDetails();
            SystempayNavigation nav          = new SystempayNavigation(Request.QueryString)
            {
                OrderID = order.OrderID,
                // Return URL
                GatewayExit = "return"
            };

            transaction.ReturnURL = AddAuthority(nav.GetNavigationUrl(), urlAuthority);
            // Refused URL
            nav.GatewayExit        = "refused";
            transaction.RefusedURL = AddAuthority(nav.GetNavigationUrl(), urlAuthority);
            // Error URL
            nav.GatewayExit      = "error";
            transaction.ErrorURL = AddAuthority(nav.GetNavigationUrl(), urlAuthority);
            // Cancel URL
            nav.GatewayExit       = "cancel";
            transaction.CancelURL = AddAuthority(nav.GetNavigationUrl(), urlAuthority);
            // IPN URL
            string language = Request.QueryString["language"];

            if (string.IsNullOrEmpty(language))
            {
                language = System.Threading.Thread.CurrentThread.CurrentCulture.ToString();
            }
            transaction.NotifyURL = urlAuthority + TemplateSourceDirectory + "/SystempayIPN.aspx?language=" + language;
            string messages = Localization.GetString("SystempayButtons", LocalResourceFile);

            transaction.Buttons  = string.Format(messages, StoreSettings.Name);
            transaction.ShopName = StoreSettings.Name;
            transaction.Email    = billingAddress.Email;

            SystempayGatewayProvider provider = new SystempayGatewayProvider(StoreSettings.GatewaySettings);

            provider.ProcessTransaction(CheckoutControl.BillingAddress, order, transaction);
        }