Merge pull request #1311 from ONLYOFFICE/feature/payment-notify

Feature/payment notify
This commit is contained in:
Alexey Bannov 2023-03-20 13:52:15 +03:00 committed by GitHub
commit 20e5829e13
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 299 additions and 6 deletions

View File

@ -40,4 +40,5 @@ public interface ITariffService
void SetTariff(int tenantId, Tariff tariff);
Uri GetAccountLink(int tenant, string backUrl);
Task<bool> PaymentChange(int tenant, Dictionary<string, int> quantity);
int GetPaymentDelay();
}

View File

@ -940,4 +940,9 @@ public class TariffService : ITariffService
}
}
}
public int GetPaymentDelay()
{
return _paymentDelay;
}
}

View File

@ -147,4 +147,9 @@ public static class Actions
public static readonly INotifyAction EnterpriseAdminUserAppsTipsV1 = new NotifyAction("enterprise_admin_user_apps_tips_v1");
public static readonly INotifyAction RoomsActivity = new NotifyAction("rooms_activity", "rooms activity");
public static readonly INotifyAction SaasOwnerPaymentWarningGracePeriodBeforeActivation = new NotifyAction("saas_owner_payment_warning_grace_period_before_activation");
public static readonly INotifyAction SaasOwnerPaymentWarningGracePeriodActivation = new NotifyAction("saas_owner_payment_warning_grace_period_activation");
public static readonly INotifyAction SaasOwnerPaymentWarningGracePeriodLastDay = new NotifyAction("saas_owner_payment_warning_grace_period_last_day");
public static readonly INotifyAction SaasOwnerPaymentWarningGracePeriodExpired = new NotifyAction("saas_owner_payment_warning_grace_period_expired");
}

View File

@ -677,7 +677,7 @@ public class StudioNotifyService
}
tagValues.Add(new TagValue(Tags.UserName, newUserInfo.FirstName.HtmlEncode()));
tagValues.Add(new TagValue(Tags.PricingPage, _commonLinkUtility.GetFullAbsolutePath("~/payments")));
tagValues.Add(new TagValue(Tags.PricingPage, _commonLinkUtility.GetFullAbsolutePath("~/portal-settings/payments/portal-payments")));
_client.SendNoticeToAsync(
notifyAction,

View File

@ -145,7 +145,12 @@ public class StudioNotifySource : NotifySource
Actions.SaasUserActivationV1,
Actions.EnterpriseUserActivationV1,
Actions.EnterpriseWhitelabelUserActivationV1,
Actions.OpensourceUserActivationV1
Actions.OpensourceUserActivationV1,
Actions.SaasOwnerPaymentWarningGracePeriodBeforeActivation,
Actions.SaasOwnerPaymentWarningGracePeriodActivation,
Actions.SaasOwnerPaymentWarningGracePeriodLastDay,
Actions.SaasOwnerPaymentWarningGracePeriodExpired
);
}

View File

