public InitializePayPalCheckoutResponse InitializeWebPayment(Guid accountId, Guid orderId, string baseUri, double?estimatedFare, decimal bookingFees, string clientLanguageCode)
        {
            if (!estimatedFare.HasValue)
            {
                return(new InitializePayPalCheckoutResponse
                {
                    IsSuccessful = false,
                    Message = _resources.Get("CannotCreateOrder_PrepaidNoEstimate", clientLanguageCode)
                });
            }

            var regionName     = _serverSettings.ServerData.PayPalRegionInfoOverride;
            var conversionRate = _serverSettings.ServerData.PayPalConversionRate;

            _logger.LogMessage("PayPal Conversion Rate: {0}", conversionRate);

            // Fare amount
            var fareAmount = Math.Round(Convert.ToDecimal(estimatedFare.Value) * conversionRate, 2);
            var currency   = conversionRate != 1
                ? CurrencyCodes.Main.UnitedStatesDollar
                : _resources.GetCurrencyCode();

            // Need the fare object because tip amount should be calculated on the fare excluding taxes
            var fareObject = FareHelper.GetFareFromAmountInclTax(Convert.ToDouble(fareAmount),
                                                                 _serverSettings.ServerData.VATIsEnabled
                            ? _serverSettings.ServerData.VATPercentage
                            : 0);

            // Tip amount (on fare amount excl. taxes)
            var defaultTipPercentage = _accountDao.FindById(accountId).DefaultTipPercent;
            var tipPercentage        = defaultTipPercentage ?? _serverSettings.ServerData.DefaultTipPercentage;
            var tipAmount            = FareHelper.CalculateTipAmount(fareObject.AmountInclTax, tipPercentage);

            // Booking Fees with conversion rate if necessary
            var bookingFeesAmount = Math.Round(bookingFees * conversionRate, 2);

            // Fare amount with tip and booking fee
            var totalAmount = fareAmount + tipAmount + bookingFeesAmount;

            var redirectUrl = baseUri + string.Format("/{0}/proceed", orderId);

            _logger.LogMessage("PayPal Web redirect URL: {0}", redirectUrl);

            var redirUrls = new RedirectUrls
            {
                cancel_url = redirectUrl + "?cancel=true",
                return_url = redirectUrl
            };

            // Create transaction
            var transactionList = new List <Transaction>
            {
                new Transaction
                {
                    amount = new Amount
                    {
                        currency = currency,
                        total    = totalAmount.ToString("N", CultureInfo.InvariantCulture)
                    },

                    description = string.Format(
                        _resources.Get("PayPalWebPaymentDescription", regionName.HasValue()
                            ? SupportedLanguages.en.ToString()
                            : clientLanguageCode), totalAmount),

                    item_list = new ItemList
                    {
                        items = new List <Item>
                        {
                            new Item
                            {
                                name = _resources.Get("PayPalWebFareItemDescription", regionName.HasValue()
                                        ? SupportedLanguages.en.ToString()
                                        : clientLanguageCode),
                                currency = currency,
                                price    = fareAmount.ToString("N", CultureInfo.InvariantCulture),
                                quantity = "1"
                            },
                            new Item
                            {
                                name = string.Format(_resources.Get("PayPalWebTipItemDescription", regionName.HasValue()
                                        ? SupportedLanguages.en.ToString()
                                        : clientLanguageCode), tipPercentage),
                                currency = currency,
                                price    = tipAmount.ToString("N", CultureInfo.InvariantCulture),
                                quantity = "1"
                            }
                        }
                    }
                }
            };

            if (bookingFeesAmount > 0)
            {
                transactionList.First().item_list.items.Add(new Item
                {
                    name = _resources.Get("PayPalWebBookingFeeItemDescription", regionName.HasValue()
                                        ? SupportedLanguages.en.ToString()
                                        : clientLanguageCode),
                    currency = currency,
                    price    = bookingFeesAmount.ToString("N", CultureInfo.InvariantCulture),
                    quantity = "1"
                });
            }

            // Create web experience profile
            var profile = new WebProfile
            {
                name        = Guid.NewGuid().ToString(),
                flow_config = new FlowConfig
                {
                    landing_page_type = _serverPaymentSettings.PayPalServerSettings.LandingPageType.ToString()
                }
            };

            try
            {
                var webExperienceProfile = profile.Create(GetAPIContext(GetAccessToken()));

                // Create payment
                var payment = new Payment
                {
                    intent = Intents.Sale,
                    payer  = new Payer
                    {
                        payment_method = "paypal"
                    },
                    transactions          = transactionList,
                    redirect_urls         = redirUrls,
                    experience_profile_id = webExperienceProfile.id
                };

                var createdPayment = payment.Create(GetAPIContext(GetAccessToken()));
                var links          = createdPayment.links.GetEnumerator();

                while (links.MoveNext())
                {
                    var link = links.Current;
                    if (link.rel.ToLower().Trim().Equals("approval_url"))
                    {
                        return(new InitializePayPalCheckoutResponse
                        {
                            IsSuccessful = true,
                            PaymentId = createdPayment.id,
                            PayPalCheckoutUrl = link.href       // Links that give the user the option to redirect to PayPal to approve the payment
                        });
                    }
                }

                _logger.LogMessage("Error when creating PayPal Web payment: no approval_urls found");

                // No approval_url found
                return(new InitializePayPalCheckoutResponse
                {
                    IsSuccessful = false,
                    Message = "No approval_url found"
                });
            }
            catch (Exception ex)
            {
                var exceptionMessage = ex.Message;

                var paymentException = ex as PaymentsException;
                if (paymentException != null && paymentException.Details != null)
                {
                    exceptionMessage = paymentException.Details.message;
                }

                _logger.LogMessage("Initialization of PayPal Web Store failed: {0}", exceptionMessage);

                return(new InitializePayPalCheckoutResponse
                {
                    IsSuccessful = false,
                    Message = exceptionMessage
                });
            }
        }