diff --git a/services/web/app/src/Features/Subscription/SubscriptionHandler.js b/services/web/app/src/Features/Subscription/SubscriptionHandler.js index 9cff487aec..4db44b7a25 100644 --- a/services/web/app/src/Features/Subscription/SubscriptionHandler.js +++ b/services/web/app/src/Features/Subscription/SubscriptionHandler.js @@ -83,9 +83,8 @@ async function previewSubscriptionChange(userId, planCode) { /** * @param user * @param planCode - * @param couponCode */ -async function updateSubscription(user, planCode, couponCode) { +async function updateSubscription(user, planCode) { let hasSubscription = false let subscription @@ -108,18 +107,6 @@ async function updateSubscription(user, planCode, couponCode) { } const recurlySubscriptionId = subscription.recurlySubscription_id - if (couponCode) { - const usersSubscription = await RecurlyWrapper.promises.getSubscription( - recurlySubscriptionId, - { includeAccount: true } - ) - - await RecurlyWrapper.promises.redeemCoupon( - usersSubscription.account.account_code, - couponCode - ) - } - const recurlySubscription = await RecurlyClient.promises.getSubscription( recurlySubscriptionId ) diff --git a/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js b/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js index 0517e451d4..32b9ece455 100644 --- a/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js +++ b/services/web/test/unit/src/Subscription/SubscriptionHandlerTests.js @@ -274,8 +274,7 @@ describe('SubscriptionHandler', function () { }) await this.SubscriptionHandler.promises.updateSubscription( this.user, - this.plan_code, - null + this.plan_code ) }) @@ -324,8 +323,7 @@ describe('SubscriptionHandler', function () { expect( this.SubscriptionHandler.promises.updateSubscription( this.user, - 'unknown-plan', - null + 'unknown-plan' ) ).to.be.rejected this.RecurlyClient.promises.applySubscriptionChangeRequest.called.should.equal( @@ -339,8 +337,7 @@ describe('SubscriptionHandler', function () { this.LimitationsManager.promises.userHasSubscription.resolves(false) await this.SubscriptionHandler.promises.updateSubscription( this.user, - this.plan_code, - null + this.plan_code ) }) @@ -353,57 +350,6 @@ describe('SubscriptionHandler', function () { ) }) }) - - describe('with a coupon code', function () { - beforeEach(async function () { - this.user.id = this.activeRecurlySubscription.account.account_code - - this.User.findById = (userId, projection) => ({ - exec: () => { - userId.should.equal(this.user.id) - return Promise.resolve(this.user) - }, - }) - this.plan_code = 'collaborator' - this.coupon_code = '1231312' - this.LimitationsManager.promises.userHasSubscription.resolves({ - hasSubscription: true, - subscription: this.subscription, - }) - await this.SubscriptionHandler.promises.updateSubscription( - this.user, - this.plan_code, - this.coupon_code - ) - }) - - it('should get the users account', function () { - this.RecurlyWrapper.promises.getSubscription - .calledWith(this.activeRecurlySubscription.uuid) - .should.equal(true) - }) - - it('should redeem the coupon', function () { - this.RecurlyWrapper.promises.redeemCoupon - .calledWith( - this.activeRecurlySubscription.account.account_code, - this.coupon_code - ) - .should.equal(true) - }) - - it('should update the subscription', function () { - expect( - this.RecurlyClient.promises.applySubscriptionChangeRequest - ).to.be.calledWith( - new PaymentProviderSubscriptionChangeRequest({ - subscription: this.activeRecurlyClientSubscription, - timeframe: 'now', - planCode: this.plan_code, - }) - ) - }) - }) }) describe('cancelSubscription', function () {