Просмотр исходного кода

Remove "upgrade to annual" page (#18014)

GitOrigin-RevId: b9f92ad038adab7fc7eb5e2a7175461bfefee379
Alf Eaton 2 лет назад
Родитель
Сommit
98cefaa5bd

+ 0 - 60
services/web/app/src/Features/Subscription/SubscriptionController.js

@@ -488,64 +488,6 @@ function recurlyCallback(req, res, next) {
   }
 }
 
-function renderUpgradeToAnnualPlanPage(req, res, next) {
-  const user = SessionManager.getSessionUser(req.session)
-  LimitationsManager.userHasV2Subscription(
-    user,
-    function (err, hasSubscription, subscription) {
-      let planName
-      if (err) {
-        return next(err)
-      }
-      const planCode = subscription
-        ? subscription.planCode.toLowerCase()
-        : undefined
-      if ((planCode ? planCode.indexOf('annual') : undefined) !== -1) {
-        planName = 'annual'
-      } else if ((planCode ? planCode.indexOf('student') : undefined) !== -1) {
-        planName = 'student'
-      } else if (
-        (planCode ? planCode.indexOf('collaborator') : undefined) !== -1
-      ) {
-        planName = 'collaborator'
-      }
-      if (hasSubscription) {
-        res.render('subscriptions/upgradeToAnnual', {
-          title: 'Upgrade to annual',
-          planName,
-        })
-      } else {
-        res.redirect('/user/subscription/plans')
-      }
-    }
-  )
-}
-
-function processUpgradeToAnnualPlan(req, res, next) {
-  const user = SessionManager.getSessionUser(req.session)
-  const { planName } = req.body
-  const couponCode = Settings.coupon_codes.upgradeToAnnualPromo[planName]
-  const annualPlanName = `${planName}-annual`
-  logger.debug(
-    { userId: user._id, planName: annualPlanName },
-    'user is upgrading to annual billing with discount'
-  )
-  return SubscriptionHandler.updateSubscription(
-    user,
-    annualPlanName,
-    couponCode,
-    function (err) {
-      if (err) {
-        OError.tag(err, 'error updating subscription', {
-          user_id: user._id,
-        })
-        return next(err)
-      }
-      res.sendStatus(200)
-    }
-  )
-}
-
 async function extendTrial(req, res) {
   const user = SessionManager.getSessionUser(req.session)
   const { subscription } =
@@ -684,8 +626,6 @@ module.exports = {
   updateAccountEmailAddress,
   reactivateSubscription,
   recurlyCallback,
-  renderUpgradeToAnnualPlanPage,
-  processUpgradeToAnnualPlan,
   extendTrial: expressify(extendTrial),
   recurlyNotificationParser,
   refreshUserFeatures: expressify(refreshUserFeatures),

+ 0 - 13
services/web/app/src/Features/Subscription/SubscriptionRouter.js

@@ -147,19 +147,6 @@ module.exports = {
       SubscriptionController.extendTrial
     )
 
-    webRouter.get(
-      '/user/subscription/upgrade-annual',
-      AuthenticationController.requireLogin(),
-      RateLimiterMiddleware.rateLimit(subscriptionRateLimiter),
-      SubscriptionController.renderUpgradeToAnnualPlanPage
-    )
-    webRouter.post(
-      '/user/subscription/upgrade-annual',
-      AuthenticationController.requireLogin(),
-      RateLimiterMiddleware.rateLimit(subscriptionRateLimiter),
-      SubscriptionController.processUpgradeToAnnualPlan
-    )
-
     webRouter.post(
       '/user/subscription/account/email',
       AuthenticationController.requireLogin(),

+ 0 - 24
services/web/app/views/subscriptions/upgradeToAnnual.pug

@@ -1,24 +0,0 @@
-extends ../layout
-
-block content
-
-	main.content.content-alt#main-content
-		.container(ng-controller="AnnualUpgradeController")
-			.row(ng-cloak)
-				.col-md-6.col-md-offset-3
-					.card(ng-init="planName = "+JSON.stringify(planName))
-						.page-header
-							h1.text-centered #{translate("move_to_annual_billing")}
-						div(ng-hide="upgradeComplete")
-							.row
-								div.col-md-12 !{translate("change_to_annual_billing_and_save", {percentage:'20%', yearlySaving:'${{yearlySaving}}'}, ['strong', 'strong'])}
-							.row  
-							.row
-								div.col-md-12
-									center
-										button.btn.btn-primary(ng-click="completeAnnualUpgrade()", ng-disabled="inflight")
-											span(ng-show="inflight") #{translate("processing")}
-											span(ng-hide="inflight") #{translate("move_to_annual_billing")} now
-
-						div(ng-show="upgradeComplete")
-							h3  #{translate("annual_billing_enabled")}, #{translate("thank_you")}.

+ 0 - 1
services/web/frontend/js/main.js

@@ -11,7 +11,6 @@
 import './main/token-access' // used in project/token/access
 import './main/event' // used in various controllers
 import './main/system-messages' // used in project/editor
-import './main/annual-upgrade' // used in subscriptions/upgradeToAnnual
 import './main/subscription/team-invite-controller' // used in subscriptions/team/invite
 import './directives/eventTracking' // used in lots of places
 import './features/cookie-banner'

+ 0 - 48
services/web/frontend/js/main/annual-upgrade.js

@@ -1,48 +0,0 @@
-/* eslint-disable
-    max-len,
-    no-return-assign,
-*/
-// TODO: This file was created by bulk-decaffeinate.
-// Fix any style issues and re-enable lint.
-/*
- * decaffeinate suggestions:
- * DS102: Remove unnecessary code created because of implicit returns
- * Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
- */
-import App from '../base'
-import { debugConsole } from '@/utils/debugging'
-
-export default App.controller('AnnualUpgradeController', [
-  '$scope',
-  '$http',
-  function ($scope, $http) {
-    const MESSAGES_URL = '/user/subscription/upgrade-annual'
-
-    $scope.upgradeComplete = false
-    const savings = {
-      student: '19.2',
-      collaborator: '36',
-    }
-    $scope.$watch($scope.planName, function () {
-      $scope.yearlySaving = savings[$scope.planName]
-      if ($scope.planName === 'annual') {
-        return ($scope.upgradeComplete = true)
-      }
-    })
-    return ($scope.completeAnnualUpgrade = function () {
-      const body = {
-        planName: $scope.planName,
-        _csrf: window.csrfToken,
-      }
-
-      $scope.inflight = true
-
-      return $http
-        .post(MESSAGES_URL, body)
-        .then(() => ($scope.upgradeComplete = true))
-        .catch(err =>
-          debugConsole.error('something went wrong changing plan', err)
-        )
-    })
-  },
-])

+ 0 - 3
services/web/locales/en.json

@@ -107,7 +107,6 @@
   "an_error_occurred_when_verifying_the_coupon_code": "An error occurred when verifying the coupon code",
   "and": "and",
   "annual": "Annual",
-  "annual_billing_enabled": "Annual billing enabled",
   "anonymous": "Anonymous",
   "anyone_with_link_can_edit": "Anyone with this link can edit this project",
   "anyone_with_link_can_view": "Anyone with this link can view this project",
@@ -218,7 +217,6 @@
   "change_primary_email_address_instructions": "To change your primary email, please add your new primary email address first (by clicking <0>Add another email</0>) and confirm it. Then click the <0>Make Primary</0> button. <1>Learn more</1> about managing your __appName__ emails.",
   "change_project_owner": "Change Project Owner",
   "change_the_ownership_of_your_personal_projects": "Change the ownership of your personal projects to the new account. <0>Find out how to change project owner.</0>",
-  "change_to_annual_billing_and_save": "Get <0>__percentage__</0> off with annual billing. If you switch now you’ll save <1>__yearlySaving__</1> per year.",
   "change_to_group_plan": "Change to a group plan",
   "change_to_this_plan": "Change to this plan",
   "changing_the_position_of_your_figure": "Changing the position of your figure",
@@ -1120,7 +1118,6 @@
   "more_project_collaborators": "<0>More</0> project <0>collaborators</0>",
   "more_than_one_kind_of_snippet_was_requested": "The link to open this content on Overleaf included some invalid parameters. If this keeps happening for links on a particular site, please report this to them.",
   "most_popular": "most popular",
-  "move_to_annual_billing": "Move to Annual Billing",
   "must_be_email_address": "Must be an email address",
   "my_library": "My Library",
   "n_items": "__count__ item",

+ 0 - 96
services/web/test/unit/src/Subscription/SubscriptionControllerTests.js

@@ -695,100 +695,4 @@ describe('SubscriptionController', function () {
       })
     })
   })
