コード例 #1
0
        /// <summary>
        /// Retrieve an existing customer profile along with all the associated customer payment profiles and customer shipping addresses. 
        /// </summary>
        /// <param name="profileID">The profile ID</param>
        /// <returns></returns>
        public Customer GetCustomer(string profileID) {
            var response = new getCustomerProfileResponse();
            var req = new getCustomerProfileRequest();
            
            req.customerProfileId = profileID;

            response = (getCustomerProfileResponse)_gateway.Send(req);
            

            var result = new Customer();
            
            result.Email = response.profile.email;
            result.Description = response.profile.description;
            result.ProfileID = response.profile.customerProfileId;
            result.ID = response.profile.merchantCustomerId;

            if (response.profile.shipToList !=null) {
                for (int i = 0; i < response.profile.shipToList.Length; i++) {
                    result.ShippingAddresses.Add(new Address(response.profile.shipToList[i]));
                }
            }

            if (response.profile.paymentProfiles != null) {

                for (int i = 0; i < response.profile.paymentProfiles.Length; i++) {
                    result.PaymentProfiles.Add(new PaymentProfile(response.profile.paymentProfiles[i]));
                }
            }
            return result;
        }
コード例 #2
0
 public ActionResult Items(int id = 0) {
     try {
         Cart order = new Cart();
         order = order.GetByPayment(id);
         Customer customer = new Customer{ ID = order.cust_id };
         customer.Get();
         ViewBag.customer = customer;
         ViewBag.order = order;
         ViewBag.statuses = new OrderStatus().GetAll();
     } catch (Exception) {
         return RedirectToAction("Index");
     }
     return View();
 }
コード例 #3
0
        public async Task<ActionResult> Index(string message = "") {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer customer = new Customer();
            ViewBag.timezone = UDF.GetTimeZone(ctx);

            var pcats = CURTAPI.GetParentCategoriesAsync();
            await Task.WhenAll(new Task[] { pcats });
            ViewBag.parent_cats = await pcats;

            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage(ctx);

            if (!customer.Cart.Validate()) {
                return RedirectToAction("Index", "Cart");
            }

            if (customer.Cart.payment_id > 0) {
                UDF.ExpireCart(ctx, customer.ID);
                return RedirectToAction("Index", "Cart");
            }
            // Create Cart object from customer
            customer.BindAddresses();
            Cart cart = customer.Cart;

            // Get the parts from this Cart
            cart.GetParts();

            ViewBag.showTotal = true;
            ViewBag.cart = cart;
            ViewBag.message = message;
            List<int> months = new List<int>();
            for (int i = 1; i <= 12; i++) {
                months.Add(i);
            }
            List<int> yearlist = new List<int>();
            for (int i = DateTime.Now.Year; i <= (DateTime.Now.Year + 20); i++) {
                yearlist.Add(i);
            }
            ViewBag.months = months;
            ViewBag.yearlist = yearlist;

            return View();
        }
コード例 #4
0
        public ActionResult Add()
        {
            List<Country> countries = UDF.GetCountries();

            Customer cust = new Customer();
            Address billing = new Address();
            Address shipping = new Address();
            try {
                cust = (Customer)TempData["customer"];
            } catch (Exception) { }
            try {
                billing = (Address)TempData["billing"];
            } catch (Exception) { }
            try {
                shipping = (Address)TempData["shipping"];
            } catch (Exception) { }
            ViewBag.error = (TempData["error"] != null) ? (string)TempData["error"] : "";
            ViewBag.cust = cust;
            ViewBag.billing = billing;
            ViewBag.shipping = shipping;
            ViewBag.countries = countries;
            return View();
        }
