/// <summary> /// validate coupon code /// </summary> /// <param name="customerHandle">customer id</param> /// <param name="planHandle">plan id</param> /// <param name="couponCode">Coupon code</param> /// <returns>subscription data</returns> public ApiResponse <Coupon> ValidateCouponCode(string customerHandle, string planHandle, string couponCode) { var myClassname = MethodBase.GetCurrentMethod().Name; var config = this.GetDefaultApiConfiguration(); var api = new CouponApi(config); for (var i = 0; i <= MaxNoOfRetries; i++) { try { var res = api.ValidateCodeWithHttpInfo(couponCode, planHandle, customerHandle); return(res); } catch (ApiException apiException) { this._log.Error($"{myClassname} {apiException.ErrorCode} {apiException.ErrorContent}"); return(new ApiResponse <Coupon>(apiException.ErrorCode, null, null)); } catch (Exception) when(i < MaxNoOfRetries) { this._log.Debug($"{myClassname} retry attempt {i}"); } } return(new ApiResponse <Coupon>((int)HttpStatusCode.InternalServerError, null, null)); }
public CouponBase() { _UserApi = new UserAPI(); _CouponApi = new CouponApi(); _ContentApi = new ContentAPI(); _SiteApi = new SiteAPI(); _CurrencyApi = new CurrencyApi(); m_refMsg = m_refContentApi.EkMsgRef; this.IsAdmin = _ContentApi.IsAdmin(); this.IsCommerceAdmin = _UserApi.EkUserRef.IsARoleMember_CommerceAdmin(); this.SitePath = _ContentApi.SitePath.TrimEnd(new char[] { '/' }); this.ApplicationPath = _SiteApi.ApplicationPath.TrimEnd(new char[] { '/' }); }
public CouponUserControlBase() { _UserApi = new UserAPI(); _CouponApi = new CouponApi(); _ContentApi = new ContentAPI(); _SiteApi = new SiteAPI(); _CurrencyApi = new CurrencyApi(); this.SitePath = _ContentApi.SitePath.TrimEnd(new char[] { '/' }); this.ApplicationPath = _SiteApi.ApplicationPath.TrimEnd(new char[] { '/' }); this.IsAdmin = _ContentApi.IsAdmin(); this.IsCommerceAdmin = _UserApi.EkUserRef.IsARoleMember_CommerceAdmin(); //check permissions - both admin and commerce admin can edit this.IsEditable = (this.IsCommerceAdmin == true || this.IsAdmin == true) ? true : false; }
public static void InsertCouponCall() { const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00"; var api = new CouponApi(simpleKey); }
public static void GenerateOneTimeCodesByMerchantCodeCall() { const string simpleKey = "109ee846ee69f50177018ab12f008a00748a25aa28dbdc0177018ab12f008a00"; var api = new CouponApi(simpleKey); }
protected override void Page_Load(object sender, System.EventArgs e) { base.Page_Load(sender, e); if (!Ektron.Cms.DataIO.LicenseManager.LicenseManager.IsFeatureEnable(m_refContentApi.RequestInformationRef, Ektron.Cms.DataIO.LicenseManager.Feature.eCommerce)) { Utilities.ShowError(m_refContentApi.EkMsgRef.GetMessage("feature locked error")); } m_refCurrency = new Currency(m_refContentApi.RequestInformationRef); AppPath = m_refContentApi.AppPath; RegisterResources(); try { CouponManager = new CouponApi(); Util_CheckAccess(); drp_discounttype.Items.Add(new ListItem(GetMessage("lbl coupon amount"), "0")); drp_discounttype.Items.Add(new ListItem(GetMessage("lbl coupon amount percent"), "1")); drp_discounttype.Items.Add(new ListItem(GetMessage("lbl free shipping"), "2")); drp_discounttype.Attributes.Add("onchange", "document.getElementById(\'txt_discountval\').disabled = (this.selectedIndex == 2); document.getElementById(\'sel_currency\').disabled = (this.selectedIndex == 1 || this.selectedIndex == 2);"); rad_type.Items.Add(new ListItem(GetMessage("lbl coupon type basket"), EkEnumeration.CouponType.BasketLevel.ToString())); rad_type.Items.Add(new ListItem(GetMessage("lbl coupon type basket item most exp"), EkEnumeration.CouponType.MostExpensiveItem.ToString())); rad_type.Items.Add(new ListItem(GetMessage("lbl coupon type basket item least exp"), EkEnumeration.CouponType.LeastExpensiveItem.ToString())); rad_type.Items.Add(new ListItem(GetMessage("lbl coupon type basket item all"), EkEnumeration.CouponType.AllItems.ToString())); switch (m_sPageAction) { case "addedit": Util_SetJS(); if (Page.IsPostBack) { Process_AddEdit(); } else { Display_AddEdit(); } Util_SetDropEnabled(); break; case "view": Display_View(); break; case "delete": Process_Delete(); break; case "deactivate": Process_Deactivate(); break; default: if (Page.IsPostBack == false) { Display_View_All(); } break; } Util_SetLabels(); } catch (Exception ex) { Utilities.ShowError(ex.Message); } }
protected void Display_ViewBaskets(bool WithEdit) { Ektron.Cms.Commerce.Basket currentBasket; long basketId = 0; CouponApi _CouponApi = new CouponApi(); BasketCalculatorData basketCouponData; if ((Request.QueryString["basketid"] != null) && Request.QueryString["basketid"] != "") { basketId = Convert.ToInt64(Request.QueryString["basketid"]); } if (basketId > 0) { HttpBrowserCapabilities browser = Request.Browser; Ektron.Cms.Framework.Context.CmsContextService context = new Ektron.Cms.Framework.Context.CmsContextService(); if (browser.Type.Contains("IE") && browser.MajorVersion >= 9) { // work around to prevent errors in IE9 when it destroys native JS objects // see http://msdn.microsoft.com/en-us/library/gg622929%28v=VS.85%29.aspx uxViewBasketIframe.Attributes.Add("src", "about:blank"); } else { uxViewBasketIframe.Attributes.Add("src", context.SitePath + "customers.aspx?action=viewbasket&basketid=" + basketId + "&customerid=" + m_iCustomerId + "&thickox=true&height=300&width=700&modal=true&EkTB_iframe=true"); } uxDialog.Title = m_refMsg.GetMessage("lbl view basket"); currentBasket = basketApi.GetItem(basketId); if ((currentBasket != null) && currentBasket.Items.Count > 0) { dg_viewbasket.DataSource = currentBasket.Items; dg_viewbasket.DataBind(); BasketCalculator basketCalc = new BasketCalculator(currentBasket, this.m_refContentApi.RequestInformationRef); basketCouponData = _CouponApi.CalculateBasketCoupons(basketId); if (basketCouponData.BasketCoupons.Count > 0) { ltr_noitems.Text = "<hr/><table width=\"100%\">"; ltr_noitems.Text += "<tr><td align=\"right\" width=\"90%\">" + GetMessage("lbl coupon discount") + "</td><td align=\"right\">(" + Ektron.Cms.Common.EkFunctions.FormatCurrency(basketCouponData.TotalCouponDiscount, defaultCurrency.CultureCode) + ")</td></tr>"; ltr_noitems.Text += "<tr><td align=\"right\" width=\"90%\">" + GetMessage("lbl total") + ": </td><td align=\"right\">" + Ektron.Cms.Common.EkFunctions.FormatCurrency(basketCouponData.BasketTotal, defaultCurrency.CultureCode) + "</td></tr>"; ltr_noitems.Text += "</table>"; } } else { ltr_noitems.Text = this.GetMessage("lbl no items"); } } else { ltr_noitems.Text = this.GetMessage("lbl no items"); } }
public void Init() { instance = new CouponApi(); }