public static OrderVariables AssignShippingToOrderVariable(OrderVariables oVariables, ShippingAddress newShippingAddress) { CommonModels oComm = new CommonModels(); //OrderVariables oVariables = new OrderVariables(); oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname = newShippingAddress.ShippingFirstName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname = newShippingAddress.ShippingLastName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1 = newShippingAddress.ShippingAddress1; oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt = newShippingAddress.ShippingAddress2; oVariables.ShipVars[oVariables.default_shp_id].ship_to_city = newShippingAddress.ShippingCity; oVariables.ShipVars[oVariables.default_shp_id].ship_to_state = newShippingAddress.ShippingState; oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode = newShippingAddress.ShippingZipCode; oVariables.referring_url = HttpContext.Current.Request.Url.ToString(); oVariables.ip_address = oComm.GetIPAddress(); oVariables.phone = newShippingAddress.ShippingPhone; oVariables.email = newShippingAddress.ShippingEmail; oVariables.bonus_option = false; if (newShippingAddress.isBonusSelected) { oVariables.bonus_option = true; } //Setting billing Address by default same as shipping address. // later on payment page it will be updated if shipping and biling not same oVariables.bill_to_fname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname; oVariables.bill_to_lname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname; oVariables.bill_to_address1 = oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1; oVariables.bill_to_apt = oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt; oVariables.bill_to_city = oVariables.ShipVars[oVariables.default_shp_id].ship_to_city; oVariables.bill_to_state = oVariables.ShipVars[oVariables.default_shp_id].ship_to_state; oVariables.bill_to_zipcode = oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode; return oVariables; }
/// <summary> /// 提交订单 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void Button_SaveMessage_Click(object sender, EventArgs e) { Customer currentUser = null; if (Session["User"] != null) { currentUser = (Customer)Session["User"]; } else { Response.Write("<script>alert('登陆失效,请重新登陆')</script>"); } string name = TextBox_Name.Text; string address = TextBox_Province.Text + Textbox_City.Text + Textbox_Area.Text + TextBox_Address.Text; string postcode = TextBox_Postcode.Text; string phone = TextBox_Phonenumber.Text; string remark = "remark"; ShippingAddress shippingAddress=new ShippingAddress(name,address,postcode,phone,remark); Order order =new Order(currentUser.Name,shippingAddress,DateTime.Now, bookItems); int state=currentUser.SubmitOrder(order); if (state == 0) { Response.Write("<script>alert('购买成功,谢谢您的支持!')</script>"); Response.Redirect("MainPage.aspx");//跳转到首页 } else { Response.Redirect("<script>alert(‘购买失败,请稍后重试!')</script>"); } }
public void SetOrderInformation(string orderId, string userName, decimal Price, int Valid, string orderDate, ShippingAddress shippingAddress) { orderid = orderId; username = userName; price = Price; isvalid = Valid; orderdate = orderDate; shippingaddress = shippingAddress; }
internal ShippingAddress getShipping() { ShippingAddress address = new ShippingAddress { StreetLines = new string[] { this.street1, this.street2 }, City = this.city, StateOrProvinceCode = this.State1.abbr, CountryCode = this.State1.Country.abbr, PostalCode = this.postal_code, Residential = this.residential, ResidentialSpecified = true, UrbanizationCode = null }; return address; }
public void TestInitialize() { this.dictionary = new Dictionary <string, object>(); this.cart = new Cart(); this.customer = new Customer(); this.payment = new Payment(); this.orders = new Orders(); this.orderDetails = new OrderDetails(); this.product = new Product(); this.orderStatus = new OrderStatus(); this.paymentMode = new PaymentMode(); this.category = new Category(); this.subCategory = new SubCategory(); this.paymentDetails = new PaymentDetails(); this.shippingAddress = new ShippingAddress(); }
public async Task CreatePaymentAsync(Amount amount, ShippingAddress shippingAddress, Item article) { var payment = new Payment() { Intent = "sale", Transactions = new List <Transaction>() { new Transaction() { Amount = amount, ItemList = new ItemList() { Items = new List <Item>() { article }, //ShippingAddress = shippingAddress } } }, //RedirectUrls = new RedirectUrls() //{ // CancelUrl = "https://example.com/cancel", // ReturnUrl = "https://example.com/return" //}, Payer = new Payer() { PaymentMethod = "paypal" } }; PaymentCreateRequest request = new PaymentCreateRequest(); request.RequestBody(payment); try { HttpResponse response = await _paypalClient.Execute(request); var statusCode = response.StatusCode; Payment result = response.Result <Payment>(); } catch (HttpException httpException) { var statusCode = httpException.StatusCode; } }
public IActionResult AddOrder(Dictionary <int, int> products, int id, PaymentType paymentType, bool isAddress, string address, string city, string state, string zipCode, string country) { try { Customer customer = _unitOfWork.Customers.GetCustomersWithAddress(id); Dictionary <Product, int> productQty = new Dictionary <Product, int>(); ShippingAddress shippingAddress = customer.ShippingAddress; if (!isAddress) { shippingAddress = new ShippingAddress(address, city, state, zipCode, country); } foreach (var productId in products.Keys) { productQty[_unitOfWork.Products.Get(productId)] = products[productId]; } Order order = new Order(customer, shippingAddress, paymentType, productQty); _unitOfWork.Orders.Add(order); _unitOfWork.Complete(); return(StatusCode(200)); } catch (OrderEmptyProductsException) { return(StatusCode(409, "You have to add at least one product.")); } catch (ArgumentNullException) { return(StatusCode(409, "Cant add the order,make sure you fill all the fields.")); } catch (ArgumentException) { return(StatusCode(409, "Cant add the order, make sure you fill all the fields with the right length.")); } catch (DbUpdateException) { return(StatusCode(409, "Cant add the order.")); } catch (Exception) { return(StatusCode(409, "Cant add the order.")); } }
public Purchase CheckOut(PaymentMethod paymentMethod, ShippingAddress shippingAddress) { var cart = this.GetForCurrentSession(); if (cart.Products.Count > 0) { var purchase = CreatePurchaseFromCartForCurrentSession(cart, paymentMethod, shippingAddress); ResetCartForCurrentSession(cart); return(purchase); } else { throw new Exception("Cannot checkout an empty cart"); } }
private void writeOnAudit(int id, ShippingAddress item) { Context().ShippingAddressAudit.Add(new ShippingAddressAudit() { id_shipping = id, first_name = item.first_name, last_name = item.last_name, company = item.company, address = item.address, city = item.city, country = item.country, province = item.province, postal_code = item.postal_code, phone = item.phone, date_upd = DateTime.Now }); }
public async Task <IActionResult> GetAccountInformation() { string userId = User.Claims.FirstOrDefault(c => c.Type == ClaimTypes.Sid)?.Value; WebshopUser user = await UserManager.FindByIdAsync(userId); if (user == null) { return(BadRequest()); } ShippingAddress address = AddressRepository.GetByGuid(user.UserGuid); return(Ok(new { address, email = user.Email, name = user.FirstName, lastName = user.LastName, phone = user.PhoneNumber })); }
public void EditShippingAddress(ShippingAddress editAddress) { var url = string.Format("http://www.test.com/user/shippingaddress/edit"); HttpWebRequest httpWebRequest = (HttpWebRequest)WebRequest.Create(url); var jsonData = _javaScriptSerializer.Serialize(editAddress); byte[] bytes = Encoding.UTF8.GetBytes(jsonData); httpWebRequest.GetRequestStream().Write(bytes, 0, bytes.Length); using (HttpWebResponse httpWebResponse = (HttpWebResponse)httpWebRequest.GetResponse()) { if (httpWebResponse.StatusCode == HttpStatusCode.OK) { } throw new ApplicationException("编辑收货地址请求失败,状态码:" + httpWebResponse.StatusCode.ToString()); } }
private void SetUpPurchaseData() { var paymentMethod = new PaymentMethod() { Name = "PaymentMethod#1" }; var shippingAddress = new ShippingAddress() { Address = "AddressMethod#1", FirstName = "Sport", LastName = "Store", Phone = "1234" }; paymentMethod.Id = this.businessLogic.PaymentMethod.Create(paymentMethod); shippingAddress.Id = this.businessLogic.ShippingAddress.Create(shippingAddress); this.fakePaymentMethod = paymentMethod; this.fakeShippingAddress = shippingAddress; }
private static ShippingAddress CreateFakeShippingAddress() { ShippingAddress shippingAddress = new ShippingAddress(); shippingAddress.first_name = Faker.Name.First(); shippingAddress.last_name = Faker.Name.Last(); shippingAddress.street_1 = Faker.Address.StreetAddress(); shippingAddress.street_2 = "Room 104"; shippingAddress.city = Faker.Address.City(); shippingAddress.state = Faker.Address.UsState(); shippingAddress.zip = Faker.Address.ZipCode(); shippingAddress.country_iso2 = "US"; shippingAddress.phone = Faker.Phone.Number(); shippingAddress.shipping_method = "Priority"; return(shippingAddress); }
public async Task <ShippingAddress> Get(long Id) { ShippingAddress ShippingAddress = await DataContext.ShippingAddress.Where(x => x.Id == Id).Select(ShippingAddressDAO => new ShippingAddress() { Id = ShippingAddressDAO.Id, CustomerId = ShippingAddressDAO.CustomerId, FullName = ShippingAddressDAO.FullName, CompanyName = ShippingAddressDAO.CompanyName, PhoneNumber = ShippingAddressDAO.PhoneNumber, ProvinceId = ShippingAddressDAO.ProvinceId, DistrictId = ShippingAddressDAO.DistrictId, WardId = ShippingAddressDAO.WardId, Address = ShippingAddressDAO.Address, IsDefault = ShippingAddressDAO.IsDefault, Customer = ShippingAddressDAO.Customer == null ? null : new Customer { Id = ShippingAddressDAO.Customer.Id, Username = ShippingAddressDAO.Customer.Username, DisplayName = ShippingAddressDAO.Customer.DisplayName, PhoneNumber = ShippingAddressDAO.Customer.PhoneNumber, Email = ShippingAddressDAO.Customer.Email, }, District = ShippingAddressDAO.District == null ? null : new District { Id = ShippingAddressDAO.District.Id, Name = ShippingAddressDAO.District.Name, OrderNumber = ShippingAddressDAO.District.OrderNumber, ProvinceId = ShippingAddressDAO.District.ProvinceId, }, Province = ShippingAddressDAO.Province == null ? null : new Province { Id = ShippingAddressDAO.Province.Id, Name = ShippingAddressDAO.Province.Name, OrderNumber = ShippingAddressDAO.Province.OrderNumber, }, Ward = ShippingAddressDAO.Ward == null ? null : new Ward { Id = ShippingAddressDAO.Ward.Id, Name = ShippingAddressDAO.Ward.Name, OrderNumber = ShippingAddressDAO.Ward.OrderNumber, DistrictId = ShippingAddressDAO.Ward.DistrictId, }, }).FirstOrDefaultAsync(); return(ShippingAddress); }
public static CustomerBasketDto MapToResult( this Customer customer, Basket basket, ShippingAddress address) => new CustomerBasketDto { CreateDate = basket.CreateDate, CustomerFullName = customer.FullName, CustomerEmail = customer.Email, CustomerMobile = customer.Mobile, CustomerPostalCode = address.PostalCode, CustomerShippingAddress = address.Address, Id = basket.Id, TotalPrice = basket.TotalPrice, TotalTaxAmount = basket.Items.Sum(_ => _.TaxAmount), UserId = basket.UserId, Items = basket.Items.Adapt <List <CustomerBasketItemDto> >() };
public IActionResult Checkout([Bind("CustomerName, Email, PhoneNumber, Street, PostalCode, City")] ShippingAddress user) { var cartId = _cartService.GetTempCartId(HttpContext.Session); var order = _orderService.GetOrder(cartId); if (ModelState.IsValid) { if (order != null) { _orderService.UpdateAddress(cartId, user); } _orderService.CreateOrder(cartId, user); return(View("OrderPayment", user)); } return(View(user)); }
private void GetShippingAddr() { ShippingAddressInfo dataById = ShippingAddress.GetDataById(WebUtils.GetQueryInt("id")); System.Collections.Generic.List <ShippingAddressInfo> list = (System.Collections.Generic.List <ShippingAddressInfo>)ShippingAddress.GetShippingAddrByUID(WebUtils.GetQueryInt("uid")); if (dataById != null) { base.Response.Write(JsonUtils.ObjectToJson <ShippingAddressInfo>(dataById)); } else if (list != null && list.Count > 0) { base.Response.Write(JsonUtils.ObjectToJson <System.Collections.Generic.List <ShippingAddressInfo> >(list)); } else { base.Response.Write("{\"ret\":\"fail\",\"status\":0,\"msg\":\"Chúng tôi không tìm thấy bất kỳ dữ liệu\"}"); } }
public DistrictMaster_ShippingAddressDTO(ShippingAddress ShippingAddress) { this.Id = ShippingAddress.Id; this.CustomerId = ShippingAddress.CustomerId; this.FullName = ShippingAddress.FullName; this.CompanyName = ShippingAddress.CompanyName; this.PhoneNumber = ShippingAddress.PhoneNumber; this.ProvinceId = ShippingAddress.ProvinceId; this.DistrictId = ShippingAddress.DistrictId; this.WardId = ShippingAddress.WardId; this.Address = ShippingAddress.Address; this.IsDefault = ShippingAddress.IsDefault; this.Customer = new DistrictMaster_CustomerDTO(ShippingAddress.Customer); this.Province = new DistrictMaster_ProvinceDTO(ShippingAddress.Province); this.Ward = new DistrictMaster_WardDTO(ShippingAddress.Ward); }
public static ShippingAddress CreateTestShippingAddress() { var shippingAddress = new ShippingAddress { ShippingMethod = "NextDay", FirstName = "John", LastName = "Smith", Street1 = "Level 5", Street2 = "369 Queen Street", City = "Sydney", State = "NSW", Country = "au", PostalCode = "2000", Phone = "09 889 0986" }; return(shippingAddress); }
/// <summary> /// 生成完整的收货地址字符串 /// </summary> /// <param name="address">收货地址</param> /// <returns></returns> public static string GenerateSummary(this ShippingAddress address) { // 获取国家和地区名称 // 如果设置了不显示国家下拉框,则国家名称等于空 var regionManager = Application.Ioc.Resolve <RegionManager>(); var configManager = Application.Ioc.Resolve <GenericConfigManager>(); var country = regionManager.GetCountry(address.Country) ?? regionManager.GetDefaultCountry(); var region = (address.RegionId == null ? null : country.GetRegionsTreeNode(address.RegionId.Value)); var regionSettings = configManager.GetData <RegionSettings>(); var countryName = regionSettings.DisplayCountryDropdown ? new T(country.Name) : ""; var regionName = region == null ? null : region.GetFullname(); // 生成完整的收货地址字符串 return(string.Format("{0} {1}{2}{3} {4}", address.ReceiverName, countryName, regionName, address.DetailedAddress, address.ReceiverTel)); }
/// <summary> /// 更新成功时调用 /// </summary> /// <param name="address"></param> protected void OnSuccess(ShippingAddress address) { if (Success != null) { Delegate[] list = Success.GetInvocationList(); foreach (Delegate d in list) { try { Action <ShippingAddress> action = (Action <ShippingAddress>)d; action.BeginInvoke(address, null, null); } catch { } } } }
//Create a new Shipping Address public async Task <bool> CreateShippingAddress(ShippingAddressCreate model) { var entity = new ShippingAddress() { ShippingAddressId = model.ShippingAddressId, CustomerId = model.CustomerId, LocationName = model.LocationName, StreetAddress = model.StreetAddress, StateId = model.StateId, ZipCodeId = model.ZipCodeId }; using (var ctx = new ApplicationDbContext()) { ctx.ShippingAddresses.Add(entity); return(await ctx.SaveChangesAsync() == 1); } }
public ShippingControllerUnitTests() { shipTo = new ShippingAddress() { addressLine1 = "2294 Cloverdale Dr", city = "Atlanta", state = "GA", zip = "30316" }; shipFrom = new ShippingAddress() { addressLine1 = "13890 Lowe St", city = "Chantilly", state = "VA", zip = "20151" }; }
private void DeleteShippingAddress() { Customer customer = DataAccessContext.CustomerRepository.GetOne(CustomerID); ShippingAddress shippingAddress = new ShippingAddress(); int deleteIndex = -1; for (int i = 0; i < customer.ShippingAddresses.Count; i++) { if (customer.ShippingAddresses[i].ShippingAddressID == ShippingAddressID) { deleteIndex = i; } } customer.ShippingAddresses.RemoveAt(deleteIndex); customer = DataAccessContext.CustomerRepository.Save(customer); }
public async Task <bool> Update(ShippingAddress ShippingAddress) { ShippingAddressDAO ShippingAddressDAO = DataContext.ShippingAddress.Where(x => x.Id == ShippingAddress.Id).FirstOrDefault(); ShippingAddressDAO.Id = ShippingAddress.Id; ShippingAddressDAO.CustomerId = ShippingAddress.CustomerId; ShippingAddressDAO.FullName = ShippingAddress.FullName; ShippingAddressDAO.CompanyName = ShippingAddress.CompanyName; ShippingAddressDAO.PhoneNumber = ShippingAddress.PhoneNumber; ShippingAddressDAO.ProvinceId = ShippingAddress.ProvinceId; ShippingAddressDAO.DistrictId = ShippingAddress.DistrictId; ShippingAddressDAO.WardId = ShippingAddress.WardId; ShippingAddressDAO.Address = ShippingAddress.Address; ShippingAddressDAO.IsDefault = ShippingAddress.IsDefault; await DataContext.SaveChangesAsync(); return(true); }
public void PatchShippingAddressesTestMethod() { controller = new ShippingAddressesController(context); ShippingAddress shippingAddress = new ShippingAddress() { country = "Germany", }; IActionResult actionResult = controller.ShippingAddresses(1, shippingAddress); OkObjectResult result = actionResult as OkObjectResult; ShippingAddress shippingAddressUpdated = result.Value as ShippingAddress; Assert.IsNotNull(result); Assert.AreEqual(result.StatusCode, 200); Assert.AreEqual(shippingAddressUpdated.country, shippingAddress.country); controller.Dispose(); }
public ActionResult AddShippingAddresses([Bind(Include = "Id,CustomerId,AddressDesc,Recipient,StreetAddress,City,State,ZipCode,PhoneNumber,SpecInstructions")] ShippingAddress shippingAddress, Boolean isDefault) { if (ModelState.IsValid) { var user = db.Users.Find(User.Identity.GetUserId()); shippingAddress.CustomerId = (User.Identity.GetUserId()); db.ShippingAddresses.Add(shippingAddress); db.SaveChanges(); if (isDefault) { user.DefaultShippingAddressId = shippingAddress.Id; db.SaveChanges(); } var model = new IndexViewModel(); // This is added because the Manage/Index view requires the model to be passed. return(View("../Manage/Index", model)); } return(View(shippingAddress)); }
protected static void ValidateJobDetails(ContactDetails contactDetails, ShippingAddress shippingAddress, JobResource getJob) { Assert.NotNull(getJob.Details); Assert.NotNull(getJob.Details.ContactDetails.NotificationPreference); Assert.Equal(contactDetails.ContactName, getJob.Details.ContactDetails.ContactName); Assert.Equal(contactDetails.Phone, getJob.Details.ContactDetails.Phone); Assert.Equal(contactDetails.PhoneExtension, getJob.Details.ContactDetails.PhoneExtension); Assert.Equal(contactDetails.EmailList, getJob.Details.ContactDetails.EmailList); Assert.Equal(shippingAddress.AddressType, getJob.Details.ShippingAddress.AddressType); Assert.Equal(shippingAddress.City, getJob.Details.ShippingAddress.City); Assert.Equal(shippingAddress.CompanyName, getJob.Details.ShippingAddress.CompanyName); Assert.Equal(shippingAddress.Country, getJob.Details.ShippingAddress.Country); Assert.Equal(shippingAddress.PostalCode, getJob.Details.ShippingAddress.PostalCode); Assert.Equal(shippingAddress.StateOrProvince, getJob.Details.ShippingAddress.StateOrProvince); Assert.Equal(shippingAddress.StreetAddress1, getJob.Details.ShippingAddress.StreetAddress1); Assert.Equal(shippingAddress.StreetAddress2, getJob.Details.ShippingAddress.StreetAddress2); Assert.Equal(shippingAddress.StreetAddress3, getJob.Details.ShippingAddress.StreetAddress3); }
public WardDetail_ShippingAddressDTO(ShippingAddress ShippingAddress) { this.Id = ShippingAddress.Id; this.CustomerId = ShippingAddress.CustomerId; this.FullName = ShippingAddress.FullName; this.CompanyName = ShippingAddress.CompanyName; this.PhoneNumber = ShippingAddress.PhoneNumber; this.ProvinceId = ShippingAddress.ProvinceId; this.DistrictId = ShippingAddress.DistrictId; this.WardId = ShippingAddress.WardId; this.Address = ShippingAddress.Address; this.IsDefault = ShippingAddress.IsDefault; this.Customer = new WardDetail_CustomerDTO(ShippingAddress.Customer); this.District = new WardDetail_DistrictDTO(ShippingAddress.District); this.Province = new WardDetail_ProvinceDTO(ShippingAddress.Province); }
private Agreement EjecutarPlanRecurrente(Plan plan, int diasCobro) { try { DateTime startDate = DateTime.Now.AddDays(diasCobro); DateTime endDate = startDate.AddMonths(1); APIContext apiContext = GetAPIContext(); var shippingAddress = new ShippingAddress() { line1 = "AVENIDA JUAREZ 1123, COL. UNIVERSIDAD", city = "TOLUCA", state = "ESTADO DE MEXICO", postal_code = "95070", country_code = "MX" }; var agreement = new Agreement() { name = plan.name, description = plan.description, start_date = startDate.ToString("yyyy-MM-ddTHH:mm:ss") + "Z", //update_time = endDate.ToString("yyyy-MM-ddTHH:mm:ss") + "Z", payer = new Payer() { payment_method = "paypal" }, plan = new Plan() { id = plan.id }, shipping_address = shippingAddress }; var createdAgreement = agreement.Create(apiContext); return(createdAgreement); } catch (Exception ex) { return(null); } }
public int Add(CartModel model) { var order = new Order { ProductId = model.ProductId, Amount = model.Price, Quantity = model.Quantity, OrderStatusId = 1, OrderOn = DateTime.Now, UserId = Convert.ToInt32(System.Web.HttpContext.Current.Session["UserId"]) }; if (model.CouponApplied) { order.CouponApplied = model.CouponApplied; order.CouponId = model.CouponId; } var payment = new Payment { CardNo = model.Payment.CardNo, ExpiryMonth = model.Payment.ExpiryMonth, ExpiryYear = model.Payment.ExpiryYear, CVV = model.Payment.CVV, PaidOn = DateTime.Now, PaymentStatus = "Success" }; order.Payments.Add(payment); var address = new ShippingAddress { Name = model.ShippingAddress.Name, Mobile = model.ShippingAddress.Mobile, Address = model.ShippingAddress.Address, City = model.ShippingAddress.City, ZipCode = model.ShippingAddress.ZipCode }; order.ShippingAddresses.Add(address); db.Orders.Add(order); return(db.SaveChanges()); }
/// <summary> /// Allows you to convert the current order snapshot object to the DTO equivalent for use with the REST API /// </summary> /// <returns>A new instance of OrderSnapshotDTO</returns> public OrderSnapshotDTO ToDto() { var dto = new OrderSnapshotDTO(); dto.AffiliateID = AffiliateID; dto.BillingAddress = BillingAddress.ToDto(); dto.bvin = bvin ?? string.Empty; dto.CustomProperties = new List <CustomPropertyDTO>(); foreach (var prop in CustomProperties) { dto.CustomProperties.Add(prop.ToDto()); } dto.FraudScore = FraudScore; dto.Id = Id; dto.Instructions = Instructions ?? string.Empty; dto.IsPlaced = IsPlaced; dto.LastUpdatedUtc = LastUpdatedUtc; dto.OrderNumber = OrderNumber ?? string.Empty; dto.PaymentStatus = (OrderPaymentStatusDTO)(int)PaymentStatus; dto.ShippingAddress = ShippingAddress.ToDto(); dto.ShippingMethodDisplayName = ShippingMethodDisplayName ?? string.Empty; dto.ShippingMethodId = ShippingMethodId ?? string.Empty; dto.ShippingProviderId = ShippingProviderId ?? string.Empty; dto.ShippingProviderServiceCode = ShippingProviderServiceCode ?? string.Empty; dto.ShippingStatus = (OrderShippingStatusDTO)(int)ShippingStatus; dto.StatusCode = StatusCode ?? string.Empty; dto.StatusName = StatusName ?? string.Empty; dto.StoreId = StoreId; dto.ThirdPartyOrderId = ThirdPartyOrderId ?? string.Empty; dto.TimeOfOrderUtc = TimeOfOrderUtc; dto.TotalGrand = TotalGrand; dto.TotalHandling = TotalHandling; dto.TotalOrderBeforeDiscounts = TotalOrderBeforeDiscounts; dto.TotalOrderDiscounts = TotalOrderDiscounts; dto.TotalShippingBeforeDiscounts = TotalShippingBeforeDiscounts; dto.TotalShippingDiscounts = TotalShippingDiscounts; dto.ItemsTax = ItemsTax; dto.ShippingTax = ShippingTax; dto.TotalTax = TotalTax; dto.UserEmail = UserEmail ?? string.Empty; dto.UserID = UserID ?? string.Empty; return(dto); }
protected void SaveShippingAddress() { if (this.UserIsLevelA) { //TODO: Save level A address //this.ShippingAddress = CheckoutCartHelper.FindAddressById(this.ddlLevelAShippingAddress.SelectedValue); foreach (CustomerAddress address in this.UserOrganization.Addresses) { if (address.Name == ddlLevelAShippingAddress.SelectedValue) { //convert the selected address into an OrderAddress, including custom meta data. OrderAddress shippingAddress = StoreHelper.ConvertToOrderAddress(address); shippingAddress["TaxRate"] = address["TaxRate"]; shippingAddress["IsFreightTaxable"] = address["IsFreightTaxable"]; shippingAddress["SBOAddressId"] = address["SBOAddressId"]; this.ShippingAddress = shippingAddress; } } } else { //Save the level B Address ShippingAddress.City = tbShippingCity.Text; ShippingAddress.State = ssShippingState.SelectedState; ShippingAddress.Line1 = tbShippingAddress.Text; ShippingAddress.PostalCode = tbShippingZip.Text; ShippingAddress.DaytimePhoneNumber = pnShippingDayPhone.Text; ShippingAddress.FaxNumber = pnShippingFax.Text; ShippingAddress.AcceptChanges(); } //save the meta data this.CheckoutCart["ShippingInstructions"] = this.tbShippingSpecialInstructions.Text; //set the line item addresses foreach (LineItem lineItem in this.CheckoutCartHelper.LineItems) { lineItem.ShippingAddressId = ShippingAddress.Name; } //TODO:Save the shipping Meta Data this.CheckoutCart.AcceptChanges(); }
public async Task <Order> CreateOrderAsync( string customerEmail, int deliveryMethodId, string cartId, ShippingAddress shippingAddress) { // Get cart var cart = await _cartService.GetCartAsync(cartId); // Get order items var orderItems = new List <OrderItem>(); foreach (var cartItem in cart.Items) { var productItem = await _unitOfWork.Service <Product>().GetByIdAsync(cartItem.Id); var itemOrdered = new ProductItemOrdered(productItem.Id, productItem.Name, productItem.PictureURL); var orderItem = new OrderItem(itemOrdered, productItem.Price, cartItem.Quantity); orderItems.Add(orderItem); } // Get delivery method var deliveryMethod = await _unitOfWork.Service <DeliveryMethod>().GetByIdAsync(deliveryMethodId); // Calculate subttotal var subTotal = orderItems.Sum(orderitem => orderitem.Price * orderitem.Quantity); // Create order var order = new Order(customerEmail, subTotal, shippingAddress, deliveryMethod, orderItems); // Save to database _unitOfWork.Service <Order>().Add(order); var orderSaved = await _unitOfWork.SaveChangesToDatabase(); // Sanity check if (orderSaved <= 0) { return(null); } // Empty cart await _cartService.EmptyCartAsync(cartId); return(order); }
internal static ShippingResponse GetShipping(FedExAuthentication auth, ShippingAddress origin, ShippingAddress dest, List<int> parts) { ShippingResponse response = new ShippingResponse(); try { WebClient wc = new WebClient(); wc.Proxy = null; Settings settings = new Settings(); wc.Headers["Content-type"] = "application/x-www-form-urlencoded"; string URI = settings.Get("CURTAPISHIPPINGDOMAIN") + "GetShipping"; string parameters = "dataType=JSON"; parameters += "&auth=" + Newtonsoft.Json.JsonConvert.SerializeObject(auth); parameters += "&origin=" + Newtonsoft.Json.JsonConvert.SerializeObject(origin); parameters += "&destination=" + Newtonsoft.Json.JsonConvert.SerializeObject(dest); parameters += "&parts=" + Newtonsoft.Json.JsonConvert.SerializeObject(parts); if (settings.Get("FedExEnvironment") == "development") { parameters += "&environment=development"; } else { parameters += "&environment=production"; } string APIresponse = wc.UploadString(URI, parameters); response = JsonConvert.DeserializeObject<ShippingResponse>(APIresponse); if (response.Status == "ERROR") { throw new Exception("FedEx is having issues at the moment. Please try again."); } } catch (Exception) { } return response; }
public static OrderVariables AssignShippingToOrderVariable(OrderVariables oVariables, ShippingAddress newShippingAddress) { CommonModels oComm = new CommonModels(); OrderProcess oProcess = new OrderProcess(); //OrderVariables oVariables = new OrderVariables(); oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname = newShippingAddress.ShippingFirstName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname = newShippingAddress.ShippingLastName; oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1 = newShippingAddress.ShippingAddress1; oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt = newShippingAddress.ShippingAddress2; oVariables.ShipVars[oVariables.default_shp_id].ship_to_city = newShippingAddress.ShippingCity; oVariables.ShipVars[oVariables.default_shp_id].ship_to_state = newShippingAddress.ShippingState; oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode = newShippingAddress.ShippingZipCode; oVariables.ShipVars[oVariables.default_shp_id].child_dob = newShippingAddress.ChildDOB != null ? newShippingAddress.ChildDOB.ToString() : ""; //oVariables.ShipVars[oVariables.default_shp_id].child_fname = newShippingAddress.ChildName; #region Code for Child Name Gender and DOB //======================================== string chName = ""; chName = string.IsNullOrEmpty(newShippingAddress.ChildName) ? "" : newShippingAddress.ChildName.Trim(); string[] name = chName.Split(' '); int cnt = name.Count(); string fname = ""; for (int i = 0; i < name.Count() - 1; i++) { fname += name[i] + " "; } string lname = ""; if (cnt > 1) { lname = name[cnt - 1]; } if (fname.Trim().Length == 0) fname = name.Length > 0 ? name[0] : ""; if (lname.Trim().Length == 0) lname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname; //oVariables.ShipVars[oVariables.default_shp_id].child_dob = oProcess.ValidateDateTime(newShippingAddress.ChildDOB.ToString()); oVariables.ShipVars[oVariables.default_shp_id].child_fname = fname.Trim(); oVariables.ShipVars[oVariables.default_shp_id].child_lname = lname.Trim(); if (string.IsNullOrEmpty(newShippingAddress.ChildGender) || newShippingAddress.ChildGender == "") oVariables.ShipVars[oVariables.default_shp_id].child_gender = "0"; else oVariables.ShipVars[oVariables.default_shp_id].child_gender = newShippingAddress.ChildGender; //oVariables.referring_url = HttpContext.Current.Request.Url.ToString(); #endregion //================================================= oVariables.ip_address = oComm.GetIPAddress(); oVariables.phone = newShippingAddress.ShippingPhone; oVariables.email = newShippingAddress.ShippingEmail; oVariables.bonus_option = false; if (newShippingAddress.isBonusSelected) { oVariables.bonus_option = true; } //Setting billing Address by default same as shipping address. // later on payment page it will be updated if shipping and biling not same oVariables.bill_to_fname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_fname; oVariables.bill_to_lname = oVariables.ShipVars[oVariables.default_shp_id].ship_to_lname; oVariables.bill_to_address1 = oVariables.ShipVars[oVariables.default_shp_id].ship_to_address1; oVariables.bill_to_apt = oVariables.ShipVars[oVariables.default_shp_id].ship_to_apt; oVariables.bill_to_city = oVariables.ShipVars[oVariables.default_shp_id].ship_to_city; oVariables.bill_to_state = oVariables.ShipVars[oVariables.default_shp_id].ship_to_state; oVariables.bill_to_zipcode = oVariables.ShipVars[oVariables.default_shp_id].ship_to_zipcode; return oVariables; }
public ShippingResponse getShipping(HttpContext ctx) { Customer customer = new Customer(); Settings settings = ViewBag.settings; customer.GetFromStorage(ctx); FedExAuthentication auth = new FedExAuthentication { AccountNumber = Convert.ToInt32(settings.Get("FedExAccount")), Key = settings.Get("FedExKey"), Password = settings.Get("FedExPassword"), CustomerTransactionId = "", MeterNumber = Convert.ToInt32(settings.Get("FedExMeter")) }; customer.Cart.BindAddresses(); ShippingAddress destination = new ShippingAddress(); try { destination = customer.Cart.Shipping.getShipping(); } catch (Exception) { Response.Redirect("/Cart/Checkout"); } DistributionCenter d = new DistributionCenter().GetNearest(customer.Cart.Shipping.GeoLocate()); ShippingAddress origin = d.getAddress().getShipping(); List<int> parts = new List<int>(); foreach (CartItem item in customer.Cart.CartItems) { for (int i = 1; i <= item.quantity; i++) { parts.Add(item.partID); } } ShippingResponse response = CURTAPI.GetShipping(auth, origin, destination, parts); return response; }
/// <summary> /// 查询订单信息(所有订单 /// orderList->Order->bookItemList->Book ① /// 思路: /// 1.对比当前订单与之前订单的订单号 /// 2.如果订单号相同,说明图书属于一个订单,获取订单列表中的最后一个订单,然后删除(删除是为了步骤5插入订单列表时方便操作) /// 3.如果订单号不同,说明图书不属于同一订单,则新建一个订单 /// 4.获取到订单后,根据①创建订单对象 /// 5.将订单插入到订单列表尾部 /// </summary> /// <returns></returns> public List<Order> QueryOrderInformation() { SqlConnection sql = DataBaseOperations.CreateConnection(); string preOrderId = null;//上一个订单号 string curOrderId;//当前订单号 List<Order> orderList = new List<Order>();//订单列表 Order order;//订单 //根据当前用户名查询订单 string cmdText = "select a.OrderID,a.UserName,a.Address,a.Remark,a.Price,a.isValid,a.OrderDate,b.BookID,b.Amount,c.BookName,c.BookAuthor,c.BookPrice,c.BookPress,c.BookDetail,c.BookCategory,c.BookImageURL,c.ShelveDate,c.Inventory,c.Rating from [Order] a inner join [OrderDetail] b on a.OrderID=b.OrderID inner join [Book] c on b.BookID=c.BookID where a.UserName='******' order by a.OrderID desc"; DataSet dataSet = DataBaseOperations.GetDataSet(cmdText, sql); if (dataSet != null) { for (int i = 0; i < dataSet.Tables[0].Rows.Count; i++) { curOrderId = dataSet.Tables[0].Rows[i][0].ToString();//获取到当前订单id ShippingAddress shippingAddress = new ShippingAddress(dataSet.Tables[0].Rows[i][2].ToString(), dataSet.Tables[0].Rows[i][3].ToString());//创建收货对象 //创建book对象 Book aBook = new Book(dataSet.Tables[0].Rows[i][7].ToString(), dataSet.Tables[0].Rows[i][9].ToString(), dataSet.Tables[0].Rows[i][10].ToString(), Convert.ToDecimal(dataSet.Tables[0].Rows[i][11]), dataSet.Tables[0].Rows[i][12].ToString(), dataSet.Tables[0].Rows[i][13].ToString(), dataSet.Tables[0].Rows[i][14].ToString(), dataSet.Tables[0].Rows[i][15].ToString(), Convert.ToInt32(dataSet.Tables[0].Rows[i][17]), Convert.ToInt32(dataSet.Tables[0].Rows[i][18]),dataSet.Tables[0].Rows[i][16].ToString()); //创建bookItem对象(book对象,book的数量) BookItem bookItem = new BookItem(aBook, Convert.ToInt32(dataSet.Tables[0].Rows[i][8])); //图书来自不同的订单 if (!isFromSameOrder(preOrderId, curOrderId)) { order = new Order();//新建订单,初始化bookItemList //不同的订单需要设置 OrerId/userName/orderPrice/isValid/oderDate/shippingAddress //相同订单的信息已经设置过了,不需要重新设置 order.SetOrderInformation(dataSet.Tables[0].Rows[i][0].ToString(), dataSet.Tables[0].Rows[i][1].ToString(), Convert.ToDecimal(dataSet.Tables[0].Rows[i][4]), Convert.ToInt32(dataSet.Tables[0].Rows[i][5]), dataSet.Tables[0].Rows[i][6].ToString(), shippingAddress); } else { order = orderList[orderList.Count-1];//获取到订单列表的最后一个订单 orderList.RemoveAt(orderList.Count-1);//删除这个订单信息 } order.bookItemList.Add(bookItem);//将bookItem添加到bookItemList中 orderList.Add(order);//将order添加到orderList中 //设置订单的OrderID/UserName/价格/状态/OrderDate/ShippingAddres preOrderId = curOrderId;//处理完一个订单后,将curOrderId赋值给preOrderId } } sql.Close();//关闭sql连接 return orderList; }
/// <summary> /// 构造方法 /// </summary> /// <param name="username"></param> /// <param name="shippingaddress"></param> /// <param name="remark"></param> /// <param name="price"></param> /// <param name="orderdate"></param> /// <param name="bookitemlist"></param> public Order(string username, ShippingAddress shippingaddress, DateTime orderdate, List<BookItem> bookitemlist) { orderid = CreateOrderID(username);//订单号 this.username = username;//用户名 this.shippingaddress = shippingaddress;//收货地址 price = ComputeOrderPrice(bookitemlist);//图书价格 this.orderdate = orderdate.Year+"-"+orderdate.Month+"-"+orderdate.Day;//订单时间 this.bookitemlist = bookitemlist;//订单图书 isvalid = 0;//订单状态 }
/* * Add app-provided shipping address to payment */ private void addAppProvidedShippingAddress(PayPalPayment paypalPayment) { ShippingAddress shippingAddress = new ShippingAddress ().RecipientName ("Mom Parker").Line1 ("52 North Main St.") .City ("Austin").State ("TX").PostalCode ("78729").CountryCode ("US"); paypalPayment.InvokeProvidedShippingAddress (shippingAddress); }
public ShippingResponse getShipping() { Settings settings = new Settings(); FedExAuthentication auth = new FedExAuthentication { AccountNumber = Convert.ToInt32(settings.Get("FedExAccount")), Key = settings.Get("FedExKey"), Password = settings.Get("FedExPassword"), CustomerTransactionId = "", MeterNumber = Convert.ToInt32(settings.Get("FedExMeter")) }; ShippingAddress destination = new ShippingAddress(); destination = this.Shipping.getShipping(); DistributionCenter d = new DistributionCenter().GetNearest(this.Shipping.GeoLocate()); ShippingAddress origin = d.getAddress().getShipping(); List<int> parts = new List<int>(); foreach (CartItem item in this.CartItems) { for (int i = 1; i <= item.quantity; i++) { parts.Add(item.partID); } } ShippingResponse response = CURTAPI.GetShipping(auth, origin, destination, parts); return response; }