зеркало из https://github.com/mozilla/fxa.git
Merge pull request #15508 from mozilla/FXA-6691
feat(payments): remove same billing copy from subscription upgrade
This commit is contained in:
Коммит
dbe37a69e6
|
@ -3156,9 +3156,6 @@ export class StripeHelper extends StripeHelperBase {
|
|||
|
||||
const productPaymentCycleOld = this.stripePlanToPaymentCycle(planOld);
|
||||
|
||||
const sameBillingCycle =
|
||||
productPaymentCycleOld === baseDetails.productPaymentCycleNew;
|
||||
|
||||
// get next invoice details
|
||||
const nextInvoice = upcomingInvoiceWithInvoiceItem
|
||||
? upcomingInvoiceWithInvoiceItem
|
||||
|
@ -3185,13 +3182,26 @@ export class StripeHelper extends StripeHelperBase {
|
|||
tax_amounts: upcomingInvoiceTaxAmounts,
|
||||
} = upcomingInvoiceLineItem || {};
|
||||
|
||||
const {
|
||||
productPaymentCycleNew: productPaymentCycleNew,
|
||||
invoiceTotalOldInCents: invoiceTotalOldInCents,
|
||||
} = baseDetails;
|
||||
|
||||
// remove everything between asterisk in FXA-7796
|
||||
// **************** //
|
||||
const sameBillingCycle = productPaymentCycleOld === productPaymentCycleNew;
|
||||
const sameBillingCondition = sameBillingCycle && !!upcomingInvoiceLineItem;
|
||||
|
||||
const invoiceImmediately =
|
||||
this.config.subscriptions.stripeInvoiceImmediately.enabled;
|
||||
|
||||
// used for newTotalInCents
|
||||
const newListPriceTotalWithoutTax =
|
||||
sameBillingCondition && !!upcomingInvoiceAmount
|
||||
? upcomingInvoiceAmount
|
||||
: undefined;
|
||||
|
||||
// used for newTotalInCents
|
||||
const newListPriceDiscounts =
|
||||
(sameBillingCondition &&
|
||||
upcomingInvoiceDiscountAmounts?.reduce(
|
||||
|
@ -3201,6 +3211,7 @@ export class StripeHelper extends StripeHelperBase {
|
|||
)) ||
|
||||
0;
|
||||
|
||||
// used for newTotalInCents
|
||||
const newListPriceTotalTaxes = sameBillingCondition
|
||||
? upcomingInvoiceTaxAmounts?.reduce(
|
||||
(acc, tax) => (tax.inclusive ? acc + 0 : acc + tax.amount),
|
||||
|
@ -3231,7 +3242,8 @@ export class StripeHelper extends StripeHelperBase {
|
|||
// else get current invoiceTotal
|
||||
const oldTotalInCents = sameBillingCycle
|
||||
? invoiceTotalNewInCents
|
||||
: baseDetails.invoiceTotalOldInCents;
|
||||
: invoiceTotalOldInCents;
|
||||
// **************** //
|
||||
|
||||
return {
|
||||
...baseDetails,
|
||||
|
@ -3240,14 +3252,25 @@ export class StripeHelper extends StripeHelperBase {
|
|||
productNameOld,
|
||||
productIconURLOld,
|
||||
productPaymentCycleOld,
|
||||
paymentAmountOldInCents: oldTotalInCents,
|
||||
// remove condition and keep invoiceTotalOldInCents as value in FXA-7796
|
||||
paymentAmountOldInCents: !invoiceImmediately
|
||||
? oldTotalInCents
|
||||
: invoiceTotalOldInCents,
|
||||
paymentAmountOldCurrency: planOld.currency,
|
||||
paymentAmountNewInCents: newTotalInCents,
|
||||
// remove condition and keep nextInvoiceTotal as value in FXA-7796
|
||||
paymentAmountNewInCents: !invoiceImmediately
|
||||
? newTotalInCents
|
||||
: nextInvoiceTotal,
|
||||
paymentAmountNewCurrency: nextInvoiceCurrency,
|
||||
invoiceNumber,
|
||||
invoiceId,
|
||||
paymentProratedInCents: paymentProratedInCents,
|
||||
// remove condition and keep invoiceAmountDue as value in FXA-7796
|
||||
paymentProratedInCents: !invoiceImmediately
|
||||
? paymentProratedInCents
|
||||
: invoiceAmountDue,
|
||||
paymentProratedCurrency,
|
||||
// remove in FXA-7796
|
||||
invoiceImmediately: invoiceImmediately,
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -2,18 +2,22 @@
|
|||
# $productName (String) - The name of the subscribed product, e.g. Mozilla VPN
|
||||
subscriptionUpgrade-subject = You have upgraded to { $productName }
|
||||
subscriptionUpgrade-title = Thank you for upgrading!
|
||||
|
||||
# Variables:
|
||||
# $productNameOld (String) - The name of the previously subscribed product, e.g. Mozilla VPN
|
||||
# $productName (String) - The name of the new subscribed product, e.g. Mozilla VPN
|
||||
subscriptionUpgrade-upgrade-info = You have successfully upgraded from { $productNameOld } to { $productName }.
|
||||
|
||||
# Variables:
|
||||
# $paymentAmountOld (String) - The amount of the previous subscription payment, including currency, e.g. $10.00
|
||||
# $paymentAmountNew (String) - The amount of the new subscription payment, including currency, e.g. $10.00
|
||||
# $productPaymentCycleNew (String) - The interval of time from the end of one payment statement date to the next payment statement date of the new subscription, e.g. month
|
||||
# $productPaymentCycleOld (String) - The interval of time from the end of one payment statement date to the next payment statement date of the old subscription, e.g. month
|
||||
# $paymentProrated (String) - The one time fee to reflect the higher charge for the remainder of the payment cycle, including currency, e.g. $10.00
|
||||
# remove subscriptionUpgrade-content-charge-info in FXA-7796; additionally remove in subscriptionUpgrade/index.txt
|
||||
subscriptionUpgrade-content-charge-info = Starting with your next bill, your charge will change from { $paymentAmountOld } per { $productPaymentCycleOld } to { $paymentAmountNew } per { $productPaymentCycleNew }. At that time you will also be charged a one-time fee of { $paymentProrated } to reflect the higher charge for the remainder of this { $productPaymentCycleOld }.
|
||||
subscriptionUpgrade-content-charge-info-different-cycle = You will be charged a one-time fee of { $paymentProrated } to reflect your subscription’s higher price for the remainder of this { $productPaymentCycleOld }. Starting with your next bill, your charge will change from { $paymentAmountOld } per { $productPaymentCycleOld } to { $paymentAmountNew } per { $productPaymentCycleNew }.
|
||||
|
||||
# Variables:
|
||||
# $productName (String) - The name of the new subscribed product, e.g. Mozilla VPN
|
||||
subscriptionUpgrade-install = If there is new software for you to install in order to use { $productName }, you will receive a separate email with download instructions.
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
</mj-text>
|
||||
|
||||
<mj-text css-class="text-body">
|
||||
<% if (locals.productPaymentCycleOld === locals.productPaymentCycleNew) { %>
|
||||
<% if (!locals.invoiceImmediately && locals.productPaymentCycleOld === locals.productPaymentCycleNew) { %>
|
||||
<span data-l10n-id="subscriptionUpgrade-content-charge-info" data-l10n-args="<%= JSON.stringify({paymentAmountNew, paymentAmountOld, paymentProrated, productPaymentCycleNew, productPaymentCycleOld}) %>">Starting with your next bill, your charge will change from <%- paymentAmountOld %> per <%- productPaymentCycleOld %> to <%- paymentAmountNew %> per <%- productPaymentCycleNew %>. At that time you will also be charged a one-time fee of <%- paymentProrated %> to reflect the higher charge for the remainder of this <%- productPaymentCycleOld %>.</span>
|
||||
<% } else { %>
|
||||
<span data-l10n-id="subscriptionUpgrade-content-charge-info-different-cycle" data-l10n-args="<%= JSON.stringify({paymentAmountNew, paymentAmountOld, paymentProrated, productPaymentCycleNew, productPaymentCycleOld}) %>">You will be charged a one-time fee of <%- paymentProrated %> to reflect your subscription’s higher price for the remainder of this <%- productPaymentCycleOld %>. Starting with your next bill, your charge will change from <%- paymentAmountOld %> per <%- productPaymentCycleOld %> to <%- paymentAmountNew %> per <%- productPaymentCycleNew %>.</span>
|
||||
|
|
|
@ -13,32 +13,36 @@ const createStory = subplatStoryWithProps(
|
|||
'subscriptionUpgrade',
|
||||
'Sent when a user upgrades their subscription.',
|
||||
{
|
||||
paymentAmountNew: '£123,121.00',
|
||||
paymentAmountOld: '¥99,991',
|
||||
paymentAmountNew: '$69.89',
|
||||
paymentAmountOld: '$9.89',
|
||||
productIconURLNew:
|
||||
'https://accounts-static.cdn.mozilla.net/product-icons/mozilla-vpn-email.png',
|
||||
productIconURLOld:
|
||||
'https://accounts-static.cdn.mozilla.net/product-icons/mozilla-vpn-email.png',
|
||||
productName: 'Product Name B',
|
||||
productNameOld: 'Product Name A',
|
||||
productPaymentCycleNew: 'month',
|
||||
productPaymentCycleNew: 'year',
|
||||
productPaymentCycleOld: 'month',
|
||||
paymentProrated: '$5,231.00',
|
||||
paymentProrated: '$60.00',
|
||||
subscriptionSupportUrl: 'http://localhost:3030/support',
|
||||
}
|
||||
);
|
||||
|
||||
export const SubscriptionUpgradeSameBillingCycle = createStory(
|
||||
export const Default = createStory();
|
||||
|
||||
// remove in FXA-7796
|
||||
export const SubscriptionUpgradeDifferentBillingCycle = createStory(
|
||||
{},
|
||||
'Subscription upgrade - same billing cycle'
|
||||
'Subscription upgrade - differnt billing cycle'
|
||||
);
|
||||
|
||||
export const SubscriptionUpgradeDifferentBillingCycle = createStory(
|
||||
// remove in FXA-7796
|
||||
export const SubscriptionUpgradeSameBillingCycle = createStory(
|
||||
{
|
||||
paymentAmountNew: '$69.89',
|
||||
paymentAmountOld: '$9.89',
|
||||
productPaymentCycleNew: 'year',
|
||||
paymentProrated: '$60.00',
|
||||
paymentAmountNew: '£123,121.00',
|
||||
paymentAmountOld: '¥99,991',
|
||||
productPaymentCycleNew: 'month',
|
||||
paymentProrated: '$5,231.00',
|
||||
},
|
||||
'Subscription upgrade - different billing cycle'
|
||||
'Subscription upgrade - same billing cycle'
|
||||
);
|
||||
|
|
|
@ -5962,6 +5962,8 @@ describe('#integration - StripeHelper', () => {
|
|||
const event = deepCopy(eventCustomerSubscriptionUpdated);
|
||||
const productIdOld = event.data.previous_attributes.plan.product;
|
||||
const productIdNew = event.data.object.plan.product;
|
||||
const invoiceImmediately =
|
||||
stripeHelper.config.subscriptions.stripeInvoiceImmediately.enabled;
|
||||
|
||||
const baseDetails = {
|
||||
...expectedBaseUpdateDetails,
|
||||
|
@ -6036,26 +6038,28 @@ describe('#integration - StripeHelper', () => {
|
|||
paymentAmountOldCurrency:
|
||||
event.data.previous_attributes.plan.currency,
|
||||
paymentAmountOldInCents:
|
||||
upcomingInvoice && upcomingInvoice.total
|
||||
upcomingInvoice && upcomingInvoice.total && !invoiceImmediately
|
||||
? upcomingInvoice.total
|
||||
: mockInvoice.invoiceTotalOldInCents,
|
||||
: baseDetails.invoiceTotalOldInCents,
|
||||
paymentAmountNewCurrency:
|
||||
upcomingInvoice && upcomingInvoice.currency
|
||||
upcomingInvoice && upcomingInvoice.currency && !invoiceImmediately
|
||||
? upcomingInvoice.currency
|
||||
: mockInvoice.currency,
|
||||
paymentAmountNewInCents:
|
||||
upcomingInvoice && upcomingInvoice.total
|
||||
upcomingInvoice && upcomingInvoice.total && !invoiceImmediately
|
||||
? upcomingInvoice.total
|
||||
: mockInvoice.total,
|
||||
paymentProratedCurrency:
|
||||
upcomingInvoice && upcomingInvoice.currency
|
||||
upcomingInvoice && upcomingInvoice.currency && !invoiceImmediately
|
||||
? upcomingInvoice.currency
|
||||
: mockInvoice.currency,
|
||||
paymentProratedInCents: upcomingInvoice
|
||||
? expectedPaymentProratedInCents
|
||||
: mockInvoice.amount_due,
|
||||
paymentProratedInCents:
|
||||
upcomingInvoice && !invoiceImmediately
|
||||
? expectedPaymentProratedInCents
|
||||
: mockInvoice.amount_due,
|
||||
invoiceNumber: mockInvoice.number,
|
||||
invoiceId: mockInvoice.id,
|
||||
invoiceImmediately: invoiceImmediately,
|
||||
});
|
||||
};
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче