diff --git a/website/server/controllers/top-level/payments/amazon.js b/website/server/controllers/top-level/payments/amazon.js index 23650cd2a6..9d81f4f4d7 100644 --- a/website/server/controllers/top-level/payments/amazon.js +++ b/website/server/controllers/top-level/payments/amazon.js @@ -235,10 +235,16 @@ api.subscribeCancel = { if (!billingAgreementId) throw new NotAuthorized(res.t('missingSubscription')); - await amzLib.closeBillingAgreement({ + let details = await amzLib.getBillingAgreementDetails({ AmazonBillingAgreementId: billingAgreementId, }); + if (details.BillingAgreementDetails.BillingAgreementStatus.status !== 'Closed') { + await amzLib.closeBillingAgreement({ + AmazonBillingAgreementId: billingAgreementId, + }); + } + let subscriptionBlock = shared.content.subscriptionBlocks[user.purchased.plan.planId]; let subscriptionLength = subscriptionBlock.months * 30;