public static JwtCustomerDataResponseContent DecodeJwtToken(string token) { var decoded = new TotalCodeApiService().Decode(Token); decoded.EncodedToken = Token; return(decoded); }
public static ApiKeyLoginResponseContent GetOrSetAuthorization(string tenantUid) { var cacheInfo = new CacheInfo() { CacheName = AUTH_KEY, TenantUid = tenantUid }; var result = CacheHelper.GetCache <ApiKeyLoginResponseContent>(cacheInfo); if (result == null || result.Expires <= DateTime.UtcNow) { CacheHelper.ClearCache(cacheInfo); result = CacheHelper.GetOrSetCache <ApiKeyLoginResponseContent>(cacheInfo, () => { var key = ApiKeyCache.GetByTenantUid(tenantUid); var apiService = new TotalCodeApiService(); var res = (ApiKeyLoginResponseContent)apiService.ApiKeyLogin(key.ApiKey, key.AppId); return(res); }, TimeSpan.FromSeconds(CacheSetting.TimeoutInSeconds)); } return(result); }
public TotalCodeHomePageController(IContentService contentService) { this.contentService = contentService; this.apiService = new TotalCodeApiService(); using (var scope = ConnectorContext.ScopeProvider.CreateScope(autoComplete: true)) { //ApiKeyCache.UpdateCache(scope.Database); } }
public BaseController() { apiService = new TotalCodeApiService(); contentService = ConnectorContext.ContentService; using (var scope = ConnectorContext.ScopeProvider.CreateScope(autoComplete: true)) { ApiKeyCache.UpdateCache(scope.Database); } }
public RegistrationController() { verificationService = new TotalCodeApiService(); contentService = ConnectorContext.ContentService; helper = new Helpers.UrlHelper(Umbraco); using (var scope = ConnectorContext.ScopeProvider.CreateScope(autoComplete: true)) { ApiKeyCache.UpdateCache(scope.Database); } }
public GameController(IGameService gameService) { _gameService = gameService; this.apiService = new TotalCodeApiService(); this.contentService = ConnectorContext.ContentService; using (var scope = ConnectorContext.ScopeProvider.CreateScope(autoComplete: true)) { ApiKeyCache.UpdateCache(scope.Database); } }
public ConfirmEmailController(ILogger logger) { this.logger = logger; verificationService = new TotalCodeApiService(); helper = new Helpers.UrlHelper(Umbraco); using (var scope = ConnectorContext.ScopeProvider.CreateScope(autoComplete: true)) { ApiKeyCache.UpdateCache(scope.Database); } }
public async Task Connector_ApiKeyLogin() { //Arrange TotalCodeApiService helper = new TotalCodeApiService(); //Act var response = await helper.ApiKeyLoginAsync("api_key_customer_management", "CustomerManagementGuid"); //Assert Assert.IsNotNull(response); }
public async Task Connector_VerifyMobileSendSMS() { //Arrange TotalCodeApiService helper = new TotalCodeApiService(); var authorization = (ApiKeyLoginResponseContent)await helper.ApiKeyLoginAsync("api_key_customer_management", "CustomerManagementGuid"); //Act var response = await helper.VerifyMobileAsync("B3988460-F283-4D44-8A5E-58EB7C909B39", "http://customer-management-service-api.totalcoding-test1.com", "+441500000000", "PT", authorization.AccessToken); //Assert Assert.IsNotNull(response); }
public ActionResult GameIframe() { string token = String.Empty; var apiService = new TotalCodeApiService(); var page = Umbraco.Content(CurrentPage.Parent.Id); var homePage = CurrentPage.Root(); var TenantUid = homePage.Value <string>("tenantUid"); var currentCulture = Umbraco.CultureDictionary.Culture.TwoLetterISOLanguageName; int gameId; Int32.TryParse(CurrentPage.GetProperty("gameId").Value().ToString(), out gameId); HttpCookie tokenCookie = Request.Cookies["token"]; if (tokenCookie != null) { token = tokenCookie.Value; } else { System.Web.HttpContext.Current.Response.Redirect(page.GetUrl(currentCulture) + "?gameId=" + gameId + "#popup-login"); } System.Web.HttpContext.Current.Response.Redirect(page.GetUrl(currentCulture) + "?gameId=" + gameId); string origin = Request.Url.ToString(); string gameName = CurrentPage.GetProperty("gameName").Value().ToString(); var game = (GameByIdResponseContent)apiService.GetGameById(TenantUid, origin, gameId, gameIdentifier: gameName, authorization: token, languageCode: currentCulture); var lobby = ""; if (game != null) { var gameLobbyUrl = (GameLobbyResponseContent)apiService.GetGameLobby(game.Url, TenantUid, origin, customerToken: token, locale: currentCulture); if (gameLobbyUrl.Success) { lobby = gameLobbyUrl.Link; } } var result = "<iframe src=\"" + lobby + "\" id=\"game-iframe\" frameborder=\"0\" allowfullscreen></iframe>"; return(Content(result)); }
public TotalCodeAccountPageController() { apiService = new TotalCodeApiService(); }
public GamesHelper(IContentService contentService, TotalCodeApiService apiService) { this.apiService = apiService; this.contentService = contentService; }
void CheckSession(string origin, string tenantUid) { HttpCookie usernameCookie = Request.Cookies["username"]; HttpCookie tokenCookie = Request.Cookies["token"]; HttpCookie lastLoginCookie = Request.Cookies["lastLogin"]; if (usernameCookie != null) { LoginSession.LoggedIn = true; LoginSession.Username = usernameCookie.Value; string sa = @"""" + lastLoginCookie?.Value + @""""; LoginSession.LastLogin = lastLoginCookie != null?JsonConvert.DeserializeObject <DateTime>(sa) : DateTime.UtcNow; if (tokenCookie != null) { LoginSession.Token = tokenCookie.Value; LoginSession.Username = LoginSession.DecodedJwtToken.Username; } //LoginSession.Token = Request.Cookies["token"] != null ? Request.Cookies["token"].Value : string.Empty; } else { LoginSession.Logout(); } var api = new TotalCodeApiService(); if (LoginSession.LastLogin > DateTime.MinValue && LoginSession.LastLogin < DateTime.UtcNow) { LoginSession.LoggedIn = true; } else if (LoginSession.LastLogin == DateTime.UtcNow) { var refresh = (LoginResponseContent)api.RefreshToken(tenantUid, origin, LoginSession.Token); LoginSession.LoggedIn = true; LoginSession.Token = refresh.Token; LoginSession.LastLogin = refresh.LastLogin.Value; } else if (LoginSession.LastLogin > DateTime.UtcNow) { LoginSession.Logout(); } if (LoginSession.LoggedIn) { //if (LoginSession.CustomerSummary == null) //{ LoginSession.CustomerSummary = api.GetCustomerSummary(tenantUid, origin, LoginSession.DecodedJwtToken); if (!LoginSession.CustomerSummary.Balance.IsLiveBalance) { LoginSession.Logout(); } //} } if (!LoginSession.IsMobileBrowser.HasValue) { LoginSession.IsMobileBrowser = ContentHelper.BrowserIsMobile(); } }
static TenantHelper() { apiService = new TotalCodeApiService(); }
public Authorization() { apiService = new TotalCodeApiService(); }
public JsonResult GetCards(Guid rootGuid, Guid customerGuid, string token, string pageId, string lang) { var apiService = new TotalCodeApiService(); var root = Umbraco.Content(rootGuid); var tenantUid = root.GetProperty("tenantUid").GetValue().ToString(); var origin = TenantHelper.GetCurrentTenantUrl(contentService, tenantUid); string type = string.Empty; int page_id; Int32.TryParse(pageId, out page_id); var currentPage = Umbraco.Content(page_id); if (currentPage != null) { if (currentPage.ContentType.Alias == "totalCodeDepositPage") { type = "2"; } if (currentPage.ContentType.Alias == "totalCodeWithdrawPage") { type = "1"; } } var preferences = root.Value <string>("tenantPreferencesProperty"); var preferencesJson = JsonConvert.DeserializeObject <TenantPreferences>(preferences); var paymentMethods = preferencesJson.PaymentSettings.PaymentMethods.ToList(); List <PaymentMethod> availablePaymentMethods = new List <PaymentMethod>(); var userPaymentMethods = apiService.CustomerPaymentSystems(customerGuid.ToString(), token, origin, tenantUid, type); CultureInfo newLanguage = new CultureInfo(lang); System.Threading.Thread.CurrentThread.CurrentCulture = newLanguage; System.Threading.Thread.CurrentThread.CurrentUICulture = newLanguage; foreach (var method in paymentMethods) { method.PaymentSystemNameOrig = method.PaymentSystemName; var name = "[PM]" + method.PaymentSystemName; method.PaymentSystemName = Umbraco.GetDictionaryValue(name, method.PaymentSystemName); if (userPaymentMethods != null) { foreach (var paymentId in userPaymentMethods.PaymentIds) { if (paymentId.PaymentIdentifier == method.PaymentIdentifier) { method.Priority = paymentId.Priority; if (paymentId.Priority == null) { method.Priority = 99; } if (paymentId.IsDefault) { method.isDefault = true; } availablePaymentMethods.Add(method); } } } } availablePaymentMethods = availablePaymentMethods.OrderBy(x => x.Priority).ToList(); if (Convert.ToBoolean(WebConfigurationManager.AppSettings["TestApi"])) { paymentMethods.Add(new PaymentMethod { PaymentIdentifier = "Cartipay", PaymentSystemName = "Cartipay", WithdrawalFields = new List <CustomField> { new CustomField { Name = "CardNumber", Type = "card", Label = "Card Number", Value = "", Required = true, IsReadonly = false }, new CustomField { Name = "WithdrawAmount", Type = "amount", Label = "Amount", Value = "", Required = true, IsReadonly = false }, }, DepositFields = new List <CustomField> { new CustomField { Name = "CardNumber", Type = "card", Label = "Card Number", Value = "", Required = true, IsReadonly = false }, new CustomField { Name = "DepositAmount", Type = "amount", Label = "Amount", Value = "", Required = true, IsReadonly = false }, } }); paymentMethods.Add(new PaymentMethod { PaymentIdentifier = "Cartipal", PaymentSystemName = "Cartipal" }); paymentMethods.Add(new PaymentMethod { PaymentIdentifier = "Bitcoin", PaymentSystemName = "Bitcoin", WithdrawalFields = new List <CustomField> { new CustomField { Name = "Amount Details", Type = "amount", Label = "Amount", Alias = "withdrawAmount", Value = "", Required = true, IsReadonly = false }, new CustomField { Name = "Currency", Type = "text", Label = "Currency", Alias = "currency", Value = "", Required = true, IsReadonly = false }, new CustomField { Name = "Bitcoin Address", Type = "text", Label = "Bitcoin Address", Alias = "bitCoinAddress", Value = "", Required = true, IsReadonly = false }, }, }); return(Json(paymentMethods, JsonRequestBehavior.DenyGet)); } return(Json(availablePaymentMethods, JsonRequestBehavior.DenyGet)); }