Example #1
0
        public static UrlSettings Create(string orderNumberId, IDictionary <string, string> settings)
        {
            var urlSettings = new UrlSettings();

            // Build notify Url (PayPal will redirect back to this url after processing OK or FAIL)

            // This key is sent to PayPal using https so it is not likely it will come from other because
            // only PayPal knows this key to send back to us
            string acceptSecurityKey = GetMD5Key(orderNumberId + "accepted");
            string cancelSecurityKey = GetMD5Key(orderNumberId + "canceled");

            string notifyUrl = UriSupport.AbsoluteUrlBySettings(settings[PayPalConstants.Configuration.SuccessUrl]);


            string acceptUrl = UriSupport.AddQueryString(notifyUrl, "accept", "true");

            acceptUrl = UriSupport.AddQueryString(acceptUrl, "hash", acceptSecurityKey);

            var cancelUrl = UriSupport.AbsoluteUrlBySettings(settings[PayPalConstants.Configuration.CancelUrl]);

            cancelUrl = UriSupport.AddQueryString(cancelUrl, "accept", "false");
            cancelUrl = UriSupport.AddQueryString(cancelUrl, "hash", cancelSecurityKey);

            urlSettings.NotifyUrl = notifyUrl;
            urlSettings.AcceptUrl = acceptUrl;
            urlSettings.CancelUrl = cancelUrl;

            return(urlSettings);
        }
        private ActionResult PostCheckAndRedirect(ICart currentCart, IPayment payment)
        {
            var transactionRequest = new TransactionRequest(Request.QueryString, _epayRequestHelper.EpayConfiguration);

            if (transactionRequest.IsProcessable())
            {
                var cancelUrl = Utilities.GetUrlFromStartPageReferenceProperty("CheckoutPage"); // get link to Checkout page
                cancelUrl = UriSupport.AddQueryString(cancelUrl, "success", "false");
                cancelUrl = UriSupport.AddQueryString(cancelUrl, "paymentmethod", "epay");

                var redirectUrl = cancelUrl; //default
                var gateway     = new EpayPaymentGateway();

                // Process successful transaction
                if (transactionRequest.IsSuccessful())
                {
                    var acceptUrl = Utilities.GetUrlFromStartPageReferenceProperty("EpayPaymentLandingPage");
                    redirectUrl = gateway.ProcessSuccessfulTransaction(currentCart, payment, transactionRequest.Transact, transactionRequest.SubscriptionId, transactionRequest.OrderId, acceptUrl, cancelUrl);
                }
                // Process unsuccessful transaction
                else if (transactionRequest.IsUnsuccessful())
                {
                    TempData["Message"] = Utilities.Translate("CancelMessage");
                    redirectUrl         = gateway.ProcessUnsuccessfulTransaction(cancelUrl, Utilities.Translate("CancelMessage"));
                }

                return(Redirect(redirectUrl));
            }

            return(null);
        }
Example #3
0
        private SetExpressCheckoutRequestDetailsType SetupExpressCheckoutReqDetailsType(ICart cart, IPayment payment, string orderNumber)
        {
            var setExpressChkOutReqDetails = _payPalApiHelper.CreateExpressCheckoutReqDetailsType(payment, _paymentMethodConfiguration);

            // This key is sent to PayPal using https so it is not likely it will come from other because
            // only PayPal knows this key to send back to us
            var acceptSecurityKey = Utilities.GetAcceptUrlHashValue(orderNumber);
            var cancelSecurityKey = Utilities.GetCancelUrlHashValue(orderNumber);

            _acceptUrl = UriSupport.AbsoluteUrlBySettings(_paymentMethodConfiguration.SuccessUrl);
            _cancelUrl = UriSupport.AbsoluteUrlBySettings(_paymentMethodConfiguration.CancelUrl);

            var acceptUrl = UriSupport.AddQueryString(_acceptUrl, "accept", "true");

            acceptUrl = UriSupport.AddQueryString(acceptUrl, "hash", acceptSecurityKey);

            var cancelUrl = UriSupport.AddQueryString(_cancelUrl, "accept", "false");

            cancelUrl = UriSupport.AddQueryString(cancelUrl, "hash", cancelSecurityKey);

            setExpressChkOutReqDetails.CancelURL      = cancelUrl;
            setExpressChkOutReqDetails.ReturnURL      = acceptUrl;
            setExpressChkOutReqDetails.PaymentDetails = new List <PaymentDetailsType> {
                _payPalApiHelper.GetPaymentDetailsType(payment, cart, orderNumber, _acceptUrl)
            };

            setExpressChkOutReqDetails.BillingAddress = AddressHandling.ToAddressType(payment.BillingAddress);

            return(setExpressChkOutReqDetails);
        }
