[MM-44729] Update payment failed email (#20925)
* Update Payment Failed Email * Actually add the mjml file: * Fix mjml indentation * Fix pipelines * Fix translations * Fix translations * Clean up translations Co-authored-by: Mattermod <mattermod@users.noreply.github.com>
Этот коммит содержится в:
43
app/cloud.go
43
app/cloud.go
@@ -40,14 +40,40 @@ func (a *App) getSysAdminsEmailRecipients() ([]*model.User, *model.AppError) {
|
||||
return a.GetUsersFromProfiles(userOptions)
|
||||
}
|
||||
|
||||
func getCurrentPlanName(a *App) (string, *model.AppError) {
|
||||
subscription, err := a.Cloud().GetSubscription("")
|
||||
if err != nil {
|
||||
return "", model.NewAppError("getCurrentPlanName", "app.cloud.get_subscription.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if subscription == nil {
|
||||
return "", model.NewAppError("getCurrentPlanName", "app.cloud.get_subscription.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
products, err := a.Cloud().GetCloudProducts("", false)
|
||||
if err != nil {
|
||||
return "", model.NewAppError("getCurrentPlanName", "app.cloud.get_cloud_products.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if products == nil {
|
||||
return "", model.NewAppError("getCurrentPlanName", "app.cloud.get_cloud_products.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
planName := getCurrentProduct(subscription.ProductID, products).Name
|
||||
return planName, nil
|
||||
}
|
||||
|
||||
func (a *App) SendPaymentFailedEmail(failedPayment *model.FailedPayment) *model.AppError {
|
||||
sysAdmins, err := a.getSysAdminsEmailRecipients()
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
planName, err := getCurrentPlanName(a)
|
||||
if err != nil {
|
||||
return model.NewAppError("SendPaymentFailedEmail", "app.cloud.get_current_plan_name.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
for _, admin := range sysAdmins {
|
||||
_, err := a.Srv().EmailService.SendPaymentFailedEmail(admin.Email, admin.Locale, failedPayment, *a.Config().ServiceSettings.SiteURL)
|
||||
_, err := a.Srv().EmailService.SendPaymentFailedEmail(admin.Email, admin.Locale, failedPayment, planName, *a.Config().ServiceSettings.SiteURL)
|
||||
if err != nil {
|
||||
a.Log().Error("Error sending payment failed email", mlog.Err(err))
|
||||
}
|
||||
@@ -69,6 +95,11 @@ func (a *App) SendDelinquencyEmail(emailToSend model.DelinquencyEmail) *model.Ap
|
||||
if aErr != nil {
|
||||
return aErr
|
||||
}
|
||||
planName, aErr := getCurrentPlanName(a)
|
||||
if aErr != nil {
|
||||
return model.NewAppError("SendDelinquencyEmail", "app.cloud.get_current_plan_name.app_error", nil, aErr.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
subscription, err := a.Cloud().GetSubscription("")
|
||||
if err != nil {
|
||||
return model.NewAppError("SendDelinquencyEmail", "app.cloud.get_subscription.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
@@ -77,16 +108,6 @@ func (a *App) SendDelinquencyEmail(emailToSend model.DelinquencyEmail) *model.Ap
|
||||
return model.NewAppError("SendDelinquencyEmail", "app.cloud.get_subscription.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
products, err := a.Cloud().GetCloudProducts("", false)
|
||||
if err != nil {
|
||||
return model.NewAppError("SendDelinquencyEmail", "app.cloud.get_cloud_products.app_error", nil, err.Error(), http.StatusInternalServerError)
|
||||
}
|
||||
if products == nil {
|
||||
return model.NewAppError("SendDelinquencyEmail", "app.cloud.get_cloud_products.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
planName := getCurrentProduct(subscription.ProductID, products).Name
|
||||
|
||||
if subscription.DelinquentSince == nil {
|
||||
return model.NewAppError("SendDelinquencyEmail", "app.cloud.get_subscription_delinquency_date.app_error", nil, "", http.StatusInternalServerError)
|
||||
}
|
||||
|
||||
@@ -943,24 +943,27 @@ func (es *Service) SendLicenseUpForRenewalEmail(email, name, locale, siteURL, re
|
||||
return nil
|
||||
}
|
||||
|
||||
func (es *Service) SendPaymentFailedEmail(email string, locale string, failedPayment *model.FailedPayment, siteURL string) (bool, error) {
|
||||
func (es *Service) SendPaymentFailedEmail(email string, locale string, failedPayment *model.FailedPayment, planName, siteURL string) (bool, error) {
|
||||
T := i18n.GetUserTranslations(locale)
|
||||
|
||||
subject := T("api.templates.payment_failed.subject")
|
||||
subject := T("api.templates.payment_failed.subject", map[string]any{"Plan": planName})
|
||||
|
||||
data := es.NewEmailTemplateData(locale)
|
||||
data.Props["SiteURL"] = siteURL
|
||||
data.Props["Title"] = T("api.templates.payment_failed.title")
|
||||
data.Props["Info1"] = T("api.templates.payment_failed.info1", map[string]any{"CardBrand": failedPayment.CardBrand, "LastFour": failedPayment.LastFour})
|
||||
data.Props["Info2"] = T("api.templates.payment_failed.info2")
|
||||
data.Props["Info3"] = T("api.templates.payment_failed.info3")
|
||||
data.Props["Button"] = T("api.templates.over_limit_fix_now")
|
||||
data.Props["SubTitle1"] = T("api.templates.payment_failed.info1", map[string]any{"CardBrand": failedPayment.CardBrand, "LastFour": failedPayment.LastFour})
|
||||
data.Props["SubTitle2"] = T("api.templates.payment_failed.info2")
|
||||
data.Props["FailedReason"] = failedPayment.FailureMessage
|
||||
data.Props["SubTitle3"] = T("api.templates.payment_failed.info3", map[string]any{"Plan": planName})
|
||||
data.Props["QuestionTitle"] = T("api.templates.questions_footer.title")
|
||||
data.Props["QuestionInfo"] = T("api.templates.questions_footer.info")
|
||||
data.Props["SupportEmail"] = *es.config().SupportSettings.SupportEmail
|
||||
data.Props["Button"] = T("api.templates.delinquency_45.button")
|
||||
data.Props["IncludeSecondaryActionButton"] = false
|
||||
data.Props["EmailUs"] = T("api.templates.email_us_anytime_at")
|
||||
|
||||
data.Props["Footer"] = T("api.templates.copyright")
|
||||
|
||||
data.Props["FailedReason"] = failedPayment.FailureMessage
|
||||
|
||||
body, err := es.templatesContainer.RenderToString("payment_failed_body", data)
|
||||
if err != nil {
|
||||
return false, err
|
||||
|
||||
@@ -463,20 +463,20 @@ func (_m *ServiceInterface) SendPasswordResetEmail(_a0 string, token *model.Toke
|
||||
return r0, r1
|
||||
}
|
||||
|
||||
// SendPaymentFailedEmail provides a mock function with given fields: _a0, locale, failedPayment, siteURL
|
||||
func (_m *ServiceInterface) SendPaymentFailedEmail(_a0 string, locale string, failedPayment *model.FailedPayment, siteURL string) (bool, error) {
|
||||
ret := _m.Called(_a0, locale, failedPayment, siteURL)
|
||||
// SendPaymentFailedEmail provides a mock function with given fields: _a0, locale, failedPayment, planName, siteURL
|
||||
func (_m *ServiceInterface) SendPaymentFailedEmail(_a0 string, locale string, failedPayment *model.FailedPayment, planName string, siteURL string) (bool, error) {
|
||||
ret := _m.Called(_a0, locale, failedPayment, planName, siteURL)
|
||||
|
||||
var r0 bool
|
||||
if rf, ok := ret.Get(0).(func(string, string, *model.FailedPayment, string) bool); ok {
|
||||
r0 = rf(_a0, locale, failedPayment, siteURL)
|
||||
if rf, ok := ret.Get(0).(func(string, string, *model.FailedPayment, string, string) bool); ok {
|
||||
r0 = rf(_a0, locale, failedPayment, planName, siteURL)
|
||||
} else {
|
||||
r0 = ret.Get(0).(bool)
|
||||
}
|
||||
|
||||
var r1 error
|
||||
if rf, ok := ret.Get(1).(func(string, string, *model.FailedPayment, string) error); ok {
|
||||
r1 = rf(_a0, locale, failedPayment, siteURL)
|
||||
if rf, ok := ret.Get(1).(func(string, string, *model.FailedPayment, string, string) error); ok {
|
||||
r1 = rf(_a0, locale, failedPayment, planName, siteURL)
|
||||
} else {
|
||||
r1 = ret.Error(1)
|
||||
}
|
||||
|
||||
@@ -142,7 +142,7 @@ type ServiceInterface interface {
|
||||
SendNotificationMail(to, subject, htmlBody string) error
|
||||
SendMailWithEmbeddedFiles(to, subject, htmlBody string, embeddedFiles map[string]io.Reader, messageID string, inReplyTo string, references string) error
|
||||
SendLicenseUpForRenewalEmail(email, name, locale, siteURL, renewalLink string, daysToExpiration int) error
|
||||
SendPaymentFailedEmail(email string, locale string, failedPayment *model.FailedPayment, siteURL string) (bool, error)
|
||||
SendPaymentFailedEmail(email string, locale string, failedPayment *model.FailedPayment, planName, siteURL string) (bool, error)
|
||||
// Cloud delinquency email sequence
|
||||
SendDelinquencyEmail7(email, locale, siteURL, planName string) error
|
||||
SendDelinquencyEmail14(email, locale, siteURL, planName string) error
|
||||
|
||||
Ссылка в новой задаче
Block a user