コード例 #5
0
        public ActionResult AddBillingAddress()
        {
            int ID = Convert.ToInt32(Request.Form["customerID"]);
            try {
                Customer customer = new Customer { ID = ID };
                customer.Get();
                Cart currentCart = customer.Carts.Where(x => x.payment_id == 0).First<Cart>();

                Address billing = new Address();
                // Build out our Billing object
                billing = new Address {
                    first = Request.Form["bfirst"],
                    last = Request.Form["blast"],
                    street1 = Request.Form["bstreet1"],
                    street2 = Request.Form["bstreet2"],
                    city = Request.Form["bcity"],
                    postal_code = Request.Form["bzip"],
                    residential = (Request.Form["bresidential"] == null) ? false : true,
                    active = true
                };
                try {
                    billing.state = Convert.ToInt32(Request.Form["bstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a billing state/province.");
                }
                //shipping.GeoLocate();
                billing.Save(customer.ID);

                // Retrieve Customer from Sessions/Cookie
                currentCart.SetBilling(billing.ID);
            } catch (Exception e) {
                TempData["error"] = e.Message;
            }

            return RedirectToAction("Step4", new { id = ID });
        }
コード例 #6
0
        public ActionResult Step3(int id = 0)
        {
            Customer c = new Customer {
                ID = id
            };
            c.Get();
            ViewBag.customer = c;

            string error = (TempData["message"] != null) ? (string)TempData["message"] : null;
            ViewBag.error = error;

            List<Address> addresses = c.GetAddresses();
            ViewBag.addresses = addresses;

            Cart currentCart = c.Carts.Where(x => x.payment_id == 0).First<Cart>();
            ViewBag.cart = currentCart;

            List<Country> countries = UDF.GetCountries();
            ViewBag.countries = countries;

            ShippingResponse shippingresponse = new ShippingResponse();
            shippingresponse = currentCart.getShipping();
            ViewBag.shippingresponse = shippingresponse;
            return View("Add-Shipping");
        }
コード例 #7
0
        public void UpdateCustomerTest()
        {
            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><updateCustomerProfileResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages></updateCustomerProfileResponse>";
            LocalRequestObject.ResponseString = responseString;

            var email = Path.GetRandomFileName() + "@visa.com";
            const string description = "Create a new customer";
            var customer = CreateCustomer(email, description);

            var newEmail = Path.GetRandomFileName() + "@visa.com";
            const string newDescription = "Update the Customer";

            var updateCustomer = new Customer
                {
                    ID = "",
                    ProfileID = customer.ProfileID,
                    Email = newEmail,
                    Description = newDescription
                };
	    
            var actual = false;

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                actual = _target.UpdateCustomer(updateCustomer);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.UpdateCustomer() failed: " + e.Message);
            }

            Assert.IsTrue(actual);
        }
コード例 #8
0
        private string SendAuthOnly(decimal amount, bool returnTransId, out Customer customer, out string paymentProfileId)
        {
            const string responseString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><createCustomerProfileTransactionResponse xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns=\"AnetApi/xml/v1/schema/AnetApiSchema.xsd\"><messages><resultCode>Ok</resultCode><message><code>I00001</code><text>Successful.</text></message></messages><directResponse>1,1,1,This transaction has been approved.,2JM6IE,Y,2207702136,,,11.21,CC,auth_only,,,,,,,,,,,,[email protected],,,,,,,,,,,,,,C8E9860C9B9DF58A73FFD9D7A8BFB82F,,2,,,,,,,,,,,XXXX1111,Visa,,,,,,,,,,,,,,,,</directResponse></createCustomerProfileTransactionResponse>";
            LocalRequestObject.ResponseString = responseString;

            var email = Path.GetRandomFileName() + "@visa.com";
            const string description = "Create a new customer";
            customer = CreateCustomer(email, description);
	    
            paymentProfileId = CreateCustomerPaymentProfile(customer.ProfileID,  "4111111111111111", 1, 2030);

            IGatewayResponse response = null;

            // if choose "USELOCAL", the test should pass with no exception
            // Otherwise, the test might fail for error, i.e. duplicated request.
            try
            {
                response = _target.Authorize(customer.ProfileID, paymentProfileId, amount);
            }
            catch (Exception e)
            {
                Console.WriteLine("CustomerGateway.Authorize() failed: " + e.Message);
            }

            if (response != null && response.Approved)
            {
                return returnTransId ? response.TransactionID : response.AuthorizationCode;
            }
            else
            {
                return "";
            }
        }
