Search Unity

Unable to parse introductory period cycles

Discussion in 'Unity IAP' started by kodekq, Oct 31, 2018.

  1. kodekq

    kodekq

    Joined:
    Sep 27, 2014
    Posts:
    21
    At some point, an error began to appear, there was definitely no earlier, I didn’t make any global changes, and I already reset to several versions, it still appears. This happens on iOS. Help, please, to understand the reason.

    This happens when var info = subscriptionManager.getSubscriptionInfo ();
    intro_json at this moment contains {"introductoryPrice": "0", "introductoryPriceLocale": "CZK", "introductoryPriceNumberOfPeriods": "1", "numberOfUnits": "3", "unit": ""}

    Unable to parse introductory period cycles and duration, this product does not have configuration of introductory price period: System.FormatException: Input string was not in the correct format
    at System.Int32.Parse (System.String s) [0x00000] in <filename unknown>:0
    at UnityEngine.Purchasing.SubscriptionInfo..ctor (UnityEngine.Purchasing.Security.AppleInAppPurchaseReceipt r, System.String intro_json) [0x00000] in <filename unknown>:0
    at UnityEngine.Purchasing.SubscriptionManager.getAppleAppStoreSubInfo (System.String payload, System.String productId) [0x00000] in <filename unknown>:0
    at UnityEngine.Purchasing.SubscriptionManager.getSubscriptionInfo () [0x00000] in <filename unknown>:0

    Fully method code
    Code (CSharp):
    1.  public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    2.     {
    3.         this.controller = controller;
    4.         this.extensions = extensions;
    5.  
    6.         initialized = true;
    7.  
    8.         m_AppleExtensions = extensions.GetExtension<IAppleExtensions>();
    9.  
    10.         var introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary();
    11.  
    12.         foreach (var item in controller.products.all) {
    13.             if (item.availableToPurchase) {
    14.  
    15. #if UNITY_IOS
    16.                 m_AppleExtensions.SetStorePromotionVisibility(item, AppleStorePromotionVisibility.Show);
    17. #endif
    18.  
    19.                 if (item.receipt != null) {
    20.                     if (item.definition.type == ProductType.Subscription) {
    21.                         string intro_json = (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId];
    22.                         var subscriptionManager = new SubscriptionManager(item, intro_json);
    23.                         var info = subscriptionManager.getSubscriptionInfo();
    24.                         var id = info.getProductId();
    25.                         CheckNeedSubscriptionTrack(item, info);
    26.  
    27.                         }
    28.                     }
    29.                 }
    30.             }
    31.         }
    32.  
    33.  
    34.     }
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,511
    @kodekq I will let the IAP team know.
     
  3. kodekq

    kodekq

    Joined:
    Sep 27, 2014
    Posts:
    21
    Thank you.
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,511
    In discussing with the team, this is expected behavior. We catch the exception with the mentioned reason, and output to the debug.log. You would want to confirm that this product indeed has an introductory price period. If not, then you can likely ignore the log output.
     
  5. gfaraj

    gfaraj

    Joined:
    Jul 11, 2016
    Posts:
    35
    Hi,

    I would like to revive this thread because this is also happening to me, the JSON for my product's introductory period is this:

    {"introductoryPrice":"0","introductoryPriceLocale":"USD","introductoryPriceNumberOfPeriods":"1","numberOfUnits":"3","unit":""}

    This is all mostly correct - my product has 1 introductory period that's a free 3-day trial. This fails though because the "unit" field is empty when it should be "0" (the representation for the Day unit). For some reason the IAppleExtensions.GetIntroductoryPriceDictionary() method is not populating that "unit" field correctly. I've confirmed that everything is set up correctly in App Store Connect. I think this might be a bug in the IAppleExtensions interface implementation.

    Please look into this, thanks.
     
  6. gfaraj

    gfaraj

    Joined:
    Jul 11, 2016
    Posts:
    35
    For anyone else that might be having this problem, this hack got rid of the issue:

    Code (CSharp):
    1. introJson = introJson?.Replace("\"unit\":\"\"", "\"unit\":\"0\"");
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    6,511
    Great info!! I will let the IAP team know right away and see if we might be able to handle this, although it may actually be an Apple issue.
     
  8. gfaraj

    gfaraj

    Joined:
    Jul 11, 2016
    Posts:
    35
    Sure thing, thanks for looking into it.
     
unityunity