Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ subscriptionRenewalReminder-content-greeting = Dear { $productName } customer,
# Variables
# $reminderLength (String) - The number of days until the current subscription is set to automatically renew, e.g. 14
subscriptionRenewalReminder-content-intro = Your current subscription is set to automatically renew in { $reminderLength } days.
subscriptionRenewalReminder-content-discount-change = Your next invoice reflects a change in pricing, as a previous discount has ended and a new discount has been applied.
subscriptionRenewalReminder-content-discount-ending = Because a previous discount has ended, your subscription will renew at the standard price.
# Variables
# $invoiceTotal (String) - The amount of the subscription invoice, including currency, e.g. $10.00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@
</mj-text>

<% if (locals.hadDiscount) { %>
<% if (locals.hasRenewalDiscount) { %>
<mj-text css-class="text-body">
<span data-l10n-id="subscriptionRenewalReminder-content-discount-change">
Your next invoice reflects a change in pricing, as a previous discount has ended and a new discount has been applied.
</span>
</mj-text>
<% } else { %>
<mj-text css-class="text-body">
<span data-l10n-id="subscriptionRenewalReminder-content-discount-ending">
Because a previous discount has ended, your subscription will renew at the standard price.
</span>
</mj-text>
<% } %>
<% } %>

<mj-text css-class="text-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ const data = {
subscriptionSupportUrl: 'http://localhost:3030/support',
updateBillingUrl: 'http://localhost:3030/subscriptions',
hadDiscount: false,
hasRenewalDiscount: false,
};

const createStory = subplatStoryWithProps<TemplateData>(
Expand Down Expand Up @@ -58,6 +59,28 @@ export const YearlyPlanDiscountEnding = createStory(
reminderLength: '15',
invoiceTotal: '$199.99',
hadDiscount: true,
hasRenewalDiscount: false,
},
'Yearly Plan - Discount Ending'
);

export const MonthlyPlanDiscountChanging = createStory(
{
hadDiscount: true,
hasRenewalDiscount: true,
invoiceTotal: '$14.00',
},
'Monthly Plan - Discount Changing'
);

export const YearlyPlanDiscountChanging = createStory(
{
planInterval: 'year',
planIntervalCount: '1',
reminderLength: '15',
invoiceTotal: '$139.99',
hadDiscount: true,
hasRenewalDiscount: true,
},
'Yearly Plan - Discount Changing'
);
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ export type TemplateData = SubscriptionSupportContactTemplateData &
subscriptionSupportUrl: string;
updateBillingUrl: string;
hadDiscount?: boolean;
hasRenewalDiscount?: boolean;
};

