Skip to content

Commit 3cb4cab

Browse files
committed
fix(auth): use strapi links for non-webhook emails
Because: - Some emails that are not triggered by stripe webhooks do not include privacy and terms of service links from the CMS. This commit: - Ensure that planId is populated when generating the CMS links. Closes #PAY-3431
1 parent b146334 commit 3cb4cab

2 files changed

Lines changed: 10 additions & 10 deletions

File tree

packages/fxa-auth-server/lib/senders/email.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2782,7 +2782,7 @@ module.exports = function (log, config, bounces, statsd) {
27822782
};
27832783

27842784
Mailer.prototype.subscriptionPaymentExpiredEmail = async function (message) {
2785-
const { email, uid, planId, acceptLanguage, subscriptions } = message;
2785+
const { email, uid, acceptLanguage, subscriptions } = message;
27862786

27872787
const enabled = config.subscriptions.transactionalEmails.enabled;
27882788
log.trace('mailer.subscriptionPaymentExpired', {
@@ -2817,7 +2817,7 @@ module.exports = function (log, config, bounces, statsd) {
28172817
}
28182818

28192819
const cmsLinks = await this._generateCmsLinks(
2820-
planId,
2820+
subscriptions[0]?.planId,
28212821
acceptLanguage,
28222822
template
28232823
);
@@ -2841,7 +2841,7 @@ module.exports = function (log, config, bounces, statsd) {
28412841
Mailer.prototype.subscriptionPaymentProviderCancelledEmail = async function (
28422842
message
28432843
) {
2844-
const { email, uid, planId, acceptLanguage, subscriptions } = message;
2844+
const { email, uid, acceptLanguage, subscriptions } = message;
28452845

28462846
const enabled = config.subscriptions.transactionalEmails.enabled;
28472847
log.trace('mailer.subscriptionPaymentProviderCancelled', {
@@ -2876,7 +2876,7 @@ module.exports = function (log, config, bounces, statsd) {
28762876
}
28772877

28782878
const cmsLinks = await this._generateCmsLinks(
2879-
planId,
2879+
subscriptions[0]?.planId,
28802880
acceptLanguage,
28812881
template
28822882
);
@@ -3201,7 +3201,7 @@ module.exports = function (log, config, bounces, statsd) {
32013201
};
32023202

32033203
Mailer.prototype.subscriptionEndingReminderEmail = async function (message) {
3204-
const { email, uid, planId, acceptLanguage, subscription } = message;
3204+
const { email, uid, acceptLanguage, subscription } = message;
32053205

32063206
const enabled = config.subscriptions.transactionalEmails.enabled;
32073207
log.trace('mailer.subscriptionEndingReminderEmail', {
@@ -3227,7 +3227,7 @@ module.exports = function (log, config, bounces, statsd) {
32273227
template
32283228
);
32293229
const cmsLinks = await this._generateCmsLinks(
3230-
planId,
3230+
subscription.planId,
32313231
acceptLanguage,
32323232
template
32333233
);
@@ -3280,7 +3280,7 @@ module.exports = function (log, config, bounces, statsd) {
32803280
};
32813281

32823282
Mailer.prototype.subscriptionRenewalReminderEmail = async function (message) {
3283-
const { email, uid, planId, acceptLanguage, subscription } = message;
3283+
const { email, uid, acceptLanguage, subscription } = message;
32843284

32853285
const enabled = config.subscriptions.transactionalEmails.enabled;
32863286
log.trace('mailer.subscriptionRenewalReminderEmail', {
@@ -3306,7 +3306,7 @@ module.exports = function (log, config, bounces, statsd) {
33063306
template
33073307
);
33083308
const cmsLinks = await this._generateCmsLinks(
3309-
planId,
3309+
subscription.planId,
33103310
acceptLanguage,
33113311
template
33123312
);

packages/fxa-auth-server/test/local/senders/emails.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ const MESSAGE = {
140140
productId: 'wibble',
141141
},
142142
subscriptions: [
143-
{ productName: 'Firefox Fortress' },
144-
{ productName: 'Cooking with Foxkeh' },
143+
{ planId: 'plan-example', productName: 'Firefox Fortress' },
144+
{ planId: 'other-plan', productName: 'Cooking with Foxkeh' },
145145
],
146146
showPaymentMethod: true,
147147
discountType: 'forever',

0 commit comments

Comments
 (0)