コード例 #1
0
        private void ConfirmOrder()
        {
            //Adds order to db...
            OrderInfo order = CheckoutControl.GetFinalizedOrderInfo();

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

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

            EmailNavigation nav = new EmailNavigation(Request.QueryString)
            {
                GatewayExit = "return",
                OrderID     = order.OrderID
            };

            Response.Redirect(nav.GetNavigationUrl());
        }
コード例 #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;
        }
コード例 #3
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);
        }