/// <summary>
        /// Sets paypal express checkout
        /// </summary>
        /// <param name="OrderTotal">Order total</param>
        /// <param name="ReturnURL">Return URL</param>
        /// <param name="CancelURL">Cancel URL</param>
        /// <returns>Express checkout URL</returns>
        public string SetExpressCheckout(decimal OrderTotal, 
            string ReturnURL, string CancelURL)
        {
            InitSettings();
            TransactMode transactionMode = GetCurrentTransactionMode();

            SetExpressCheckoutReq req = new SetExpressCheckoutReq();
            req.SetExpressCheckoutRequest = new SetExpressCheckoutRequestType();
            req.SetExpressCheckoutRequest.Version = this.APIVersion;
            SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();
            req.SetExpressCheckoutRequest.SetExpressCheckoutRequestDetails = details;
            if (transactionMode == TransactMode.Authorize)
                details.PaymentAction = PaymentActionCodeType.Authorization;
            else
                details.PaymentAction = PaymentActionCodeType.Sale;
            details.PaymentActionSpecified = true;
            details.OrderTotal = new BasicAmountType();
            details.OrderTotal.Value = OrderTotal.ToString("N", new CultureInfo("en-us"));
            details.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);
            details.ReturnURL = ReturnURL;
            details.CancelURL = CancelURL;
            SetExpressCheckoutResponseType response = service2.SetExpressCheckout(req);
            string error;
            if (PaypalHelper.CheckSuccess(response, out error))
                return GetPaypalUrl(response.Token);
            throw new NopException(error);
        }
        /// <summary>
        /// Special method which Sets paypal express checkout
        /// using the cart.  This method also allows for the items to be included
        /// which will appear in the paypal checkout page.
        /// </summary>
        /// <param name="OrderTotal">Order total</param>
        /// <param name="ReturnURL">Return URL</param>
        /// <param name="CancelURL">Cancel URL</param>
        /// <returns>Express checkout URL</returns>
        public string SetExpressCheckout(ShoppingCart Cart, decimal OrderTotal,
            string ReturnURL, string CancelURL, string NotifyURL, string noteToSeller)
        {
            InitSettings();
            TransactMode transactionMode = GetCurrentTransactionMode();

            SetExpressCheckoutReq req = new SetExpressCheckoutReq();
            req.SetExpressCheckoutRequest = new SetExpressCheckoutRequestType();
            req.SetExpressCheckoutRequest.Version = this.APIVersion;

            SetExpressCheckoutRequestDetailsType details = new SetExpressCheckoutRequestDetailsType();

            details.PaymentDetails = new PaymentDetailsType[1];

            details.AllowNote = "1";

            PaymentDetailsType payDetails = new PaymentDetailsType();
            details.BrandName = "Sewbie";
            details.OrderTotal = new BasicAmountType();
            details.OrderTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);
            details.OrderTotal.Value = OrderTotal.ToString("N", new CultureInfo("en-us"));

            details.Custom = Cart[0].VendorID.ToString() + ":" + Cart[0].CustomerSession.CustomerId;

            decimal discountAmount = 0, subTotalWithoutDiscount = 0, subTotalWithDiscount = 0;
            NopCommerce.BusinessLogic.Promo.Discounts.Discount appliedDiscount = new NopCommerce.BusinessLogic.Promo.Discounts.Discount();
            string scError = IoC.Resolve<IShoppingCartService>().GetShoppingCartSubTotal(Cart, NopCommerce.BusinessLogic.NopContext.Current.User, out discountAmount, out appliedDiscount, out subTotalWithoutDiscount, out subTotalWithDiscount);
            //TODO: We may need to put an error check in here.
            payDetails.ItemTotal = new BasicAmountType();
            payDetails.ItemTotal.Value = subTotalWithoutDiscount.ToString("N", new CultureInfo("en-us"));
            payDetails.ItemTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

            payDetails.TaxTotal = new BasicAmountType();
            payDetails.TaxTotal.Value = 0.ToString("N", new CultureInfo("en-us"));
            payDetails.TaxTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

            decimal shippingAmount = 0;
            payDetails.ShippingTotal = new BasicAmountType();
            foreach (ShoppingCartItem sci in Cart)
            {
                shippingAmount = shippingAmount + sci.AdditionalShippingCharge;
            }
            payDetails.ShippingTotal.Value = shippingAmount.ToString("N", new CultureInfo("en-us"));
            payDetails.ShippingTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

            payDetails.HandlingTotal = new BasicAmountType();
            payDetails.HandlingTotal.Value = 0.ToString("N", new CultureInfo("en-us"));
            payDetails.HandlingTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

            payDetails.InsuranceTotal = new BasicAmountType();
            payDetails.InsuranceTotal.Value = 0.ToString("N", new CultureInfo("en-us"));
            payDetails.InsuranceTotal.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

            //payDetails.ShipToAddress.Name = "";
            //payDetails.ShipToAddress.Street1 = "";
            //payDetails.ShipToAddress.Street2 = "";
            //payDetails.ShipToAddress.CityName = "";
            //payDetails.ShipToAddress.PostalCode = "";
            //payDetails.ShipToAddress.StateOrProvince = "";

            payDetails.NoteText = noteToSeller.Length > 0? noteToSeller:String.Empty;

            payDetails.SellerDetails = new SellerDetailsType();
            payDetails.SellerDetails.PayPalAccountID = Cart[0].Vendor.PaypalEmailAddress;

            payDetails.PaymentDetailsItem = new PaymentDetailsItemType[Cart.TotalProducts];

            payDetails.NotifyURL = NotifyURL;

            int itemCounter = 0;
            foreach (ShoppingCartItem sci in Cart)
            {
               PaymentDetailsItemType item = new PaymentDetailsItemType();
               item.Name = sci.ProductVariant.Product.Name;
               item.Number = sci.ProductVariant.Product.ProductId.ToString();
               item.Description = sci.ProductVariant.Product.ShortDescription;

               item.Amount = new BasicAmountType();
               item.Amount.Value = sci.ProductVariant.Price.ToString("N", new CultureInfo("en-us"));
               item.Amount.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

               item.Quantity = sci.Quantity.ToString();

               item.Tax = new BasicAmountType();
               item.Tax.Value = 0.ToString("N", new CultureInfo("en-us"));;
               item.Tax.currencyID = PaypalHelper.GetPaypalCurrency(IoC.Resolve<ICurrencyService>().PrimaryStoreCurrency);

               payDetails.PaymentDetailsItem[itemCounter] = item;

               itemCounter++;
            }

            details.PaymentDetails[0] = payDetails;

            details.PaymentAction = PaymentActionCodeType.Sale;
            details.PaymentActionSpecified = true;
            details.ReturnURL = ReturnURL;
            details.CancelURL = CancelURL;
            req.SetExpressCheckoutRequest.SetExpressCheckoutRequestDetails = details;

            SetExpressCheckoutResponseType response = service2.SetExpressCheckout(req);
            string error;
            if (PaypalHelper.CheckSuccess(response, out error))
                return GetPaypalUrl(response.Token);
            throw new NopException(error);
        }