diff --git a/test/api/v3/unit/libs/payments.test.js b/test/api/v3/unit/libs/payments.test.js index 7d28ce5ac8..9107849270 100644 --- a/test/api/v3/unit/libs/payments.test.js +++ b/test/api/v3/unit/libs/payments.test.js @@ -856,7 +856,7 @@ describe('payments/index', () => { let headers = {}; let coupon; - await api.payWithStripe([ + await api.payWithStripe({ token, user, gift, @@ -865,7 +865,7 @@ describe('payments/index', () => { email, headers, coupon, - ], stripe); + }, stripe); expect(stripeCreateCustomerSpy.calledOnce).to.be.true; expect(createSubSpy.calledOnce).to.be.true; @@ -899,22 +899,21 @@ describe('payments/index', () => { api.createSubscription.restore(); }); - it('subscribes with stripe', async () => { + it('subscribes with amazon', async () => { let billingAgreementId = 'billingAgreementId'; let sub = data.sub; let coupon; let groupId = group._id; let headers = {}; - await api.subscribeWithAmazon([ + await api.subscribeWithAmazon({ billingAgreementId, sub, coupon, - sub, user, groupId, headers, - ]); + }); expect(amazonSetBillingAgreementDetailsSpy.calledOnce).to.be.true; expect(amazonConfirmBillingAgreementSpy.calledOnce).to.be.true; diff --git a/website/server/controllers/api-v3/groups.js b/website/server/controllers/api-v3/groups.js index 906b40c596..9e52b4808f 100644 --- a/website/server/controllers/api-v3/groups.js +++ b/website/server/controllers/api-v3/groups.js @@ -158,7 +158,7 @@ api.createGroupPlan = { let headers = req.headers; let coupon = req.query.coupon; - await payments.payWithStripe([ + await payments.payWithStripe({ token, user, gift, @@ -167,7 +167,7 @@ api.createGroupPlan = { email, headers, coupon, - ]); + }); } else if (req.body.paymentType === 'Amazon') { let billingAgreementId = req.body.billingAgreementId; let sub = req.body.subscription ? shared.content.subscriptionBlocks[req.body.subscription] : false; @@ -175,14 +175,14 @@ api.createGroupPlan = { let groupId = savedGroup._id; let headers = req.headers; - await payments.subscribeWithAmazon([ + await payments.subscribeWithAmazon({ billingAgreementId, sub, coupon, user, groupId, headers, - ]); + }); } // Instead of populate we make a find call manually because of https://github.com/Automattic/mongoose/issues/3833 diff --git a/website/server/libs/payments.js b/website/server/libs/payments.js index aa17fe7c0c..01338ae7d3 100644 --- a/website/server/libs/payments.js +++ b/website/server/libs/payments.js @@ -397,7 +397,7 @@ api.buyGems = async function buyGems (data) { * @return undefined */ api.payWithStripe = async function payWithStripe (options, stripeInc) { - let [ + let { token, user, gift, @@ -406,7 +406,7 @@ api.payWithStripe = async function payWithStripe (options, stripeInc) { email, headers, coupon, - ] = options; + } = options; let response; let subscriptionId; // @TODO: We need to mock this, but curently we don't have correct Dependency Injection @@ -498,14 +498,14 @@ api.payWithStripe = async function payWithStripe (options, stripeInc) { * @return undefined */ api.subscribeWithAmazon = async function subscribeWithAmazon (options) { - let [ + let { billingAgreementId, sub, coupon, user, groupId, headers, - ] = options; + } = options; if (!sub) throw new BadRequest(shared.i18n.t('missingSubscriptionCode')); if (!billingAgreementId) throw new BadRequest('Missing req.body.billingAgreementId');