Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Family libk and subscriptions Codeless IAP

Discussion in 'Android' started by aholla, Dec 20, 2021.

  1. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81
    I have built a kids app. It works fine when using a standard account but if you try and subscribe on a childs device I get no response from the Codless IAP.

    Is there a workflow for this? I.e. preven t the app from showing the IAPs if its a child account?

    Thanks!
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Are you testing via Codeless? You might reconsider Codeless, it does not support receipt validation for example. Instead you would want to use Scripted IAP, there is a working Sample IAP Project here that you can start with

    https://forum.unity.com/threads/sample-iap-project.529555/#post-6950270

    https://docs.unity3d.com/Packages/com.unity.purchasing@3.2/manual/UnityIAPGoogleConfiguration.html

    To debug on the device you mention, we would need to see the device logs:

    https://forum.unity.com/threads/how-to-capturing-device-logs-on-android.528680/
     
  3. aholla

    aholla

    Joined:
    May 27, 2014
    Posts:
    81

    Hi @JeffDUnity3D .

    Yes I am currently using the Codeless, I pass the product to the 'SubsciptionManager' via code though so its a sort of hybrid.

    Code (CSharp):
    1.  
    2. private bool CheckProducts(){
    3.    var productCollection = CodelessIAPStoreListener.Instance?.StoreController?.products;
    4.  
    5.    foreach (var product in productCollection.all)
    6.    {
    7.         // If it doesnt have a reciept, do nothing.
    8.         if (product == null || product.definition == null || product.hasReceipt == false)
    9.         {
    10.              continue;
    11.         }
    12.  
    13.         // Check product for subscription.
    14.         // If we find a subscription, return so no more are processed and the failed subsciption is not dispatched.
    15.         var found = CheckProductForSubscription(product);
    16.         if (found)
    17.         {
    18.                return;
    19.         }
    20.     }
    21. }
    22.  
    23. private static bool CheckProductForSubscription(Product product)
    24.     {
    25.         Debug.Log($"[CodelessIAPHandler] Checking Product. Product={product.definition.id}");
    26.  
    27.         var subsciptionManager = new SubscriptionManager(product, null);
    28.         var subscriptionInfo = subsciptionManager.getSubscriptionInfo();
    29.         var isSubscribed = subscriptionInfo.isSubscribed() == Result.True || subscriptionInfo.isFreeTrial() == Result.True;
    30.         if (isSubscribed)
    31.         {
    32.             Debug.Log($"[CodelessIAPHandler] FOUND SUBSCRIPTION. Product={product.definition.id}");
    33.             Event_SubscriptionComplete?.Invoke(true);
    34.             return true;
    35.         }
    36.         else
    37.         {
    38.             return false;
    39.         }
    40.     }

    Based on the above, do you think I would need to do more? Should I be expecting the SubscriptionManager to be returning a 'isSubscribed'? OR do I need to do something with the receipt validation?

    Thanks,

    Adam
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Sorry we would not be able to support a mix of Scripted and Codeless IAP. You may need to parse the receipt directly as you suggest, please test accordingly.