public ChangeSubscription(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.entBillingMgr = entBillingMgr; this.idMgr = idMgr; this.secMgr = secMgr; }
public ResetStateCheck(IEnterprisesBillingManagerService entBillingMgr, IIdentityAccessService idMgr, ISecurityDataTokenService secMgr) { this.entBillingMgr = entBillingMgr; this.idMgr = idMgr; this.secMgr = secMgr; }
public CompletePayment(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.entBillingMgr = entBillingMgr; this.idMgr = idMgr; this.secMgr = secMgr; }
public BillingStripeWebhook(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, IIdentityAccessService idMgr) { this.entBillingMgr = entBillingMgr; this.secMgr = secMgr; this.idMgr = idMgr; }
public Refresh(IEnterprisesBillingManagerService entBillingMgr, IIdentityAccessService idAccessSvc, ISecurityDataTokenService secMgr) { this.entBillingMgr = entBillingMgr; this.idAccessSvc = idAccessSvc; this.secMgr = secMgr; }
// public virtual async Task<Status> SendNotification(IEnterprisesBillingManagerService entMgr, string entLookup, string username, SendNotificationRequest notification) // { // // Send email from app manager client // var model = new MetadataModel(); // model.Metadata.Add(new KeyValuePair<string, JToken>("SendNotificationRequest", JToken.Parse(JsonConvert.SerializeObject(notification)))); // await entMgr.SendNotificationEmail(model, entLookup); // return Status.Success; // } public virtual async Task <Status> SendTemplateEmail(IEnterprisesBillingManagerService entBillingMgr, string entLookup, SendNotificationRequest notification) { // Send email from app manager client var model = new MetadataModel(); model.Metadata.Add(new KeyValuePair <string, JToken>("TemplateEmail", JToken.Parse(JsonConvert.SerializeObject(notification)))); // await entBillingMgr.SendTemplateEmail(model, entLookup); return(Status.Success); }
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 LoadBillingPlans(IEnterprisesBillingManagerService entBillingMgr, string entLookup, string licenseType) { var plansResp = await entBillingMgr.ListBillingPlanOptions(entLookup, licenseType); State.Plans = plansResp.Model ?? new List <API.UserManagement.Host.TempRefit.BillingPlanOption>(); State.FeaturedPlanGroup = State.Plans.FirstOrDefault(plan => { return(plan.Metadata.ContainsKey("Featured") && plan.Metadata["Featured"].ToObject <bool>()); })?.PlanGroup; State.PopularPlanGroup = State.Plans.FirstOrDefault(plan => { return(plan.Metadata.ContainsKey("Popular") && plan.Metadata["Popular"].ToObject <bool>()); })?.PlanGroup; }
public virtual async Task UpdatePaymentInfo(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr, string entLookup, string username, string methodId, string customerName) { State.CustomerName = customerName; State.PaymentMethodID = methodId; var updateResp = await entBillingMgr.UpdateStripeSubscription(entLookup, new UpdateStripeSubscriptionRequest() { CustomerName = State.CustomerName, PaymentMethodID = methodId, Username = username }); State.PaymentStatus = updateResp.Status; if (State.PaymentStatus) { 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(), }); } }
public SendFeedback(IEnterprisesBillingManagerService entMgr) { this.entMgr = entMgr; }
public ValidateSubscription(IEnterprisesBillingManagerService engMgr, IIdentityAccessService idMgr) { this.engMgr = engMgr; this.idMgr = idMgr; }
public SetOrganizationDetails(IEnterprisesBillingManagerService entMgr) { this.entMgr = entMgr; }
public LoadSubscriptionDetails(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr) { this.entBillingMgr = entBillingMgr; 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 SendNotification(IEnterprisesBillingManagerService entMgr) { this.entMgr = entMgr; }
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 ConfigureInfrastructure(EnterpriseArchitectClient entArch, IEnterprisesBillingManagerService entMgr) { this.entArch = entArch; this.entMgr = entMgr; }
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 ListBillingOptions(IEnterprisesBillingManagerService entBillingMgr) { this.entBillingMgr = entBillingMgr; }
public UpdatePaymentInfo(IEnterprisesBillingManagerService entBillingMgr, ISecurityDataTokenService secMgr) { this.entBillingMgr = entBillingMgr; this.secMgr = secMgr; }