protected override void BuildPostForm(Order order, IndividualOrderCollection indOrders, decimal price, decimal shipping, Customer customer) { var remotePostHelper = new RemotePost { FormName = "AssistForm", Url = GetPaymentServiceUrl() }; remotePostHelper.Add("Merchant_ID", "706403"); remotePostHelper.Add("OrderNumber", order.OrderID.ToString()); remotePostHelper.Add("OrderAmount", Math.Round(price + shipping).ToString()); remotePostHelper.Add("OrderCurrency", ConvertToUsd ? "USD" : CurrencyId); remotePostHelper.Add("TestMode", IsTestMode? "1": "0"); if (!String.IsNullOrEmpty(customer.BillingAddress.LastName)) { remotePostHelper.Add("Lastname", customer.BillingAddress.LastName); } if (!String.IsNullOrEmpty(customer.BillingAddress.FirstName)) { remotePostHelper.Add("Firstname", customer.BillingAddress.FirstName); } if (!String.IsNullOrEmpty(customer.BillingAddress.Email)) { remotePostHelper.Add("Email", customer.BillingAddress.Email); } remotePostHelper.Add("URL_RETURN_OK", SettingManager.GetSettingValue("PaymentMethod.Assist.OkUrl")); remotePostHelper.Add("URL_RETURN_NO", SettingManager.GetSettingValue("PaymentMethod.Assist.NoUrl")); remotePostHelper.Post(); }
protected override void BuildPostForm(Order order, IndividualOrderCollection indOrders, decimal price, decimal shipping, Customer customer) { var remotePostHelper = new RemotePost { FormName = "AssistForm", Url = GetPaymentServiceUrl() }; remotePostHelper.Add("Merchant_ID", "706403"); remotePostHelper.Add("OrderNumber", order.OrderID.ToString()); remotePostHelper.Add("OrderAmount", Math.Round(price + shipping).ToString()); remotePostHelper.Add("OrderCurrency", ConvertToUsd ? "USD" : CurrencyId); remotePostHelper.Add("TestMode", IsTestMode? "1": "0"); if (!String.IsNullOrEmpty(customer.BillingAddress.LastName)) { remotePostHelper.Add("Lastname", customer.BillingAddress.LastName); } if (!String.IsNullOrEmpty(customer.BillingAddress.FirstName)) { remotePostHelper.Add("Firstname", customer.BillingAddress.FirstName); } if (!String.IsNullOrEmpty(customer.BillingAddress.Email)) { remotePostHelper.Add("Email", customer.BillingAddress.Email); } remotePostHelper.Add("URL_RETURN_OK", SettingManager.GetSettingValue("PaymentMethod.Assist.OkUrl")); remotePostHelper.Add("URL_RETURN_NO", SettingManager.GetSettingValue("PaymentMethod.Assist.NoUrl")); remotePostHelper.Post(); }
public static IndividualOrderCollection GetIndividualOrderByCurrentUserSessionGuid(Guid userGuid) { DBIndividualOrderCollection dbCollection = DBProviderManager <DBIndividualOrderProvider> .Provider.IndividualOrderGetByCustomerSessionGUID(userGuid); IndividualOrderCollection indivCollection = DBMapping(dbCollection); return(indivCollection); }
private decimal CalculatePriceWithFee(Order order, IndividualOrderCollection indOrders, out object shippingPrice) { var prodVars = order.OrderProductVariants.Select(opv => ProductManager.GetProductVariantByID(opv.ProductVariantID)).ToList(); decimal totalWithFee = CalculateTotalOrderServiceFee(order.OrderProductVariants, prodVars, order, out shippingPrice); ShippingPrice = (decimal)shippingPrice; totalWithFee += AddServiceFee(IndividualOrderManager.GetTotalPriceIndOrders(indOrders), ConvertToUsd); return(totalWithFee); }
public static decimal GetTotalPriceIndOrders(IndividualOrderCollection indOrderCollection) { decimal price = 0; foreach (var order in indOrderCollection) { price += order.Price; } return(price); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (!shoppingCartRequiresShipping) { NopContext.Current.User.LastShippingOption = null; Response.Redirect("~/CheckoutPaymentMethod.aspx"); } if (!Page.IsPostBack) { if (shoppingCartRequiresShipping) { //ShipmentPackage shipmentPackage = ShippingManager.CreateShipmentPackage(Cart, NopContext.Current.User.ShippingAddress); string error = string.Empty; ShippingOptionCollection shippingOptions = ShippingManager.GetShippingOptions(Cart, NopContext.Current.User, NopContext.Current.User.ShippingAddress, ref error); if (!String.IsNullOrEmpty(error)) { LogManager.InsertLog(LogTypeEnum.ShippingErrror, error, error); lError.Text = Server.HtmlEncode(error); } else { if (shippingOptions.Count > 0) { dlShippingOptions.DataSource = shippingOptions; dlShippingOptions.DataBind(); } else { phSelectShippingMethod.Visible = false; phShippingIsNotAllowed.Visible = true; } } } } }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) { CommonHelper.EnsureSSL(); } Response.CacheControl = "private"; Response.Expires = 0; Response.AddHeader("pragma", "no-cache"); ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (NopContext.Current.User == null && CustomerManager.AnonymousCheckoutAllowed) { //create anonymous record string email = "*****@*****.**"; string password = string.Empty; MembershipCreateStatus status = MembershipCreateStatus.UserRejected; Customer guestCustomer = CustomerManager.AddCustomer(email, email, password, false, true, true, out status); if (guestCustomer != null && status == MembershipCreateStatus.Success) { NopContext.Current.User = guestCustomer; if (NopContext.Current.Session == null) { NopContext.Current.Session = NopContext.Current.GetSession(true); } NopContext.Current.Session = CustomerManager.SaveCustomerSession(NopContext.Current.Session.CustomerSessionGUID, guestCustomer.CustomerID, DateTime.Now, NopContext.Current.Session.IsExpired); } } if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } string title = GetLocaleResourceString("PageTitle.Checkout"); SEOHelper.RenderTitle(this, title, true); Response.Redirect("~/CheckoutBillingAddress.aspx"); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } }
private static IndividualOrderCollection DBMapping(DBIndividualOrderCollection dbCollection) { if (dbCollection == null) { return(null); } IndividualOrderCollection collection = new IndividualOrderCollection(); foreach (DBIndividualOrder dbItem in dbCollection) { IndividualOrder item = DBMapping(dbItem); collection.Add(item); } return(collection); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } btnNextStep.Attributes.Add("onclick", "this.disabled = true;" + Page.ClientScript.GetPostBackEventReference(this.btnNextStep, "")); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { CustomerManager.ResetCheckoutData(NopContext.Current.User.CustomerID, false); } bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (!shoppingCartRequiresShipping) { SelectAddress(null); Response.Redirect("~/CheckoutBillingAddress.aspx"); } if (!Page.IsPostBack) { AddressCollection addresses = getAllowedShippingAddresses(NopContext.Current.User); if (addresses.Count > 0) { dlAddress.DataSource = addresses; dlAddress.DataBind(); lEnterShippingAddress.Text = GetLocaleResourceString("Checkout.OrEnterNewAddress"); } else { pnlSelectShippingAddress.Visible = false; lEnterShippingAddress.Text = GetLocaleResourceString("Checkout.EnterShippingAddress"); } } }
private static void StartPaymentMethod(IndividualOrderCollection indOrders, Order order) { PaymentMethod pm = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (pm.ClassName.Equals("Nop.Payment.WebPay.WebPayPaymentProcessor, Nop.Payment.WebPay")) { var webPayMethod = new Nop.Payment.WebPay.WebPayPaymentProcessor(); webPayMethod.PostProcessPayment(order, indOrders); } else if (pm.ClassName.Equals("Nop.Payment.Assist.AssistPaymentProcessor, Nop.Payment.Assist")) { var assistPaymentProcessor = new Nop.Payment.Assist.AssistPaymentProcessor(); assistPaymentProcessor.PostProcessPayment(order, indOrders, NopContext.Current.User); } else { PaymentManager.PostProcessPayment(order); } }
public string PostProcessPayment(Order order, IndividualOrderCollection indOrders, Customer customer) { object shippingPrice; decimal totalWithFee = CalculatePriceWithFee(order, indOrders, out shippingPrice); OrderManager.UpdateOrder(order.OrderID, order.OrderGUID, order.CustomerID, order.CustomerLanguageID, order.CustomerTaxDisplayType, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax, order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax, order.OrderTax, order.OrderTotal, order.OrderDiscount, order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, order.OrderTaxInCustomerCurrency, order.OrderTotalInCustomerCurrency, order.CustomerCurrencyCode, order.OrderWeight, order.AffiliateID, order.OrderStatus, order.AllowStoringCreditCardNumber, order.CardType, order.CardName, order.CardNumber, order.MaskedCreditCardNumber, order.CardCVV2, order.CardExpirationMonth, order.CardExpirationYear, order.PaymentMethodID, order.PaymentMethodName, order.AuthorizationTransactionID, order.AuthorizationTransactionCode, order.AuthorizationTransactionResult, order.CaptureTransactionID, order.CaptureTransactionResult, order.PurchaseOrderNumber, order.PaymentStatus, order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber, order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1, order.BillingAddress2, order.BillingCity, order.BillingStateProvince, order.BillingStateProvinceID, order.BillingZipPostalCode, order.BillingCountry, order.BillingCountryID, order.ShippingStatus, order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber, order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany, order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity, order.ShippingStateProvince, order.ShippingStateProvinceID, order.ShippingZipPostalCode, order.ShippingCountry, order.ShippingCountryID, order.ShippingMethod, order.ShippingRateComputationMethodID, order.ShippedDate, order.Deleted, order.CreatedOn); BuildPostForm(order, indOrders, totalWithFee, (decimal)shippingPrice, customer); return(string.Empty); }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { Address shippingAddress = NopContext.Current.User.ShippingAddress; pnlTheSameAsShippingAddress.Visible = CustomerManager.CanUseAddressAsBillingAddress(shippingAddress); AddressCollection addresses = getAllowedBillingAddresses(NopContext.Current.User); if (addresses.Count > 0) { //bind data //if (addresses.Count > 1) // addresses.RemoveRange(1, addresses.Count - 1); dlAddress.DataSource = addresses; dlAddress.DataBind(); lEnterBillingAddress.Text = GetLocaleResourceString("Checkout.OrEnterNewAddress"); } else { pnlSelectBillingAddress.Visible = false; lEnterBillingAddress.Text = GetLocaleResourceString("Checkout.EnterBillingAddress"); } } }
protected string GetShoppingCartSum() { ShoppingCart cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); bool isUsd = Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD"; decimal indOrderTotal = 0; IndividualOrderCollection indOrders = new IndividualOrderCollection(); if (NopContext.Current.Session != null) { Guid customerSessionGuid = NopContext.Current.Session.CustomerSessionGUID; indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(customerSessionGuid); indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (isUsd) { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } } if (cart.Count > 0 || indOrders.Count > 0) { //subtotal string subTotalError = string.Empty; decimal shoppingCartSubTotalDiscountBase; decimal shoppingCartSubTotalBase = ShoppingCartManager.GetShoppingCartSubTotal(cart, NopContext.Current.User, out shoppingCartSubTotalDiscountBase, ref subTotalError); if (String.IsNullOrEmpty(subTotalError)) { decimal shoppingCartSubTotal = CurrencyManager.ConvertCurrency(shoppingCartSubTotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shoppingCartSubTotal += indOrderTotal; return(AddCurrency(PriceHelper.FormatPrice(shoppingCartSubTotal), isUsd)); } } return(AddCurrency("0", isUsd)); }
public void BindData() { ShoppingCart Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { pnlEmptyCart.Visible = true; pnlCart.Visible = false; } else { pnlEmptyCart.Visible = false; pnlCart.Visible = true; phCoupon.Visible = DiscountManager.HasDiscountsWithCouponCode(); rptShoppingCart.DataSource = Cart; rptShoppingCart.DataBind(); ValidateCart(); } this.ctrlOrderTotals.BindData(); }
public string PostProcessPayment(Order order, IndividualOrderCollection indOrders) { bool convertToUsd = HttpContext.Current.Request.Cookies["Currency"] != null && HttpContext.Current.Request.Cookies["Currency"].Value == "USD"; shippingRate = SettingManager.GetSettingValueDecimalNative("ShippingRateComputationMethod.FixedRate.Rate"); freeShippingBorder = SettingManager.GetSettingValueDecimalNative("Shipping.FreeShippingOverX.Value"); if (convertToUsd) { freeShippingBorder = Math.Round(PriceConverter.ToUsd(freeShippingBorder)); } var prodVars = new List <ProductVariant>(); foreach (var opv in order.OrderProductVariants) { prodVars.Add(ProductManager.GetProductVariantByID(opv.ProductVariantID)); } decimal totalWithFee = (int)CalculateTotalServiceFee(order.OrderProductVariants, prodVars, order, convertToUsd, out shippingPrice); totalWithFee += AddServiceFee(IndividualOrderManager.GetTotalPriceIndOrders(indOrders), convertToUsd); var remotePostHelper = new RemotePost { FormName = "WebPeyForm", Url = GetWebPayUrl() }; OrderManager.UpdateOrder(order.OrderID, order.OrderGUID, order.CustomerID, order.CustomerLanguageID, order.CustomerTaxDisplayType, order.OrderSubtotalInclTax, order.OrderSubtotalExclTax, order.OrderShippingInclTax, order.OrderShippingExclTax, order.PaymentMethodAdditionalFeeInclTax, order.PaymentMethodAdditionalFeeExclTax, order.OrderTax, order.OrderTotal, order.OrderDiscount, order.OrderSubtotalInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.OrderShippingInclTaxInCustomerCurrency, order.OrderShippingExclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeInclTaxInCustomerCurrency, order.PaymentMethodAdditionalFeeExclTaxInCustomerCurrency, order.OrderTaxInCustomerCurrency, order.OrderTotalInCustomerCurrency, order.CustomerCurrencyCode, order.OrderWeight, order.AffiliateID, order.OrderStatus, order.AllowStoringCreditCardNumber, order.CardType, order.CardName, order.CardNumber, order.MaskedCreditCardNumber, order.CardCVV2, order.CardExpirationMonth, order.CardExpirationYear, order.PaymentMethodID, order.PaymentMethodName, order.AuthorizationTransactionID, order.AuthorizationTransactionCode, order.AuthorizationTransactionResult, order.CaptureTransactionID, order.CaptureTransactionResult, order.PurchaseOrderNumber, order.PaymentStatus, order.BillingFirstName, order.BillingLastName, order.BillingPhoneNumber, order.BillingEmail, order.BillingFaxNumber, order.BillingCompany, order.BillingAddress1, order.BillingAddress2, order.BillingCity, order.BillingStateProvince, order.BillingStateProvinceID, order.BillingZipPostalCode, order.BillingCountry, order.BillingCountryID, order.ShippingStatus, order.ShippingFirstName, order.ShippingLastName, order.ShippingPhoneNumber, order.ShippingEmail, order.ShippingFaxNumber, order.ShippingCompany, order.ShippingAddress1, order.ShippingAddress2, order.ShippingCity, order.ShippingStateProvince, order.ShippingStateProvinceID, order.ShippingZipPostalCode, order.ShippingCountry, order.ShippingCountryID, order.ShippingMethod, order.ShippingRateComputationMethodID, order.ShippedDate, order.Deleted, order.CreatedOn); remotePostHelper.Add("*scart", ""); remotePostHelper.Add("wsb_storeid", StoreId); remotePostHelper.Add("wsb_store", "voobrazi.by"); remotePostHelper.Add("wsb_order_num", order.OrderID.ToString()); remotePostHelper.Add("wsb_currency_id", convertToUsd ? "USD" : CurrencyId); remotePostHelper.Add("wsb_version", "2"); remotePostHelper.Add("wsb_language_id", "russian"); string seed = ((int)(DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0)).TotalSeconds).ToString(); remotePostHelper.Add("wsb_seed", seed); var signatureBulder = new StringBuilder(seed); signatureBulder.Append(StoreId); signatureBulder.Append(order.OrderID); signatureBulder.Append(UseSandBox ? "1" : "0"); signatureBulder.Append(convertToUsd ? "USD" : CurrencyId); signatureBulder.Append(totalWithFee.ToString()); signatureBulder.Append(Sk); byte[] buffer = Encoding.Default.GetBytes(signatureBulder.ToString()); var sha1 = new SHA1CryptoServiceProvider(); string signature = BitConverter.ToString(sha1.ComputeHash(buffer)).Replace("-", "").ToLower(); remotePostHelper.Add("wsb_signature", signature); remotePostHelper.Add("wsb_return_url", string.Format(SettingManager.GetSettingValue("PaymentMethod.WebPay.ReturnUrl"), order.OrderID)); remotePostHelper.Add("wsb_cancel_return_url", string.Format(SettingManager.GetSettingValue("PaymentMethod.WebPay.CancelUrl"), order.OrderID)); remotePostHelper.Add("wsb_notify_url", string.Format(SettingManager.GetSettingValue("PaymentMethod.WebPay.NotifyUrl"), order.OrderID)); remotePostHelper.Add("wsb_test", UseSandBox ? "1" : "0"); for (int i = 0; i < order.OrderProductVariants.Count; i++) { var opv = order.OrderProductVariants[i]; remotePostHelper.Add(string.Format("wsb_invoice_item_name[{0}]", i), opv.ProductVariant.Product.Name); remotePostHelper.Add(string.Format("wsb_invoice_item_quantity[{0}]", i), opv.Quantity.ToString()); var prodVar = ProductManager.GetProductVariantByID(opv.ProductVariantID); decimal prodPrice = !convertToUsd ? prodVar.Price : Math.Round(PriceConverter.ToUsd(prodVar.Price)); remotePostHelper.Add(string.Format("wsb_invoice_item_price[{0}]", i), AddServiceFee(prodPrice, convertToUsd).ToString()); } int cartCount = order.OrderProductVariants.Count; for (int i = order.OrderProductVariants.Count; i < indOrders.Count + cartCount; i++) { var opv = indOrders[i - cartCount]; remotePostHelper.Add(string.Format("wsb_invoice_item_name[{0}]", i), "Индивидуальный заказ"); remotePostHelper.Add(string.Format("wsb_invoice_item_quantity[{0}]", i), "1"); decimal prodPrice = !convertToUsd ? opv.Price : Math.Round(PriceConverter.ToUsd(opv.Price)); remotePostHelper.Add(string.Format("wsb_invoice_item_price[{0}]", i), AddServiceFee(prodPrice, convertToUsd).ToString()); } remotePostHelper.Add("wsb_tax", "0"); remotePostHelper.Add("wsb_shipping_name", "Доставка курьером"); remotePostHelper.Add("wsb_shipping_price", AddServiceFee(shippingPrice, convertToUsd).ToString()); remotePostHelper.Add("wsb_total", totalWithFee.ToString()); if (!string.IsNullOrEmpty(order.ShippingEmail)) { remotePostHelper.Add("wsb_email", order.ShippingEmail); } remotePostHelper.Add("wsb_phone", order.ShippingPhoneNumber); remotePostHelper.Post(); return(string.Empty); }
private static void StartPaymentMethod(IndividualOrderCollection indOrders, Order order) { PaymentMethod pm = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (pm.ClassName.Equals("Nop.Payment.WebPay.WebPayPaymentProcessor, Nop.Payment.WebPay")) { var webPayMethod = new Nop.Payment.WebPay.WebPayPaymentProcessor(); webPayMethod.PostProcessPayment(order, indOrders); } else if (pm.ClassName.Equals("Nop.Payment.Assist.AssistPaymentProcessor, Nop.Payment.Assist")) { var assistPaymentProcessor = new Nop.Payment.Assist.AssistPaymentProcessor(); assistPaymentProcessor.PostProcessPayment(order, indOrders, NopContext.Current.User); } else { PaymentManager.PostProcessPayment(order); } }
protected void Page_Load(object sender, EventArgs e) { if ((NopContext.Current.User == null) || (NopContext.Current.User.IsGuest && !CustomerManager.AnonymousCheckoutAllowed)) { string loginURL = CommonHelper.GetLoginPageURL(true); Response.Redirect(loginURL); } Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); IndividualOrderCollection indOrders = IndividualOrderManager.GetCurrentUserIndividualOrders(); if (Cart.Count == 0 && indOrders.Count == 0) { Response.Redirect("~/ShoppingCart.aspx"); } if (!Page.IsPostBack) { PaymentMethodCollection paymentMethods = PaymentMethodManager.GetAllPaymentMethods(); PaymentMethod paypalExpressPaymentMethod = null; foreach (PaymentMethod pm in paymentMethods) { if (pm.SystemKeyword == "PayPalExpress") { paypalExpressPaymentMethod = pm; } } PaymentMethod googleCheckoutPaymentMethod = null; foreach (PaymentMethod pm in paymentMethods) { if (pm.SystemKeyword == "GoogleCheckout") { googleCheckoutPaymentMethod = pm; } } bool hasButtonMethods = false; if (paypalExpressPaymentMethod != null && paypalExpressPaymentMethod.IsActive) { hasButtonMethods = true; } PaymentMethodCollection boundPaymentMethods = new PaymentMethodCollection(); foreach (PaymentMethod pm in paymentMethods) { if (pm != paypalExpressPaymentMethod && pm != googleCheckoutPaymentMethod) { boundPaymentMethods.Add(pm); } } if (boundPaymentMethods.Count == 0) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = false; } else { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = true; } } else if (boundPaymentMethods.Count == 1) { if (hasButtonMethods) { phSelectPaymentMethod.Visible = true; phNoPaymentMethods.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } else { phSelectPaymentMethod.Visible = false; phNoPaymentMethods.Visible = false; NopContext.Current.User = CustomerManager.SetLastPaymentMethodID(NopContext.Current.User.CustomerID, paymentMethods[0].PaymentMethodID); Response.Redirect("~/CheckoutConfirm.aspx"); } } else { phSelectPaymentMethod.Visible = true; phNoPaymentMethods.Visible = false; dlPaymentMethod.DataSource = boundPaymentMethods; dlPaymentMethod.DataBind(); } } divAdditionalPaymentInfo.Visible = Request["OrderId"] != null; }
protected abstract void BuildPostForm(Order order, IndividualOrderCollection indOrders, decimal price, decimal shipping, Customer customer);
protected void btnNextStep_Click(object sender, EventArgs e) { if (Page.IsValid) { try { PaymentInfo paymentInfo = this.PaymentInfo; //if (paymentInfo == null) // Response.Redirect("~/CheckoutPaymentInfo.aspx"); paymentInfo.BillingAddress = NopContext.Current.User.BillingAddress; paymentInfo.ShippingAddress = NopContext.Current.User.ShippingAddress; paymentInfo.CustomerLanguage = NopContext.Current.WorkingLanguage; paymentInfo.CustomerCurrency = NopContext.Current.WorkingCurrency; int orderId = 0; string result = ""; if (Request["OrderId"] == null) { result = OrderManager.PlaceOrder(paymentInfo, NopContext.Current.User, out orderId); } else { orderId = int.Parse(Request["OrderId"]); } this.PaymentInfo = null; Order order = OrderManager.GetOrderByID(orderId); if (!String.IsNullOrEmpty(result)) { lError.Text = Server.HtmlEncode(result); return; } if (Request["OrderId"] != null) { order.PaymentMethodID = paymentInfo.PaymentMethodID; order.PaymentMethodName = PaymentMethodManager.GetPaymentMethodByID(paymentInfo.PaymentMethodID).Name; } Guid customerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; IndividualOrderCollection indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(customerSessionGUID); string subj = "Заказ в магазине Voobrazi.by"; StringBuilder body = new StringBuilder(); body.AppendFormat("Доставка: {0}<br /><br />", ((bool)Session["Delivery"]) ? "Курьером" : "Самовывоз").AppendLine(); body.AppendFormat("<b>Заказчик</b><br />").AppendLine(); body.AppendFormat("ФИО: {0} {1}<br />", paymentInfo.BillingAddress.FirstName, paymentInfo.BillingAddress.LastName).AppendLine(); body.AppendFormat("Телефоны: {0} {1}<br />", paymentInfo.BillingAddress.PhoneNumber, !string.IsNullOrEmpty(paymentInfo.BillingAddress.FaxNumber) ? ", " + paymentInfo.BillingAddress.FaxNumber : "").AppendLine(); body.AppendFormat("Адрес: {0} {1}<br />", paymentInfo.BillingAddress.City, paymentInfo.BillingAddress.Address1).AppendLine(); body.AppendFormat("Email: {0}<br /><br />", !string.IsNullOrEmpty(NopContext.Current.User.BillingAddress.Email) ? NopContext.Current.User.BillingAddress.Email : NopContext.Current.User.Email).AppendLine(); body.AppendFormat("Комментарии: {0}<br /><br />", tbComments.Text).AppendLine(); PaymentMethod pm = PaymentMethodManager.GetPaymentMethodByID(order.PaymentMethodID); if (pm != null) { body.AppendFormat("Способ оплаты: {0}<br /><br />", pm.Name).AppendLine(); } decimal total = 0; decimal indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } total += indOrderTotal; body.AppendFormat("Индивидуальные заказы:<br />"); foreach (var indOrder in indOrders) { body.Append(indOrder.OrderText + "<br />"); } if (Session["fn"] != null) { body.AppendLine(); body.Append("<b>Получатель не заказчик</b><br />").AppendLine(); body.AppendFormat("ФИО: {0} {1}<br />", Session["fn"], Session["ln"]).AppendLine(); body.AppendFormat("Телефон: {0}<br />", Session["pn"]).AppendLine(); body.AppendFormat("Адрес: {0}<br />", Session["address"]).AppendLine(); body.AppendFormat("Дополнительная информация: {0}<br />", Session["ai"]).AppendLine(); } body.AppendFormat("Уведомление о доставке: {0} | {1}<br />", chbByMail.Checked ? "Письмом на Email" : "", chbSMS.Checked ? "СМС сообщение" : "").AppendLine(); body.AppendFormat("<br /><br /> Заказано:<br />"); foreach (OrderProductVariant variant in order.OrderProductVariants) { body.AppendFormat(" - {0} ({1}) x {2}шт. -- {3}; <br />", variant.ProductVariant.Product.Name, PriceHelper.FormatShippingPrice(variant.ProductVariant.Price, true), variant.Quantity, PriceHelper.FormatShippingPrice(variant.ProductVariant.Price * variant.Quantity, true)); total += variant.ProductVariant.Price * variant.Quantity; } string shipping = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart) && Session["SelfOrder"] == null; if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(Cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shipping = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); total += shoppingCartShipping; } } body.AppendFormat("Доставка: {0}<br />", shipping).AppendLine(); body.AppendFormat("<b>Итого:</b> {0}<br />", total).AppendLine(); body.AppendFormat("<br />Дополнительная информация: {0}<br />", Session["ai"]).AppendLine(); MessageManager.SendEmail(subj, body.ToString(), MessageManager.AdminEmailAddress, MessageManager.AdminEmailAddress); StartPaymentMethod(indOrders, order); Session.Remove("SelfOrder"); Response.Redirect("~/CheckoutCompleted.aspx"); } catch (Exception exc) { Session.Remove("SelfOrder"); LogManager.InsertLog(LogTypeEnum.OrderError, exc.Message, exc); lError.Text = Server.HtmlEncode("Во время обработки заказа произошла ошибка. Для выполнения заказа, пожалуйста, свяжитесь с администратором. Контактную информацию можно найти на странице Контакты."); } } }
public void BindData() { ShoppingCart Cart = ShoppingCartManager.GetCurrentShoppingCart(ShoppingCartTypeEnum.ShoppingCart); decimal indOrderTotal = 0; IndividualOrderCollection indOrders = new IndividualOrderCollection(); if (NopContext.Current.Session != null) { Guid CustomerSessionGUID = NopContext.Current.Session.CustomerSessionGUID; indOrders = IndividualOrderManager.GetIndividualOrderByCurrentUserSessionGuid(CustomerSessionGUID); indOrderTotal = IndividualOrderManager.GetTotalPriceIndOrders(indOrders); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { indOrderTotal = Math.Round(PriceConverter.ToUsd(indOrderTotal)); } } if (Cart.Count > 0 || indOrders.Count > 0) { //payment method (if already selected) int paymentMethodID = 0; if (NopContext.Current.User != null) { paymentMethodID = NopContext.Current.User.LastPaymentMethodID; } //subtotal string SubTotalError = string.Empty; decimal shoppingCartSubTotalDiscountBase; decimal shoppingCartSubTotalBase = ShoppingCartManager.GetShoppingCartSubTotal(Cart, NopContext.Current.User, out shoppingCartSubTotalDiscountBase, ref SubTotalError); if (String.IsNullOrEmpty(SubTotalError)) { decimal shoppingCartSubTotal = CurrencyManager.ConvertCurrency(shoppingCartSubTotalBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); shoppingCartSubTotal += indOrderTotal; lblSubTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartSubTotal); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblSubTotalAmount.Text += "$"; } lblSubTotalAmount.CssClass = "productPrice"; if (shoppingCartSubTotalDiscountBase > decimal.Zero) { decimal shoppingCartSubTotalDiscount = CurrencyManager.ConvertCurrency(shoppingCartSubTotalDiscountBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblSubTotalDiscountAmount.Text = PriceHelper.FormatPrice(shoppingCartSubTotalDiscount, true, false); phSubTotalDiscount.Visible = true; } else { phSubTotalDiscount.Visible = false; } } else { lblSubTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblSubTotalAmount.CssClass = string.Empty; } //shipping info bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart) && Session["SelfOrder"] == null; if (shoppingCartRequiresShipping) { decimal?shoppingCartShippingBase = ShippingManager.GetShoppingCartShippingTotal(Cart, NopContext.Current.User); if (shoppingCartShippingBase.HasValue) { decimal shoppingCartShipping = CurrencyManager.ConvertCurrency(shoppingCartShippingBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblShippingAmount.Text = PriceHelper.FormatShippingPrice(shoppingCartShipping, true); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblShippingAmount.Text += "$"; } lblShippingAmount.CssClass = "productPrice"; } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblShippingAmount.CssClass = string.Empty; } } else { lblShippingAmount.Text = GetLocaleResourceString("ShoppingCart.ShippingNotRequired"); lblShippingAmount.CssClass = string.Empty; } //payment method fee bool displayPaymentMethodFee = true; decimal paymentMethodAdditionalFee = PaymentManager.GetAdditionalHandlingFee(paymentMethodID); decimal paymentMethodAdditionalFeeWithTaxBase = TaxManager.GetPaymentMethodAdditionalFee(paymentMethodAdditionalFee, NopContext.Current.User); if (paymentMethodAdditionalFeeWithTaxBase > decimal.Zero) { decimal paymentMethodAdditionalFeeWithTax = CurrencyManager.ConvertCurrency(paymentMethodAdditionalFeeWithTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); lblPaymentMethodAdditionalFee.Text = PriceHelper.FormatPaymentMethodAdditionalFee(paymentMethodAdditionalFeeWithTax, true); } else { displayPaymentMethodFee = false; } phPaymentMethodAdditionalFee.Visible = displayPaymentMethodFee; //tax bool displayTax = true; if (TaxManager.HideTaxInOrderSummary && NopContext.Current.TaxDisplayType == TaxDisplayTypeEnum.IncludingTax) { displayTax = false; } else { string TaxError = string.Empty; decimal shoppingCartTaxBase = TaxManager.GetTaxTotal(Cart, paymentMethodID, NopContext.Current.User, ref TaxError); decimal shoppingCartTax = CurrencyManager.ConvertCurrency(shoppingCartTaxBase, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); //if (String.IsNullOrEmpty(TaxError)) //{ // if (shoppingCartTaxBase == 0 && TaxManager.HideZeroTax) // { // displayTax = false; // } // else // { // lblTaxAmount.Text = PriceHelper.FormatPrice(shoppingCartTax, true, false); // lblTaxAmount.CssClass = "productPrice"; // } //} //else //{ // lblTaxAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); // lblTaxAmount.CssClass = string.Empty; //} } phTaxTotal.Visible = false;// displayTax; //total decimal?shoppingCartTotalBase = ShoppingCartManager.GetShoppingCartTotal(Cart, paymentMethodID, NopContext.Current.User); if (shoppingCartTotalBase.HasValue) { decimal shoppingCartTotal = CurrencyManager.ConvertCurrency(shoppingCartTotalBase.Value, CurrencyManager.PrimaryStoreCurrency, NopContext.Current.WorkingCurrency); if (Session["SelfOrder"] != null) { shoppingCartTotal -= ShippingManager.GetShoppingCartShippingTotal(Cart).Value; } shoppingCartTotal += indOrderTotal; lblTotalAmount.Text = PriceHelper.FormatPrice(shoppingCartTotal); if (Request.Cookies["Currency"] != null && Request.Cookies["Currency"].Value == "USD") { lblTotalAmount.Text += "$"; } lblTotalAmount.CssClass = "productPrice"; } else { lblTotalAmount.Text = GetLocaleResourceString("ShoppingCart.CalculatedDuringCheckout"); lblTotalAmount.CssClass = string.Empty; } } else { this.Visible = false; } }