-
-  describe('renderUpgradeToAnnualPlanPage', function () {
-    it('should redirect to the plans page if the user does not have a subscription', function (done) {
-      this.LimitationsManager.userHasV2Subscription.callsArgWith(1, null, false)
-      this.res.redirect = function (url) {
-        url.should.equal('/user/subscription/plans')
-        done()
-      }
-      this.SubscriptionController.renderUpgradeToAnnualPlanPage(
-        this.req,
-        this.res
-      )
-    })
-
-    it('should pass the plan code to the view - student', function (done) {
-      this.LimitationsManager.userHasV2Subscription.callsArgWith(
-        1,
-        null,
-        true,
-        { planCode: 'Student free trial 14 days' }
-      )
-      this.res.render = function (view, opts) {
-        view.should.equal('subscriptions/upgradeToAnnual')
-        opts.planName.should.equal('student')
-        done()
-      }
-      this.SubscriptionController.renderUpgradeToAnnualPlanPage(
-        this.req,
-        this.res
-      )
-    })
-
-    it('should pass the plan code to the view - collaborator', function (done) {
-      this.LimitationsManager.userHasV2Subscription.callsArgWith(
-        1,
-        null,
-        true,
-        { planCode: 'free trial for Collaborator free trial 14 days' }
-      )
-      this.res.render = function (view, opts) {
-        opts.planName.should.equal('collaborator')
-        done()
-      }
-      this.SubscriptionController.renderUpgradeToAnnualPlanPage(
-        this.req,
-        this.res
-      )
-    })
-
-    it('should pass annual as the plan name if the user is already on an annual plan', function (done) {
-      this.LimitationsManager.userHasV2Subscription.callsArgWith(
-        1,
-        null,
-        true,
-        { planCode: 'student annual with free trial' }
-      )
-      this.res.render = function (view, opts) {
-        opts.planName.should.equal('annual')
-        done()
-      }
-      this.SubscriptionController.renderUpgradeToAnnualPlanPage(
-        this.req,
-        this.res
-      )
-    })
-  })
-
-  describe('processUpgradeToAnnualPlan', function () {
-    beforeEach(function () {})
-
-    it('should tell the subscription handler to update the subscription with the annual plan and apply a coupon code', function (done) {
-      this.req.body = { planName: 'student' }
-
-      this.res.sendStatus = () => {
-        this.SubscriptionHandler.updateSubscription
-          .calledWith(this.user, 'student-annual', 'STUDENTCODEHERE')
-          .should.equal(true)
-        done()
-      }
-
-      this.SubscriptionController.processUpgradeToAnnualPlan(this.req, this.res)
-    })
-
-    it('should get the collaborator coupon code', function (done) {
-      this.req.body = { planName: 'collaborator' }
-
-      this.res.sendStatus = url => {
-        this.SubscriptionHandler.updateSubscription
-          .calledWith(this.user, 'collaborator-annual', 'COLLABORATORCODEHERE')
-          .should.equal(true)
-        done()
-      }
-
-      this.SubscriptionController.processUpgradeToAnnualPlan(this.req, this.res)
-    })
-  })
 })