voltrue2 / in-app-purchase

A Node.js module for in-App-Purchase for iOS, Android, Amazon and Windows.
http://iap.gracenode.org
Other
1.04k stars 287 forks source link

isCancelled() is returning false for Android Subscription #328

Open sabinayakc opened 3 years ago

sabinayakc commented 3 years ago

Cancellation Issue:

Platform: Android

Description:

When an android subscription is cancelled, iap.isCancelled() returns false. Looking at the PurchaseItem response, there is no field called cancellationDate for android. Shouldn't the code below be checking for userCancellationTimeMillis for Android instead of cancellationDate? Same goes for isExpired() function.

I haven't checked for IOS.

https://github.com/voltrue2/in-app-purchase/blob/e966ee1348bd4f67581779abeec59c4bbc2b2ebc/index.js#L261

An example subscriptionResponse:

{

service: 'google', status: 0, packageName: 'XXX', productId: 'XXX', purchaseToken: 'XXX', startTimeMillis: '1600461854942', expiryTimeMillis: '1600462273216', autoRenewing: false, priceCurrencyCode: 'USD', priceAmountMicros: '9990000', countryCode: 'US', developerPayload: '', cancelReason: 0, userCancellationTimeMillis: '1600461907018', orderId: 'XXXXX, purchaseType: 0, acknowledgementState: 1, kind: 'androidpublisher#subscriptionPurchase' }

KochMario commented 3 years ago

You're absolutely right. I was wondering the same thing while validating my Android subscriptions. Possibly the Google API changed and @voltrue2 hasn't noticed or hasn't had the time to update.

For the time being, I added an additional validator for android.