Group migration fixes (#8555)

* fix(migration): better subs handling

* feat(migration): award jackalopes

* fix(lint): no console logs
This commit is contained in:
Sabe Jones
2017-03-10 18:18:02 -06:00
committed by GitHub
parent bde41699ee
commit ca903f0dc3
4 changed files with 101 additions and 39 deletions

View File

@@ -196,14 +196,19 @@ api.cancelSubscription = async function cancelSubscription (options = {}) {
let details = await this.getBillingAgreementDetails({
AmazonBillingAgreementId: billingAgreementId,
}).catch(function errorCatch (err) {
return err;
});
if (details.BillingAgreementDetails.BillingAgreementStatus.State !== 'Closed') {
let badBAStates = ['Canceled', 'Closed', 'Suspended'];
if (details && details.BillingAgreementDetails && details.BillingAgreementDetails.BillingAgreementStatus &&
badBAStates.indexOf(details.BillingAgreementDetails.BillingAgreementStatus.State) === -1) {
await this.closeBillingAgreement({
AmazonBillingAgreementId: billingAgreementId,
});
}
let subscriptionBlock = common.content.subscriptionBlocks[planId];
let subscriptionLength = subscriptionBlock.months * 30;