public CompletePayment(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.entBillingMgr = entBillingMgr; this.idMgr = idMgr; this.secMgr = secMgr; }
public Refresh(IEnterprisesBillingManagerService entBillingMgr, IIdentityAccessService idAccessSvc, ISecurityDataTokenService secMgr) { this.entBillingMgr = entBillingMgr; this.idAccessSvc = idAccessSvc; this.secMgr = secMgr; }
public ChangeSubscription(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.entBillingMgr = entBillingMgr; this.idMgr = idMgr; this.secMgr = secMgr; }
public RequestUserAccess(ApplicationManagerClient appMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.idMgr = idMgr; this.secMgr = secMgr; this.appMgr = appMgr; }
public BillingStripeWebhook(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.entBillingMgr = entBillingMgr; this.secMgr = secMgr; this.idMgr = idMgr; }
public virtual async Task <Status> ListLicenses(IIdentityAccessService idAccessSvc, string entLookup, string username, string licenseType) { var licenseAccess = await idAccessSvc.ListLicensesByUsername(entLookup, username, new List <string>() { licenseType }); State.ExistingLicenseTypes = licenseAccess.Model; return((licenseAccess != null) ? Status.Success : Status.Unauthorized.Clone($"No licenses found for user {username}")); }
public UpdateActiveEnterpriseSync(IApplicationsIoTService appIoTArch, IIdentityAccessService idMgr, ILogger <UpdateActiveEnterpriseSync> log) { this.appIoTArch = appIoTArch; this.idMgr = idMgr; this.log = log; }
public ResetStateCheck(IEnterprisesBillingManagerService entBillingMgr, IIdentityAccessService idMgr, ISecurityDataTokenService secMgr) { this.entBillingMgr = entBillingMgr; this.idMgr = idMgr; this.secMgr = secMgr; }
public virtual async Task Refresh(IApplicationsIoTService appIoTArch, IEnterprisesManagementService entMgr, IIdentityAccessService idMgr, string parentEntLookup) { await LoadChildEnterprises(entMgr, parentEntLookup, appIoTArch, idMgr); await LoadActiveEnterpriseDetails(appIoTArch, State.ActiveEnterpriseConfig.Page, State.ActiveEnterpriseConfig.PageSize); State.Loading = false; }
public virtual async Task <Status> RevokeDeviceEnrollment(IApplicationsIoTService appIoTArch, IEnterprisesManagementService entMgr, IIdentityAccessService idMgr, string parentEntLookup, string deviceId) { var revoked = await revokeDeviceEnrollment(appIoTArch, State.ActiveEnterpriseConfig.ActiveEnterprise.Lookup, deviceId); await LoadChildEnterprises(entMgr, parentEntLookup, appIoTArch, idMgr); return(revoked); }
public UpdateEnterprisesSync(IEnterprisesManagementService entMgr, IApplicationsIoTService appIoTArch, IIdentityAccessService idMgr, ILogger <UpdateEnterprisesSync> log) { this.appIoTArch = appIoTArch; this.entMgr = entMgr; this.idMgr = idMgr; this.log = log; }
public RevokeDeviceEnrollment(IApplicationsIoTService appIoTArch, IEnterprisesManagementService entMgr, IIdentityAccessService idMgr, ILogger <RevokeDeviceEnrollment> log) { this.appIoTArch = appIoTArch; this.entMgr = entMgr; this.idMgr = idMgr; this.log = log; }
public RemoveChildEnterprise(IApplicationsIoTService appIoTArch, IEnterprisesManagementService entMgr, IIdentityAccessService idMgr, ILogger <RemoveChildEnterprise> log) { this.appIoTArch = appIoTArch; this.entMgr = entMgr; this.idMgr = idMgr; this.log = log; }
public GenerateReferenceData(IEnterprisesManagementService entMgr, IIdentityAccessService idMgr, ILogger <GenerateReferenceData> log, IEnterprisesHostingManagerService entHostMgr) { this.entMgr = entMgr; this.entHostMgr = entHostMgr; this.idMgr = idMgr; this.log = log; parentEntLookup = Environment.GetEnvironmentVariable("LCU-ENTERPRISE-LOOKUP"); bypassGenerateRefData = Environment.GetEnvironmentVariable("LCU-BYPASS-GENERATE-REFERENCE-DATA").As <bool>(); }
public Refresh(IApplicationsIoTService appIoTArch, IEnterprisesAPIManagementService entApiArch, IEnterprisesAsCodeService eacSvc, IEnterprisesManagementService entMgr, IEnterprisesHostingManagerService entHostMgr, IIdentityAccessService idMgr, ILogger <Refresh> log, ISecurityDataTokenService secMgr) { this.appIoTArch = appIoTArch; this.entApiArch = entApiArch; this.eacSvc = eacSvc; this.entMgr = entMgr; this.entHostMgr = entHostMgr; this.idMgr = idMgr; this.log = log; this.secMgr = secMgr; }
public virtual async Task CompletePayment(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr, string entLookup, string username, string methodId, string customerName, string plan, int trialPeriodDays, string projectId) { State.CustomerName = customerName; State.PaymentMethodID = methodId; var planOption = this.State.Plans.First(p => p.Lookup == plan); var licenseTypeCore = planOption.Metadata["LicenseType"].ToString(); var licenseTypes = planOption.Metadata.ContainsKey("LicenseTypeOverrides") ? planOption.Metadata["LicenseTypeOverrides"].ToString().Split('|', StringSplitOptions.RemoveEmptyEntries) : new[] { licenseTypeCore }; var completeResp = await entBillingMgr.CompleteStripeSubscription( new CompleteStripeSubscriptionRequest() { CustomerName = State.CustomerName, PaymentMethodID = methodId, Plan = plan, TrialPeriodDays = trialPeriodDays, Username = username }, entLookup, licenseTypeCore); State.PaymentStatus = completeResp.Status; if (State.PaymentStatus.Code == 0) { State.PurchasedPlanLookup = plan; var tosResp = await secMgr.SetDataToken(new DataToken() { Lookup = "LCU-USER-BILLING.TermsOfService", Name = "LCU-USER-BILLING.TermsOfService", Description = "Billing Terms of Service", Value = DateTimeOffset.UtcNow.ToString(), }, entLookup, email : username, projectId : Guid.Parse(projectId)); var eaResp = await secMgr.SetDataToken(new DataToken() { Lookup = "LCU-USER-BILLING.EnterpriseAgreement", Name = "LCU-USER-BILLING.EnterpriseAgreement", Description = "Billing Enterprise Agreement", Value = DateTimeOffset.UtcNow.ToString(), }, entLookup, email : username, projectId : Guid.Parse(projectId)); var licenseResponse = await idMgr.IssueLicense(new License() { Details = JsonConvert.SerializeObject(planOption.Metadata), ExpirationDate = DateTimeOffset.Now.AddYears(50), IsLocked = false }, entLookup, username, projectId, plan, licenseTypeCore); State.PaymentStatus = licenseResponse.Status; State.SubscriptionID = completeResp.SubscriptionID; State.SuccessRedirect = planOption.Metadata["SuccessRedirect"].ToString(); } else { //TODO handle when payment fails but subscription is assigned } }
public SetLicense(IIdentityAccessService idMgr) { this.idMgr = idMgr; }
public ValidateSubscription(IEnterprisesBillingManagerService engMgr, IIdentityAccessService idMgr) { this.engMgr = engMgr; this.idMgr = idMgr; }
public virtual async Task <Status> HandleChargeFailed(IEnterprisesBillingManagerService entBillingMgr, IIdentityAccessService idMgr, string entLookup, string userEmail, Stripe.Event stripeEvent) { string fromEmail = "*****@*****.**"; string supportEmail = "*****@*****.**"; State.SuspendAccountOn = DateTime.Now.AddDays(15); string suspendOnStr = State.SuspendAccountOn.ToString(); State.PaymentStatus = Status.Conflict; log.LogInformation($"Users State {State.ToJSON()}"); var usersLics = await entBillingMgr.GetCustomersIncompleteLicenseTypes(userEmail, entLookup); log.LogInformation($"Users licenses {usersLics}"); if (usersLics.Model.IsNullOrEmpty()) { //existing user with license //email the user that their cc needs to be updated and the charge failed with link to update cc var suspensionNotice = new SendNotificationRequest() { EmailFrom = fromEmail, EmailTo = userEmail, dynamic_template_data = new TemplateDataModel { suspendOn = suspendOnStr }, template_id = "d-b7fb6618e8d3466b94bffd27e5a43f16" }; await SendTemplateEmail(entBillingMgr, entLookup, suspensionNotice); //email fathym support about the card failure var cardFailedNotice = new SendNotificationRequest() { EmailFrom = fromEmail, EmailTo = supportEmail, dynamic_template_data = new TemplateDataModel { userName = userEmail, suspendOn = suspendOnStr }, template_id = "d-8048d19cfc264ca6a364a964d1deec76" }; await SendTemplateEmail(entBillingMgr, entLookup, cardFailedNotice); } if (!usersLics.Model.IsNullOrEmpty()) { //new user signup that failed var ccFailedNotice = new SendNotificationRequest() { EmailFrom = fromEmail, EmailTo = userEmail, dynamic_template_data = new TemplateDataModel { }, template_id = "d-ecd308931cc54e4f91f5d795f323cd95" }; await SendTemplateEmail(entBillingMgr, entLookup, ccFailedNotice); } //TODO automate pause the users account with fathym after 15 day grace period once event is recieved //TODO automate once 15 day grace period has passed suspend the users account and notify the user. return(Status.Success); // throw new NotImplementedException(); }
public virtual async Task UpdateEnterprisesSync(IEnterprisesManagementService entMgr, IApplicationsIoTService appIoTArch, IIdentityAccessService idMgr, string parentEntLookup, int page, int pageSize) { if (State.EnterpriseConfig != null) { State.EnterpriseConfig.Page = page; State.EnterpriseConfig.PageSize = pageSize; await LoadChildEnterprises(entMgr, parentEntLookup, appIoTArch, idMgr); if (State.ActiveEnterpriseConfig != null) { await LoadActiveEnterpriseDetails(appIoTArch, State.ActiveEnterpriseConfig.Page, State.ActiveEnterpriseConfig.PageSize); } } else { throw new Exception("Unable to load the enterprise config, please try again or contact support."); } }
public virtual async Task LoadChildEnterprises(IEnterprisesManagementService entMgr, string parentEntLookup, IApplicationsIoTService appIoTArch, IIdentityAccessService idMgr) { var childEntsResp = await entMgr.ListChildEnterprises(parentEntLookup); State.EnterpriseConfig.TotalChildEnterprisesCount = childEntsResp.Model?.Count; var pagedChildEnts = childEntsResp.Model?.Page(State.EnterpriseConfig.Page, State.EnterpriseConfig.PageSize); var iotChildEnts = new List <IoTEnsembleChildEnterprise>(); await pagedChildEnts.Items.Each(async childEnt => { var devicesResp = await appIoTArch.ListEnrolledDevices(childEnt.Lookup); var licenses = await idMgr.ListLicensesByUsername(parentEntLookup, childEnt.Name, new List <string>() { "iot" }); DateTime?StartDate = null; foreach (License token in licenses.Model) { if (token.AccessStartDate != null) { StartDate = token.AccessStartDate.UtcDateTime; } } var iotChildEnt = new IoTEnsembleChildEnterprise() { Name = childEnt.Name, Lookup = childEnt.Lookup, DeviceCount = devicesResp.Model?.TotalRecords ?? 0, SignUpDate = StartDate }; iotChildEnt.Devices = devicesResp.Model?.Items?.Select(device => { var devInfo = device.JSONConvert <IoTEnsembleDeviceInfo>(); devInfo.DeviceName = devInfo.DeviceID.Replace($"{childEnt.Lookup}-", String.Empty); return(devInfo); }).ToList(); iotChildEnts.Add(iotChildEnt); }); State.EnterpriseConfig.ChildEnterprises = iotChildEnts; }
public virtual async Task Refresh(IEnterprisesBillingManagerService entBillingMgr, IIdentityAccessService idAccessSvc, ISecurityDataTokenService secMgr, string entLookup, string username, string licenseType) { ResetStateCheck(); await LoadBillingPlans(entBillingMgr, entLookup, licenseType); SetUsername(username); await DetermineRequiredOptIns(secMgr, entLookup, username); await ListLicenses(idAccessSvc, entLookup, username, licenseType); }
public virtual async Task <Status> RemoveChildEnterprise(IApplicationsIoTService appIoTArch, IEnterprisesManagementService entMgr, IIdentityAccessService idMgr, string childEntLookup, string parentEntLookup) { var childEnt = State.EnterpriseConfig.ChildEnterprises.FirstOrDefault(ent => ent.Lookup == childEntLookup ); var devices = await appIoTArch.ListEnrolledDevices(childEntLookup); //Remove devices await devices.Model.Items.Each(async d => { await revokeDeviceEnrollment(appIoTArch, childEntLookup, d.DeviceID); }, parallel : true); //If its the active ent set active to null if (State.ActiveEnterpriseConfig.ActiveEnterprise != null && State.ActiveEnterpriseConfig?.ActiveEnterprise.Lookup == childEntLookup) { State.ActiveEnterpriseConfig.ActiveEnterprise = null; } var revokePassportRequest = await idMgr.RevokePassport(parentEntLookup, childEnt.Name); var revokeAccessCardRequest = await idMgr.RevokeAccessCard(new Host.TempRefit.RevokeAccessCardRequest() { AccessConfiguration = "LCU", Username = childEnt.Name }, childEntLookup); if (revokeAccessCardRequest.Status.Code == 1) { log.LogError($"Unable to revoke access cards: {revokeAccessCardRequest.Status.Message}"); } var revokeLicenceAccess = await idMgr.RevokeLicense(parentEntLookup, childEnt.Name, "iot"); if (revokeLicenceAccess.Status.Code == 1) { log.LogError($"Unable to revoke license access: {revokeLicenceAccess.Status.Message}"); } //TODO removing the API Management keys var cancelUserSubscription = await entMgr.CancelSubscriptionByUser(childEnt.Name, parentEntLookup, "iot"); if (cancelUserSubscription.Status.Code == 1) { log.LogError($"Unable to cancel subscription: {cancelUserSubscription.Status.Message}"); } var deleteRequest = await entMgr.DeleteEnterpriseByLookup(childEntLookup, new Host.TempRefit.DeleteEnterpriseByLookupRequest() { Password = "******" }); await LoadChildEnterprises(entMgr, parentEntLookup, appIoTArch, idMgr); return(Status.Success); }
public virtual async Task ChangeSubscription(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr, string entLookup, string username, string customerName, string plan) { //cancel existing subscription var cancelResp = await entBillingMgr.CancelSubscriptionByUser(username, entLookup); var planOption = this.State.Plans.First(p => p.Lookup == plan); var licenseType = planOption.Metadata["LicenseType"].ToString(); //Remove license access await idMgr.RevokeLicense(entLookup, username, licenseType); // create new subscription var completeResp = await entBillingMgr.CompleteStripeSubscription( new CompleteStripeSubscriptionRequest() { CustomerName = State.CustomerName, Plan = plan, Username = username, TrialPeriodDays = 0 }, entLookup, licenseType); State.PaymentStatus = completeResp.Status; if (State.PaymentStatus) { State.PurchasedPlanLookup = plan; var tosResp = await secMgr.SetDataToken(new DataToken() { Lookup = "LCU-USER-BILLING.TermsOfService", Name = "LCU-USER-BILLING.TermsOfService", Description = "Billing Terms of Service", Value = DateTimeOffset.UtcNow.ToString(), }); var eaResp = await secMgr.SetDataToken(new DataToken() { Lookup = "LCU-USER-BILLING.EnterpriseAgreement", Name = "LCU-USER-BILLING.EnterpriseAgreement", Description = "Billing Enterprise Agreement", Value = DateTimeOffset.UtcNow.ToString(), }); //issue new license access // var setLicenseAccessResp = await idMgr.IssueLicenseAccess(new LicenseAccessToken() // { // AccessStartDate = System.DateTime.Now, // Details = planOption.JSONConvert<MetadataModel>(), // EnterpriseLookup = entLookup, // Lookup = licenseType, // TrialPeriodDays = 0, // Username = username // }, entLookup); // var setLicenseAccessResp = await idMgr.IssueLicense(new License() // { // Details = planOption.JSONConvert<string>(), // Lookup = licenseType, // Type = licenseType, // }, entLookup); // State.PaymentStatus = setLicenseAccessResp.Status; State.SubscriptionID = completeResp.SubscriptionID; State.SuccessRedirect = planOption.Metadata["SuccessRedirect"].ToString(); } await ListLicenses(idMgr, entLookup, username, licenseType); State.Loading = false; }
public ListSubcribers(IIdentityAccessService idMgr) { this.idMgr = idMgr; }
public ListLicenses(IIdentityAccessService idMgr) { this.idMgr = idMgr; }