fix(subs): correct cancellation check logic and test

This commit is contained in:
SabreCat 2022-02-22 11:26:15 -06:00
parent 7080715bcc
commit 08352c5f49
2 changed files with 2 additions and 1 deletions

View file

@ -327,6 +327,7 @@ describe('Google Payments', () => {
});
it('should not cancel a user subscription with autorenew', async () => {
iap.getPurchaseData.restore();
iapGetPurchaseDataStub = sinon.stub(iap, 'getPurchaseData')
.returns([{ autoRenewing: true }]);
await googlePayments.cancelSubscribe(user, headers);

View file

@ -246,7 +246,7 @@ api.cancelSubscribe = async function cancelSubscribe (user, headers) {
if (purchases.length === 0) throw new NotAuthorized(this.constants.RESPONSE_INVALID_RECEIPT);
const subscriptionData = purchases[0];
// Check to make sure the sub isn't active anymore.
if (subscriptionData.autoRenewing === false) return;
if (subscriptionData.autoRenewing !== false) return;
dateTerminated = new Date(Number(subscriptionData.expirationDate));
} catch (err) {