private void BindData() { StateProvince stateProvince = StateProvinceManager.GetStateProvinceById(this.StateProvinceId); if (stateProvince != null) { CommonHelper.SelectListItem(this.ddlCountry, stateProvince.CountryId); this.txtName.Text = stateProvince.Name; this.txtAbbreviation.Text = stateProvince.Abbreviation; this.txtDisplayOrder.Value = stateProvince.DisplayOrder; } }
protected void DeleteButton_Click(object sender, EventArgs e) { try { StateProvinceManager.DeleteStateProvince(this.StateProvinceId); Response.Redirect("StateProvinces.aspx"); } catch (Exception exc) { ProcessException(exc); } }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { StringBuilder builder = new StringBuilder(); string returnURL = CommonHelper.GetStoreLocation(false) + "PaypalPDTHandler.aspx"; string cancel_returnURL = CommonHelper.GetStoreLocation(false) + "PaypalCancel.aspx"; builder.Append(GetPaypalUrl()); builder.AppendFormat("?cmd=_xclick&business={0}", HttpUtility.UrlEncode(businessEmail)); builder.AppendFormat("&item_name=Order Number {0}", order.OrderId); builder.AppendFormat("&custom={0}", order.OrderGuid); builder.AppendFormat("&amount={0}", order.OrderTotal.ToString("N", new CultureInfo("en-us"))); builder.Append(string.Format("&no_note=1¤cy_code={0}", HttpUtility.UrlEncode(CurrencyManager.PrimaryStoreCurrency.CurrencyCode))); builder.AppendFormat("&invoice={0}", order.OrderId); builder.AppendFormat("&rm=2", new object[0]); if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { builder.AppendFormat("&no_shipping=2", new object[0]); } else { builder.AppendFormat("&no_shipping=1", new object[0]); } builder.AppendFormat("&return={0}&cancel_return={1}", HttpUtility.UrlEncode(returnURL), HttpUtility.UrlEncode(cancel_returnURL)); builder.AppendFormat("&first_name={0}", HttpUtility.UrlEncode(order.BillingFirstName)); builder.AppendFormat("&last_name={0}", HttpUtility.UrlEncode(order.BillingLastName)); builder.AppendFormat("&address1={0}", HttpUtility.UrlEncode(order.BillingAddress1)); builder.AppendFormat("&address2={0}", HttpUtility.UrlEncode(order.BillingAddress2)); builder.AppendFormat("&city={0}", HttpUtility.UrlEncode(order.BillingCity)); StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (billingStateProvince != null) { builder.AppendFormat("&state={0}", HttpUtility.UrlEncode(billingStateProvince.Abbreviation)); } else { builder.AppendFormat("&state={0}", HttpUtility.UrlEncode(order.BillingStateProvince)); } Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId); if (billingCountry != null) { builder.AppendFormat("&country={0}", HttpUtility.UrlEncode(billingCountry.TwoLetterIsoCode)); } else { builder.AppendFormat("&country={0}", HttpUtility.UrlEncode(order.BillingCountry)); } builder.AppendFormat("&Email={0}", HttpUtility.UrlEncode(order.BillingEmail)); HttpContext.Current.Response.Redirect(builder.ToString()); return(string.Empty); }
protected string GetStateProvinceInfo(int StateProvinceID) { StateProvince stateProvince = StateProvinceManager.GetStateProvinceByID(StateProvinceID); if (stateProvince != null) { return(stateProvince.Name); } else { return("*"); } }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { RemotePost remotePostHelper = new RemotePost(); remotePostHelper.FormName = "MoneybookersForm"; remotePostHelper.Url = GetMoneybookersUrl(); remotePostHelper.Add("pay_to_email", payToEmail); remotePostHelper.Add("recipient_description", SettingManager.StoreName); remotePostHelper.Add("transaction_id", order.OrderID.ToString()); remotePostHelper.Add("cancel_url", CommonHelper.GetStoreLocation(false) + "Default.aspx"); remotePostHelper.Add("status_url", CommonHelper.GetStoreLocation(false) + "MoneybookersReturn.aspx"); //supported moneybookers languages (EN, DE, ES, FR, IT, PL, GR, RO, RU, TR, CN, CZ or NL) //TODO Check if customer working language is supported by Moneybookers. remotePostHelper.Add("language", "EN"); remotePostHelper.Add("amount", order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat)); //TODO Primary store currency should be set to USD now (3-letter codes) remotePostHelper.Add("currency", CurrencyManager.PrimaryStoreCurrency.CurrencyCode); remotePostHelper.Add("detail1_description", "Order ID:"); remotePostHelper.Add("detail1_text", order.OrderID.ToString()); remotePostHelper.Add("firstname", order.BillingFirstName); remotePostHelper.Add("lastname", order.BillingLastName); remotePostHelper.Add("address", order.BillingAddress1); remotePostHelper.Add("phone_number", order.BillingPhoneNumber); remotePostHelper.Add("postal_code", order.BillingZipPostalCode); remotePostHelper.Add("city", order.BillingCity); StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceByID(order.BillingStateProvinceID); if (billingStateProvince != null) { remotePostHelper.Add("state", billingStateProvince.Abbreviation); } else { remotePostHelper.Add("state", order.BillingStateProvince); } Country billingCountry = CountryManager.GetCountryByID(order.BillingCountryID); if (billingCountry != null) { remotePostHelper.Add("country", billingCountry.ThreeLetterISOCode); } else { remotePostHelper.Add("country", order.BillingCountry); } remotePostHelper.Post(); return(string.Empty); }
protected void FillStateProvinceDropDowns() { this.ddlStateProvince.Items.Clear(); int countryID = int.Parse(this.ddlCountry.SelectedItem.Value); StateProvinceCollection stateProvinceCollection = StateProvinceManager.GetStateProvincesByCountryID(countryID); ListItem ddlStateProvinceItem = new ListItem("*", "0"); this.ddlStateProvince.Items.Add(ddlStateProvinceItem); foreach (StateProvince stateProvince in stateProvinceCollection) { ListItem ddlStateProviceItem2 = new ListItem(stateProvince.Name, stateProvince.StateProvinceID.ToString()); this.ddlStateProvince.Items.Add(ddlStateProviceItem2); } }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { RemotePost post = new RemotePost(); post.FormName = "AssistPaymentForm"; post.Url = HostedPaymentSettings.GatewayUrl; post.Method = "POST"; post.Add("Shop_IDP", HostedPaymentSettings.ShopId); post.Add("Order_IDP", order.OrderId.ToString()); post.Add("Subtotal_P", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", order.OrderTotal)); post.Add("Currency", CurrencyManager.PrimaryStoreCurrency.CurrencyCode); post.Add("Delay", HostedPaymentSettings.AuthorizeOnly ? "1" : "0"); post.Add("URL_RETURN", CommonHelper.GetStoreLocation(false)); post.Add("URL_RETURN_OK", String.Format("{0}AssistHostedPaymentReturn.aspx", CommonHelper.GetStoreLocation(false))); post.Add("FirstName", order.BillingFirstName); post.Add("LastName", order.BillingLastName); post.Add("Email", order.BillingEmail); post.Add("Address", order.BillingAddress1); post.Add("City", order.BillingCity); post.Add("Zip", order.BillingZipPostalCode); post.Add("Phone", order.BillingPhoneNumber); StateProvince state = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (state != null) { post.Add("State", state.Abbreviation); } Country country = CountryManager.GetCountryById(order.BillingCountryId); if (country != null) { post.Add("Country", country.ThreeLetterIsoCode); } if (HostedPaymentSettings.TestMode) { post.Add("DemoResult", "AS000"); } post.Post(); return(String.Empty); }
protected Address GetEnteredAddress() { Address address = new Address(); if (this.ddlCountry.SelectedItem == null) throw new NopException("Countries are not populated"); address.CountryId = int.Parse(this.ddlCountry.SelectedItem.Value); if (this.ddlStateProvince.SelectedItem == null) throw new NopException("State/Provinces are not populated"); var stateProvince = StateProvinceManager.GetStateProvinceById(int.Parse(this.ddlStateProvince.SelectedItem.Value)); if (stateProvince != null && stateProvince.CountryId == address.CountryId) address.StateProvinceId = stateProvince.StateProvinceId; address.ZipPostalCode = txtZipPostalCode.Text.Trim(); return address; }
public StateProvince SaveInfo() { StateProvince stateProvince = StateProvinceManager.GetStateProvinceById(this.StateProvinceId); if (stateProvince != null) { stateProvince = StateProvinceManager.UpdateStateProvince(stateProvince.StateProvinceId, int.Parse(this.ddlCountry.SelectedItem.Value), txtName.Text, txtAbbreviation.Text, txtDisplayOrder.Value); } else { stateProvince = StateProvinceManager.InsertStateProvince(int.Parse(this.ddlCountry.SelectedItem.Value), txtName.Text, txtAbbreviation.Text, txtDisplayOrder.Value); } return(stateProvince); }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { Uri gatewayUrl = new Uri(HostedPaymentSettings.GatewayUrl); RemotePost post = new RemotePost(); post.FormName = "ChronoPay"; post.Url = gatewayUrl.ToString(); post.Method = "POST"; post.Add("product_id", HostedPaymentSettings.ProductId); post.Add("product_name", HostedPaymentSettings.ProductName); post.Add("product_price", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", order.OrderTotal)); post.Add("product_price_currency", order.CustomerCurrencyCode); post.Add("cb_url", String.Format("{0}ChronoPayIPNHandler.aspx", CommonHelper.GetStoreLocation(false))); post.Add("cb_type", "P"); post.Add("cs1", order.OrderId.ToString()); post.Add("f_name", order.BillingFirstName); post.Add("s_name", order.BillingLastName); post.Add("street", order.BillingAddress1); post.Add("city", order.BillingCity); post.Add("zip", order.BillingZipPostalCode); post.Add("phone", order.BillingPhoneNumber); post.Add("email", order.BillingEmail); StateProvince state = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (state != null) { post.Add("state", state.Abbreviation); } Country country = CountryManager.GetCountryById(order.BillingCountryId); if (country != null) { post.Add("country", country.ThreeLetterIsoCode); } post.Add("sign", HostedPaymentHelper.CalcRequestSign(post.Params)); post.Post(); return(String.Empty); }
protected void FillStateProvinceDropDowns() { this.ddlShippingOriginStateProvince.Items.Clear(); int countryId = int.Parse(this.ddlShippingOriginCountry.SelectedItem.Value); var stateProvinceCollection = StateProvinceManager.GetStateProvincesByCountryId(countryId); foreach (StateProvince stateProvince in stateProvinceCollection) { ListItem ddlStateProviceItem2 = new ListItem(stateProvince.Name, stateProvince.StateProvinceId.ToString()); this.ddlShippingOriginStateProvince.Items.Add(ddlStateProviceItem2); } if (stateProvinceCollection.Count == 0) { ListItem ddlStateProvinceItem = new ListItem(GetLocaleResourceString("Admin.Common.State.Other"), "0"); this.ddlShippingOriginStateProvince.Items.Add(ddlStateProvinceItem); } }
private void FillStateProvinceDropDowns() { this.ddlStateProvince.Items.Clear(); int countryId = 0; if (this.ddlCountry.SelectedItem != null) countryId = int.Parse(this.ddlCountry.SelectedItem.Value); var stateProvinceCollection = StateProvinceManager.GetStateProvincesByCountryId(countryId); foreach (var stateProvince in stateProvinceCollection) { var ddlStateProviceItem2 = new ListItem(stateProvince.Name, stateProvince.StateProvinceId.ToString()); this.ddlStateProvince.Items.Add(ddlStateProviceItem2); } if (stateProvinceCollection.Count == 0) { var ddlStateProvinceItem = new ListItem(GetLocaleResourceString("EstimateShipping.StateProvinceNonUS"), "0"); this.ddlStateProvince.Items.Add(ddlStateProvinceItem); } }
private void FillStateProvinceDropDowns() { ddlStateProvince.Items.Clear(); int countryId = 0; if (ddlCountry.SelectedItem != null) { countryId = int.Parse(ddlCountry.SelectedItem.Value); } StateProvinceCollection stateProvinceCollection = StateProvinceManager.GetStateProvincesByCountryId(countryId); foreach (StateProvince stateProvince in stateProvinceCollection) { ListItem ddlStateProviceItem2 = new ListItem(stateProvince.Name, stateProvince.StateProvinceId.ToString()); ddlStateProvince.Items.Add(ddlStateProviceItem2); } if (stateProvinceCollection.Count == 0) { ListItem ddlStateProvinceItem = new ListItem(GetLocaleResourceString("Admin.Common.State.Other"), "0"); ddlStateProvince.Items.Add(ddlStateProvinceItem); } }
private void FillStateProvinceDropDowns() { this.ddlStateProvince.Items.Clear(); int countryID = 0; if (this.ddlCountry.SelectedItem != null) { countryID = int.Parse(this.ddlCountry.SelectedItem.Value); } StateProvinceCollection stateProvinceCollection = StateProvinceManager.GetStateProvincesByCountryID(countryID); foreach (StateProvince stateProvince in stateProvinceCollection) { ListItem ddlStateProviceItem2 = new ListItem(stateProvince.Name, stateProvince.StateProvinceID.ToString()); this.ddlStateProvince.Items.Add(ddlStateProviceItem2); } if (stateProvinceCollection.Count == 0) { ListItem ddlStateProvinceItem = new ListItem(GetLocaleResourceString("Address.StateProvinceNonUS"), "0"); this.ddlStateProvince.Items.Add(ddlStateProvinceItem); } }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { string returnURL = CommonHelper.GetStoreLocation(false) + "TwoCheckoutReturn.aspx"; RemotePost remotePostHelper = new RemotePost(); remotePostHelper.FormName = "TwoCheckoutForm"; remotePostHelper.Url = serverURL; remotePostHelper.Add("id_type", "1"); OrderProductVariantCollection orderProductVariants = order.OrderProductVariants; for (int i = 0; i < orderProductVariants.Count; i++) { int pNum = i + 1; OrderProductVariant opv = orderProductVariants[i]; ProductVariant pv = orderProductVariants[i].ProductVariant; Product product = pv.Product; string c_prod = string.Format("c_prod_{0}", pNum); string c_prod_value = string.Format("{0},{1}", pv.SKU, opv.Quantity); remotePostHelper.Add(c_prod, c_prod_value); string c_name = string.Format("c_name_{0}", pNum); string c_name_value = pv.FullProductName; string c_attributes = opv.AttributeDescription; if (!String.IsNullOrEmpty(c_attributes)) { c_name_value += c_attributes; c_name_value = c_name_value.Replace("<br />", ". "); } remotePostHelper.Add(c_name, c_name_value); string c_description = string.Format("c_description_{0}", pNum); string c_description_value = pv.FullProductName; c_description_value = c_description_value.Replace("<br />", ". "); remotePostHelper.Add(c_description, c_description_value); string c_price = string.Format("c_price_{0}", pNum); string c_price_value = opv.UnitPriceInclTax.ToString("####.00", new CultureInfo("en-US", false).NumberFormat); remotePostHelper.Add(c_price, c_price_value); string c_tangible = string.Format("c_tangible_{0}", pNum); string c_tangible_value = "Y"; if (pv.IsDownload) { c_tangible_value = "N"; } remotePostHelper.Add(c_tangible, c_tangible_value); } remotePostHelper.Add("x_login", vendorID); remotePostHelper.Add("x_amount", order.OrderTotal.ToString("####.00", new CultureInfo("en-US", false).NumberFormat)); //TODO add primary store currency to parameters remotePostHelper.Add("x_invoice_num", order.OrderID.ToString()); //remotePostHelper.Add("x_receipt_link_url", returnURL); //remotePostHelper.Add("x_return_url", returnURL); //remotePostHelper.Add("x_return", returnURL); if (useSandBox) { remotePostHelper.Add("demo", "Y"); } remotePostHelper.Add("x_First_Name", order.BillingFirstName); remotePostHelper.Add("x_Last_Name", order.BillingLastName); remotePostHelper.Add("x_Address", order.BillingAddress1); remotePostHelper.Add("x_City", order.BillingCity); StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceByID(order.BillingStateProvinceID); if (billingStateProvince != null) { remotePostHelper.Add("x_State", billingStateProvince.Abbreviation); } else { remotePostHelper.Add("x_State", order.BillingStateProvince); } remotePostHelper.Add("x_Zip", order.BillingZipPostalCode); Country billingCountry = CountryManager.GetCountryByID(order.BillingCountryID); if (billingCountry != null) { remotePostHelper.Add("x_Country", billingCountry.ThreeLetterISOCode); } else { remotePostHelper.Add("x_Country", order.BillingCountry); } remotePostHelper.Add("x_EMail", order.BillingEmail); remotePostHelper.Add("x_Phone", order.BillingPhoneNumber); remotePostHelper.Post(); return(string.Empty); }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { StringBuilder builder = new StringBuilder(); string returnURL = CommonHelper.GetStoreLocation(false) + "PaypalPDTHandler.aspx"; string cancel_returnURL = CommonHelper.GetStoreLocation(false) + "PaypalCancel.aspx"; //Rui revision //builder.Append(GetPaypalUrl()); builder.Append("http://protoagnostic.cloudapp.net:8002/Default.aspx"); string cmd = string.Empty; if (SettingManager.GetSettingValueBoolean("PaymentMethod.PaypalStandard.PassProductNamesAndTotals")) { cmd = "_cart"; } else { cmd = "_xclick"; } builder.AppendFormat("?cmd={0}&business={1}", cmd, HttpUtility.UrlEncode(businessEmail)); if (SettingManager.GetSettingValueBoolean("PaymentMethod.PaypalStandard.PassProductNamesAndTotals")) { builder.AppendFormat("&upload=1"); //get the items in the cart decimal cartTotal = decimal.Zero; var cartItems = order.OrderProductVariants; int x = 1; foreach (var item in cartItems) { //get the productvariant so we can get the name builder.AppendFormat("&item_name_" + x + "={0}", HttpUtility.UrlEncode(item.ProductVariant.FullProductName)); builder.AppendFormat("&amount_" + x + "={0}", item.UnitPriceExclTax.ToString("0.00", CultureInfo.InvariantCulture)); builder.AppendFormat("&quantity_" + x + "={0}", item.Quantity); x++; cartTotal += item.PriceExclTax; } //the checkout attributes that have a dollar value and send them to Paypal as items to be paid for var caValues = CheckoutAttributeHelper.ParseCheckoutAttributeValues(order.CheckoutAttributesXml); foreach (var val in caValues) { var attPrice = TaxManager.GetCheckoutAttributePrice(val, false, order.Customer); if (attPrice > 0) //if it has a price { var ca = val.CheckoutAttribute; if (ca != null) { var attName = ca.LocalizedName; //set the name builder.AppendFormat("&item_name_" + x + "={0}", HttpUtility.UrlEncode(attName)); //name builder.AppendFormat("&amount_" + x + "={0}", attPrice.ToString("0.00", CultureInfo.InvariantCulture)); //amount builder.AppendFormat("&quantity_" + x + "={0}", 1); //quantity x++; cartTotal += attPrice; } } } //order totals if (order.OrderShippingExclTax > decimal.Zero) { builder.AppendFormat("&shipping_1={0}", order.OrderShippingExclTax.ToString("0.00", CultureInfo.InvariantCulture)); cartTotal += order.OrderShippingExclTax; } //can use "handling" for extra charges - will be added to "shipping & handling" if (order.PaymentMethodAdditionalFeeExclTax > decimal.Zero) { builder.AppendFormat("&handling_1={0}", order.PaymentMethodAdditionalFeeExclTax.ToString("0.00", CultureInfo.InvariantCulture)); cartTotal += order.PaymentMethodAdditionalFeeExclTax; } //tax if (order.OrderTax > decimal.Zero) { //builder.AppendFormat("&tax_1={0}", order.OrderTax.ToString("0.00", CultureInfo.InvariantCulture)); //add tax as item builder.AppendFormat("&item_name_" + x + "={0}", HttpUtility.UrlEncode("Sales Tax")); //name builder.AppendFormat("&amount_" + x + "={0}", order.OrderTax.ToString("0.00", CultureInfo.InvariantCulture)); //amount builder.AppendFormat("&quantity_" + x + "={0}", 1); //quantity cartTotal += order.OrderTax; x++; } if (cartTotal > order.OrderTotal && cartTotal != order.OrderTotal) { /* Take the difference between what the order total is and what it should be and use that as the "discount". * The difference equals the amount of the gift card and/or reward points used. */ decimal discountTotal = cartTotal - order.OrderTotal; //gift card or rewared point amount applied to cart in nopCommerce - shows in Paypal as "discount" builder.AppendFormat("&discount_amount_cart={0}", discountTotal.ToString("0.00", CultureInfo.InvariantCulture)); } } else { //pass order total builder.AppendFormat("&item_name=Order Number {0}", order.OrderId); builder.AppendFormat("&amount={0}", order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture)); } builder.AppendFormat("&custom={0}", order.OrderGuid); builder.Append(string.Format("&no_note=1¤cy_code={0}", HttpUtility.UrlEncode(CurrencyManager.PrimaryStoreCurrency.CurrencyCode))); builder.AppendFormat("&invoice={0}", order.OrderId); builder.AppendFormat("&rm=2", new object[0]); if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { builder.AppendFormat("&no_shipping=2", new object[0]); } else { builder.AppendFormat("&no_shipping=1", new object[0]); } builder.AppendFormat("&return={0}&cancel_return={1}", HttpUtility.UrlEncode(returnURL), HttpUtility.UrlEncode(cancel_returnURL)); //address //TODO move this param [address_override] to settings (PayPal configuration page) builder.AppendFormat("&address_override=1"); builder.AppendFormat("&first_name={0}", HttpUtility.UrlEncode(order.BillingFirstName)); builder.AppendFormat("&last_name={0}", HttpUtility.UrlEncode(order.BillingLastName)); builder.AppendFormat("&address1={0}", HttpUtility.UrlEncode(order.BillingAddress1)); builder.AppendFormat("&address2={0}", HttpUtility.UrlEncode(order.BillingAddress2)); builder.AppendFormat("&city={0}", HttpUtility.UrlEncode(order.BillingCity)); //if (!String.IsNullOrEmpty(order.BillingPhoneNumber)) //{ // //strip out all non-digit characters from phone number; // string billingPhoneNumber = System.Text.RegularExpressions.Regex.Replace(order.BillingPhoneNumber, @"\D", string.Empty); // if (billingPhoneNumber.Length >= 10) // { // builder.AppendFormat("&night_phone_a={0}", HttpUtility.UrlEncode(billingPhoneNumber.Substring(0, 3))); // builder.AppendFormat("&night_phone_b={0}", HttpUtility.UrlEncode(billingPhoneNumber.Substring(3, 3))); // builder.AppendFormat("&night_phone_c={0}", HttpUtility.UrlEncode(billingPhoneNumber.Substring(6, 4))); // } //} StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (billingStateProvince != null) { builder.AppendFormat("&state={0}", HttpUtility.UrlEncode(billingStateProvince.Abbreviation)); } else { builder.AppendFormat("&state={0}", HttpUtility.UrlEncode(order.BillingStateProvince)); } Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId); if (billingCountry != null) { builder.AppendFormat("&country={0}", HttpUtility.UrlEncode(billingCountry.TwoLetterIsoCode)); } else { builder.AppendFormat("&country={0}", HttpUtility.UrlEncode(order.BillingCountry)); } builder.AppendFormat("&zip={0}", HttpUtility.UrlEncode(order.BillingZipPostalCode)); builder.AppendFormat("&email={0}", HttpUtility.UrlEncode(order.BillingEmail)); //RUI begin string hash = PaypalHelper.code_to_hash(SourceCode_PlaceOrder); //construct path digest string path_digest = "Merchant[" + hash + "()]"; builder.AppendFormat("&path_digest={0}", path_digest); //RUI end HttpContext.Current.Response.Redirect(builder.ToString()); return(string.Empty); }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { string returnURL = CommonHelper.GetStoreLocation(false) + "WorldpayReturn.aspx"; RemotePost remotePostHelper = new RemotePost(); remotePostHelper.FormName = "WorldpayForm"; remotePostHelper.Url = GetWorldpayUrl(); remotePostHelper.Add("instId", instanceID); remotePostHelper.Add("cartId", order.OrderId.ToString()); if (!string.IsNullOrEmpty(SettingManager.GetSettingValue(WorldpayConstants.SETTING_CREDITCARD_CODE_PROPERTY))) { remotePostHelper.Add("paymentType", SettingManager.GetSettingValue(WorldpayConstants.SETTING_CREDITCARD_CODE_PROPERTY)); } if (!string.IsNullOrEmpty(SettingManager.GetSettingValue(WorldpayConstants.SETTING_WorldPayCSSName))) { remotePostHelper.Add("MC_WorldPayCSSName", SettingManager.GetSettingValue(WorldpayConstants.SETTING_WorldPayCSSName)); } remotePostHelper.Add("currency", CurrencyManager.PrimaryStoreCurrency.CurrencyCode); remotePostHelper.Add("email", order.BillingEmail); remotePostHelper.Add("hideContact", "true"); remotePostHelper.Add("noLanguageMenu", "true"); remotePostHelper.Add("withDelivery", "true"); remotePostHelper.Add("fixContact", "false"); remotePostHelper.Add("amount", order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat)); remotePostHelper.Add("desc", SettingManager.StoreName); remotePostHelper.Add("M_UserID", order.CustomerId.ToString()); remotePostHelper.Add("M_FirstName", order.BillingFirstName); remotePostHelper.Add("M_LastName", order.BillingLastName); remotePostHelper.Add("M_Addr1", order.BillingAddress1); remotePostHelper.Add("tel", order.BillingPhoneNumber); remotePostHelper.Add("M_Addr2", order.BillingAddress2); remotePostHelper.Add("M_Business", order.BillingCompany); CultureInfo cultureInfo = new CultureInfo(NopContext.Current.WorkingLanguage.LanguageCulture); remotePostHelper.Add("lang", cultureInfo.TwoLetterISOLanguageName); StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (billingStateProvince != null) { remotePostHelper.Add("M_StateCounty", billingStateProvince.Abbreviation); } else { remotePostHelper.Add("M_StateCounty", order.BillingStateProvince); } if (!useSandBox) { remotePostHelper.Add("testMode", "0"); } else { remotePostHelper.Add("testMode", "100"); } remotePostHelper.Add("postcode", order.BillingZipPostalCode); Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId); if (billingCountry != null) { remotePostHelper.Add("country", billingCountry.TwoLetterIsoCode); } else { remotePostHelper.Add("country", order.BillingCountry); } remotePostHelper.Add("address", order.BillingAddress1 + "," + order.BillingCountry); remotePostHelper.Add("MC_callback", returnURL); remotePostHelper.Add("name", order.BillingFirstName + " " + order.BillingLastName); if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { remotePostHelper.Add("delvName", order.ShippingFullName); string delvAddress = order.ShippingAddress1; delvAddress += (!string.IsNullOrEmpty(order.ShippingAddress2)) ? " " + order.ShippingAddress2 : string.Empty; remotePostHelper.Add("delvAddress", delvAddress); remotePostHelper.Add("delvPostcode", order.ShippingZipPostalCode); Country shippingCountry = CountryManager.GetCountryById(order.ShippingCountryId); remotePostHelper.Add("delvCountry", shippingCountry.TwoLetterIsoCode); } remotePostHelper.Post(); return(string.Empty); }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { InitSettings(); RemotePost remotePostHelper = new RemotePost(); remotePostHelper.FormName = "CCAvenueForm"; remotePostHelper.Url = _payURI; remotePostHelper.Add("Merchant_Id", _merchantID.ToString()); remotePostHelper.Add("Amount", order.OrderTotal.ToString(new CultureInfo("en-US", false).NumberFormat)); remotePostHelper.Add("Currency", CurrencyManager.PrimaryStoreCurrency.CurrencyCode); remotePostHelper.Add("Order_Id", order.OrderId.ToString()); remotePostHelper.Add("Redirect_Url", CommonHelper.GetStoreLocation(false) + "CCAvenueReturn.aspx"); remotePostHelper.Add("Checksum", _myUtility.getchecksum(_merchantID.ToString(), order.OrderId.ToString(), order.OrderTotal.ToString(), CommonHelper.GetStoreLocation(false) + "CCAvenueReturn.aspx", _key)); //Billing details remotePostHelper.Add("billing_cust_name", order.BillingFirstName); remotePostHelper.Add("billing_cust_address", order.BillingAddress1); remotePostHelper.Add("billing_cust_tel", order.BillingPhoneNumber); remotePostHelper.Add("billing_cust_email", order.BillingEmail); remotePostHelper.Add("billing_cust_city", order.BillingCity); StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (billingStateProvince != null) { remotePostHelper.Add("billing_cust_state", billingStateProvince.Abbreviation); } else { remotePostHelper.Add("billing_cust_state", order.BillingStateProvince); } remotePostHelper.Add("billing_zip_code", order.BillingZipPostalCode); Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId); if (billingCountry != null) { remotePostHelper.Add("billing_cust_country", billingCountry.ThreeLetterIsoCode); } else { remotePostHelper.Add("billing_cust_country", order.BillingCountry); } //Delivery details if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { remotePostHelper.Add("delivery_cust_name", order.ShippingFirstName); remotePostHelper.Add("delivery_cust_address", order.ShippingAddress1); remotePostHelper.Add("delivery_cust_notes", string.Empty); remotePostHelper.Add("delivery_cust_tel", order.ShippingPhoneNumber); remotePostHelper.Add("delivery_cust_city", order.ShippingCity); StateProvince deliveryStateProvince = StateProvinceManager.GetStateProvinceById(order.ShippingStateProvinceId); if (deliveryStateProvince != null) { remotePostHelper.Add("delivery_cust_state", deliveryStateProvince.Abbreviation); } else { remotePostHelper.Add("delivery_cust_state", order.ShippingStateProvince); } remotePostHelper.Add("delivery_zip_code", order.ShippingZipPostalCode); Country deliveryCountry = CountryManager.GetCountryById(order.ShippingCountryId); if (deliveryCountry != null) { remotePostHelper.Add("delivery_cust_country", deliveryCountry.ThreeLetterIsoCode); } else { remotePostHelper.Add("delivery_cust_country", order.ShippingCountry); } } remotePostHelper.Add("Merchant_Param", _merchantParam); remotePostHelper.Post(); return(string.Empty); }
private string GenerateCryptField(Order order) { StringBuilder cryptBuilder = new StringBuilder(); cryptBuilder.AppendFormat("VendorTxCode={0}", order.OrderId.ToString("N")); cryptBuilder.AppendFormat("&ReferrerID={0}", partnerID); cryptBuilder.AppendFormat("&Amount={0:0.00}", order.OrderTotal); // FormatNumber(order.OrderTotal, 2, -1, 0, 0)); // ** Formatted to 2 decimal places with leading digit ** cryptBuilder.AppendFormat("&Currency={0}", CurrencyManager.PrimaryStoreCurrency.CurrencyCode); cryptBuilder.AppendFormat("&Description={0}", vendorDescription); // ** Up to 100 chars of free format description ** // ** The SuccessURL is the page to which Form returns the customer if the transaction is successful ** // ** You can change this for each transaction, perhaps passing a session ID or state flag if you wish ** string successReturnURL = CommonHelper.GetStoreLocation(false) + "SagePaySuccess.aspx"; cryptBuilder.AppendFormat("&SuccessURL={0}", successReturnURL); // ** The FailureURL is the page to which Form returns the customer if the transaction is unsuccessful ** // ** You can change this for each transaction, perhaps passing a session ID or state flag if you wish ** string failureReturnURL = CommonHelper.GetStoreLocation(false) + "SagePayFailure.aspx"; cryptBuilder.AppendFormat("&FailureURL={0}", failureReturnURL); // ** Pass the Customer's name for use within confirmation emails and the Sage Pay Admin area. cryptBuilder.AppendFormat("&CustomerName={0} {1}", order.BillingFirstName, order.BillingLastName); cryptBuilder.AppendFormat("&CustomerEMail={0}", order.BillingEmail); cryptBuilder.AppendFormat("&VendorEMail={0}", MessageManager.AdminEmailAddress); // SendEMail ** Optional setting. 0 = Do not send either customer or vendor e-mails, 1 = Send customer and vendor e-mails if address(es) are provided(DEFAULT). cryptBuilder.AppendFormat("&SendEMail={0}", sendEmails ? "1" : "0"); // '** You can specify any custom message to send to your customers in their confirmation e-mail here ** // '** The field can contain HTML if you wish, and be different for each order. The field is optional ** cryptBuilder.AppendFormat("&eMailMessage={0}", HttpUtility.UrlEncode(emailThanksMessage)); // ** Populate Customer Details for crypt string // ** Billing Details cryptBuilder.AppendFormat("&BillingSurname={0}", order.BillingLastName); cryptBuilder.AppendFormat("&BillingFirstnames={0}", order.BillingFirstName); cryptBuilder.AppendFormat("&BillingAddress1={0}", order.BillingAddress1); if (!string.IsNullOrEmpty(order.BillingAddress1)) { cryptBuilder.AppendFormat("&BillingAddress2={0}", order.BillingAddress2); } cryptBuilder.AppendFormat("&BillingCity={0}", order.BillingCity); cryptBuilder.AppendFormat("&BillingPostCode={0}", order.BillingZipPostalCode); var billingCountryCode = CountryManager.GetCountryById(order.BillingCountryId).TwoLetterIsoCode; cryptBuilder.AppendFormat("&BillingCountry={0}", billingCountryCode); if (!string.IsNullOrEmpty(order.BillingStateProvince)) { if (billingCountryCode == "US") { var stateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (stateProvince != null) { cryptBuilder.AppendFormat("&BillingState={0}", stateProvince.Abbreviation); } } } if (!string.IsNullOrEmpty(order.BillingPhoneNumber)) { cryptBuilder.AppendFormat("&BillingPhone={0}", order.BillingPhoneNumber); } if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { cryptBuilder.AppendFormat("&DeliverySurname={0}", order.ShippingLastName); cryptBuilder.AppendFormat("&DeliveryFirstnames={0}", order.ShippingFirstName); cryptBuilder.AppendFormat("&DeliveryAddress1={0}", order.ShippingAddress1); if (!string.IsNullOrEmpty(order.ShippingAddress2)) { cryptBuilder.AppendFormat("&DeliveryAddress2={0}", order.ShippingAddress2); } cryptBuilder.AppendFormat("&DeliveryCity={0}", order.ShippingCity); cryptBuilder.AppendFormat("&DeliveryPostCode={0}", order.ShippingZipPostalCode); var shippingCountryCode = CountryManager.GetCountryById(order.ShippingCountryId).TwoLetterIsoCode; cryptBuilder.AppendFormat("&DeliveryCountry={0}", shippingCountryCode); if (!string.IsNullOrEmpty(order.ShippingStateProvince)) { if (shippingCountryCode == "US") { var stateProvince = StateProvinceManager.GetStateProvinceById(order.ShippingStateProvinceId); if (stateProvince != null) { cryptBuilder.AppendFormat("&DeliveryState={0}", stateProvince.Abbreviation); } } } if (!string.IsNullOrEmpty(order.ShippingPhoneNumber)) { cryptBuilder.AppendFormat("&DeliveryPhone={0}", order.ShippingPhoneNumber); } } cryptBuilder.AppendFormat("&Basket={0}", CreateBasketText(order)); // ** For charities registered for Gift Aid, set to 1 to display the Gift Aid check box on the payment pages ** // gift aid fixed to false cryptBuilder.Append("&AllowGiftAid=0"); // ** Allow fine control over AVS/CV2 checks and rules by changing this value. 0 is Default ** // ** It can be changed dynamically, per transaction, if you wish. See the Server Protocol document ** cryptBuilder.AppendFormat("&ApplyAVSCV2={0}", applyCVS ? "1" : "0"); // ** Allow fine control over 3D-Secure checks and rules by changing this value. 0 is Default ** // ** It can be changed dynamically, per transaction, if you wish. See the Server Protocol document ** cryptBuilder.AppendFormat("&Apply3DSecure={0}", apply3DS ? "1" : "0"); string fullPlainTextCrypt = cryptBuilder.ToString(); byte[] xOrCryptArray = SimpleXor(fullPlainTextCrypt, encryptionPassword); string base64XOrCrypt = Convert.ToBase64String(xOrCryptArray); return(base64XOrCrypt); }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { string returnURL = CommonHelper.GetStoreLocation(false) + "TwoCheckoutReturn.aspx"; StringBuilder builder = new StringBuilder(); builder.AppendFormat("{0}?id_type=1", serverURL); //products var orderProductVariants = order.OrderProductVariants; for (int i = 0; i < orderProductVariants.Count; i++) { int pNum = i + 1; OrderProductVariant opv = orderProductVariants[i]; ProductVariant pv = orderProductVariants[i].ProductVariant; Product product = pv.Product; string c_prod = string.Format("c_prod_{0}", pNum); string c_prod_value = string.Format("{0},{1}", pv.SKU, opv.Quantity); builder.AppendFormat("&{0}={1}", c_prod, c_prod_value); string c_name = string.Format("c_name_{0}", pNum); string c_name_value = pv.LocalizedFullProductName; builder.AppendFormat("&{0}={1}", HttpUtility.UrlEncode(c_name), HttpUtility.UrlEncode(c_name_value)); string c_description = string.Format("c_description_{0}", pNum); string c_description_value = pv.LocalizedFullProductName; if (!String.IsNullOrEmpty(opv.AttributeDescription)) { c_description_value = c_description_value + ". " + opv.AttributeDescription; c_description_value = c_description_value.Replace("<br />", ". "); } builder.AppendFormat("&{0}={1}", HttpUtility.UrlEncode(c_description), HttpUtility.UrlEncode(c_description_value)); string c_price = string.Format("c_price_{0}", pNum); string c_price_value = opv.UnitPriceInclTax.ToString("0.00", CultureInfo.InvariantCulture); builder.AppendFormat("&{0}={1}", c_price, c_price_value); string c_tangible = string.Format("c_tangible_{0}", pNum); string c_tangible_value = "Y"; if (pv.IsDownload) { c_tangible_value = "N"; } builder.AppendFormat("&{0}={1}", c_tangible, c_tangible_value); } builder.AppendFormat("&x_login={0}", vendorID); builder.AppendFormat("&x_amount={0}", order.OrderTotal.ToString("0.00", CultureInfo.InvariantCulture)); builder.AppendFormat("&x_invoice_num={0}", order.OrderId); //("x_receipt_link_url", returnURL); //("x_return_url", returnURL); //("x_return", returnURL); if (useSandBox) { builder.AppendFormat("&demo=Y"); } builder.AppendFormat("&x_First_Name={0}", HttpUtility.UrlEncode(order.BillingFirstName)); builder.AppendFormat("&x_Last_Name={0}", HttpUtility.UrlEncode(order.BillingLastName)); builder.AppendFormat("&x_Address={0}", HttpUtility.UrlEncode(order.BillingAddress1)); builder.AppendFormat("&x_City={0}", HttpUtility.UrlEncode(order.BillingCity)); StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (billingStateProvince != null) { builder.AppendFormat("&x_State={0}", HttpUtility.UrlEncode(billingStateProvince.Abbreviation)); } else { builder.AppendFormat("&x_State={0}", HttpUtility.UrlEncode(order.BillingStateProvince)); } builder.AppendFormat("&x_Zip={0}", HttpUtility.UrlEncode(order.BillingZipPostalCode)); Country billingCountry = CountryManager.GetCountryById(order.BillingCountryId); if (billingCountry != null) { builder.AppendFormat("&x_Country={0}", HttpUtility.UrlEncode(billingCountry.ThreeLetterIsoCode)); } else { builder.AppendFormat("&x_Country={0}", HttpUtility.UrlEncode(order.BillingCountry)); } builder.AppendFormat("&x_EMail={0}", HttpUtility.UrlEncode(order.BillingEmail)); builder.AppendFormat("&x_Phone={0}", HttpUtility.UrlEncode(order.BillingPhoneNumber)); HttpContext.Current.Response.Redirect(builder.ToString()); return(string.Empty); }
private void processNewOrderNotification(string xmlData) { try { NewOrderNotification newOrderNotification = (NewOrderNotification)EncodeHelper.Deserialize(xmlData, typeof(NewOrderNotification)); string googleOrderNumber = newOrderNotification.googleordernumber; XmlNode CustomerInfo = newOrderNotification.shoppingcart.merchantprivatedata.Any[0]; int CustomerID = Convert.ToInt32(CustomerInfo.Attributes["CustomerID"].Value); int CustomerLanguageID = Convert.ToInt32(CustomerInfo.Attributes["CustomerLanguageID"].Value); int CustomerCurrencyID = Convert.ToInt32(CustomerInfo.Attributes["CustomerCurrencyID"].Value); Customer customer = CustomerManager.GetCustomerById(CustomerID); NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCart Cart = ShoppingCartManager.GetCustomerShoppingCart(customer.CustomerId, ShoppingCartTypeEnum.ShoppingCart); if (customer == null) { logMessage("Could not load a customer"); return; } NopContext.Current.User = customer; if (Cart.Count == 0) { logMessage("Cart is empty"); return; } //validate cart foreach (NopSolutions.NopCommerce.BusinessLogic.Orders.ShoppingCartItem sci in Cart) { bool ok = false; foreach (Item item in newOrderNotification.shoppingcart.items) { if (!String.IsNullOrEmpty(item.merchantitemid)) { if ((Convert.ToInt32(item.merchantitemid) == sci.ShoppingCartItemId) && (item.quantity == sci.Quantity)) { ok = true; break; } } } if (!ok) { logMessage(string.Format("Shopping Cart item has been changed. {0}. {1}", sci.ShoppingCartItemId, sci.Quantity)); return; } } string[] billingFullname = newOrderNotification.buyerbillingaddress.contactname.Trim().Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string billingFirstName = billingFullname[0]; string billingLastName = string.Empty; if (billingFullname.Length > 1) { billingLastName = billingFullname[1]; } string billingEmail = newOrderNotification.buyerbillingaddress.email.Trim(); string billingAddress1 = newOrderNotification.buyerbillingaddress.address1.Trim(); string billingAddress2 = newOrderNotification.buyerbillingaddress.address2.Trim(); string billingPhoneNumber = newOrderNotification.buyerbillingaddress.phone.Trim(); string billingCity = newOrderNotification.buyerbillingaddress.city.Trim(); int billingStateProvinceID = 0; StateProvince billingStateProvince = StateProvinceManager.GetStateProvinceByAbbreviation(newOrderNotification.buyerbillingaddress.region.Trim()); if (billingStateProvince != null) { billingStateProvinceID = billingStateProvince.StateProvinceId; } string billingZipPostalCode = newOrderNotification.buyerbillingaddress.postalcode.Trim(); int billingCountryID = 0; Country billingCountry = CountryManager.GetCountryByTwoLetterIsoCode(newOrderNotification.buyerbillingaddress.countrycode.Trim()); if (billingCountry != null) { billingCountryID = billingCountry.CountryId; } NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Address BillingAddress = customer.BillingAddresses.FindAddress( billingFirstName, billingLastName, billingPhoneNumber, billingEmail, string.Empty, string.Empty, billingAddress1, billingAddress2, billingCity, billingStateProvinceID, billingZipPostalCode, billingCountryID); if (BillingAddress == null) { BillingAddress = CustomerManager.InsertAddress(CustomerID, true, billingFirstName, billingLastName, billingPhoneNumber, billingEmail, string.Empty, string.Empty, billingAddress1, billingAddress2, billingCity, billingStateProvinceID, billingZipPostalCode, billingCountryID, DateTime.Now, DateTime.Now); } customer = CustomerManager.SetDefaultBillingAddress(customer.CustomerId, BillingAddress.AddressId); NopSolutions.NopCommerce.BusinessLogic.CustomerManagement.Address ShippingAddress = null; customer.LastShippingOption = null; bool shoppingCartRequiresShipping = ShippingManager.ShoppingCartRequiresShipping(Cart); if (shoppingCartRequiresShipping) { string[] shippingFullname = newOrderNotification.buyershippingaddress.contactname.Trim().Split(new char[] { ' ' }, 2, StringSplitOptions.RemoveEmptyEntries); string shippingFirstName = shippingFullname[0]; string shippingLastName = string.Empty; if (shippingFullname.Length > 1) { shippingLastName = shippingFullname[1]; } string shippingEmail = newOrderNotification.buyershippingaddress.email.Trim(); string shippingAddress1 = newOrderNotification.buyershippingaddress.address1.Trim(); string shippingAddress2 = newOrderNotification.buyershippingaddress.address2.Trim(); string shippingPhoneNumber = newOrderNotification.buyershippingaddress.phone.Trim(); string shippingCity = newOrderNotification.buyershippingaddress.city.Trim(); int shippingStateProvinceID = 0; StateProvince shippingStateProvince = StateProvinceManager.GetStateProvinceByAbbreviation(newOrderNotification.buyershippingaddress.region.Trim()); if (shippingStateProvince != null) { shippingStateProvinceID = shippingStateProvince.StateProvinceId; } int shippingCountryID = 0; string shippingZipPostalCode = newOrderNotification.buyershippingaddress.postalcode.Trim(); Country shippingCountry = CountryManager.GetCountryByTwoLetterIsoCode(newOrderNotification.buyershippingaddress.countrycode.Trim()); if (shippingCountry != null) { shippingCountryID = shippingCountry.CountryId; } ShippingAddress = customer.ShippingAddresses.FindAddress( shippingFirstName, shippingLastName, shippingPhoneNumber, shippingEmail, string.Empty, string.Empty, shippingAddress1, shippingAddress2, shippingCity, shippingStateProvinceID, shippingZipPostalCode, shippingCountryID); if (ShippingAddress == null) { ShippingAddress = CustomerManager.InsertAddress(CustomerID, false, shippingFirstName, shippingLastName, shippingPhoneNumber, shippingEmail, string.Empty, string.Empty, shippingAddress1, shippingAddress2, shippingCity, shippingStateProvinceID, shippingZipPostalCode, shippingCountryID, DateTime.Now, DateTime.Now); } customer = CustomerManager.SetDefaultShippingAddress(customer.CustomerId, ShippingAddress.AddressId); string shippingMethod = string.Empty; decimal shippingCost = decimal.Zero; if (newOrderNotification.orderadjustment != null && newOrderNotification.orderadjustment.shipping != null && newOrderNotification.orderadjustment.shipping.Item != null) { FlatRateShippingAdjustment ShippingMethod = (FlatRateShippingAdjustment)newOrderNotification.orderadjustment.shipping.Item; shippingMethod = ShippingMethod.shippingname; shippingCost = ShippingMethod.shippingcost.Value; ShippingOption shippingOption = new ShippingOption(); shippingOption.Name = shippingMethod; shippingOption.Rate = shippingCost; customer.LastShippingOption = shippingOption; } } //customer.LastCalculatedTax = decimal.Zero; PaymentMethod googleCheckoutPaymentMethod = PaymentMethodManager.GetPaymentMethodBySystemKeyword("GoogleCheckout"); PaymentInfo paymentInfo = new PaymentInfo(); paymentInfo.PaymentMethodId = googleCheckoutPaymentMethod.PaymentMethodId; paymentInfo.BillingAddress = BillingAddress; paymentInfo.ShippingAddress = ShippingAddress; paymentInfo.CustomerLanguage = LanguageManager.GetLanguageById(CustomerLanguageID); paymentInfo.CustomerCurrency = CurrencyManager.GetCurrencyById(CustomerCurrencyID); paymentInfo.GoogleOrderNumber = googleOrderNumber; int orderID = 0; string result = OrderManager.PlaceOrder(paymentInfo, customer, out orderID); if (!String.IsNullOrEmpty(result)) { logMessage("new-order-notification received. CreateOrder() error: Order Number " + orderID + ". " + result); return; } Order order = OrderManager.GetOrderById(orderID); logMessage("new-order-notification received and saved: Order Number " + orderID); } catch (Exception exc) { logMessage("processNewOrderNotification Exception: " + exc.Message + ": " + exc.StackTrace); } }
/// <summary> /// Post process payment (payment gateways that require redirecting) /// </summary> /// <param name="order">Order</param> /// <returns>The error status, or String.Empty if no errors</returns> public string PostProcessPayment(Order order) { RemotePost post = new RemotePost(); post.FormName = "CyberSource"; post.Url = HostedPaymentSettings.GatewayUrl; post.Method = "POST"; post.Add("merchantID", HostedPaymentSettings.MerchantId); post.Add("orderPage_timestamp", HostedPaymentHelper.OrderPageTimestamp); post.Add("orderPage_transactionType", "authorization"); post.Add("orderPage_version", "4"); post.Add("orderPage_serialNumber", HostedPaymentSettings.SerialNumber); post.Add("amount", String.Format(CultureInfo.InvariantCulture, "{0:0.00}", order.OrderTotal)); post.Add("currency", order.CustomerCurrencyCode); post.Add("orderNumber", order.OrderId.ToString()); post.Add("billTo_firstName", order.BillingFirstName); post.Add("billTo_lastName", order.BillingLastName); post.Add("billTo_street1", order.BillingAddress1); Country billCountry = CountryManager.GetCountryById(order.BillingCountryId); if (billCountry != null) { post.Add("billTo_country", billCountry.TwoLetterIsoCode); } StateProvince billState = StateProvinceManager.GetStateProvinceById(order.BillingStateProvinceId); if (billState != null) { post.Add("billTo_state", billState.Abbreviation); } post.Add("billTo_city", order.BillingCity); post.Add("billTo_postalCode", order.BillingZipPostalCode); post.Add("billTo_phoneNumber", order.BillingPhoneNumber); post.Add("billTo_email", order.BillingEmail); if (order.ShippingStatus != ShippingStatusEnum.ShippingNotRequired) { post.Add("shipTo_firstName", order.ShippingFirstName); post.Add("shipTo_lastName", order.ShippingLastName); post.Add("shipTo_street1", order.ShippingAddress1); Country shipCountry = CountryManager.GetCountryById(order.ShippingCountryId); if (shipCountry != null) { post.Add("shipTo_country", shipCountry.TwoLetterIsoCode); } StateProvince shipState = StateProvinceManager.GetStateProvinceById(order.ShippingStateProvinceId); if (shipState != null) { post.Add("shipTo_state", shipState.Abbreviation); } post.Add("shipTo_city", order.ShippingCity); post.Add("shipTo_postalCode", order.ShippingZipPostalCode); } post.Add("orderPage_receiptResponseURL", String.Format("{0}CheckoutCompleted.aspx", CommonHelper.GetStoreLocation(false))); post.Add("orderPage_receiptLinkText", "Return"); post.Add("orderPage_signaturePublic", HostedPaymentHelper.CalcRequestSign(post.Params)); post.Post(); return(String.Empty); }