mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-06-10 22:50:46 +02:00
Enable additional currencies when purchasing (or upgrading to) a group plan (#4884)
* Add script to fetch group data pricing from Recurly * Update groups pricing data using script to fetch prices from Recurly * Add additional currencies to saas settings * Refactor group plans upgrade modal to use shared options from settings GitOrigin-RevId: 6d13d5b152d01e0399f9d2b8f6f8bf99784589e8
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
// Get prices from Recurly in GroupPlansData format, ie to update:
|
||||
// app/templates/plans/groups.json
|
||||
//
|
||||
// Usage example:
|
||||
// node scripts/recurly/get_recurly_group_prices.js
|
||||
|
||||
const recurly = require('recurly')
|
||||
const Settings = require('@overleaf/settings')
|
||||
|
||||
const recurlySettings = Settings.apis.recurly
|
||||
const recurlyApiKey = recurlySettings ? recurlySettings.apiKey : undefined
|
||||
|
||||
const client = new recurly.Client(recurlyApiKey)
|
||||
|
||||
async function getRecurlyGroupPrices() {
|
||||
const prices = {}
|
||||
const plans = client.listPlans({ params: { limit: 200 } })
|
||||
for await (const plan of plans.each()) {
|
||||
if (plan.code.substr(0, 6) === 'group_') {
|
||||
const [, type, size, usage] = plan.code.split('_')
|
||||
plan.currencies.forEach(planPricing => {
|
||||
const { currency, unitAmount } = planPricing
|
||||
prices[usage] = prices[usage] || {}
|
||||
prices[usage][type] = prices[usage][type] || {}
|
||||
prices[usage][type][currency] = prices[usage][type][currency] || {}
|
||||
prices[usage][type][currency][size] = unitAmount
|
||||
})
|
||||
}
|
||||
}
|
||||
return prices
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const prices = await getRecurlyGroupPrices()
|
||||
console.log(JSON.stringify(prices, undefined, 2))
|
||||
}
|
||||
|
||||
main()
|
||||
.then(() => {
|
||||
process.exit(0)
|
||||
})
|
||||
.catch(error => {
|
||||
console.error({ error })
|
||||
process.exit(1)
|
||||
})
|
||||
Reference in New Issue
Block a user