@ -23,7 +23,7 @@
// All the Product's GUI elements, including illustrations and icon sets, as well as technical writing
// content are licensed under the terms of the Creative Commons Attribution-ShareAlike 4.0
// International. See the License terms at http://creativecommons.org/licenses/by-sa/4.0/legalcode
namespace ASC.Web.Studio.Core.Notify;
[Scope]
@ -127,6 +127,7 @@ public class StudioPeriodicNotify
var toadmins = false;
var tousers = false;
var toowner = false;
var topayer = false;
Func<string> greenButtonText = () => string.Empty;
var greenButtonUrl = string.Empty;
@ -215,10 +216,62 @@ public class StudioPeriodicNotify
else if (tariff.State >= TariffState.Paid)
{
#region Payment warning letters
#region 3 days before grace period
if (dueDateIsNotMax && dueDate.AddDays(-3) == nowDate)
{
action = Actions.SaasOwnerPaymentWarningGracePeriodBeforeActivation;
toowner = true;
topayer = true;
greenButtonText = () => WebstudioNotifyPatternResource.ButtonVisitPaymentsSection;
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/portal-settings/payments/portal-payments");
}
#endregion
#region grace period activation
else if (dueDateIsNotMax && dueDate == nowDate)
{
action = Actions.SaasOwnerPaymentWarningGracePeriodActivation;
toowner = true;
topayer = true;
greenButtonText = () => WebstudioNotifyPatternResource.ButtonVisitPaymentsSection;
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/portal-settings/payments/portal-payments");
}
#endregion
#region grace period last day
else if (tariff.State == TariffState.Delay && delayDueDateIsNotMax && delayDueDate.AddDays(-1) == nowDate)
{
action = Actions.SaasOwnerPaymentWarningGracePeriodLastDay;
toowner = true;
topayer = true;
greenButtonText = () => WebstudioNotifyPatternResource.ButtonVisitPaymentsSection;
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/portal-settings/payments/portal-payments");
}
#endregion
#region grace period expired
else if (tariff.State == TariffState.Delay && delayDueDateIsNotMax && delayDueDate == nowDate)
{
action = Actions.SaasOwnerPaymentWarningGracePeriodExpired;
toowner = true;
topayer = true;
greenButtonText = () => WebstudioNotifyPatternResource.ButtonVisitPaymentsSection;
greenButtonUrl = _commonLinkUtility.GetFullAbsolutePath("~/portal-settings/payments/portal-payments");
}
#endregion
#region 6 months after SAAS PAID expired
if (tariff.State == TariffState.NotPaid && dueDateIsNotMax && dueDate.AddMonths(6) == nowDate)
else if (tariff.State == TariffState.NotPaid && dueDateIsNotMax && dueDate.AddMonths(6) == nowDate)
{
action = Actions.SaasAdminTrialWarningAfterHalfYearV1;
toowner = true;
@ -258,6 +311,17 @@ public class StudioPeriodicNotify
? new List<UserInfo> { _userManager.GetUsers(tenant.OwnerId) }
: _studioNotifyHelper.GetRecipients(toadmins, tousers, false);
if (topayer)
{
var payerId = _tariffService.GetTariff(tenant.Id).CustomerId;
var payer = _userManager.GetUserByEmail(payerId);
if (payer.Id != ASC.Core.Users.Constants.LostUser.Id && !users.Any(u => u.Id == payer.Id))
{
users = users.Concat(new[] { payer });
}
}
foreach (var u in users.Where(u => paymentMessage || _studioNotifyHelper.IsSubscribedToNotify(u, Actions.PeriodicNotify)))
{
var culture = string.IsNullOrEmpty(u.CultureName) ? tenant.GetCulture() : u.GetCulture();
@ -276,6 +340,7 @@ public class StudioPeriodicNotify
new TagValue(Tags.DueDate, dueDate.ToLongDateString()),
new TagValue(Tags.DelayDueDate, (delayDueDateIsNotMax ? delayDueDate : dueDate).ToLongDateString()),
TagValues.GreenButton(greenButtonText, greenButtonUrl),
new TagValue(Tags.PaymentDelay, _tariffService.GetPaymentDelay()),
new TagValue(CommonTags.Footer, _userManager.IsDocSpaceAdmin(u) ? "common" : "social"));
}
}

View File

@ -66,6 +66,7 @@ public static class Tags
public const string BlogLink = "TagBlogLink";
public const string DueDate = "DueDate";
public const string DelayDueDate = "DelayDueDate";
public const string PaymentDelay = "PaymentDelay";
public const string LinkToRecovery = "LinkToRecovery";
public const string FromUserName = "FromUserName";

View File

