Merge pull request #29564 from overleaf/kh-add-stripe-info-to-front
[web] include Stripe customer dashboard link in Front GitOrigin-RevId: 73a268426610e48a3211fa8e1e994428c84a79ef
This commit is contained in:
@@ -799,6 +799,24 @@ async function terminateSubscriptionByUuid(subscriptionUuid) {
|
||||
return subscription
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the Recurly admin dashboard url for a user
|
||||
*
|
||||
* @param {string} userId
|
||||
* @returns {string}
|
||||
*/
|
||||
function getCustomerAdminUrlFromUserId(userId) {
|
||||
const isStagOrDev =
|
||||
Settings.siteUrl.includes('dev-overleaf') ||
|
||||
Settings.siteUrl.includes('stag-overleaf')
|
||||
|
||||
if (isStagOrDev) {
|
||||
return `https://sharelatex-sandbox.recurly.com/accounts/${userId}`
|
||||
}
|
||||
|
||||
return `https://sharelatex.recurly.com/accounts/${userId}`
|
||||
}
|
||||
|
||||
export default {
|
||||
errors: recurly.errors,
|
||||
|
||||
@@ -823,6 +841,7 @@ export default {
|
||||
getPastDueInvoices: callbackify(getPastDueInvoices),
|
||||
failInvoice: callbackify(failInvoice),
|
||||
terminateSubscriptionByUuid: callbackify(terminateSubscriptionByUuid),
|
||||
getCustomerAdminUrlFromUserId,
|
||||
|
||||
promises: {
|
||||
getSubscription,
|
||||
|
||||
@@ -789,4 +789,31 @@ describe('RecurlyClient', function () {
|
||||
expect(invoices).to.deep.equal(pastDueInvoices)
|
||||
})
|
||||
})
|
||||
|
||||
describe('getCustomerAdminUrlFromUserId', function () {
|
||||
it('should return staging URL for dev-overleaf sites', async function (ctx) {
|
||||
ctx.settings.siteUrl = 'https://dev-overleaf.example.com'
|
||||
const userId = 'user-123'
|
||||
const url = await ctx.RecurlyClient.getCustomerAdminUrlFromUserId(userId)
|
||||
expect(url).to.equal(
|
||||
'https://sharelatex-sandbox.recurly.com/accounts/user-123'
|
||||
)
|
||||
})
|
||||
|
||||
it('should return staging URL for stag-overleaf sites', async function (ctx) {
|
||||
ctx.settings.siteUrl = 'https://stag-overleaf.example.com'
|
||||
const userId = 'user-456'
|
||||
const url = await ctx.RecurlyClient.getCustomerAdminUrlFromUserId(userId)
|
||||
expect(url).to.equal(
|
||||
'https://sharelatex-sandbox.recurly.com/accounts/user-456'
|
||||
)
|
||||
})
|
||||
|
||||
it('should return production URL for production sites', async function (ctx) {
|
||||
ctx.settings.siteUrl = 'https://www.overleaf.com'
|
||||
const userId = 'user-789'
|
||||
const url = await ctx.RecurlyClient.getCustomerAdminUrlFromUserId(userId)
|
||||
expect(url).to.equal('https://sharelatex.recurly.com/accounts/user-789')
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user