Skip to content

Commit 69e8dae

Browse files
committed
fix(emails): Subscription invoice emails have outdate email addresses
Because: * When a customer changes their FxA account email, this change is not propagated through to Stripe * Emails relating to Stripe's invoices pull the customer's email field from their invoice * This causes these emails to contain outdated email addresses This commit: * Because the text of the invoice references the customer receiving the email because there is a Mozilla account with the listed email address, this commit updates the emails to use the account's primary email for these fields. Closes #PAY-3215
1 parent 1a59f7b commit 69e8dae

2 files changed

Lines changed: 9 additions & 0 deletions

File tree

packages/fxa-auth-server/lib/routes/subscriptions/stripe-webhook.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -949,6 +949,7 @@ export class StripeWebhookHandler extends StripeHandler {
949949
{
950950
acceptLanguage: account.locale,
951951
...invoiceDetails,
952+
email: account.primaryEmail
952953
}
953954
);
954955
await this.stripeHelper.updateEmailSent(invoice, 'paymentFailed');
@@ -970,6 +971,7 @@ export class StripeWebhookHandler extends StripeHandler {
970971
{
971972
acceptLanguage: account.locale,
972973
...invoiceDetails,
974+
email: account.primaryEmail
973975
},
974976
];
975977
switch (invoice.billing_reason) {
@@ -1083,6 +1085,7 @@ export class StripeWebhookHandler extends StripeHandler {
10831085
{
10841086
acceptLanguage: account.locale,
10851087
...invoiceDetails,
1088+
email: account.primaryEmail
10861089
}
10871090
);
10881091
} else if (!subscription.cancel_at_period_end) {
@@ -1097,6 +1100,7 @@ export class StripeWebhookHandler extends StripeHandler {
10971100
...invoiceDetails,
10981101
showOutstandingBalance,
10991102
cancelAtEnd: subscription.cancel_at_period_end,
1103+
email: account.primaryEmail
11001104
}
11011105
);
11021106
}

packages/fxa-auth-server/test/local/routes/subscriptions/stripe-webhooks.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2175,6 +2175,7 @@ describe('StripeWebhookHandler', () => {
21752175
{
21762176
acceptLanguage: mockAccount.locale,
21772177
...mockInvoiceDetails,
2178+
email: mockAccount.primaryEmail
21782179
}
21792180
);
21802181
});
@@ -2212,6 +2213,7 @@ describe('StripeWebhookHandler', () => {
22122213
{
22132214
acceptLanguage: mockAccount.locale,
22142215
...mockInvoiceDetails,
2216+
email: mockAccount.primaryEmail
22152217
}
22162218
);
22172219
if (expectedMethodName === 'sendSubscriptionFirstInvoiceEmail') {
@@ -2223,6 +2225,7 @@ describe('StripeWebhookHandler', () => {
22232225
{
22242226
acceptLanguage: mockAccount.locale,
22252227
...mockInvoiceDetails,
2228+
email: mockAccount.primaryEmail
22262229
}
22272230
);
22282231
} else {
@@ -2411,6 +2414,7 @@ describe('StripeWebhookHandler', () => {
24112414
{
24122415
acceptLanguage: mockAccount.locale,
24132416
...mockInvoiceDetails,
2417+
email: mockAccount.primaryEmail
24142418
}
24152419
);
24162420
} else {
@@ -2451,6 +2455,7 @@ describe('StripeWebhookHandler', () => {
24512455
...mockInvoiceDetails,
24522456
showOutstandingBalance: options.hasOutstandingBalance,
24532457
cancelAtEnd: subscription.cancel_at_period_end,
2458+
email: mockAccount.primaryEmail
24542459
}
24552460
);
24562461
} else {

0 commit comments

Comments
 (0)