Search Unity

Bug Problem with Unity IAP android subscription

Discussion in 'Unity IAP' started by funmirko, Mar 28, 2023.

  1. funmirko

    funmirko

    Joined:
    Mar 28, 2023
    Posts:
    5
    Hello.
    Actually i'm working on a mobile game, and i'm using IAP for subscriptions, what i'm figuring out is that in case i buy one month of subscription, then i pause it, and inside the game i buy 3 months, i'm able to buy it, so i'll end with double subscriptions, there is a way to see if it's paused or not?
     
  2. glenhunter

    glenhunter

    Unity Technologies

    Joined:
    Apr 2, 2019
    Posts:
    92
    Hi, there!

    There isn't a dedication feature for checking whether or not a subscription has been paused. However, you can use the Subscription Manager/getSubscriptionInfo to check the expiration date which is a helpful way to gain insights into the status of a subscription.

    By keeping an eye on the expiration date, you'll be able to determine the remaining active period of the subscription and understand whether the payment has been temporarily halted.
     
  3. funmirko

    funmirko

    Joined:
    Mar 28, 2023
    Posts:
    5
    thank for your help!
    actually in case is paused i'm not able to get the recipt with
    "product.hasReceipt" where product is got from " controller.products.all "
    and controller is "IStoreController"

    is this a bug?
     
    Last edited: Mar 30, 2023
  4. funmirko

    funmirko

    Joined:
    Mar 28, 2023
    Posts:
    5

    To be more clear here and give you a better understand of what i'm doing, well our game need a subscription to be played, you can buy it on google play store or in app, if you buy it on google play store and pause it this part of code will fail

    Code (CSharp):
    1.  
    2.         foreach (Product product in controller.products.all)
    3.         {
    4. #if UNITY_ANDROID
    5.             if(product.hasReceipt == false)
    6.             {
    7.  
    8.                 isCheckOK = CheckReceiptOfGoogle(product.receipt);
    9.             }
    10. #elif UNITY_IOS
    11.             isCheckOK = CheckReceiptOfApple(product.receipt);
    12. #endif
    13.  
    14.             if (isCheckOK == true)
    15.             {
    16.                 SubscriptionManager p = new SubscriptionManager(product, null);
    17.                 SubscriptionInfo info = p.getSubscriptionInfo();
    18.  
    19.  
    20.                 CheckSubscriptionInfo(info);
    21.                 break;
    22.             }
    23.         }
    exactly fails on product.hasReceipt that will return false, but if i resume it from the paused state, then, it will be true....
    i'm missing something here?
     
  5. glenhunter

    glenhunter

    Unity Technologies

    Joined:
    Apr 2, 2019
    Posts:
    92
    Hi,

    Thank you for bringing the subscription state issue to our attention and sorry for the inconvenience. I have spoken with the rest of the team and we currently do check for the subscription state. However, we do not currently support the SUBSCRIPTION_STATE_PAUSED status in the subscriptionsv2 in the following link.

    https://developer.android.com/google/play/billing/subscriptions#lifecycle.

    I recommend reviewing the table in the provided link to determine which subscription statuses will show up as active when initializing IAP (under BillingClient.queryPurchasesAsync()) :

    As noted, subscriptions that are paused are not returned on initialization. If data is being tied to a specific user then perhaps there may be a workaround that would involve keeping a history of subscriptions the user purchased in the past and saving the expiration dates before cancelled.
     
  6. funmirko

    funmirko

    Joined:
    Mar 28, 2023
    Posts:
    5

    thank you for your help really appreciated.
    actually, how we could get those information about the user logged in?
     
  7. Baroni

    Baroni

    Joined:
    Aug 20, 2010
    Posts:
    3,268
    @funmirko You would want to implement a login / authentification system to retrieve the player ID for the current user, save the purchase receipts (transaction IDs) on a server and match that with the player ID to build a user inventory. This way, the user can always requests their current purchase inventory when logging in.

    #AD I am offering a cloud service for this use case - the Receipt Validator Service. Not only does it validate the IAP receipts on the server by sending it to Apple/Google (the most secure way to validate purchases), it also automatically creates a user inventory for them, where you have access to the products and expiration dates in case of subscriptions. So, it will allow you to display the next renewal or expiration date in-game.