Hi,
in our app we would like to make certain features only available, when a monthly subscription was paid. I have followed the code samples provided with the Unity IAP package in order to locally validate the subscription purchase and its expiry (let’s assume local validation will suffice for our purposes). However, I have encountered multiple issues during internal testing.
As expected during internal testing on the Google Play Store, our monthly subscription is renewed every 5 minutes instead of 1 month. I am using the SubscriptionManager in order to get the SubscriptionInfo once the ProcessPurchase callback is called with the following code snippet:
SubscriptionManager p = new SubscriptionManager(product, intro_json);
SubscriptionInfo info = p.getSubscriptionInfo();
Debug.Log($"Subscription info: \n" +
$"id: {info.getProductId()} \n" +
$"Purchase date: {info.getPurchaseDate()} \n" +
$"IsSubscribed: {info.isSubscribed()} \n" +
$"IsExpired: {info.isExpired()} \n" +
$"IsCancelled: {info.isCancelled()} \n" +
$"ExpireDate: {info.getExpireDate()} \n" +
$"FreeTrialPeriod: {info.getFreeTrialPeriod()} \n" +
$"FreeTrialPeriodString: {info.getFreeTrialPeriodString()} \n");
Where product is the product returned by the ProcessPurchase callback and intro_json was populated in the same manner as the IAP Demo.
My first issue is, that info.getExpireDate() will return a date 1 month in the future, even though the subscription will expire in 5 minutes. Is this behaviour intended?
Furthermore, I noticed that when I forward my local device time by one month, the purchase date will stay the original date, while the expiry date will be adjusted accordingly, i.e. now 2 months in the future relative to the date returned by getPurchaseDate().
Finally, we would like to implement a check for whether the subscription has expired in the app’s OnApplicationFocus method. I tried to get an updated subscription info when OnApplicationFocus is triggered by calling the same code as pasted above with the product returned by storeController.products.all. However, when I cancel my subscription during internal testing and return to the app, getSubscriptionInfo will still return an object where getExpireDate is 1 month in the future and IsSubscribed will return true even long after the 5 minute subscription is expired, thus my subscription prompt is not triggered. Once I restart the app, the product returned by storeController.products.all will have a null receipt again and my subscription logic will correctly trigger a purchase prompt.
Do I somehow have to update the storeController in order to receive an updated receipt, or am I using the SubscriptionManager incorrectly? Or am I encountering these issues simply because I am still in internal testing?
Thank you very much for your help!