コード例 #9
0
        private void SaveCreditCardToProfile(string cardNumber, string cardCode, DateTime expires, PaymentInfo paymentInfo, Customer customer)
        {
            var foundPaymentProfile = customer.PaymentProfiles.SingleOrDefault(p => p.ProfileID == paymentInfo.AuNetCustPayId.ToString());

            if (foundPaymentProfile == null)
            {
                var paymentProfileId = CustomerGateway.AddCreditCard(customer.ProfileID, cardNumber,
                    expires.Month, expires.Year, cardCode, customer.BillingAddress);

                paymentInfo.AuNetCustPayId = paymentProfileId.ToInt();
            }
            else
            {
                if (!cardNumber.StartsWith("X"))
                    foundPaymentProfile.CardNumber = cardNumber;

                if (cardCode != null && !cardCode.StartsWith("X"))
                    foundPaymentProfile.CardCode = cardCode;

                foundPaymentProfile.CardExpiration = expires.ToString("MMyy");

                var isSaved = CustomerGateway.UpdatePaymentProfile(customer.ProfileID, foundPaymentProfile);
                if (!isSaved)
                    throw new Exception($"UpdatePaymentProfile failed to save echeck for {paymentInfo.PeopleId}");
            }
        }
コード例 #10
0
        private void SaveECheckToProfile(string routingNumber, string accountNumber, PaymentInfo paymentInfo, Customer customer)
        {
            if (accountNumber.StartsWith("X"))
                return;

            var foundPaymentProfile = customer.PaymentProfiles.SingleOrDefault(p => p.ProfileID == paymentInfo.AuNetCustPayBankId.ToString());

            var bankAccount = new BankAccount
            {
                accountType = BankAccountType.Checking,
                nameOnAccount = customer.Description,
                accountNumber = accountNumber,
                routingNumber = routingNumber
            };

            if (foundPaymentProfile == null)
            {
                var paymentProfileId = CustomerGateway.AddECheckBankAccount(customer.ProfileID, BankAccountType.Checking, routingNumber, accountNumber, customer.Description);
                paymentInfo.AuNetCustPayBankId = paymentProfileId.ToInt();
            }
            else
            {
                foundPaymentProfile.eCheckBankAccount = bankAccount;

                var isSaved = CustomerGateway.UpdatePaymentProfile(customer.ProfileID, foundPaymentProfile);
                if (!isSaved)
                    throw new Exception($"UpdatePaymentProfile failed to save credit card for {paymentInfo.PeopleId}");
            }
        }
コード例 #11
0
        /// <summary>
        /// Updates a customer's record.
        /// </summary>
        /// <param name="customer">The customer.</param>
        /// <returns></returns>
        public bool UpdateCustomer(Customer customer)
        {
            var req = new updateCustomerProfileRequest();
            req.profile = new customerProfileExType();
            req.profile.customerProfileId = customer.ProfileID;
            req.profile.description = customer.Description;
            req.profile.email = customer.Email;
            req.profile.merchantCustomerId = customer.ID;

            var response = (updateCustomerProfileResponse)_gateway.Send(req);

            return true;
        }
コード例 #12
0
        public ActionResult Step5(int id = 0, int address = 0)
        {
            Customer c = new Customer { ID = id };
            c.Get();
            ViewBag.customer = c;

            Cart currentCart = c.Carts.Where(x => x.payment_id == 0).First<Cart>();
            if (address != 0) {
                currentCart.SetBilling(address);
            }
            currentCart.SetTax();
            ViewBag.cart = currentCart;

            ViewBag.showShipping = true;
            ViewBag.message = TempData["message"];

            List<int> months = new List<int>();
            for (int i = 1; i <= 12; i++) {
                months.Add(i);
            }
            List<int> yearlist = new List<int>();
            for (int i = DateTime.Now.Year; i <= (DateTime.Now.Year + 20); i++) {
                yearlist.Add(i);
            }
            ViewBag.months = months;
            ViewBag.yearlist = yearlist;

            return View("Add-Payment");
        }
コード例 #13
0
        public ActionResult Complete(int id = 0)
        {
            Customer customer = new Customer();

            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage();
            Cart order = new Cart().Get(id);

            if (!customer.LoggedIn() || order.cust_id != customer.ID) {
                return RedirectToAction("Index", "Authenticate");
            }

            order.BindAddresses();
            Payment payment = order.getPayment();

            ViewBag.order = order;
            ViewBag.payment = payment;

            return View();
        }