@ -600,6 +600,15 @@ namespace ASC.Web.Core.PublicResources {
}
}
/// <summary>
/// Looks up a localized string similar to Visit Payments Section.
/// </summary>
public static string ButtonVisitPaymentsSection {
get {
return ResourceManager.GetString("ButtonVisitPaymentsSection", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Learn More &gt;&gt;.
/// </summary>
@ -2035,6 +2044,82 @@ namespace ASC.Web.Core.PublicResources {
}
}
/// <summary>
/// Looks up a localized string similar to Hello, $UserName!
///
///Please take into consideration that the grace period of $PaymentDelay days for your ONLYOFFICE DocSpace is activated.
///
///Make sure to pay your Business subscription before the grace period is due. Thus, you will be able to further use all the benefits of your ONLYOFFICE DocSpace.
///
///$GreenButton
///
///Truly yours,
///ONLYOFFICE Team
///&quot;www.onlyoffice.com&quot;:&quot;https://onlyoffice.com/&quot;.
/// </summary>
public static string pattern_saas_owner_payment_warning_grace_period_activation {
get {
return ResourceManager.GetString("pattern_saas_owner_payment_warning_grace_period_activation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hello, $UserName!
///
///Please take into consideration that your ONLYOFFICE DocSpace subscription expires in three days. After that, the grace period of $PaymentDelay days will be activated.
///
///We recommend paying your Business subscription now and continue to use all the benefits of your ONLYOFFICE DocSpace.
///
///$GreenButton
///
///Truly yours,
///ONLYOFFICE Team
///&quot;www.onlyoffice.com&quot;:&quot;https://onlyoffice.com/&quot;.
/// </summary>
public static string pattern_saas_owner_payment_warning_grace_period_before_activation {
get {
return ResourceManager.GetString("pattern_saas_owner_payment_warning_grace_period_before_activation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hello, $UserName!
///
///Please take into consideration that the grace period of $PaymentDelay days for your ONLYOFFICE DocSpace is over.
///
///Make sure to pay your Business subscription as soon as possible. Thus, you will be able to use all the benefits of your ONLYOFFICE DocSpace as before.
///
///$GreenButton
///
///Truly yours,
///ONLYOFFICE Team
///&quot;www.onlyoffice.com&quot;:&quot;https://onlyoffice.com/&quot;.
/// </summary>
public static string pattern_saas_owner_payment_warning_grace_period_expired {
get {
return ResourceManager.GetString("pattern_saas_owner_payment_warning_grace_period_expired", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hello, $UserName!
///
///Please take into consideration that the grace period of $PaymentDelay days for your ONLYOFFICE DocSpace will expire tomorrow.
///
///Make sure to pay your Business subscription today. Thus, you will be able to further use all the benefits of your ONLYOFFICE DocSpace.
///
///$GreenButton
///
///Truly yours,
///ONLYOFFICE Team
///&quot;www.onlyoffice.com&quot;:&quot;https://onlyoffice.com/&quot;.
/// </summary>
public static string pattern_saas_owner_payment_warning_grace_period_last_day {
get {
return ResourceManager.GetString("pattern_saas_owner_payment_warning_grace_period_last_day", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Hello!
///
@ -2873,6 +2958,42 @@ namespace ASC.Web.Core.PublicResources {
}
}
/// <summary>
/// Looks up a localized string similar to Grace period for your ONLYOFFICE DocSpace activated.
/// </summary>
public static string subject_saas_owner_payment_warning_grace_period_activation {
get {
return ResourceManager.GetString("subject_saas_owner_payment_warning_grace_period_activation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Your ONLYOFFICE DocSpace subscription is about to expire.
/// </summary>
public static string subject_saas_owner_payment_warning_grace_period_before_activation {
get {
return ResourceManager.GetString("subject_saas_owner_payment_warning_grace_period_before_activation", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Grace period for your ONLYOFFICE DocSpace expired.
/// </summary>
public static string subject_saas_owner_payment_warning_grace_period_expired {
get {
return ResourceManager.GetString("subject_saas_owner_payment_warning_grace_period_expired", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Grace period for your ONLYOFFICE DocSpace expires tomorrow.
/// </summary>
public static string subject_saas_owner_payment_warning_grace_period_last_day {
get {
return ResourceManager.GetString("subject_saas_owner_payment_warning_grace_period_last_day", resourceCulture);
}
}
/// <summary>
/// Looks up a localized string similar to Join ONLYOFFICE DocSpace.
/// </summary>

View File

@ -1862,4 +1862,71 @@ ONLYOFFICE Team
<data name="ActionUserUpdated" xml:space="preserve">
<value>DocSpace user updated: &lt;b&gt;{0} ({1})&lt;/b&gt; - &lt;b&gt;{2}&lt;/b&gt;</value>
</data>
<data name="ButtonVisitPaymentsSection" xml:space="preserve">
<value>Visit Payments Section</value>
</data>
<data name="pattern_saas_owner_payment_warning_grace_period_activation" xml:space="preserve">
<value>Hello, $UserName!
Please take into consideration that the grace period of $PaymentDelay days for your ONLYOFFICE DocSpace is activated.
Make sure to pay your Business subscription before the grace period is due. Thus, you will be able to further use all the benefits of your ONLYOFFICE DocSpace.
$GreenButton
Truly yours,
ONLYOFFICE Team
"www.onlyoffice.com":"https://onlyoffice.com/"</value>
</data>
<data name="pattern_saas_owner_payment_warning_grace_period_before_activation" xml:space="preserve">
<value>Hello, $UserName!
Please take into consideration that your ONLYOFFICE DocSpace subscription expires in three days. After that, the grace period of $PaymentDelay days will be activated.
We recommend paying your Business subscription now and continue to use all the benefits of your ONLYOFFICE DocSpace.
$GreenButton
Truly yours,
ONLYOFFICE Team
"www.onlyoffice.com":"https://onlyoffice.com/"</value>
</data>
<data name="pattern_saas_owner_payment_warning_grace_period_expired" xml:space="preserve">
<value>Hello, $UserName!
Please take into consideration that the grace period of $PaymentDelay days for your ONLYOFFICE DocSpace is over.
Make sure to pay your Business subscription as soon as possible. Thus, you will be able to use all the benefits of your ONLYOFFICE DocSpace as before.
$GreenButton
Truly yours,
ONLYOFFICE Team
"www.onlyoffice.com":"https://onlyoffice.com/"</value>
</data>
<data name="pattern_saas_owner_payment_warning_grace_period_last_day" xml:space="preserve">
<value>Hello, $UserName!
Please take into consideration that the grace period of $PaymentDelay days for your ONLYOFFICE DocSpace will expire tomorrow.
Make sure to pay your Business subscription today. Thus, you will be able to further use all the benefits of your ONLYOFFICE DocSpace.
$GreenButton
Truly yours,
ONLYOFFICE Team
"www.onlyoffice.com":"https://onlyoffice.com/"</value>
</data>
<data name="subject_saas_owner_payment_warning_grace_period_activation" xml:space="preserve">
<value>Grace period for your ONLYOFFICE DocSpace activated</value>
</data>
<data name="subject_saas_owner_payment_warning_grace_period_before_activation" xml:space="preserve">
<value>Your ONLYOFFICE DocSpace subscription is about to expire</value>
</data>
<data name="subject_saas_owner_payment_warning_grace_period_expired" xml:space="preserve">
<value>Grace period for your ONLYOFFICE DocSpace expired</value>
</data>
<data name="subject_saas_owner_payment_warning_grace_period_last_day" xml:space="preserve">
<value>Grace period for your ONLYOFFICE DocSpace expires tomorrow</value>
</data>
</root>

View File

@ -522,6 +522,29 @@ $activity.Key
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_saas_admin_user_apps_tips_v1|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
</pattern>
<!-- saas owner payment warning grace period before activation for DocSpace -->
<pattern id="saas_owner_payment_warning_grace_period_before_activation">
<subject resource="|subject_saas_owner_payment_warning_grace_period_before_activation|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_saas_owner_payment_warning_grace_period_before_activation|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
</pattern>
<!-- saas owner payment warning grace period activation for DocSpace -->
<pattern id="saas_owner_payment_warning_grace_period_activation">
<subject resource="|subject_saas_owner_payment_warning_grace_period_activation|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_saas_owner_payment_warning_grace_period_activation|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
</pattern>
<!-- saas owner payment warning grace period last day for DocSpace -->
<pattern id="saas_owner_payment_warning_grace_period_last_day">
<subject resource="|subject_saas_owner_payment_warning_grace_period_last_day|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_saas_owner_payment_warning_grace_period_last_day|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
</pattern>
<!-- saas owner payment warning grace period expired for DocSpace -->
<pattern id="saas_owner_payment_warning_grace_period_expired">
<subject resource="|subject_saas_owner_payment_warning_grace_period_expired|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
<body styler="ASC.Notify.Textile.TextileStyler,ASC.Notify.Textile" resource="|pattern_saas_owner_payment_warning_grace_period_expired|ASC.Web.Core.PublicResources.WebstudioNotifyPatternResource,ASC.Web.Core" />
</pattern>
<!-- saas admin trial warning after half year v1 for DocSpace -->
<pattern id="saas_admin_trial_warning_after_half_year_v1">