Skip to content

Commit 83eb5d7

Browse files
committed
fix(payments): display invoice currency on upgrade
Because: - Customers on a multi-currency subscription, performing an upgrade on SP2 would see the default currency instead of the customers current currency This commit: - Use the customer currency retrieved via the invoicePreview Closes #FXA-11457
1 parent 3c17eb2 commit 83eb5d7

2 files changed

Lines changed: 16 additions & 13 deletions

File tree

packages/fxa-payments-server/src/routes/Product/SubscriptionUpgrade/PlanUpgradeDetails.tsx

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,8 @@ export const PlanUpgradeDetails = ({
2929
className?: string;
3030
}) => {
3131
const { navigatorLanguages, config } = useContext(AppContext);
32-
const { product_name, amount, currency, interval, interval_count } =
32+
const invoiceCurrency = invoicePreview.line_items[0].currency;
33+
const { product_name, amount, interval, interval_count } =
3334
selectedPlan;
3435
const formattedInterval = formatPlanInterval({
3536
interval: interval,
@@ -64,13 +65,13 @@ export const PlanUpgradeDetails = ({
6465
<Localized id="sub-update-current-plan-label">Current plan</Localized>
6566
</p>
6667

67-
<PlanDetailsCard className="from-plan" plan={upgradeFromPlan} />
68+
<PlanDetailsCard className="from-plan" plan={upgradeFromPlan} currency={invoiceCurrency} />
6869

6970
<p className="plan-label new-plan-label">
7071
<Localized id="sub-update-new-plan-label">New plan</Localized>
7172
</p>
7273

73-
<PlanDetailsCard className="to-plan" plan={selectedPlan} />
74+
<PlanDetailsCard className="to-plan" plan={selectedPlan} currency={invoiceCurrency} />
7475

7576
<div className="py-6 border-t-0">
7677
{showTax && !!subTotal && !!exclusiveTaxRates.length && (
@@ -93,7 +94,7 @@ export const PlanUpgradeDetails = ({
9394

9495
<PriceDetails
9596
total={subTotal}
96-
currency={currency}
97+
currency={invoiceCurrency}
9798
dataTestId="plan-upgrade-subtotal"
9899
/>
99100
</div>
@@ -106,7 +107,7 @@ export const PlanUpgradeDetails = ({
106107

107108
<PriceDetails
108109
total={exclusiveTaxRates[0].amount}
109-
currency={currency}
110+
currency={invoiceCurrency}
110111
dataTestId="plan-upgrade-tax-amount"
111112
/>
112113
</div>
@@ -118,7 +119,7 @@ export const PlanUpgradeDetails = ({
118119

119120
<PriceDetails
120121
total={taxRate.amount}
121-
currency={currency}
122+
currency={invoiceCurrency}
122123
dataTestId="plan-upgrade-tax-amount"
123124
/>
124125
</div>
@@ -134,7 +135,7 @@ export const PlanUpgradeDetails = ({
134135

135136
<PriceDetails
136137
total={totalAmount}
137-
currency={currency}
138+
currency={invoiceCurrency}
138139
interval={interval}
139140
intervalCount={interval_count}
140141
className="total-price"
@@ -159,7 +160,7 @@ export const PlanUpgradeDetails = ({
159160

160161
<PriceDetails
161162
total={oneTimeCharge}
162-
currency={currency}
163+
currency={invoiceCurrency}
163164
className="total-price"
164165
dataTestId="prorated-amount"
165166
/>
@@ -173,13 +174,15 @@ export const PlanUpgradeDetails = ({
173174

174175
export const PlanDetailsCard = ({
175176
plan,
177+
currency,
176178
className = '',
177179
}: {
178180
plan: Plan;
181+
currency: string,
179182
className?: string;
180183
}) => {
181184
const { navigatorLanguages, config } = useContext(AppContext);
182-
const { product_name, amount, currency, interval, interval_count } = plan;
185+
const { product_name, amount, interval, interval_count } = plan;
183186
const { webIcon, webIconBackground } = webIconConfigFromProductConfig(
184187
plan,
185188
navigatorLanguages,

packages/fxa-payments-server/src/routes/Product/SubscriptionUpgrade/index.test.tsx

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async function rendersAsExpected(
9393
// and interval count match or not.
9494
const expectedInvoiceDate =
9595
upgradeFromPlan.interval !== selectedPlan.interval &&
96-
selectedPlan.interval_count === upgradeFromPlan.interval_count
96+
selectedPlan.interval_count === upgradeFromPlan.interval_count
9797
? getLocalizedDateString(invoicePreview.line_items[0].period.end)
9898
: getLocalizedDateString(customerWebSubscription.current_period_end);
9999

@@ -342,7 +342,7 @@ describe('PlanDetailsCard', () => {
342342
expectedMsgId: string,
343343
expectedMsg: string
344344
) {
345-
const props = { plan: plan };
345+
const props = { plan: plan, currency: plan.currency };
346346

347347
const testRenderer = TestRenderer.create(
348348
withLocalizationProvider(<PlanDetailsCard {...props} />)
@@ -365,7 +365,7 @@ describe('PlanDetailsCard', () => {
365365
const plan_id = 'plan_withname';
366366
const plan = findMockPlan(plan_id);
367367

368-
const props = { plan: plan };
368+
const props = { plan: plan, currency: plan.currency };
369369

370370
const testRenderer = TestRenderer.create(
371371
withLocalizationProvider(<PlanDetailsCard {...props} />)
@@ -384,7 +384,7 @@ describe('PlanDetailsCard', () => {
384384
const plan_id = 'plan_daily';
385385
const plan = findMockPlan(plan_id);
386386

387-
const props = { plan: plan };
387+
const props = { plan: plan, currency: plan.currency };
388388

389389
const testRenderer = TestRenderer.create(
390390
withLocalizationProvider(<PlanDetailsCard {...props} />)

0 commit comments

Comments
 (0)