Example #4
0
        public ActionResult Index(EventPageBase currentPage, string contentLink)
        {
            if (TempData["ViewData"] != null)
            {
                ViewData = (ViewDataDictionary)TempData["ViewData"];
            }

            var viewModel = CreateEventRegistrationModel(currentPage, contentLink);

            var      pageRouteHelper = ServiceLocator.Current.GetInstance <PageRouteHelper>();
            PageData hostPageData    = pageRouteHelper.Page;

            if (currentPage != null && hostPageData != null)
            {
                var urlResolver = ServiceLocator.Current.GetInstance <UrlResolver>();
                var pageUrl     = urlResolver.GetUrl(hostPageData.ContentLink);

                var actionUrl = string.Format("{0}/", pageUrl);
                if (BVNetwork.Attend.Business.API.AttendRegistrationEngine.UseForms == false)
                {
                    actionUrl = UriSupport.AddQueryString(actionUrl, "XFormId", currentPage.RegistrationForm.Id.ToString());
                }
                actionUrl = UriSupport.AddQueryString(actionUrl, "failedAction", "Failed");
                actionUrl = UriSupport.AddQueryString(actionUrl, "successAction", "Success");

                viewModel.ActionUrl = actionUrl;
            }

            //return PartialView(viewModel);
            return(PartialView("~/modules/BVNetwork.Attend/Views/Pages/Partials/EventPagePartial.cshtml", viewModel));
        }
Example #5
0
        public string GetSectionGroupUrl(string groupName)
        {
            string url = UriSupport.AddQueryString(HttpContext.Current.Request.RawUrl, "t", HttpContext.Current.Server.UrlEncode(groupName));

            url = UriSupport.AddQueryString(url, "p", "1");
            return(url);
        }
Example #6
0
        protected void PerformSearch(object sender, EventArgs e)
        {
            var    searchPageRedirectUrl = GetUrl(Settings.SearchPage);
            string searchText            = Server.UrlEncode(SearchKeywords.Text.Trim());

            searchPageRedirectUrl = UriSupport.AddQueryString(searchPageRedirectUrl, "search", searchText);
            Response.Redirect(searchPageRedirectUrl);
        }
Example #7
0
        private string BuildUrl(string imageUrl)
        {
            string endpoint = ImageOptimizationSettings.Instance.ImageOptimizationApi ?? "http://api.resmush.it/ws.php";

            endpoint = UriSupport.AddQueryString(endpoint, "img", HttpUtility.UrlEncode(imageUrl));

            return(endpoint);
        }
Example #8
0
        private string BuildUrl(string imageUrl)
        {
            string endpoint = "http://www.resmush.it/ws.php";

            endpoint = UriSupport.AddQueryString(endpoint, "img", HttpUtility.UrlEncode(imageUrl));

            return(endpoint);
        }
Example #9
0
        private string CreateRedirectUrl(string expChkoutUrlSetting, string token)
        {
            var redirectUrl = expChkoutUrlSetting;

            redirectUrl = UriSupport.AddQueryString(redirectUrl, "cmd", "_express-checkout");
            redirectUrl = UriSupport.AddQueryString(redirectUrl, "token", token);
            redirectUrl = UriSupport.AddQueryString(redirectUrl, "useraction", "commit");
            return(redirectUrl);
        }
Example #10
0
        /// <summary>
        /// Handles the Click event of the Search control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Search_Click(object sender, EventArgs e)
        {
            string searchText = Server.UrlEncode(search.Text.Trim());
            string classType  = ClassType.SelectedValue.Trim();
            string query      = UriSupport.AddQueryString(CurrentPage.LinkURL, "search", searchText);

            query = UriSupport.AddQueryString(query, "type", classType);
            Response.Redirect(query);
        }