export const template = 'subscriptionRenewalReminder';
export const version = 3;
export const version = 4;
export const layout = 'subscription';
export const includes = {
subject: {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ subscriptionRenewalReminder-content-greeting = "Dear <%- productName %> customer
subscriptionRenewalReminder-content-intro = "Your current subscription is set to automatically renew in <%- reminderLength %> days."

<% if (locals.hadDiscount) { %>
<% if (locals.hasRenewalDiscount) { %>
subscriptionRenewalReminder-content-discount-change = "Your next invoice reflects a change in pricing, as a previous discount has ended and a new discount has been applied."
<% } else { %>
subscriptionRenewalReminder-content-discount-ending = "Because a previous discount has ended, your subscription will renew at the standard price."
<% } %>
<% } %>

subscriptionRenewalReminder-content-charge = "At that time, Mozilla will renew your <%- planIntervalCount %> <%- planInterval %> subscription and a charge of <%- invoiceTotal %> will be applied to the payment method on your account."
<% } else { %>
subscriptionRenewalReminder-content-charge = "At that time, Mozilla will renew your <%- planIntervalCount %> <%- planInterval %> subscription and a charge of <%- invoiceTotal %> will be applied to the payment method on your account."
<% } %>

<%- include ('/partials/subscriptionUpdateBillingEnsure/index.txt') %>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,8 @@ export class GetInterstitialOfferContentActionResult {
pageContent!: PageContent | null;

@IsString()
reason!: string;
@IsOptional()
reason?: string | null;

@IsOptional()
@IsString()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,6 @@ export class SubscriptionReminders {
/**
* Determine if a discount is ending by checking that the subscription currently
* has a discount but the upcoming invoice does not.
* TODO in PAY-3485: Handle the case where the discount changes without ending.
*/
private hasDiscountEnding(
subscription: Stripe.Subscription,
Expand All @@ -277,6 +276,15 @@ export class SubscriptionReminders {
return !!subscription.discount && !invoicePreview.discount;
}

/**
* Determine if the upcoming invoice has a discount.
*/
private hasRenewalDiscount(
invoicePreview: Stripe.UpcomingInvoice
): boolean {
return !!invoicePreview.discount;
}

/**
* Send out a renewal reminder email if we haven't already sent one.
*/
Expand Down Expand Up @@ -341,6 +349,8 @@ export class SubscriptionReminders {

// Detect if discount is ending
const hadDiscount = this.hasDiscountEnding(subscription, invoicePreview);
// Detect if renewal has a discount
const hasRenewalDiscount = this.hasRenewalDiscount(invoicePreview);

await this.mailer.sendSubscriptionRenewalReminderEmail(
account.emails,
Expand All @@ -359,6 +369,7 @@ export class SubscriptionReminders {
productMetadata: formattedSubscription.productMetadata,
planConfig: formattedSubscription.planConfig,
hadDiscount,
hasRenewalDiscount,
}
);
await this.updateSentEmail(
Expand Down
1 change: 1 addition & 0 deletions packages/fxa-auth-server/lib/senders/email.js
Original file line number Diff line number Diff line change
Expand Up @@ -3253,6 +3253,7 @@ module.exports = function (log, config, bounces, statsd) {
message.acceptLanguage
),
hadDiscount: message.hadDiscount || false,
hasRenewalDiscount: message.hasRenewalDiscount || false,
},
});
};
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"subscriptionReactivation": 2,
"subscriptionRenewalReminder": 3,
"subscriptionRenewalReminder": 4,
"subscriptionEndingReminder": 1,
"subscriptionUpgrade": 7,
"subscriptionDowngrade": 2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ subscriptionRenewalReminder-content-greeting = Dear { $productName } customer,
# Variables
# $reminderLength (String) - The number of days until the current subscription is set to automatically renew, e.g. 14
subscriptionRenewalReminder-content-intro = Your current subscription is set to automatically renew in { $reminderLength } days.
subscriptionRenewalReminder-content-discount-change = Your next invoice reflects a change in pricing, as a previous discount has ended and a new discount has been applied.
subscriptionRenewalReminder-content-discount-ending = Because a previous discount has ended, your subscription will renew at the standard price.
# Variables
# $invoiceTotal (String) - The amount of the subscription invoice, including currency, e.g. $10.00
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,19 @@
</mj-text>

<% if (hadDiscount) { %>
<% if (hasRenewalDiscount) { %>
<mj-text css-class="text-body">
<span data-l10n-id="subscriptionRenewalReminder-content-discount-change">
Your next invoice reflects a change in pricing, as a previous discount has ended and a new discount has been applied.
</span>
</mj-text>
<% } else { %>
<mj-text css-class="text-body">
<span data-l10n-id="subscriptionRenewalReminder-content-discount-ending">
Because a previous discount has ended, your subscription will renew at the standard price.
</span>
</mj-text>
<% } %>
<% } %>

<mj-text css-class="text-body">
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ const createStory = subplatStoryWithProps(
subscriptionSupportUrl: 'http://localhost:3030/support',
updateBillingUrl: 'http://localhost:3030/subscriptions',
hadDiscount: false,
hasRenewalDiscount: false,
}
);

Expand Down Expand Up @@ -54,6 +55,28 @@ export const YearlyPlanDiscountEnding = createStory(
reminderLength: '15',
invoiceTotal: '$199.99',
hadDiscount: true,
hasRenewalDiscount: false,
},
'Yearly Plan - Discount Ending'
);

export const MonthlyPlanDiscountChanging = createStory(
{
hadDiscount: true,
hasRenewalDiscount: true,
invoiceTotal: '$14.00',
},
'Monthly Plan - Discount Changing'
);

export const YearlyPlanDiscountChanging = createStory(
{
planInterval: 'year',
planIntervalCount: '1',
reminderLength: '15',
invoiceTotal: '$139.99',
hadDiscount: true,
hasRenewalDiscount: true,
},
'Yearly Plan - Discount Changing'
);
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,14 @@ subscriptionRenewalReminder-content-greeting = "Dear <%- productName %> customer
subscriptionRenewalReminder-content-intro = "Your current subscription is set to automatically renew in <%- reminderLength %> days."

<% if (hadDiscount) { %>
<% if (hasRenewalDiscount) { %>
subscriptionRenewalReminder-content-discount-change = "Your next invoice reflects a change in pricing, as a previous discount has ended and a new discount has been applied."
<% } else { %>
subscriptionRenewalReminder-content-discount-ending = "Because a previous discount has ended, your subscription will renew at the standard price."
<% } %>
<% } %>

subscriptionRenewalReminder-content-charge = "At that time, Mozilla will renew your <%- planIntervalCount %> <%- planInterval %> subscription and a charge of <%- invoiceTotal %> will be applied to the payment method on your account."
<% } else { %>
subscriptionRenewalReminder-content-charge = "At that time, Mozilla will renew your <%- planIntervalCount %> <%- planInterval %> subscription and a charge of <%- invoiceTotal %> will be applied to the payment method on your account."
<% } %>

<%- include ('/partials/subscriptionUpdateBillingEnsure/index.txt') %>

Expand Down
Loading