Search Unity

[Solved] Unity IAP triggering double purchase

Discussion in 'Unity IAP' started by raglet, Mar 9, 2016.

Thread Status:
Not open for further replies.
  1. raglet

    raglet

    Joined:
    Nov 22, 2015
    Posts:
    30
    I've incorporated IAP with Unity 5.3.2p3 and I'm having an issue where, on occasion, when I purchase an item, xcode shows a NullReferenceException (see the log below) and when I check, I've got double the coins I should have, from the purchase. I can't tell if I'm being charge twice in the sandbox environment. Can someone please tell me why this could be happening?

    Xcode Log:

    2016-03-09 22:00:37.923 PoogeonBeta[3749:1434697] UnityIAP:UpdatedTransactions
    ProcessPurchase: PASS. Product: 'MugOfCoins'
    InAppPurchases:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.AppleStoreImpl:processMessage(String, String, String, String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/artifacts/generated/common/runtime/UnityEngineDebugBindings.gen.cpp Line: 37)

    NullReferenceException
    at InAppPurchases.setLoadingPanel (Boolean state) [0x00000] in <filename unknown>:0
    at InAppPurchases.ProcessPurchase (UnityEngine.Purchasing.PurchaseEventArgs args) [0x00000] in <filename unknown>:0
    at UnityEngine.Purchasing.PurchasingManager.ProcessPurchaseIfNew (UnityEngine.Purchasing.Product product) [0x00000] in <filename unknown>:0
    at UnityEngine.Purchasing.AppleStoreImpl.ProcessMessage (System.String subject, System.String payload, System.String receipt, System.String transactionId) [0x00000] in <filename unknown>:0
    at UnityEngine.Purchasing.Extension.UnityUtil.Update () [0x00000] in <filename unknown>:0

    (Filename: currently not available on il2cpp Line: -1)
     
  2. raglet

    raglet

    Joined:
    Nov 22, 2015
    Posts:
    30
  3. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    The NullReferenceException is coming from your setLoadingPanel method, you need to understand why that is happening and fix it.

    If an exception is thrown from ProcessPurchase Unity IAP will call ProcessPurchase again on next initialisation.
     
  4. raglet

    raglet

    Joined:
    Nov 22, 2015
    Posts:
    30
    Hi Banderous,

    Thanks for the reply. I've attached my InAppPurchases.cs script below. This should give you a clear idea of where I'm calling this setLoadingPanel method. Basically all I want to do is have the loading panel active until a purchase completes or fails. I'm not sure I've put the calls in the right places so any help with that would really mean a lot, as this is the only thing I need to fix to launch my game. I just want the user to know that something is happing and be unable to press the other purchase button while one purchase is being processed.

    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using System.Collections;
    4. using UnityEngine;
    5. using UnityEngine.Purchasing;
    6.  
    7.  
    8. // Deriving the Purchaser class from IStoreListener enables it to receive messages from Unity Purchasing.
    9. public class InAppPurchases : MonoBehaviour, IStoreListener
    10. {
    11.     private static IStoreController m_StoreController;                                                                  // Reference to the Purchasing system.
    12.     private static IExtensionProvider m_StoreExtensionProvider;                                                         // Reference to store-specific Purchasing subsystems.
    13.  
    14.     // Product identifiers for all products capable of being purchased: "convenience" general identifiers for use with Purchasing, and their store-specific identifier counterparts
    15.     // for use with and outside of Unity Purchasing. Define store-specific identifiers also on each platform's publisher dashboard (iTunes Connect, Google Play Developer Console, etc.)
    16.  
    17.     private static string kProductIDConsumable =    "consumable";                                                         // General handle for the consumable product.
    18.     private static string kProductIDNonConsumable = "nonconsumable";                                                  // General handle for the non-consumable product.
    19.     private static string kProductIDSubscription =  "subscription";                                                   // General handle for the subscription product.
    20.  
    21.     private static string kProductNameAppleConsumable =    "com.unity3d.test.services.purchasing.consumable";             // Apple App Store identifier for the consumable product.
    22.     private static string kProductNameAppleNonConsumable = "com.unity3d.test.services.purchasing.nonconsumable";      // Apple App Store identifier for the non-consumable product.
    23.     private static string kProductNameAppleSubscription =  "com.unity3d.test.services.purchasing.subscription";       // Apple App Store identifier for the subscription product.
    24.  
    25.     private static string kProductNameGooglePlayConsumable =    "com.unity3d.test.services.purchasing.consumable";        // Google Play Store identifier for the consumable product.
    26.     private static string kProductNameGooglePlayNonConsumable = "com.unity3d.test.services.purchasing.nonconsumable";     // Google Play Store identifier for the non-consumable product.
    27.     private static string kProductNameGooglePlaySubscription =  "com.unity3d.test.services.purchasing.subscription";  // Google Play Store identifier for the subscription product.
    28.  
    29.     private static string kProductIDConsumableMugOfCoins = "MugOfCoins";
    30.     private static string kProductIDConsumablePotOfCoins = "PottyOfCoins";
    31.     private static string kProductIDConsumableTubOfCoins = "TubOfCoins";
    32.  
    33.     private static string kProductIDNonConsumableRemoveAds = "RemoveAds";
    34.  
    35.  
    36.     private static string kProductNameAppleConsumableMugOfCoins = "com.agletdesign.poogeonBeta.MugOfCoins001";
    37.     private static string kProductNameAppleConsumablePotOfCoins = "com.agletdesign.poogeonBeta.PotOfCoins001";
    38.     private static string kProductNameAppleConsumableTubOfCoins = "com.agletdesign.poogeonBeta.TubOfCoins001";
    39.  
    40.     private static string kProductNameAppleNonConsumableRemoveAds = "com.agletdesign.poogeonBeta.RemoveAds001";
    41.  
    42.  
    43.     private static string kProductNameGooglePlayConsumableMugOfCoins = "com.agletdesign.poogeonbeta.mugofcoins001";
    44.     private static string kProductNameGooglePlayConsumablePotOfCoins = "com.noarguments.poogeon.PottyOfCoins001";
    45.     private static string kProductNameGooglePlayConsumableTubOfCoins = "com.noarguments.poogeon.TubOfCoins001";
    46.  
    47.     private static string kProductNameGooglePlayNonConsumableRemoveAds = "com.agletdesign.poogeonbeta.removeads001";
    48.  
    49.     public GameObject loadingPanel;
    50.     bool applicationActive = true;
    51.  
    52.     void Start()
    53.     {
    54.         // If we haven't set up the Unity Purchasing reference
    55.         if (m_StoreController == null)
    56.         {
    57.             // Begin to configure our connection to Purchasing
    58.             InitializePurchasing();
    59.         }
    60.     }
    61.  
    62.     public void InitializePurchasing()
    63.     {
    64.         // If we have already connected to Purchasing ...
    65.         if (IsInitialized())
    66.         {
    67.             // ... we are done here.
    68.             return;
    69.         }
    70.  
    71.         // Create a builder, first passing in a suite of Unity provided stores.
    72.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    73.  
    74.         #region Products Added
    75.  
    76.         builder.AddProduct(
    77.             kProductIDNonConsumableRemoveAds,
    78.             ProductType.NonConsumable,
    79.             new IDs(){
    80.                 { kProductNameAppleNonConsumableRemoveAds, AppleAppStore.Name},
    81.                 { kProductNameGooglePlayNonConsumableRemoveAds, GooglePlay.Name},
    82.             }
    83.         );// Remove adds
    84.  
    85.         builder.AddProduct(
    86.             kProductIDConsumableMugOfCoins,
    87.             ProductType.Consumable,
    88.             new IDs() {
    89.                 {kProductNameAppleConsumableMugOfCoins, AppleAppStore.Name},
    90.                 {kProductNameGooglePlayConsumableMugOfCoins, GooglePlay.Name},
    91.             }
    92.         );// Buy 3000 coins
    93.  
    94.         builder.AddProduct(
    95.             kProductIDConsumablePotOfCoins,
    96.             ProductType.Consumable,
    97.             new IDs() {
    98.                 {kProductNameAppleConsumablePotOfCoins, AppleAppStore.Name},
    99.                 {kProductNameGooglePlayConsumablePotOfCoins, GooglePlay.Name},
    100.             }
    101.         );// Buy 15000 coins
    102.  
    103.         builder.AddProduct(
    104.             kProductIDConsumableTubOfCoins,
    105.             ProductType.Consumable,
    106.             new IDs() {
    107.                 {kProductNameAppleConsumableTubOfCoins, AppleAppStore.Name},
    108.                 {kProductNameGooglePlayConsumableTubOfCoins, GooglePlay.Name},
    109.             }
    110.         );// Buy 15000 coins
    111.  
    112.  
    113.         #endregion
    114.  
    115.         UnityPurchasing.Initialize(this, builder);
    116.     }
    117.  
    118.     private bool IsInitialized()
    119.     {
    120.         // Only say we are initialized if both the Purchasing references are set.
    121.         return m_StoreController != null && m_StoreExtensionProvider != null;
    122.     }
    123.  
    124.     #region Purchase Methods
    125.  
    126.     public void BuyConsumableMugOfCoins()
    127.     {
    128.         // Buy the consumable product using its general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    129.         BuyProductID(kProductIDConsumableMugOfCoins);
    130.         //BuyProductID(kProductIDConsumableMugOfCoins);
    131.     }
    132.  
    133.     public void BuyConsumablePottyOfCoins()
    134.     {
    135.         // Buy the consumable product using its general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    136.         BuyProductID(kProductIDConsumablePotOfCoins);
    137.     }
    138.  
    139.     public void BuyConsumableTubOfCoins()
    140.     {
    141.         // Buy the consumable product using its general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    142.         BuyProductID(kProductIDConsumableTubOfCoins);
    143.     }
    144.  
    145.     public void BuyNonConsumableRemoveAds()
    146.     {
    147.         // Buy the consumable product using its general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    148.         BuyProductID(kProductIDNonConsumableRemoveAds);
    149.     }
    150.  
    151.     #endregion
    152.  
    153.     public void BuyConsumable()
    154.     {
    155.         // Buy the consumable product using its general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    156.         BuyProductID(kProductIDConsumable);
    157.     }
    158.  
    159.     public void BuyNonConsumable()
    160.     {
    161.         // Buy the non-consumable product using its general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    162.         BuyProductID(kProductIDNonConsumable);
    163.     }
    164.  
    165.  
    166.     public void BuySubscription()
    167.     {
    168.         // Buy the subscription product using its the general identifier. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    169.         BuyProductID(kProductIDSubscription);
    170.     }
    171.  
    172.  
    173.     void BuyProductID(string productId)
    174.     {
    175.         setLoadingPanel (true);
    176.  
    177.         // If the stores throw an unexpected exception, use try..catch to protect my logic here.
    178.         try
    179.         {
    180.             // If Purchasing has been initialized ...
    181.             if (IsInitialized())
    182.             {
    183.                 // ... look up the Product reference with the general product identifier and the Purchasing system's products collection.
    184.                 Product product = m_StoreController.products.WithID(productId);
    185.  
    186.                 Debug.Log("Localized Price: " + product.metadata.localizedPriceString + " || " + product.metadata.localizedPrice);
    187.  
    188.                 // If the look up found a product for this device's store and that product is ready to be sold ...
    189.                 if (product != null && product.availableToPurchase)
    190.                 {
    191.                     Debug.Log (string.Format("Purchasing product asychronously: '{0}'", product.definition.id));// ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed asynchronously.
    192.                     m_StoreController.InitiatePurchase(product);
    193.                 }
    194.                 // Otherwise ...
    195.                 else
    196.                 {
    197.                     // ... report the product look-up failure situation
    198.                     Debug.Log ("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
    199.                     setLoadingPanel(false);
    200.                 }
    201.             }
    202.             // Otherwise ...
    203.             else
    204.             {
    205.                 // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or retrying initiailization.
    206.                 Debug.Log("BuyProductID FAIL. Not initialized.");
    207.                 setLoadingPanel(false);
    208.             }
    209.         }
    210.         // Complete the unexpected exception handling ...
    211.         catch (Exception e)
    212.         {
    213.             // ... by reporting any unexpected exception for later diagnosis.
    214.             Debug.Log ("BuyProductID: FAIL. Exception during purchase. " + e);
    215.             setLoadingPanel(false);
    216.         }
    217.            
    218.     }
    219.  
    220.     /*public void callRestorePurchases(){
    221.         setLoadingPanel(true);
    222.         StartCoroutine(checkInternetConnection((isConnected)=>{
    223.             if (isConnected == true){
    224.                 Debug.Log("Internet Works! " + isConnected);
    225.                 setLoadingPanel (false);
    226.                 RestorePurchases();
    227.             }else{
    228.                 setLoadingPanel (false);
    229.                 Debug.Log("Internet Broked! " + isConnected);
    230.             }
    231.         }));
    232.     }*/
    233.  
    234.  
    235.     // Restore purchases previously made by this customer. Some platforms automatically restore purchases. Apple currently requires explicit purchase restoration for IAP.
    236.     public void RestorePurchases()
    237.     {
    238.         setLoadingPanel (true);
    239.  
    240.         // If Purchasing has not yet been set up ...
    241.         if (!IsInitialized())
    242.         {
    243.             setLoadingPanel(false);
    244.             // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
    245.             Debug.Log("RestorePurchases FAIL. Not initialized.");
    246.             return;
    247.         }
    248.  
    249.         // If we are running on an Apple device ...
    250.         if (Application.platform == RuntimePlatform.IPhonePlayer ||
    251.             Application.platform == RuntimePlatform.OSXPlayer)
    252.         {
    253.             // ... begin restoring purchases
    254.             Debug.Log("RestorePurchases started ...");
    255.  
    256.             // Fetch the Apple store-specific subsystem.
    257.             var apple = m_StoreExtensionProvider.GetExtension<IAppleExtensions>();
    258.             // Begin the asynchronous process of restoring purchases. Expect a confirmation response in the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore.
    259.             apple.RestoreTransactions((result) => {
    260.                 // The first phase of restoration. If no more responses are received on ProcessPurchase then no purchases are available to be restored.
    261.                 Debug.Log("RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore.");
    262.             });
    263.         }
    264.         // Otherwise ...
    265.         else
    266.         {
    267.             setLoadingPanel(false);
    268.             // We are not running on an Apple device. No work is necessary to restore purchases.
    269.             Debug.Log("RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform);
    270.  
    271.         }
    272.     }
    273.  
    274.  
    275.     //
    276.     // --- IStoreListener
    277.     //
    278.  
    279.     public static List<string> localisedPrices;
    280.  
    281.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    282.     {
    283.         // Purchasing has succeeded initializing. Collect our Purchasing references.
    284.         Debug.Log("OnInitialized: PASS");
    285.         localisedPrices = new List<string> ();
    286.  
    287.         // Overall Purchasing system, configured with products for this application.
    288.         m_StoreController = controller;
    289.         // Store specific subsystem, for accessing device-specific store features.
    290.         m_StoreExtensionProvider = extensions;
    291.  
    292.         Debug.Log("Available items:");
    293.         foreach (var item in controller.products.all)
    294.         {
    295.             if (item.availableToPurchase)
    296.             {
    297.                 localisedPrices.Add (item.metadata.localizedPriceString);
    298.                 Debug.Log(string.Join(" - ",
    299.                     new[]
    300.                     {
    301.                         item.metadata.localizedTitle,
    302.                         item.metadata.localizedDescription,
    303.                         item.metadata.isoCurrencyCode,
    304.                         item.metadata.localizedPrice.ToString(),
    305.                         item.metadata.localizedPriceString
    306.                     }));
    307.             }
    308.         }
    309.     }
    310.  
    311.  
    312.     public void OnInitializeFailed(InitializationFailureReason error)
    313.     {
    314.         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    315.         Debug.Log("OnInitializeFailed InitializationFailureReason:" + error);
    316.     }
    317.  
    318.  
    319.     public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    320.     {
    321.         setLoadingPanel(false);
    322.  
    323.         // A consumable product has been purchased by this user.
    324.         if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal))
    325.         {
    326.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));//If the consumable item has been successfully purchased, add 100 coins to the player's in-game score.
    327.             //ScoreManager.score += 100;
    328.         }
    329.  
    330.         #region Process Result
    331.  
    332.         else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumableMugOfCoins, StringComparison.Ordinal))
    333.         {
    334.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));//If the consumable item has been successfully purchased, add x coins to the player's in-game score.
    335.             buyCoins(3000);
    336.         }
    337.         else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumablePotOfCoins, StringComparison.Ordinal))
    338.         {
    339.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));//If the consumable item has been successfully purchased, add x coins to the player's in-game score.
    340.             buyCoins(10000);
    341.         }
    342.         else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumableTubOfCoins, StringComparison.Ordinal))
    343.         {
    344.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));//If the consumable item has been successfully purchased, add x coins to the player's in-game score.
    345.             buyCoins(25000);
    346.         }
    347.         else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumableRemoveAds, StringComparison.Ordinal))
    348.         {
    349.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));//If the consumable item has been successfully purchased, add x coins to the player's in-game score.
    350.             removeAds();
    351.         }
    352.  
    353.         #endregion
    354.  
    355.         // Or ... a non-consumable product has been purchased by this user.
    356.         else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal))
    357.         {
    358.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));}// Or ... a subscription product has been purchased by this user.
    359.         else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal))
    360.         {
    361.             Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));}// Or ... an unknown product has been purchased by this user. Fill in additional products here.
    362.         else
    363.         {
    364.             Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));}// Return a flag indicating wither this product has completely been received, or if the application needs to be reminded of this purchase at next app launch. Is useful when saving purchased products to the cloud, and when that save is delayed.
    365.        
    366.         return PurchaseProcessingResult.Complete;
    367.  
    368.     }
    369.  
    370.  
    371.     public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    372.     {
    373.         setLoadingPanel(false);
    374.         // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing this reason with the user.
    375.         Debug.Log(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}",product.definition.storeSpecificId, failureReason));
    376.  
    377.         InternetChecker.Instance.checkInternetConnection ();
    378.     }
    379.        
    380.  
    381.     #region Post Purchase Methods
    382.  
    383.     public void removeAds(){
    384.        
    385.         Prefs.setPlayerPrefs (Prefs.removeAdsPrefs, 1);
    386.         EventManager.TriggerEvent ("RemoveAds");
    387.     }
    388.  
    389.     public void buyCoins(int noOfCoins){
    390.         int coins = Prefs.getPlayerPrefs (Prefs.coinsPrefs, 0);
    391.         coins += noOfCoins;
    392.         Prefs.setPlayerPrefs (Prefs.coinsPrefs, coins);
    393.         EventManager.TriggerEvent ("CoinsPurchased");
    394.     }
    395.  
    396.     void setLoadingPanel(bool state){
    397.         loadingPanel.SetActive (state);
    398.         Debug.Log ("SLP Called");
    399.     }
    400.  
    401.     #endregion
    402. }
    403.  
     
  5. raglet

    raglet

    Joined:
    Nov 22, 2015
    Posts:
    30
    BUMP
     
  6. nicholasr

    nicholasr

    Joined:
    Aug 15, 2015
    Posts:
    183
    @raglet I understand now the "loading panel" is displayed during purchase. Thanks for sharing the source.

    Unity IAP will call line #319 ProcessPurchase() on a successful purchase over and over again until the app returns a PurchaseProcessingResult.Complete value.

    To clarify the problem, I suggest adding a Debug.Log("START PROCESSPURCHASE"); at line #321 (before "setLoadingPanel") and a Debug.Log("FINISH PROCESSPURCHASE"); at line #365.

    If the app does not reach that FINISH line...then one can expect Unity IAP to call ProcessPurchase again and again.

    I speculate, as @Banderous suggests, that setLoadingPanel is generating a NullReferenceException if, for instance, "loadingPanel == null".

    Does this seem like a possibility? GameObjects (like the loadingPanel) are automatically "nulled" in certain situations in Unity. Who sets this value? Perhaps use a "getter" to get the fresh copy of the GameObject from the scene instead of storing a public variable? I'm using question marks because I don't have "the one true solution" :) - an example of something I've had to do from our "IAP Samples" repository: https://bitbucket.org/Unity-Technol...eviewer=file-view-default#UnityIAPDemo.cs-284
     
    erika_d likes this.
  7. martindrek

    martindrek

    Joined:
    Dec 10, 2015
    Posts:
    6
    Having the same issue - unable to initialize Purchase Manager - the very official code provided by Unity itself.

    I'm initializing PurchaseManager at startup and it gives me the following error:
    ArgumentException: An element with the same key already exists in the dictionary.
    at System.linq.Enumerable.ToDictionary(Tsource, Tkey, Telement)
    Filename: currently not available on il2cpp line: -1)

    In the Editor mode everything works.

    Please tell me how to fix it.

    Unity version: 5.3.3

    Edit: to clarify the problem i'll post my constructor:

    public PurchaseManager(Text t) { //Text t is used to display log output
    te = t;
    // If we haven't set up the Unity Purchasing reference
    if (m_StoreController == null) {
    powerBallPurchases = new List<PurchaseItem>(); //initialize purchasable items.
    //PurchaseComplete property defines action via delegate what to invoke after purchase has successfully processed.
    powerBallPurchases.Add(new PurchaseItem() { Name = "PB 1", Type = ProductType.Consumable, AppStoreID = "p_1", GooglePlayID = "p_1", Value = 1 });

    // Begin to configure our connection to Purchasing
    InitializePurchasing();
    }
    }
    _________________

    Editor works, Android works, but iOS throws exception. So the problem seems to lie within module provided by Unity.

    More edit:
    It seems that PurchaseManager seems to initialize when there is only one object on the list. I'm pointing my finger at my custom PurchaseItem class. Will try to override Equals method and see what happens.
     
    Last edited: Mar 17, 2016
  8. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    Are you trying to define two items with the same ID?
     
  9. martindrek

    martindrek

    Joined:
    Dec 10, 2015
    Posts:
    6
    I got it to work.
    The problem was in the ID's, yes. I defined AppStore ID's with "n/a"-string identifier and run the program as a test build, because project was imported from Windows and wanted to make sure if all the plugins start up correctly. Apparently it killed the whole program. PS! There were no error messages and everything worked under Editor mode. In Windows and in Mac.
    But when i was debugging the program, i changed the ID's so they would all be unique, but it did not fix the issue anymore. What i eventually did was fix the ID's in Windows, reimport it to Mac platform and build the program as new and everything started to magically work and PurchaseManager initializes. Second solution would have been to Override Equals method and make sure items in ProductBuilder are treated as unique values.
    4 days of hard work and i wish there would be some guidelines or thoroughly commented tutorials covering how to do things and at the same time covering topics what not to do. Oh well... at least it's working!
     
Thread Status:
Not open for further replies.