Example #11
0
        private string UpdateAcceptUrl(IPurchaseOrder purchaseOrder, IPayment payment, string acceptUrl)
        {
            var redirectionUrl = UriSupport.AddQueryString(acceptUrl, "success", "true");

            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "contactId", purchaseOrder.CustomerId.ToString());
            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "orderNumber", purchaseOrder.OrderLink.OrderGroupId.ToString());
            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "notificationMessage", string.Format(_localizationService.GetString("/OrderConfirmationMail/ErrorMessages/SmtpFailure"), payment.BillingAddress.Email));
            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "email", payment.BillingAddress.Email);
            return(redirectionUrl);
        }
Example #12
0
        /// <summary>
        /// Processes the unsuccessful transaction, delete PayPal-related information in Cookie.
        /// </summary>
        /// <param name="cancelUrl">The cancel url.</param>
        /// <param name="errorMessage">The error message.</param>
        /// <returns>The url redirection after process.</returns>
        public string ProcessUnsuccessfulTransaction(string cancelUrl, string errorMessage)
        {
            if (HttpContext.Current == null)
            {
                return(cancelUrl);
            }

            _logger.Error($"PayPal transaction failed [{errorMessage}].");
            return(UriSupport.AddQueryString(cancelUrl, "message", errorMessage));
        }
Example #13
0
        /// <summary>
        /// Processes the successful transaction, will be called when epay server processes
        /// the payment successfully and redirect back.
        /// </summary>
        /// <param name="cart">The cart that was processed.</param>
        /// <param name="payment">The order payment.</param>
        /// <param name="transactionId">The transaction id.</param>
        /// <param name="subscriptionId">The subscription id in case returned</param>
        /// <param name="orderNumber">The order number.</param>
        /// <param name="acceptUrl">The redirect url when finished.</param>
        /// <param name="cancelUrl">The redirect url when error happens.</param>
        /// <returns>The redirection url after processing.</returns>
        public string ProcessSuccessfulTransaction(ICart cart, IPayment payment, string transactionId, string subscriptionId, string orderNumber, string acceptUrl, string cancelUrl)
        {
            if (cart == null)
            {
                return(cancelUrl);
            }

            var redirectionUrl = string.Empty;

            using (TransactionScope scope = new TransactionScope())
            {
                // Change status of payments to processed.
                // It must be done before execute workflow to ensure payments which should mark as processed.
                // To avoid get errors when executed workflow.
                PaymentStatusManager.ProcessPayment(payment);

                var errorMessages = new List <string>();
                var cartCompleted = DoCompletingCart(cart, errorMessages);

                if (!cartCompleted)
                {
                    return(UriSupport.AddQueryString(cancelUrl, "message", string.Join(";", errorMessages.Distinct().ToArray())));
                }

                // Save the transact from epay to payment.
                payment.TransactionID = transactionId;


                // Save subscription id in the payment properties.
                if (!string.IsNullOrEmpty(subscriptionId))
                {
                    payment.AuthorizationCode = subscriptionId; //properties wasnt saved
                }

                // Create a purchase order
                var purchaseOrder = MakePurchaseOrder(cart, orderNumber);

                // Create a subscription plan
                var supscriptionPlan = MakeSubscription(cart, payment);

                // Commit changes
                scope.Complete();

                if (HttpContext.Current.Session != null)
                {
                    HttpContext.Current.Session.Remove("LastCouponCode"); //todo: is this needed?
                }

                //todo: change in case of subscription or?
                redirectionUrl = UpdateAcceptUrl(purchaseOrder, payment, acceptUrl);
            }

            return(redirectionUrl);
        }
Example #14
0
        private string CreateRedirectionUrl(IPurchaseOrder purchaseOrder, string acceptUrl, string email)
        {
            var redirectionUrl = UriSupport.AddQueryString(acceptUrl, "success", "true");

            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "contactId", purchaseOrder.CustomerId.ToString());
            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "orderNumber", purchaseOrder.OrderLink.OrderGroupId.ToString());
            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "notificationMessage", string.Format(Utilities.GetLocalizationMessage("/OrderConfirmationMail/ErrorMessages/SmtpFailure"), email));
            redirectionUrl = UriSupport.AddQueryString(redirectionUrl, "email", email);

            return(redirectionUrl);
        }
