Search Unity

[Solved] InitiatePurchase(product); bug

Discussion in 'Unity IAP' started by IntDev, Dec 9, 2015.

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

    IntDev

    Joined:
    Jan 14, 2013
    Posts:
    152
    If I call InitiatePurchase(product) with the product in the "Already recorded transaction <id>" state, my game enters in an infinite loop state.
     
  2. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,629
    Could you create a bug report please?
     
  3. IntDev

    IntDev

    Joined:
    Jan 14, 2013
    Posts:
    152
    I cannot attach an example though. Is that ok?
     
  4. karl_jones

    karl_jones

    Unity Technologies

    Joined:
    May 5, 2015
    Posts:
    3,629
    Sure any bug report is better than none. A good description to reproduce will have to suffice although a simple repro will increase the chances much more ;)
     
  5. IntDev

    IntDev

    Joined:
    Jan 14, 2013
    Posts:
    152
    There you go 752180
     
    karl_jones likes this.
  6. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @IntDev which platform is this on? And what exactly do you mean by infinite loop - is the player locking up?
     
  7. IntDev

    IntDev

    Joined:
    Jan 14, 2013
    Posts:
    152
    Android. Yes, I can't click anywhere else.
     
  8. rxmarccall

    rxmarccall

    Joined:
    Oct 13, 2011
    Posts:
    303
    I am also getting this message for each product I add to the builder on app startup, though it doesn't lock up for me. (It is locking up for me when I attempt a purchase however, it freezes and the navigation menu pops up like it should be opening the purchase modal. This might be unrelated though.)
     
  9. DoenitZ

    DoenitZ

    Joined:
    Oct 23, 2012
    Posts:
    16
    Hi! I am having a similar problem, the in-app purchase works fine in editor and it works fine the first time I try it in an android mobile device. The problem is when I perform a second attempt in the android device, I get this message in LogCat:

    Unity(20889): Already recorded transaction transactionId.android.test.purchased

    The problem when it happens is I don't get the callback, so I cannot process the purchase.

    In other words, the following function is not called and the app does not know if the purchase was successful or if it failed.

    Code (CSharp):
    1. public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)

    Anyone knows how to fix it?
    Thanks!
     
  10. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @DoenitZ This is as expected; your application has already acknowledged that it has processed the purchase of the non consumable product "android.test.purchased" so Unity IAP will not tell your app about it again.

    @rxmarccall When your app starts up Unity IAP looks for any products that the player owns that the application has not processed the purchases for, which will give rise to those logging messages. When the application freezes are you buying an already owned non consumable?
     
  11. DoenitZ

    DoenitZ

    Joined:
    Oct 23, 2012
    Posts:
    16
    Thanks for the reply, the problem is I set it as "consumable":

    Code (CSharp):
    1.  
    2. private static string idAndroidTest = "android.test.purchased";
    3. // And then:
    4. builder.AddProduct(idTest, ProductType.Consumable,
    5.             new IDs(){{ idAppleTest, AppleAppStore.Name },
    6.                 { idAndroidTest, GooglePlay.Name },});
    7.  
    And even in the LogCat I get the message:

    ---
    I/Unity(20889): Already recorded transaction transactionId.android.test.purchased
    ... (skipping some unrelated lines)
    I/UnityIAP(20889): Finish transaction:transactionId.android.test.purchased
    I/UnityIAP(20889): Consuming android.test.purchased
    I/UnityIAP(20889): invoking callback -- This call back seems to no be related with the one I need
    I/UnityIAP(20889): Consuming sku: android.test.purchased, token: inapp:com.TestProject:android.test.purchased
    I/UnityIAP(20889): Successfully consumed sku: android.test.purchased
    I/UnityIAP(20889): onConsumeFinished:true
    I/UnityIAP(20889): Successful consume of sku android.test.purchased (response: 0:OK)
    I/UnityIAP(20889): 0
    ---

    Maybe the problem is just with the android test product?
     
  12. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    android.test.purchased always gives a transaction id of 'transactionId.android.test.purchased' which is not how real purchases work; they are given a unique ID per transaction. This is why repeated purchases are de-duplicated by Unity IAP.

    I suggest you try sandbox purchases, or you can clear the IAP transaction log with the following

    Code (CSharp):
    1. using System.IO;
    2. //...
    3. Directory.Delete(Path.Combine (Path.Combine (Application.persistentDataPath, "Unity"), "UnityPurchasing"), true);
     
  13. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @IntDev the apparent freeze when trying to buy an owned non consumable is fixed in IAP package 1.1.1 which will be live later on today; just reimport the package from the IAP service window. You can see the version you have installed by checking Changelog.md.
     
    IntDev likes this.
  14. CaptainTire

    CaptainTire

    Joined:
    Feb 1, 2013
    Posts:
    25
    Hello,.I have a problem with InitiatePurchase too.

    My IStoreListener is a singleton object (not attached to a GameObject).

    The game is organized as follows: a single scene, "core", is loaded at the start of the game, then an additional scene that contains MainMenu is loaded additively. From there a user can click on the shop button, MainMenu gets unloaded, Shop gets loaded. And, conversely, when a user leaves the shop scene, it gets unloaded and the MainMenu scene gets loaded again.

    When the shop scene gets loaded, IStoreListener object gets initialized (only once per the lifetime of the application).

    Here's the problem:
    - core scene -> Main menu -> Shop: all the purchases work
    - core scene -> Main menu -> Shop -> Main menu -> Shop: InitiatePurchase gets called, but no corresponding ProcessPurchase/OnPurchaseFailed call happens, and my shop screen gets locked up.

    Then I tried a simpler case. I created a scene with a small tester script that has a button to initialize the IStoreListener and buttons to check if a product has been bought / to buy a product, and a single button to load the "core" scene again. And I made the switch between this and the "core" scene non-additive. And got the same result.

    I have also tried initializing the IStoreListener in one of my shop scenes and then using it in another, and still had the same problem.

    To sum it up, if the scene, during lifetime of which the IStoreListener was initialized, gets unloaded, purchase callbacks seem to break.

    The problem occurs both on local machine and on a windows phone device. In Editor, surprisingly, everything works perfectly.

    Could someone please shed some light on this issue?
     
  15. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    @CaptainTire This works fine in my testing against the desktop Windows store 8.1 simulator. Can you attach any debugging trace from visual studio?
     
  16. CaptainTire

    CaptainTire

    Joined:
    Feb 1, 2013
    Posts:
    25
    @Banderous well I have this exception every time I call UnityPurchasing.Initialize:
    Code (csharp):
    1.  
    2. 'The Last Day of the Decade.exe' (Win32): Loaded 'D:\LDOD_builds\ldod_wsa_d3d_none\The Last Day of the Decade\bin\x86\Debug\AppX\System.Reflection.TypeExtensions.dll'.
    3. 'The Last Day of the Decade.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'D:\LDOD_builds\ldod_wsa_d3d_none\The Last Day of the Decade\bin\x86\Debug\AppX\System.Reflection.TypeExtensions.dll'. Cannot find or open the PDB file.
    4. [5.861886 / 64.130844] - OnWindowActivated event - Deactivated.
    5. [15.461514 / 79.592358] - OnWindowActivated event - CodeActivated.
    6. Initter: start
    7.  
    8. (Filename: C:\buildslave\unity\build\artifacts/generated/Metro/runtime/UnityEngineDebugBindings.gen.cpp Line: 40)
    9.  
    10.  
    11. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'. Cannot find or open the PDB file.
    12. 'The Last Day of the Decade.exe' (Win32): Unloaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'
    13. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'. Cannot find or open the PDB file.
    14. 'The Last Day of the Decade.exe' (Win32): Unloaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'
    15. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'. Cannot find or open the PDB file.
    16. 'The Last Day of the Decade.exe' (Win32): Unloaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'
    17. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'. Cannot find or open the PDB file.
    18. 'The Last Day of the Decade.exe' (Win32): Unloaded 'C:\Windows\WinSxS\x86_microsoft.windows.common-controls_6595b64144ccf1df_5.82.11082.1000_none_31a4a043eeb25f60\comctl32.dll'
    19. Exception thrown at 0x747A1048 (KernelBase.dll) in The Last Day of the Decade.exe: 0x40080201: WinRT originate error (parameters: 0x8000000B, 0x00000040, 0x1680F428).
    20. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.ApplicationModel.Store.TestingFramework.dll'. Cannot find or open the PDB file.
    21. Exception thrown at 0x747A1048 in The Last Day of the Decade.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x08EFC974.
    22. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\SysWOW64\webservices.dll'. Cannot find or open the PDB file.
    23. WinStoreManager: init start <- this is printed immediately after calling Initialize()
    24.  
    25. (Filename: C:\buildslave\unity\build\artifacts/generated/Metro/runtime/UnityEngineDebugBindings.gen.cpp Line: 40)
    26.  
    27.  
    28. 'The Last Day of the Decade.exe' (Win32): Loaded 'C:\Windows\SysWOW64\Windows.ApplicationModel.Store.dll'. Cannot find or open the PDB file.
    29. Initter: after calling initialize
    30.  
    31. (Filename: C:\buildslave\unity\build\artifacts/generated/Metro/runtime/UnityEngineDebugBindings.gen.cpp Line: 40)
    32.  
    33.  
    34. Exception thrown at 0x747A1048 in The Last Day of the Decade.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x0913DC14.
    35. 'The Last Day of the Decade.exe' (Win32): Loaded 'D:\LDOD_builds\ldod_wsa_d3d_none\The Last Day of the Decade\bin\x86\Debug\AppX\System.Text.Encoding.Extensions.dll'. Module was built without symbols.
    36. 'The Last Day of the Decade.exe' (CoreCLR: CoreCLR_UWP_Domain): Loaded 'D:\LDOD_builds\ldod_wsa_d3d_none\The Last Day of the Decade\bin\x86\Debug\AppX\System.Text.Encoding.Extensions.dll'. Module was built without symbols.
    37. Exception thrown at 0x747A1048 in The Last Day of the Decade.exe: Microsoft C++ exception: EETypeLoadException at memory location 0x0913DC1C.
    38. WinStoreManager: init end <- this is printed in OnInitialized((
    39.  
    40. (Filename: C:\buildslave\unity\build\artifacts/generated/Metro/runtime/UnityEngineDebugBindings.gen.cpp Line: 40)
    41.  
    42.  
    43. Initter: end
    44.  
    45. (Filename: C:\buildslave\unity\build\artifacts/generated/Metro/runtime/UnityEngineDebugBindings.gen.cpp Line: 40)
    46.  
    47.  
    When I initialize a purchase (both in successful and unsuccessful cases), I get this line in the output:
    Code (csharp):
    1.  
    2. purchase({0}): ldod.ep2
    3.  
    In the case of an unsuccessful purchase that's it, I get nothing else.
    If the purchase succeeds though, I get additional lines from Unity IAP logs:
    Code (csharp):
    1.  
    2. UnibillWin8:Purchase ldod.ep2 status:Succeeded
    3. PURCHASE SUCCEEDED!:{0}: 0
    4. Already recorded transaction c3cbe9f0-ad6a-47ce-89c0-58380c1d5818
    5. Fulfilling transaction c3cbe9f0-ad6a-47ce-89c0-58380c1d5818
    6. UnibillWin8:Consuming:ldod.ep2
    7. UnibillWin8:Fulfilment result for ldod.ep2 - c3cbe9f0-ad6a-47ce-89c0-58380c1d5818 : NothingToFulfill
    8.  
    And for some reason the last three lines get repeated over and over when I minimize/maximize the application
     
    Last edited: Jan 21, 2016
  17. Banderous

    Banderous

    Joined:
    Dec 25, 2011
    Posts:
    669
    Is this running with simulated local IAP testing or a live/beta distribution of your App?

    I'm not sure what exception you're referring to in the first trace, I can't see anything that's necessarily a problem.

    The last scenario is as expected. Unity IAP checks for new purchases when the App is foregrounded, which is required by Microsoft's guidelines. There are no new transactions so no new ProcessPurchase method is called.
     
  18. CaptainTire

    CaptainTire

    Joined:
    Feb 1, 2013
    Posts:
    25
    @Banderous with simulated local IAP testing, with useMockBillingSystem set to true for both my module and builder.

    By the exception in the first trace I meant WinRT originate error. I don't notice it too often and I thought that maybe it is somehow responsible for the bug.

    Thanks for clarifications about the last scenario.
     
    Last edited: Jan 26, 2016
Thread Status:
Not open for further replies.
unityunity