mirror of
https://github.com/HabitRPG/habitica.git
synced 2025-12-18 07:07:35 +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'));
|
if (!billingAgreementId) throw new NotAuthorized(res.t('missingSubscription'));
|
||||||
|
|
||||||
await amzLib.closeBillingAgreement({
|
let details = await amzLib.getBillingAgreementDetails({
|
||||||
AmazonBillingAgreementId: billingAgreementId,
|
AmazonBillingAgreementId: billingAgreementId,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
if (details.BillingAgreementDetails.BillingAgreementStatus.status !== 'Closed') {
|
||||||
|
await amzLib.closeBillingAgreement({
|
||||||
|
AmazonBillingAgreementId: billingAgreementId,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
let subscriptionBlock = shared.content.subscriptionBlocks[user.purchased.plan.planId];
|
let subscriptionBlock = shared.content.subscriptionBlocks[user.purchased.plan.planId];
|
||||||
let subscriptionLength = subscriptionBlock.months * 30;
|
let subscriptionLength = subscriptionBlock.months * 30;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user