Example #15
0
        public virtual ActionResult ProcessPayPalPayment(CheckoutPage currentPage)
        {
            var currentCart = _orderRepository.LoadCart <ICart>(PrincipalInfo.CurrentPrincipal.GetContactId(), _cartService.DefaultCartName);

            if (!currentCart.Forms.Any() || !currentCart.GetFirstForm().Payments.Any())
            {
                throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("GenericError"));
            }

            var paymentConfiguration = new PayPalConfiguration();
            var payment = currentCart.Forms.SelectMany(f => f.Payments).FirstOrDefault(c => c.PaymentMethodId.Equals(paymentConfiguration.PaymentMethodId));

            if (payment == null)
            {
                throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("PaymentNotSpecified"));
            }


            var orderNumber = payment.Properties[PayPalPaymentGateway.PayPalOrderNumberPropertyName] as string;

            if (string.IsNullOrEmpty(orderNumber))
            {
                throw new PaymentException(PaymentException.ErrorType.ProviderError, "", Utilities.Translate("PaymentNotSpecified"));
            }



            var currentPageUrl = _urlResolver.GetUrl(currentPage.ContentLink);

            // Redirect customer to receipt page
            var cancelUrl = currentPageUrl;// get link to Checkout page

            cancelUrl = UriSupport.AddQueryString(cancelUrl, "success", "false");
            cancelUrl = UriSupport.AddQueryString(cancelUrl, "paymentmethod", "paypal");

            var gateway     = new PayPalPaymentGateway();
            var redirectUrl = cancelUrl;

            if (string.Equals(Request.QueryString["accept"], "true") && Utilities.GetAcceptUrlHashValue(orderNumber) == Request.QueryString["hash"])
            {
                // Try to load purchase order and return redirect based on viewmodel and purchaseorder.
                // this is not working with serializeable cart, since properties for OrderNumber is not persisted from gateway. Properties are empty for IPayment when getting here.
                var acceptUrl = currentPageUrl + "/FinishPaypalTransaction";
                redirectUrl = gateway.ProcessSuccessfulTransaction(currentCart, payment, acceptUrl, cancelUrl);
            }
            else if (string.Equals(Request.QueryString["accept"], "false") && Utilities.GetCancelUrlHashValue(orderNumber) == Request.QueryString["hash"])
            {
                TempData["Message"] = Utilities.Translate("CancelMessage");
                redirectUrl         = gateway.ProcessUnsuccessfulTransaction(cancelUrl, Utilities.Translate("CancelMessage"));
            }

            return(Redirect(redirectUrl));
        }
Example #16
0
        /// <summary>
        /// Performs a search by redirecting to the search page
        /// </summary>
        protected void PerformSearch(object sender, EventArgs e)
        {
            var searchPageLink = PageReference.StartPage.GetPage <StartPage>().SearchPageLink;

            if (PageReference.IsNullOrEmpty(searchPageLink))
            {
                throw new ConfigurationErrorsException("No search page specified in site settings, please specify the 'Search Page' property on the start page");
            }

            var searchPageRedirectUrl = searchPageLink.GetPage().LinkURL;

            // Add query string parameter containing the search keywords to the search page's URL
            searchPageRedirectUrl = UriSupport.AddQueryString(searchPageRedirectUrl, "q", SearchKeywords.Text.Trim());

            Response.Redirect(searchPageRedirectUrl);
        }
