mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-11-15 14:43:46 +01:00
Merge pull request #35836 from overleaf/rh-prices-split
[web] Update monthly plan prices for new subscriptions with split test GitOrigin-RevId: 42d0adaf68647adc93f4c05d5ddeefb356753db2
This commit is contained in:
+17
-6
@@ -21,6 +21,7 @@ import {
|
||||
import { Institution } from '../../../../../types/institution'
|
||||
import getMeta from '../../../utils/meta'
|
||||
import {
|
||||
formatPriceForDisplayData,
|
||||
loadDisplayPriceWithTaxPromise,
|
||||
loadGroupDisplayPriceWithTaxForRecurlyPromise,
|
||||
loadGroupDisplayPriceWithTaxForStripePromise,
|
||||
@@ -173,15 +174,25 @@ export function SubscriptionDashboardProvider({
|
||||
personalSubscription?.payment
|
||||
) {
|
||||
const { currency, taxRate } = personalSubscription.payment
|
||||
// Only Stripe subscriptions can be derived from the price version. Recurly only has one version of each price.
|
||||
const isStripe = Boolean(personalSubscription.service?.includes('stripe'))
|
||||
const fetchPlansDisplayPrices = async () => {
|
||||
for (const plan of plansWithoutDisplayPrice) {
|
||||
try {
|
||||
const priceData = await loadDisplayPriceWithTaxPromise(
|
||||
plan.planCode,
|
||||
currency,
|
||||
taxRate,
|
||||
i18n.language
|
||||
)
|
||||
const priceData =
|
||||
isStripe && plan.listPrice !== undefined
|
||||
? formatPriceForDisplayData(
|
||||
plan.listPrice,
|
||||
taxRate,
|
||||
currency,
|
||||
i18n.language
|
||||
)
|
||||
: await loadDisplayPriceWithTaxPromise(
|
||||
plan.planCode,
|
||||
currency,
|
||||
taxRate,
|
||||
i18n.language
|
||||
)
|
||||
if (priceData?.totalAsNumber !== undefined) {
|
||||
plan.displayPrice = formatCurrency(
|
||||
priceData.totalAsNumber,
|
||||
|
||||
@@ -28,12 +28,12 @@ function queryRecurlyPlanPrice(planCode: string, currency: CurrencyCode) {
|
||||
}
|
||||
|
||||
export function formatPriceForDisplayData(
|
||||
price: string,
|
||||
price: string | number,
|
||||
taxRate: number,
|
||||
currencyCode: CurrencyCode,
|
||||
locale: string
|
||||
): PriceForDisplayData {
|
||||
const totalPriceExTax = parseFloat(price)
|
||||
const totalPriceExTax = typeof price === 'number' ? price : parseFloat(price)
|
||||
let taxAmount = totalPriceExTax * taxRate
|
||||
if (isNaN(taxAmount)) {
|
||||
taxAmount = 0
|
||||
|
||||
Reference in New Issue
Block a user