コード例 #14
0
        public async Task<ActionResult> Complete(int id = 0) {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer customer = new Customer();
            ViewBag.timezone = UDF.GetTimeZone(ctx);

            var pcats = CURTAPI.GetParentCategoriesAsync();
            await Task.WhenAll(new Task[] { pcats });
            ViewBag.parent_cats = await pcats;

            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage(ctx);
            Cart order = new Cart().Get(id);

            order.BindAddresses();
            Payment payment = order.getPayment();

            ViewBag.order = order;
            ViewBag.payment = payment;

            return View();
        }
コード例 #15
0
 public ActionResult Step2(int id = 0)
 {
     Customer c = new Customer {
         ID = id
     };
     c.Get();
     Cart currentCart = new Cart();
     try {
         currentCart = c.Carts.Where(x => x.payment_id == 0).First<Cart>();
     } catch {
         Cart cart = new Cart();
         currentCart = cart.Save(c.ID);
     }
     ViewBag.customer = c;
     ViewBag.cart = currentCart;
     return View("Add-Items");
 }
コード例 #16
0
        public ActionResult Step1New()
        {
            Customer cust = new Customer();
            Address billing = new Address();
            Address shipping = new Address();
            try {
                #region Object Instantiation
                // Build out our Customer object
                cust = new Customer {
                    email = Request.Form["email"],
                    fname = Request.Form["fname"],
                    lname = Request.Form["lname"],
                    phone = Request.Form["phone"],
                    dateAdded = DateTime.Now,
                    isSuspended = 0,
                    isValidated = 1,
                    validator = Guid.NewGuid()
                };

                cust.GeneratePassword();

                // Build out our Billing object
                billing = new Address {
                    first = Request.Form["bfirst"],
                    last = Request.Form["blast"],
                    street1 = Request.Form["bstreet1"],
                    street2 = Request.Form["bstreet2"],
                    city = Request.Form["bcity"],
                    postal_code = Request.Form["bzip"],
                    residential = (Request.Form["bresidential"] == null) ? false : true,
                    active = true
                };

                // Build out our Shipping object
                shipping = new Address {
                    first = Request.Form["sfirst"],
                    last = Request.Form["slast"],
                    street1 = Request.Form["sstreet1"],
                    street2 = Request.Form["sstreet2"],
                    city = Request.Form["scity"],
                    postal_code = Request.Form["szip"],
                    residential = (Request.Form["sresidential"] == null) ? false : true,
                    active = true
                };
                #endregion

                #region Address state validation
                // Validate billing state
                try {
                    billing.state = Convert.ToInt32(Request.Form["bstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a billing state/province.");
                }
                // Validate shipping state
                try {
                    shipping.state = Convert.ToInt32(Request.Form["sstate"]);
                } catch (Exception) {
                    throw new Exception("You must select a shipping state/province.");
                }
                #endregion

                string[] nullables = new string[] { "phone", "address", "address1", "issuspended", "receivenewsletter", "receiveoffers", "isvalidated", "billingid", "shippingid", "cart", "id", "orders" };
                UDF.Sanitize(cust,nullables);

                cust.Save();
                billing.Save(cust.ID);
                if(billing.Equals(shipping)) {
                    shipping = billing;
                } else {
                    shipping.Save(cust.ID);
                }
                cust.SaveAddresses(billing, shipping);
                cust.Address = billing;
                cust.Address1 = shipping;
                return RedirectToAction("Step2", new { id = cust.ID });
            } catch (Exception e) {
                TempData["customer"] = cust;
                TempData["billing"] = billing;
                TempData["shipping"] = shipping;
                TempData["error"] = e.Message;
                return RedirectToAction("Add");
            }
        }
コード例 #17
0
 public ActionResult ChooseShipping(int id, int address)
 {
     Customer customer = new Customer { ID = id };
     customer.Get();
     Cart currentCart = customer.Carts.Where(x => x.payment_id == 0).First<Cart>();
     currentCart.SetShipping(address);
     return RedirectToAction("Step3", new { id = id });
 }
コード例 #18
0
        public ActionResult Authorize(int id = 0)
        {
            Customer c = new Customer { ID = id };
            c.Get();
            Cart currentCart = c.Carts.Where(x => x.payment_id == 0).First<Cart>();
            Settings settings = ViewBag.settings;

            decimal amount = currentCart.getTotal();
            string cardnum = Request.Form["cardnumber"];
            string month = Request.Form["expiremonth"];
            string year = Request.Form["expireyear"];
            string cvv = Request.Form["cvv"];
            string first = Request.Form["first"];
            string last = Request.Form["last"];

            //step 1 - create the request
            IGatewayRequest request = new AuthorizationRequest(cardnum, month + year, amount, "Transaction");

            //These are optional calls to the API
            request.AddCardCode(cvv);

            //Customer info - this is used for Fraud Detection
            request.AddCustomer(c.ID.ToString(), first, last, currentCart.Billing.street1 + ((currentCart.Billing.street2 != "") ? " " + currentCart.Billing.street2 : ""), currentCart.Billing.State1.abbr, currentCart.Billing.postal_code);

            //order number
            //request.AddInvoice("invoiceNumber");

            //Custom values that will be returned with the response
            //request.AddMerchantValue("merchantValue", "value");

            //Shipping Address
            request.AddShipping(c.ID.ToString(), currentCart.Shipping.first, currentCart.Shipping.last, currentCart.Shipping.street1 + ((currentCart.Shipping.street2 != "") ? " " + currentCart.Shipping.street2 : ""), currentCart.Shipping.State1.abbr, currentCart.Shipping.postal_code);

            //step 2 - create the gateway, sending in your credentials and setting the Mode to Test (boolean flag)
            //which is true by default
            //this login and key are the shared dev account - you should get your own if you
            //want to do more testing
            bool testmode = false;
            if (settings.Get("AuthorizeNetTestMode").Trim() == "true") {
                testmode = true;
            }

            Gateway gate = new Gateway(settings.Get("AuthorizeNetLoginKey"), settings.Get("AuthorizeNetTransactionKey"), testmode);

            //step 3 - make some money
            IGatewayResponse response = gate.Send(request);
            if (response.Approved) {
                currentCart.AddPayment("credit card", response.AuthorizationCode,"Complete");
                currentCart.SendConfirmation();
                int cartid = currentCart.ID;
                return RedirectToAction("Step6", new { id = cartid });
            } else {
                TempData["message"] = response.Message;
                return RedirectToAction("Step5", new { id = c.ID });
            }
        }
コード例 #19
0
        public ActionResult Index(string message = "")
        {
            Customer customer = new Customer();

            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage();
            if (!customer.LoggedIn()) {
                return RedirectToAction("Index", "Authenticate", new { referrer = "https://" + Request.Url.Host + "/Cart/Checkout" });
            }

            if (customer.Cart.payment_id > 0) {
                UDF.ExpireCart(customer.ID);
                return RedirectToAction("Index", "Cart");
            }
            // Create Cart object from customer
            customer.BindAddresses();
            Cart cart = customer.Cart;

            // Get the parts from this Cart
            cart.GetParts();

            ViewBag.showShipping = true;
            ViewBag.cart = cart;
            ViewBag.message = message;
            List<int> months = new List<int>();
            for (int i = 1; i <= 12; i++) {
                months.Add(i);
            }
            List<int> yearlist = new List<int>();
            for (int i = DateTime.Now.Year; i <= (DateTime.Now.Year + 20); i++) {
                yearlist.Add(i);
            }
            ViewBag.months = months;
            ViewBag.yearlist = yearlist;

            return View();
        }
コード例 #20
0
        public ActionResult Authorize() {
            HttpContext ctx = System.Web.HttpContext.Current;
            Customer customer = new Customer();
            Settings settings = ViewBag.settings;
            // Retrieve Customer from Sessions/Cookie
            customer.GetFromStorage(ctx);
            if (!customer.Cart.Validate()) {
                return RedirectToAction("Index", "Cart");
            }

            if (customer.Cart.GetPaymentID() > 0) {
                UDF.ExpireCart(ctx, customer.ID);
                return RedirectToAction("Index", "Cart");
            }

            customer.BindAddresses();

            decimal amount = customer.Cart.getTotal();
            string cardnum = Request.Form["cardnumber"];
            string month = Request.Form["expiremonth"];
            string year = Request.Form["expireyear"];
            string cvv = Request.Form["cvv"];
            string first = Request.Form["first"];
            string last = Request.Form["last"];

            //step 1 - create the request
            IGatewayRequest request = new AuthorizationRequest(cardnum, month + year, amount, "Transaction");

            //These are optional calls to the API
            request.AddCardCode(cvv);

            //Customer info - this is used for Fraud Detection
            request.AddCustomer(customer.ID.ToString(), first, last, customer.Cart.Billing.street1 + ((customer.Cart.Billing.street2 != "") ? " " + customer.Cart.Billing.street2 : ""), customer.Cart.Billing.State1.abbr, customer.Cart.Billing.postal_code);

            //order number
            //request.AddInvoice("invoiceNumber");

            //Custom values that will be returned with the response
            //request.AddMerchantValue("merchantValue", "value");

            //Shipping Address
            request.AddShipping(customer.ID.ToString(), customer.Cart.Shipping.first, customer.Cart.Shipping.last, customer.Cart.Shipping.street1 + ((customer.Cart.Shipping.street2 != "") ? " " + customer.Cart.Shipping.street2 : ""), customer.Cart.Shipping.State1.abbr, customer.Cart.Shipping.postal_code);


            //step 2 - create the gateway, sending in your credentials and setting the Mode to Test (boolean flag)
            //which is true by default
            //this login and key are the shared dev account - you should get your own if you 
            //want to do more testing
            bool testmode = false;
            if (settings.Get("AuthorizeNetTestMode").Trim() == "true") {
                testmode = true;
            }

            Gateway gate = new Gateway(settings.Get("AuthorizeNetLoginKey"), settings.Get("AuthorizeNetTransactionKey"), testmode);
            customer.Cart.SetStatus((int)OrderStatuses.PaymentPending);

            //step 3 - make some money
            IGatewayResponse response = gate.Send(request);
            if (response.Approved) {
                customer.Cart.AddPayment("credit card", response.AuthorizationCode, "Complete");
                customer.Cart.SetStatus((int)OrderStatuses.PaymentComplete);
                customer.Cart.SendConfirmation(ctx);
                customer.Cart.SendInternalOrderEmail(ctx);
                int cartid = customer.Cart.ID;
                
                Cart new_cart = new Cart().Save();
                new_cart.UpdateCart(ctx, customer.ID);
                DateTime cookexp = Request.Cookies["hdcart"].Expires;
                HttpCookie cook = new HttpCookie("hdcart", new_cart.ID.ToString());
                cook.Expires = cookexp;
                Response.Cookies.Add(cook);

                customer.Cart = new_cart;
                customer.Cart.BindAddresses();

                return RedirectToAction("Complete", new { id = cartid });
            } else {
                customer.Cart.SetStatus((int)OrderStatuses.PaymentDeclined);
                return RedirectToAction("Index", new { message = response.Message });
            }
        }
コード例 #21
0
        public ActionResult Step4(int id = 0, string shipping_type = "")
        {
            Customer c = new Customer {ID = id};
            c.Get();
            ViewBag.customer = c;

            string error = (TempData["message"] != null) ? (string)TempData["message"] : null;
            ViewBag.error = error;

            List<Address> addresses = c.GetAddresses();
            ViewBag.addresses = addresses;

            Cart currentCart = c.Carts.Where(x => x.payment_id == 0).First<Cart>();

            List<Country> countries = UDF.GetCountries();
            ViewBag.countries = countries;

            if (shipping_type != "") {
                decimal shipping_price = 0;
                string shiptype = "";
                string[] typesplit = shipping_type.Split('|');
                shiptype = typesplit[0];
                shipping_price = Convert.ToDecimal(typesplit[1]);
                currentCart.setShippingType(shiptype, shipping_price);
            }
            // We need to calculate the tax now that we know the shipping state
            ViewBag.cart = currentCart;

            return View("Add-Billing");
        }