Example #17
0
        public ActionResult Index(ContactUsPage currentPage)
        {
            var md        = new ContactUsPageModel(currentPage);
            var locations = string.Empty;

            if (currentPage.OfficeItems != null && currentPage.OfficeItems.Items.Any())
            {
                for (var i = 0; i < currentPage.OfficeItems.Items.Count; i++)
                {
                    var item        = currentPage.OfficeItems.Items[i];
                    var officeBlock = _icontentLoader.Get <OfficeBlock>(item.ContentLink);
                    if (!Double.IsNaN(officeBlock.Latitude) && !officeBlock.Latitude.Equals(0) &&
                        !Double.IsNaN(officeBlock.Longitude) && !officeBlock.Longitude.Equals(0))
                    {
                        var str = string.Format("['{0}',{1},{2},{3}]", HttpUtility.HtmlEncode(officeBlock.Address),
                                                officeBlock.Latitude,
                                                officeBlock.Longitude, i + 1);
                        locations = !string.IsNullOrEmpty(locations) ? string.Format("{0},{1}", locations, str) : str;
                    }
                }
            }
            md.Locations = string.Format("[{0}]", locations);
            if (currentPage != null && currentPage.ContactUsForm != null)
            {
                var urlResolver = ServiceLocator.Current.GetInstance <UrlResolver>();
                var pageUrl     = urlResolver.GetUrl(currentPage.ContentLink);
                var actionUrl   = string.Format("{0}XFormPost/", pageUrl);
                actionUrl = UriSupport.AddQueryString(actionUrl, "XFormId", currentPage.ContactUsForm.Id.ToString());
                actionUrl = UriSupport.AddQueryString(actionUrl, "failedAction", "Failed");
                actionUrl = UriSupport.AddQueryString(actionUrl, "successAction", "Success");
                actionUrl = UriSupport.AddQueryString(actionUrl, "contentId",
                                                      currentPage.ContentLink.ID.ToString(CultureInfo.InvariantCulture));
                md.ActionUrl = actionUrl;
            }
            ViewBag.Country = LocationHelpers.GetCountryCodeByIp();
            var result = GetPhoneCodeByCountryCode(ViewBag.Country);

            ViewBag.PhoneCode   = result.Data.phone;
            ViewBag.ListCountry = GetAllCountries();
            return(View(md));
        }
