mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-24 21:12:38 -04:00
72af966c9c
* Schedule subscription downgrades to occur at the current term end. If the plan is a downgrade, schedule the subscription change for term end. Use Recurly v3 API subscription change event instead of v2 update subscription. * Add ability for user to revert a pending subscription change In the case where a user has downgraded, but has since decided they'd rather stay on their current plan, we need a way to let them revert. It isn't enough to re-use a subscription change, because Recurly sees it as an attempt to make a change from the current plan to itself. Instead, we use a new dialog and call a new endpoint that has the specific intent of reverting the pending plan change, by calling the removeSubscriptionChange recurly client method. * Add message prompting users to contact support for immediate changes We're showing this in the confirmation modal for a plan change that would occur in the future, and and on the subscription page if a pending change is due. Most users shouldn't need this, but it should help them out if they find an edge case like moving from eg. Student (Annual) to Professional (Monthly) and were expecting to be "upgraded" immediately. GitOrigin-RevId: c5be0efbeb8568ed9caa941aadcef6f6db65c420
54 lines
2.2 KiB
JavaScript
54 lines
2.2 KiB
JavaScript
const Settings = require('settings-sharelatex')
|
|
const fs = require('fs')
|
|
const Path = require('path')
|
|
|
|
// The groups.json file encodes the various group plan options we provide, and
|
|
// is used in the app the render the appropriate dialog in the plans page, and
|
|
// to generate the appropriate entries in the Settings.plans array.
|
|
// It is also used by scripts/recurly/sync_recurly.rb, which will make sure
|
|
// Recurly has a plan configured for all the groups, and that the prices are
|
|
// up to date with the data in groups.json.
|
|
const data = fs.readFileSync(
|
|
Path.join(__dirname, '/../../../templates/plans/groups.json')
|
|
)
|
|
const groups = JSON.parse(data.toString())
|
|
|
|
const capitalize = string => string.charAt(0).toUpperCase() + string.slice(1)
|
|
|
|
// With group accounts in Recurly, we end up with a lot of plans to manage.
|
|
// Rather than hand coding them in the settings file, and then needing to keep
|
|
// that data in sync with the data in groups.json, we can auto generate the
|
|
// group plan entries and append them to Settings.plans at boot time. This is not
|
|
// a particularly clean pattern, since it's a little surprising that settings
|
|
// are modified at boot-time, but I think it's a better option than trying to
|
|
// keep two sources of data in sync.
|
|
for (const [usage, planData] of Object.entries(groups)) {
|
|
for (const [planCode, currencyData] of Object.entries(planData)) {
|
|
// Gather all possible sizes that are set up in at least one currency
|
|
const sizes = new Set()
|
|
for (const priceData of Object.values(currencyData)) {
|
|
for (const size in priceData) {
|
|
sizes.add(size)
|
|
}
|
|
}
|
|
|
|
// Generate plans in settings
|
|
for (const size of sizes) {
|
|
Settings.plans.push({
|
|
planCode: `group_${planCode}_${size}_${usage}`,
|
|
name: `${Settings.appName} ${capitalize(
|
|
planCode
|
|
)} - Group Account (${size} licenses) - ${capitalize(usage)}`,
|
|
hideFromUsers: true,
|
|
price: groups[usage][planCode].USD[size],
|
|
annual: true,
|
|
features: Settings.features[planCode],
|
|
groupPlan: true,
|
|
membersLimit: parseInt(size),
|
|
membersLimitAddOn: 'additional-license',
|
|
})
|
|
}
|
|
}
|
|
}
|
|
|
|
module.exports = groups
|