mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-21 20:47:08 -05:00
Allow setting plans page currency with url param (#8263)
* Allow setting plans page currency with url param GitOrigin-RevId: 5ae977d9872cf5f5b1a234d1273c70c2dd0e14e9
This commit is contained in:
parent
11fddee8e4
commit
f4ef8a3ea0
2 changed files with 12 additions and 2 deletions
|
@ -33,10 +33,19 @@ const validGroupPlanModalOptions = {
|
|||
async function plansPage(req, res) {
|
||||
const plans = SubscriptionViewModelBuilder.buildPlansList()
|
||||
|
||||
const { currencyCode: recommendedCurrency } =
|
||||
await GeoIpLookup.promises.getCurrencyCode(
|
||||
let recommendedCurrency
|
||||
if (req.query.currency) {
|
||||
const queryCurrency = req.query.currency.toUpperCase()
|
||||
if (GeoIpLookup.isValidCurrencyParam(queryCurrency)) {
|
||||
recommendedCurrency = queryCurrency
|
||||
}
|
||||
}
|
||||
if (!recommendedCurrency) {
|
||||
const currencyLookup = await GeoIpLookup.promises.getCurrencyCode(
|
||||
(req.query ? req.query.ip : undefined) || req.ip
|
||||
)
|
||||
recommendedCurrency = currencyLookup.currencyCode
|
||||
}
|
||||
|
||||
function getDefault(param, category, defaultValue) {
|
||||
const v = req.query && req.query[param]
|
||||
|
|
|
@ -208,6 +208,7 @@ describe('SubscriptionController', function () {
|
|||
opts.groupPlanModalDefaults.usage.should.equal('foo')
|
||||
done()
|
||||
}
|
||||
this.GeoIpLookup.isValidCurrencyParam.returns(false)
|
||||
this.req.query = {
|
||||
number: '42',
|
||||
currency: 'ABC',
|
||||
|
|
Loading…
Reference in a new issue