Example #18
0
        private static string BuildUrl(oEmbedOptions options)
        {
            var endpoint = "http://api.embed.ly/1/oembed";

            if (options.MaxWidth > 0)
            {
                endpoint = UriSupport.AddQueryString(endpoint, "maxwidth", options.MaxWidth.ToString(CultureInfo.InvariantCulture));
            }

            if (options.MaxHeight > 0)
            {
                endpoint = UriSupport.AddQueryString(endpoint, "maxheight", options.MaxHeight.ToString(CultureInfo.InvariantCulture));
            }

            endpoint = UriSupport.AddQueryString(endpoint, "url", options.Url);

            if (Configuration.oEmbedSettings.Settings == null ||
                string.IsNullOrEmpty(Configuration.oEmbedSettings.Settings.ApiKey))
            {
                throw new ConfigurationErrorsException(@"Missing key for Geta.oEmbed. Add it to web.config: 
                                                        <configSections>
                                                            <section name=""oEmbedSettings"" type=""Geta.oEmbed.Configuration.oEmbedSettings, Geta.oEmbed""/>
                                                        </configSections>
                                                        <oEmbedSettings apikey=""your-key-here"" />
                                                        You can get your key at (also has free option): http://embed.ly/");
            }

            if (Configuration.oEmbedSettings.Settings.Secure)
            {
                endpoint = UriSupport.AddQueryString(endpoint, "secure", "true");
            }

            endpoint = UriSupport.AddQueryString(endpoint, "key", Configuration.oEmbedSettings.Settings.ApiKey);

            return(endpoint);
        }
 /// <summary>
 /// Constructs a url for a section group
 /// </summary>
 /// <param name="groupName">Name of group</param>
 /// <returns>Url</returns>
 public string GetSectionGroupUrl(string groupName)
 {
     return(UriSupport.AddQueryString(RemoveQueryStringByKey(HttpContext.Current.Request.Url.AbsoluteUri, "p"), "t", HttpContext.Current.Server.UrlEncode(groupName)));
 }
 /// <summary>
 /// Create URL for the previous paging section.
 /// </summary>
 /// <returns>Url for previous paging section</returns>
 public string GetPreviousPagingSectionUrl()
 {
     return(UriSupport.AddQueryString(HttpContext.Current.Request.RawUrl, "p", ((PagingSection - 1) * PagingSectionSize).ToString()));
 }
 /// <summary>
 /// Create URL for a specified paging page.
 /// </summary>
 /// <param name="pageNumber">Number of page for which to get a url</param>
 /// <returns>Url for specified page</returns>
 public string GetPagingUrl(int pageNumber)
 {
     return(UriSupport.AddQueryString(HttpContext.Current.Request.RawUrl, "p", pageNumber.ToString()));
 }
Example #22
0
 /// <summary>
 /// Processes the unsuccessful transaction.
 /// </summary>
 /// <param name="cancelUrl">The cancel url.</param>
 /// <param name="errorMessage">The error message.</param>
 /// <returns>The url redirection after process.</returns>
 public string ProcessUnsuccessfulTransaction(string cancelUrl, string errorMessage)
 {
     return(UriSupport.AddQueryString(cancelUrl, "message", errorMessage));
 }
Example #23
0
 /// <summary>
 /// Create URL for the next paging section.
 /// </summary>
 /// <returns>Url for next paging section</returns>
 public string GetNextPagingSectionUrl()
 {
     return UriSupport.AddQueryString(HttpContext.Current.Request.RawUrl, "p", ((PagingSection * PagingSectionSize) + 1).ToString());
 }
 public static string AddQueryParameter(this string url, string name, string value)
 {
     return(UriSupport.AddQueryString(url, name, value));
 }
Example #25
0
        /// <summary>
        /// When search button is clicked, we reload the page to trigger a new search
        /// </summary>
        protected void SearchClick(object sender, EventArgs e)
        {
            string searchText = Server.UrlEncode(SearchKeywords.Text.Trim());

            Response.Redirect(UriSupport.AddQueryString(CurrentPage.LinkURL, "q", searchText));
        }
Example #26
0
        /// <summary>
        /// Processes the successful transaction, was called when PayPal.com redirect back.
        /// </summary>
        /// <param name="orderGroup">The order group that was processed.</param>
        /// <param name="payment">The order payment.</param>
        /// <param name="acceptUrl">The redirect url when finished.</param>
        /// <param name="cancelUrl">The redirect url when error happens.</param>
        /// <returns>The url redirection after process.</returns>
        public string ProcessSuccessfulTransaction(IOrderGroup orderGroup, IPayment payment, string acceptUrl, string cancelUrl)
        {
            if (HttpContext.Current == null)
            {
                return(cancelUrl);
            }

            if (HttpContext.Current.Session != null)
            {
                HttpContext.Current.Session.Remove("LastCouponCode");
            }

            if (!(orderGroup is ICart cart))
            {
                // return to the shopping cart page immediately and show error messages
                return(ProcessUnsuccessfulTransaction(cancelUrl, Utilities.Translate("CommitTranErrorCartNull")));
            }

            string redirectionUrl;

            using (var scope = new TransactionScope())
            {
                SetSecurityProtocolToTls12();

                var getDetailRequest = new GetExpressCheckoutDetailsRequestType
                {
                    Token = payment.Properties[PayPalExpTokenPropertyName] as string // Add request-specific fields to the request.
                };

                // Execute the API operation and obtain the response.
                var caller             = PayPalApiHelper.GetPayPalApiCallerServices(_paymentMethodConfiguration);
                var getDetailsResponse = caller.GetExpressCheckoutDetails(new GetExpressCheckoutDetailsReq
                {
                    GetExpressCheckoutDetailsRequest = getDetailRequest
                });

                var errorCheck = _payPalApiHelper.CheckErrors(getDetailsResponse);
                if (!string.IsNullOrEmpty(errorCheck))
                {
                    RestoreSecurityProtocol();

                    // unsuccessful get detail call
                    return(ProcessUnsuccessfulTransaction(cancelUrl, errorCheck));
                }

                var expressCheckoutDetailsResponse = getDetailsResponse.GetExpressCheckoutDetailsResponseDetails;
                // get commerceOrderId from what we put to PayPal instead of getting from cookie
                payment.Properties[PayPalOrderNumberPropertyName] = expressCheckoutDetailsResponse.InvoiceID;

                //process details sent from paypal, changing addresses if required
                string emptyAddressMsg;

                //process billing address
                var payPalBillingAddress = expressCheckoutDetailsResponse.BillingAddress;
                if (payPalBillingAddress != null && AddressHandling.IsAddressChanged(payment.BillingAddress, payPalBillingAddress))
                {
                    emptyAddressMsg = _payPalApiHelper.ProcessOrderAddress(expressCheckoutDetailsResponse.PayerInfo, payPalBillingAddress, payment.BillingAddress, CustomerAddressTypeEnum.Billing, "CommitTranErrorPayPalBillingAddressEmpty");
                    if (!string.IsNullOrEmpty(emptyAddressMsg))
                    {
                        RestoreSecurityProtocol();

                        return(ProcessUnsuccessfulTransaction(cancelUrl, emptyAddressMsg));
                    }
                }

                //process shipping address
                var payPalShippingAddress = expressCheckoutDetailsResponse.PaymentDetails[0].ShipToAddress;
                if (payPalShippingAddress != null && AddressHandling.IsAddressChanged(cart.GetFirstShipment().ShippingAddress, payPalShippingAddress))
                {
                    //when address was changed on PayPal site, it might cause changing tax value changed and changing order value also.
                    var taxValueBefore = _taxCalculator.GetTaxTotal(cart, cart.Market, cart.Currency);

                    var shippingAddress = orderGroup.CreateOrderAddress("address");

                    emptyAddressMsg = _payPalApiHelper.ProcessOrderAddress(expressCheckoutDetailsResponse.PayerInfo, payPalShippingAddress, shippingAddress, CustomerAddressTypeEnum.Shipping, "CommitTranErrorPayPalShippingAddressEmpty");
                    if (!string.IsNullOrEmpty(emptyAddressMsg))
                    {
                        RestoreSecurityProtocol();

                        return(ProcessUnsuccessfulTransaction(cancelUrl, emptyAddressMsg));
                    }

                    cart.GetFirstShipment().ShippingAddress = shippingAddress;

                    var taxValueAfter = _taxCalculator.GetTaxTotal(cart, cart.Market, cart.Currency);
                    if (taxValueBefore != taxValueAfter)
                    {
                        RestoreSecurityProtocol();

                        _orderRepository.Save(cart); // Saving cart to submit order address changed.
                        scope.Complete();
                        return(ProcessUnsuccessfulTransaction(cancelUrl, Utilities.Translate("ProcessPaymentTaxValueChangedWarning")));
                    }
                }

                // Add request-specific fields to the request.
                // Create the request details object.
                var doExpressChkOutPaymentReqDetails = CreateExpressCheckoutPaymentRequest(getDetailsResponse, orderGroup, payment);

                // Execute the API operation and obtain the response.
                var doCheckOutResponse = caller.DoExpressCheckoutPayment(new DoExpressCheckoutPaymentReq
                {
                    DoExpressCheckoutPaymentRequest = new DoExpressCheckoutPaymentRequestType(doExpressChkOutPaymentReqDetails)
                });

                errorCheck = _payPalApiHelper.CheckErrors(doCheckOutResponse);
                if (!string.IsNullOrEmpty(errorCheck))
                {
                    RestoreSecurityProtocol();

                    // unsuccessful doCheckout response
                    return(ProcessUnsuccessfulTransaction(cancelUrl, errorCheck));
                }

                // everything is fine, this is a flag to tell ProcessPayment know about this case: redirect back from PayPal with accepted payment
                var errorMessages = new List <string>();
                var cartCompleted = DoCompletingCart(cart, errorMessages);

                if (!cartCompleted)
                {
                    RestoreSecurityProtocol();

                    return(UriSupport.AddQueryString(cancelUrl, "message", string.Join(";", errorMessages.Distinct().ToArray())));
                }

                // Place order
                var purchaseOrder = MakePurchaseOrder(doCheckOutResponse, cart, payment);

                // Commit changes
                scope.Complete();

                redirectionUrl = CreateRedirectionUrl(purchaseOrder, acceptUrl, payment.BillingAddress.Email);

                RestoreSecurityProtocol();
            }

            _logger.Information($"PayPal transaction succeeds, redirect end user to {redirectionUrl}");
            return(redirectionUrl);
        }
 /// <summary>
 /// Handle click of search button
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void SearchClick(object sender, EventArgs e)
 {
     Response.Redirect(UriSupport.AddQueryString(CurrentPage.LinkURL, "q", Server.UrlEncode(srchTxt.Text.Trim())));
 }