public void RedirectToPayPal()
        {
            //fill In invoice Details

            List <Product> productArray = (List <Product>)Session["ProductsUPA"];
            StringBuilder  prodNames    = new StringBuilder();
            decimal        ammount      = 0;

            foreach (Product prod in productArray)
            {
                ammount += prod.Ammount;
                prodNames.Append(prod.ProductName + ";");
            }
            Session["UPAproducts"] = prodNames.ToString();


            invoice = new Invoice(productArray, ammount, (string)Session["buyerEmail"]);

            //Calculate Gross VAT ammount
            ammount = invoice.CalculateGrossAmmountWithVAT(0);

            //work out ammount to submit in Invoice to paypal:
            foreach (Product p in invoice)
            {
                invoice.CalculateItemAmmountVAT(p, 0);
            }
            //Store Info about transaction in Session
            Session["grossAmmount"] = ammount;

            Session["Invoice"] = invoice;
            int invoiceNo = (int)Session["InvoiceNo"];

            hasBeenRedirected = true;
            URLBuilder urlBuilder = new URLBuilder(Session, businessEmail, successUrl, cancelUrl, notifyUrl, (string)Session["buyerEmail"], invoiceNo);
            string     requestUrl = baseUrl + urlBuilder.getFullCommandParameters();

            if (response != null)
            {
                response.Redirect(requestUrl);
            }
        }
Пример #2
0
        public string RedirectToPayPal(List <Product> productArray)
        {
            //fill In invoice Details

            StringBuilder prodNames = new StringBuilder();
            decimal       amount    = 0;

            foreach (var prod in productArray)
            {
                amount += prod.Amount;
                prodNames.Append(prod.ProductName + ";");
            }

            invoice = new Invoice(productArray, amount, buyerEmail);


            hasBeenRedirected = true;
            URLBuilder urlBuilder = new URLBuilder(businessEmail, successUrl, cancelUrl, notifyUrl, buyerEmail, invoice);
            string     requestUrl = baseUrl + urlBuilder.getFullCommandParameters();

            return(requestUrl);
        }