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. We have updated the language to the Editor Terms based on feedback from our employees and community. Learn more.
    Dismiss Notice

Question Android IAP not showing FreeTrial

Discussion in 'Unity IAP' started by DiegoL_LW, May 24, 2022.

  1. DiegoL_LW

    DiegoL_LW

    Joined:
    Mar 31, 2022
    Posts:
    1
    Hello, i'm working with Unity 2020 & EasyMobile, i can buy subscription like i need but i cannot make free trial to appear on Google Play Internal testing neither on Production, no showing on my tester or normal user, even no appear on the receipt.
    the code i used:
    Code (CSharp):
    1.  
    2.  
    3. //this is the part of the code which make the purchase
    4.  
    5. public void PurchaseSubscription(LWSubscriptionType subscriptionType) {
    6.         IsActive = true;
    7.         SetPurchaseHandlers(true);
    8.         InAppPurchasing.Purchase(subs[subscriptionType]);
    9.   }
    10.  
    11. public static void Purchase(string productName)
    12.         {
    13.             IAPProduct pd = GetIAPProductByName(productName);
    14.  
    15.             if (pd != null && pd.Id != null)
    16.             {
    17.                 PurchaseWithId(pd.Id);
    18.             }
    19.             else
    20.             {
    21.                 Debug.Log("IAP purchasing failed: Not found product with name: " + productName + " or its ID is invalid.");
    22.             }
    23.         }
    24.  
    25. public static void PurchaseWithId(string productId)
    26.         {
    27. #if EM_UIAP
    28.             if (IsInitialized())
    29.             {
    30.                 Product product = sStoreController.products.WithID(productId);
    31.  
    32.                 if (product != null && product.availableToPurchase)
    33.                 {
    34.                     Debug.Log("Purchasing product asychronously: " + product.definition.id);
    35.  
    36.                     // Buy the product, expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    37.                     sStoreController.InitiatePurchase(product);
    38.                 }
    39.                 else
    40.                 {
    41.                     Debug.Log("IAP purchasing failed: product not found or not available for purchase.");
    42.                 }
    43.             }
    44.             else
    45.             {
    46.                 // Purchasing has not succeeded initializing yet.
    47.                 Debug.Log("IAP purchasing failed: In-App Purchasing is not initialized.");
    48.             }
    49. #else
    50. // OutputLog
    51. private LWSubscriptionData UpdateSubscripcionData() {
    52.         CurrentSubData.Clear();
    53.         IAPProduct[] subscriptionPods = System.Array.FindAll(EM_Settings.InAppPurchasing.Products,
    54.             prod => prod.Type == IAPProductType.Subscription);
    55.  
    56.         foreach (IAPProduct product in subscriptionPods) {
    57.             SubscriptionInfo sInfo = InAppPurchasing.GetSubscriptionInfo(product.Name);
    58.             if (sInfo == null) {
    59.                 Debug.Log(debugTag + "Failed to retrieve sub info of" + product.Name);
    60.                 continue;
    61.             }
    62.             Debug.Log(debugTag + product.Name + "id?: " + sInfo.getProductId());
    63.             Debug.Log(debugTag + product.Name + "expired?: " + sInfo.isExpired());
    64.             Debug.Log(debugTag + product.Name + "subscribied?: " + sInfo.isSubscribed());
    65.             Debug.Log(debugTag + product.Name + "isFreeTrial?: " + sInfo.isFreeTrial() +" <-Important");
    66.             if (sInfo.isExpired() == Result.False) {
    67.                 Debug.Log(debugTag + " is suscribed to " + product.Name + "/n");
    68.                 CurrentSubData.activateProductname = product.Name;
    69.                 CurrentSubData.expirationDate = sInfo.getExpireDate().ToFileTimeUtc();
    70.             }
    71.  
    72.         }
    73.         return CurrentSubData;
    74.     }
    75.  
    This is the output on logcat https://ibb.co/Lnyjxt7
     
    Last edited: May 24, 2022
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Can you purchase a consumable as a test? So you know, the isFreeTrial flag from Google has never been reliable. You'll want to examine the receipt itself to confirm, it's in clear text. Does it mean the product HAS a free trial? Does it mean the user is IN a free trial? Does it mean that free trial is available to the user? Does the free trial show for the user when going to their Google Dashboard and viewing purchases? If not, then it's not a Unity IAP issue, we are only a pass through service for the Google Billing library. Do you get the system purchase popup? You'll want to contact EasyMobile for additional support.
     
  3. iDrone

    iDrone

    Joined:
    Apr 27, 2021
    Posts:
    1
    Have same issue. There is not info about free trial in the system purchase popup. Does that mean that it's not a Unity IAP issue? I have already checked Google console few times. Everything is set up correctly.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Have you confirmed on the user Google account page that they don't receive the free trial by default? Unity IAP would have no control over this, but we will check regardless.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    From a recent customer regarding this same issue "I managed to get it to work. Nothing needed to change in the app code. I modified the trial on the Play console to use 1 week, rather than 7 days and I removed any other offers on that product. I also enabled backwards compatibility for payments on the offer. Not sure if all of these need to be done. But the play store popup shows the trial now."