mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-17 22:57:21 +01:00
amazon: directly cancel subscription when already closed by amazon
This commit is contained in:
@@ -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;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user