|
@@ -23,8 +23,7 @@ const SubscriptionHelper = require('./SubscriptionHelper')
|
|
|
const AuthorizationManager = require('../Authorization/AuthorizationManager')
|
|
const AuthorizationManager = require('../Authorization/AuthorizationManager')
|
|
|
const Modules = require('../../infrastructure/Modules')
|
|
const Modules = require('../../infrastructure/Modules')
|
|
|
const async = require('async')
|
|
const async = require('async')
|
|
|
-const { formatCurrencyLocalized } = require('../../util/currency')
|
|
|
|
|
-const SubscriptionFormatters = require('./SubscriptionFormatters')
|
|
|
|
|
|
|
+const { formatCurrency } = require('../../util/currency')
|
|
|
const HttpErrorHandler = require('../Errors/HttpErrorHandler')
|
|
const HttpErrorHandler = require('../Errors/HttpErrorHandler')
|
|
|
const { URLSearchParams } = require('url')
|
|
const { URLSearchParams } = require('url')
|
|
|
const RecurlyClient = require('./RecurlyClient')
|
|
const RecurlyClient = require('./RecurlyClient')
|
|
@@ -113,16 +112,6 @@ async function plansPage(req, res) {
|
|
|
const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } =
|
|
const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } =
|
|
|
_plansBanners(countryCode)
|
|
_plansBanners(countryCode)
|
|
|
|
|
|
|
|
- const localCcyAssignment = await SplitTestHandler.promises.getAssignment(
|
|
|
|
|
- req,
|
|
|
|
|
- res,
|
|
|
|
|
- 'local-ccy-format-v2'
|
|
|
|
|
- )
|
|
|
|
|
- const formatCurrency =
|
|
|
|
|
- localCcyAssignment.variant === 'enabled'
|
|
|
|
|
- ? formatCurrencyLocalized
|
|
|
|
|
- : SubscriptionHelper.formatCurrencyDefault
|
|
|
|
|
-
|
|
|
|
|
const shouldLoadHotjar = await getShouldLoadHotjar(req, res)
|
|
const shouldLoadHotjar = await getShouldLoadHotjar(req, res)
|
|
|
|
|
|
|
|
res.render('subscriptions/plans', {
|
|
res.render('subscriptions/plans', {
|
|
@@ -142,8 +131,7 @@ async function plansPage(req, res) {
|
|
|
initialLocalizedGroupPrice:
|
|
initialLocalizedGroupPrice:
|
|
|
SubscriptionHelper.generateInitialLocalizedGroupPrice(
|
|
SubscriptionHelper.generateInitialLocalizedGroupPrice(
|
|
|
currency ?? 'USD',
|
|
currency ?? 'USD',
|
|
|
- language,
|
|
|
|
|
- formatCurrency
|
|
|
|
|
|
|
+ language
|
|
|
),
|
|
),
|
|
|
showInrGeoBanner,
|
|
showInrGeoBanner,
|
|
|
showBrlGeoBanner,
|
|
showBrlGeoBanner,
|
|
@@ -163,16 +151,6 @@ async function plansPageLightDesign(req, res) {
|
|
|
const plans = SubscriptionViewModelBuilder.buildPlansList()
|
|
const plans = SubscriptionViewModelBuilder.buildPlansList()
|
|
|
const groupPlanModalDefaults = _getGroupPlanModalDefaults(req, currency)
|
|
const groupPlanModalDefaults = _getGroupPlanModalDefaults(req, currency)
|
|
|
|
|
|
|
|
- const localCcyAssignment = await SplitTestHandler.promises.getAssignment(
|
|
|
|
|
- req,
|
|
|
|
|
- res,
|
|
|
|
|
- 'local-ccy-format-v2'
|
|
|
|
|
- )
|
|
|
|
|
- const formatCurrency =
|
|
|
|
|
- localCcyAssignment.variant === 'enabled'
|
|
|
|
|
- ? formatCurrencyLocalized
|
|
|
|
|
- : SubscriptionHelper.formatCurrencyDefault
|
|
|
|
|
-
|
|
|
|
|
const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } =
|
|
const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } =
|
|
|
_plansBanners(countryCode)
|
|
_plansBanners(countryCode)
|
|
|
|
|
|
|
@@ -197,8 +175,7 @@ async function plansPageLightDesign(req, res) {
|
|
|
initialLocalizedGroupPrice:
|
|
initialLocalizedGroupPrice:
|
|
|
SubscriptionHelper.generateInitialLocalizedGroupPrice(
|
|
SubscriptionHelper.generateInitialLocalizedGroupPrice(
|
|
|
currency ?? 'USD',
|
|
currency ?? 'USD',
|
|
|
- language,
|
|
|
|
|
- formatCurrency
|
|
|
|
|
|
|
+ language
|
|
|
),
|
|
),
|
|
|
showLATAMBanner,
|
|
showLATAMBanner,
|
|
|
showInrGeoBanner,
|
|
showInrGeoBanner,
|
|
@@ -222,11 +199,6 @@ function formatGroupPlansDataForDash() {
|
|
|
async function userSubscriptionPage(req, res) {
|
|
async function userSubscriptionPage(req, res) {
|
|
|
const user = SessionManager.getSessionUser(req.session)
|
|
const user = SessionManager.getSessionUser(req.session)
|
|
|
|
|
|
|
|
- const localCcyAssignment = await SplitTestHandler.promises.getAssignment(
|
|
|
|
|
- req,
|
|
|
|
|
- res,
|
|
|
|
|
- 'local-ccy-format-v2'
|
|
|
|
|
- )
|
|
|
|
|
await SplitTestHandler.promises.getAssignment(req, res, 'ai-add-on')
|
|
await SplitTestHandler.promises.getAssignment(req, res, 'ai-add-on')
|
|
|
|
|
|
|
|
// Populates splitTestVariants with a value for the split test name and allows
|
|
// Populates splitTestVariants with a value for the split test name and allows
|
|
@@ -241,10 +213,7 @@ async function userSubscriptionPage(req, res) {
|
|
|
const results =
|
|
const results =
|
|
|
await SubscriptionViewModelBuilder.promises.buildUsersSubscriptionViewModel(
|
|
await SubscriptionViewModelBuilder.promises.buildUsersSubscriptionViewModel(
|
|
|
user,
|
|
user,
|
|
|
- req.i18n.language,
|
|
|
|
|
- localCcyAssignment.variant === 'enabled'
|
|
|
|
|
- ? SubscriptionFormatters.formatPriceLocalized
|
|
|
|
|
- : SubscriptionFormatters.formatPriceDefault
|
|
|
|
|
|
|
+ req.i18n.language
|
|
|
)
|
|
)
|
|
|
const {
|
|
const {
|
|
|
personalSubscription,
|
|
personalSubscription,
|
|
@@ -364,12 +333,6 @@ async function interstitialPaymentPage(req, res) {
|
|
|
const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } =
|
|
const { showLATAMBanner, showInrGeoBanner, showBrlGeoBanner } =
|
|
|
_plansBanners(countryCode)
|
|
_plansBanners(countryCode)
|
|
|
|
|
|
|
|
- const localCcyAssignment = await SplitTestHandler.promises.getAssignment(
|
|
|
|
|
- req,
|
|
|
|
|
- res,
|
|
|
|
|
- 'local-ccy-format-v2'
|
|
|
|
|
- )
|
|
|
|
|
-
|
|
|
|
|
const shouldLoadHotjar = await getShouldLoadHotjar(req, res)
|
|
const shouldLoadHotjar = await getShouldLoadHotjar(req, res)
|
|
|
|
|
|
|
|
res.render(template, {
|
|
res.render(template, {
|
|
@@ -380,11 +343,8 @@ async function interstitialPaymentPage(req, res) {
|
|
|
recommendedCurrency,
|
|
recommendedCurrency,
|
|
|
interstitialPaymentConfig,
|
|
interstitialPaymentConfig,
|
|
|
showSkipLink,
|
|
showSkipLink,
|
|
|
- formatCurrency:
|
|
|
|
|
- localCcyAssignment.variant === 'enabled'
|
|
|
|
|
- ? formatCurrencyLocalized
|
|
|
|
|
- : SubscriptionHelper.formatCurrencyDefault,
|
|
|
|
|
- showCurrencyAndPaymentMethods: localCcyAssignment.variant === 'enabled',
|
|
|
|
|
|
|
+ formatCurrency,
|
|
|
|
|
+ showCurrencyAndPaymentMethods: true, // TODO: remove hardcode
|
|
|
showInrGeoBanner,
|
|
showInrGeoBanner,
|
|
|
showBrlGeoBanner,
|
|
showBrlGeoBanner,
|
|
|
showLATAMBanner,
|
|
showLATAMBanner,
|
|
@@ -399,18 +359,11 @@ async function interstitialPaymentPage(req, res) {
|
|
|
|
|
|
|
|
async function successfulSubscription(req, res) {
|
|
async function successfulSubscription(req, res) {
|
|
|
const user = SessionManager.getSessionUser(req.session)
|
|
const user = SessionManager.getSessionUser(req.session)
|
|
|
- const localCcyAssignment = await SplitTestHandler.promises.getAssignment(
|
|
|
|
|
- req,
|
|
|
|
|
- res,
|
|
|
|
|
- 'local-ccy-format-v2'
|
|
|
|
|
- )
|
|
|
|
|
|
|
+
|
|
|
const { personalSubscription } =
|
|
const { personalSubscription } =
|
|
|
await SubscriptionViewModelBuilder.promises.buildUsersSubscriptionViewModel(
|
|
await SubscriptionViewModelBuilder.promises.buildUsersSubscriptionViewModel(
|
|
|
user,
|
|
user,
|
|
|
- req.i18n.language,
|
|
|
|
|
- localCcyAssignment.variant === 'enabled'
|
|
|
|
|
- ? SubscriptionFormatters.formatPriceLocalized
|
|
|
|
|
- : SubscriptionFormatters.formatPriceDefault
|
|
|
|
|
|
|
+ req.i18n.language
|
|
|
)
|
|
)
|
|
|
|
|
|
|
|
const postCheckoutRedirect = req.session?.postCheckoutRedirect
|
|
const postCheckoutRedirect = req.session?.postCheckoutRedirect
|