Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Pending purchases getting called twice on restart

Discussion in 'Unity IAP' started by CMDi-admin, Nov 30, 2018.

  1. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    Hello,

    I've been seeing duplicate ProcessPurchase calls on purchases with the Pending status when relaunching the app. Is this intended behaviour?

    Steps:
    1. Buy product, return "PurchaseProcessingResult.Pending"
    2. Restart the app
    3. public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) is now invoked twice on launch

    Both calls have the same TransactionID and product definition ID.

    Unity 2018.2.6f1
    IAP 2.0.3
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    8,119
    Are you using Codeless by chance, with a Listener? If you have both a Listener and an IAP Button enabled at start, you would see two events. Otherwise, please share the code that you are using.
     
  3. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    I'm using the example from this forum

    I've only edited the NO_ADS identifier and the return_complete to set it default to false.

    Testing on iOS

    Code (CSharp):
    1. using System;
    2. using UnityEngine;
    3. using UnityEngine.Purchasing;
    4. using UnityEngine.UI;
    5.  
    6.  
    7.  
    8. public class MyIAPManager : MonoBehaviour, IStoreListener
    9. {
    10.     private static IStoreController m_StoreController;          // The Unity Purchasing system.
    11.     private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.
    12.     private static Product test_product = null;
    13.  
    14.  
    15.     public static string GOLD_50 = "gold50";
    16.     public static string NO_ADS = "mustang.avi.nlnl.op_weg_met_spiet";
    17.     public static string SUB1 = "subscription1";
    18.  
    19.     private static Text myText;
    20.  
    21.     private Boolean return_complete = false;
    22.  
    23.     void Start()
    24.     {
    25.         myText = GameObject.Find("MyText").GetComponent<Text>();
    26.  
    27.         // If we haven't set up the Unity Purchasing reference
    28.         if (m_StoreController == null)
    29.         {
    30.             // Begin to configure our connection to Purchasing
    31.             InitializePurchasing();
    32.         }
    33.         MyDebug("Complete = " + return_complete.ToString());
    34.     }
    35.  
    36.     public void InitializePurchasing()
    37.     {
    38.         if (IsInitialized())
    39.         {
    40.             return;
    41.         }
    42.  
    43.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    44.  
    45.         builder.AddProduct(NO_ADS, ProductType.NonConsumable);
    46.  
    47.         UnityPurchasing.Initialize(this, builder);
    48.     }
    49.  
    50.  
    51.     private bool IsInitialized()
    52.     {
    53.         return m_StoreController != null && m_StoreExtensionProvider != null;
    54.     }
    55.  
    56.     public void BuySubscription()
    57.     {
    58.         BuyProductID(SUB1);
    59.     }
    60.  
    61.     public void BuyGold50()
    62.     {
    63.         BuyProductID(GOLD_50);
    64.     }
    65.  
    66.     public void BuyNoAds()
    67.     {
    68.         BuyProductID(NO_ADS);
    69.     }
    70.  
    71.     public void CompletePurchase()
    72.     {
    73.         if (test_product == null)
    74.             MyDebug("Cannot complete purchase, product not initialized.");
    75.         else
    76.         {
    77.             m_StoreController.ConfirmPendingPurchase(test_product);
    78.             MyDebug("Completed purchase with " + test_product.transactionID.ToString());
    79.         }
    80.  
    81.     }
    82.  
    83.     public void ToggleComplete()
    84.     {
    85.         return_complete = !return_complete;
    86.         MyDebug("Complete = " + return_complete.ToString());
    87.  
    88.     }
    89.     public void RestorePurchases()
    90.     {
    91.         m_StoreExtensionProvider.GetExtension<IAppleExtensions>().RestoreTransactions(result => {
    92.             if (result)
    93.             {
    94.                 MyDebug("Restore purchases succeeded.");
    95.             }
    96.             else
    97.             {
    98.                 MyDebug("Restore purchases failed.");
    99.             }
    100.         });
    101.     }
    102.  
    103.     void BuyProductID(string productId)
    104.     {
    105.         if (IsInitialized())
    106.         {
    107.             Product product = m_StoreController.products.WithID(productId);
    108.  
    109.             if (product != null && product.availableToPurchase)
    110.             {
    111.                 MyDebug(string.Format("Purchasing product:" + product.definition.id.ToString()));
    112.                 m_StoreController.InitiatePurchase(product);
    113.             }
    114.             else
    115.             {
    116.                 MyDebug("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
    117.             }
    118.         }
    119.         else
    120.         {
    121.             MyDebug("BuyProductID FAIL. Not initialized.");
    122.         }
    123.     }
    124.  
    125.     public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    126.     {
    127.         MyDebug("OnInitialized: PASS");
    128.  
    129.         m_StoreController = controller;
    130.         m_StoreExtensionProvider = extensions;
    131.     }
    132.  
    133.  
    134.     public void OnInitializeFailed(InitializationFailureReason error)
    135.     {
    136.         // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    137.         MyDebug("OnInitializeFailed InitializationFailureReason:" + error);
    138.     }
    139.  
    140.  
    141.     public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    142.     {
    143.         test_product = args.purchasedProduct;
    144.  
    145.  
    146.  
    147.         //MyDebug(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
    148.  
    149.         if (return_complete)
    150.         {
    151.             MyDebug(string.Format("ProcessPurchase: Complete. Product:" + args.purchasedProduct.definition.id + " - " + test_product.transactionID.ToString()));
    152.             return PurchaseProcessingResult.Complete;
    153.         }
    154.         else
    155.         {
    156.             MyDebug(string.Format("ProcessPurchase: Pending. Product:" + args.purchasedProduct.definition.id + " - " + test_product.transactionID.ToString()));
    157.             return PurchaseProcessingResult.Pending;
    158.         }
    159.  
    160.      }
    161.  
    162.  
    163.         public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    164.     {
    165.         MyDebug(string.Format("OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason));
    166.     }
    167.  
    168.     private void MyDebug(string debug)
    169.     {
    170.      
    171.         Debug.Log(debug);
    172.         myText.text += "\r\n" + debug;
    173.     }
    174.  
    175. }
    176.  
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    8,119
    Since I wrote that code, it should be easy for me to test! I will follow up.
     
  5. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
  6. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @cmdNickyG ,
    I'm sorry that I couldn't reproduce this issue.
    Pending purchase only gets 'ProcessPurchase' callback invoked one time at each launch.
    Could you please post a full log?
    Thank you.
     
  7. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    2018-12-12 10:53:45.737340+0100 mustang[8275:3892089] [DYMTLInitPlatform] platform initialization successful
    2018-12-12 10:53:45.765171+0100 mustang[8275:3892013] UnityIAP UnityEarlyTransactionObserver: Created
    2018-12-12 10:53:45.765522+0100 mustang[8275:3892013] UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    2018-12-12 10:53:45.777115+0100 mustang[8275:3892013] Built from '2018.2/release' branch, Version '2018.2.6f1 (c591d9a97a0b)', Build type 'Development', Scripting Backend 'il2cpp'
    2018-12-12 10:53:45.793158+0100 mustang[8275:3892013] -> registered mono modules 0x1019ef960
    2018-12-12 10:53:46.168289+0100 mustang[8275:3892013] [Accessibility] ****************** Loading GAX Client Bundle ****************
    -> applicationDidFinishLaunching()
    PlayerConnection initialized from /var/containers/Bundle/Application/07940C58-A9BF-4A74-A9CE-0374BC618A06/mustang.app/Data (debug = 0)
    PlayerConnection initialized network socket : 0.0.0.0 55000
    Multi-casting "[IP] 10.4.2.18 [Port] 55000 [Flags] 2 [Guid] 3244485476 [EditorId] 3103441499 [Version] 1048832 [Id] iPhonePlayer(device-11):56000 [Debug] 0 [PackageName] iPhonePlayer" to [225.0.0.222:54997]...
    Started listening to [0.0.0.0:55000]
    PlayerConnection already initialized - listening to [0.0.0.0:55000]
    2018-12-12 10:53:46.399317+0100 mustang[8275:3892013] Metal GPU Frame Capture Enabled
    2018-12-12 10:53:46.402300+0100 mustang[8275:3892013] Metal API Validation Disabled
    2018-12-12 10:53:46.593971+0100 mustang[8275:3892013] [MC] Lazy loading NSBundle MobileCoreServices.framework
    2018-12-12 10:53:46.596120+0100 mustang[8275:3892013] [MC] Loaded MobileCoreServices.framework
    2018-12-12 10:53:46.670686+0100 mustang[8275:3892013] UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    -> applicationDidBecomeActive()
    GfxDevice: creating device client; threaded=1
    Initializing Metal device caps: Apple A7 GPU
    Initialize engine version: 2018.2.6f1 (c591d9a97a0b)
    UnloadTime: 2.540666 ms
    UnityIAP Version: 1.18.0
    UnityEngine.Purchasing.StandardPurchasingModule:Instance(AppStore)
    MyIAPManager:InitializePurchasing()
    MyIAPManager:Start()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    File Path: /var/mobile/Containers/Data/Application/EAA8BB1B-E969-4415-9CE3-A33B24C62300/Documents/Unity/IAP/store.json
    UnityEngine.Purchasing.FileReference:CreateInstance(String, ILogger)
    UnityEngine.Purchasing.StoreCatalogImpl:CreateInstance(String, String, ILogger)
    UnityEngine.Purchasing.JSONStore:Initialize(IStoreCallback)
    UnityEngine.Purchasing.PurchasingManager:Initialize(IInternalStoreListener, HashSet`1)
    MyIAPManager:Start()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Fetching optimized store details from https://ecommerce.iap.unity3d.com/c...4EDC8&userid=cf6b3851a441d4ff597a37ccc52e83f6
    UnityEngine.Purchasing.StoreCatalogImpl:FetchProducts(Action`1)
    MyIAPManager:Start()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Complete = False
    MyIAPManager:MyDebug(String)

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache
    UnityEngine.Purchasing.<>c__DisplayClass10_0:<FetchProducts>b__1(String)
    UnityEngine.Purchasing.<Process>d__4:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    2018-12-12 10:53:50.466404+0100 mustang[8275:3892013] UnityIAP:Requesting 1 products
    2018-12-12 10:53:50.467846+0100 mustang[8275:3892013] UnityIAP:Requesting product data...
    2018-12-12 10:53:51.106544+0100 mustang[8275:3892013] UnityIAP:Received 1 products
    OnInitialized: PASS
    MyIAPManager:MyDebug(String)
    MyIAPManager:OnInitialized(IStoreController, IExtensionProvider)
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    UnityIAP: Promo is ready
    UnityEngine.Purchasing.Promo:provideProductsToAds(HashSet`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    2018-12-12 10:53:51.188083+0100 mustang[8275:3892013] UnityIAP:Add transaction observer
    2018-12-12 10:53:51.188245+0100 mustang[8275:3892013] UnityIAP:UpdatedTransactions
    2018-12-12 10:53:51.193121+0100 mustang[8275:3892013] UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    ProcessPurchase: Pending. Product:mustang.avi.nlnl.op_weg_met_spiet - 1000000486254487
    MyIAPManager:MyDebug(String)
    MyIAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Purchasing product:mustang.avi.benl.de_bal_van_boe
    MyIAPManager:MyDebug(String)
    MyIAPManager:BuyProductID(String)
    UnityEngine.Events.UnityEvent:Invoke()
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    UnityEngine.EventSystems.StandaloneInputModule:process()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    2018-12-12 10:54:49.576584+0100 mustang[8275:3892013] UnityIAP:purchaseProduct: mustang.avi.benl.de_bal_van_boe
    2018-12-12 10:54:49.614424+0100 mustang[8275:3892013] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
    2018-12-12 10:54:49.617952+0100 mustang[8275:3892013] [MC] Reading from public effective user settings.
    2018-12-12 10:54:49.631826+0100 mustang[8275:3892013] UnityIAP:UpdatedTransactions
    purchase({0}): mustang.avi.benl.de_bal_van_boe
    UnityEngine.Events.UnityEvent:Invoke()
    UnityEngine.EventSystems.ExecuteEvents:Execute(GameObject, BaseEventData, EventFunction`1)
    UnityEngine.EventSystems.StandaloneInputModule:processTouchPress(PointerEventData, Boolean, Boolean)
    UnityEngine.EventSystems.StandaloneInputModule:processTouchEvents()
    UnityEngine.EventSystems.StandaloneInputModule:process()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    2018-12-12 10:54:51.269303+0100 mustang[8275:3892013] [App] if we're in the real pre-commit handler we can't actually add any new fences due to CA restriction
    -> applicationWillResignActive()
    -> applicationDidBecomeActive()
    -> applicationWillResignActive()
    -> applicationDidBecomeActive()
    2018-12-12 10:55:17.871779+0100 mustang[8275:3892013] UnityIAP:UpdatedTransactions
    -> applicationWillResignActive()
    ProcessPurchase: Pending. Product:mustang.avi.benl.de_bal_van_boe - 1000000486266487
    MyIAPManager:MyDebug(String)
    MyIAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    -> applicationDidBecomeActive()

    2018-12-12 10:56:29.647657+0100 mustang[8283:3893376] [DYMTLInitPlatform] platform initialization successful
    2018-12-12 10:56:29.673554+0100 mustang[8283:3893313] UnityIAP UnityEarlyTransactionObserver: Created
    2018-12-12 10:56:29.673830+0100 mustang[8283:3893313] UnityIAP UnityEarlyTransactionObserver: Registered for lifecycle events
    2018-12-12 10:56:29.685134+0100 mustang[8283:3893313] Built from '2018.2/release' branch, Version '2018.2.6f1 (c591d9a97a0b)', Build type 'Development', Scripting Backend 'il2cpp'
    2018-12-12 10:56:29.702248+0100 mustang[8283:3893313] -> registered mono modules 0x10173f960
    2018-12-12 10:56:29.932705+0100 mustang[8283:3893313] [Accessibility] ****************** Loading GAX Client Bundle ****************
    -> applicationDidFinishLaunching()
    PlayerConnection initialized from /var/containers/Bundle/Application/F8975262-C0BC-4900-AC69-36BF897506EB/mustang.app/Data (debug = 0)
    PlayerConnection initialized network socket : 0.0.0.0 55000
    Socket: bind failed, error: Address already in use(48)

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Network/Sockets.cpp Line: 414)

    Multi-casting "[IP] 10.4.2.18 [Port] 55000 [Flags] 2 [Guid] 1639575366 [EditorId] 3103441499 [Version] 1048832 [Id] iPhonePlayer(device-11):56000 [Debug] 0 [PackageName] iPhonePlayer" to [225.0.0.222:54997]...
    Started listening to [0.0.0.0:55000]
    PlayerConnection already initialized - listening to [0.0.0.0:55000]
    2018-12-12 10:56:30.149397+0100 mustang[8283:3893313] Metal GPU Frame Capture Enabled
    2018-12-12 10:56:30.152227+0100 mustang[8283:3893313] Metal API Validation Disabled
    2018-12-12 10:56:30.324844+0100 mustang[8283:3893313] [MC] Lazy loading NSBundle MobileCoreServices.framework
    2018-12-12 10:56:30.326920+0100 mustang[8283:3893313] [MC] Loaded MobileCoreServices.framework
    2018-12-12 10:56:30.395867+0100 mustang[8283:3893313] UnityIAP UnityEarlyTransactionObserver: Added to the payment queue
    -> applicationDidBecomeActive()
    GfxDevice: creating device client; threaded=1
    Initializing Metal device caps: Apple A7 GPU
    Initialize engine version: 2018.2.6f1 (c591d9a97a0b)
    UnloadTime: 1.743458 ms
    UnityIAP Version: 1.18.0
    UnityEngine.Purchasing.StandardPurchasingModule:Instance(AppStore)
    MyIAPManager:InitializePurchasing()
    MyIAPManager:Start()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    File Path: /var/mobile/Containers/Data/Application/B327B724-79AF-4A5B-AE9D-FF8641C7E807/Documents/Unity/IAP/store.json
    UnityEngine.Purchasing.FileReference:CreateInstance(String, ILogger)
    UnityEngine.Purchasing.StoreCatalogImpl:CreateInstance(String, String, ILogger)
    UnityEngine.Purchasing.JSONStore:Initialize(IStoreCallback)
    UnityEngine.Purchasing.PurchasingManager:Initialize(IInternalStoreListener, HashSet`1)
    MyIAPManager:Start()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Fetching optimized store details from https://ecommerce.iap.unity3d.com/c...4EDC8&userid=cf6b3851a441d4ff597a37ccc52e83f6
    UnityEngine.Purchasing.StoreCatalogImpl:FetchProducts(Action`1)
    MyIAPManager:Start()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Complete = False
    MyIAPManager:MyDebug(String)

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    Failed to fetch IAP catalog due to unexpected http status code, attempting to use cache
    UnityEngine.Purchasing.<>c__DisplayClass10_0:<FetchProducts>b__1(String)
    UnityEngine.Purchasing.<Process>d__4:MoveNext()
    UnityEngine.SetupCoroutine:InvokeMoveNext(IEnumerator, IntPtr)

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    2018-12-12 10:56:34.130397+0100 mustang[8283:3893313] UnityIAP:Requesting 1 products
    2018-12-12 10:56:34.132508+0100 mustang[8283:3893313] UnityIAP:Requesting product data...
    2018-12-12 10:56:34.906510+0100 mustang[8283:3893313] UnityIAP:Received 1 products
    OnInitialized: PASS
    MyIAPManager:MyDebug(String)
    MyIAPManager:OnInitialized(IStoreController, IExtensionProvider)
    UnityEngine.Purchasing.PurchasingManager:CheckForInitialization()
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    ProcessPurchase: Pending. Product:mustang.avi.benl.de_bal_van_boe - 1000000486266487
    MyIAPManager:MyDebug(String)
    MyIAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.PurchasingManager:OnProductsRetrieved(List`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    UnityIAP Promo: Clearing promo product metadata
    UnityEngine.Purchasing.Promo:provideProductsToAds(HashSet`1)
    UnityEngine.Purchasing.AppleStoreImpl:OnProductsRetrieved(String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    2018-12-12 10:56:34.987221+0100 mustang[8283:3893313] UnityIAP:Add transaction observer
    2018-12-12 10:56:34.987375+0100 mustang[8283:3893313] UnityIAP:UpdatedTransactions
    2018-12-12 10:56:34.993862+0100 mustang[8283:3893313] UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    ProcessPurchase: Pending. Product:mustang.avi.nlnl.op_weg_met_spiet - 1000000486254487
    MyIAPManager:MyDebug(String)
    MyIAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    ProcessPurchase: Pending. Product:mustang.avi.benl.de_bal_van_boe - 1000000486266487
    MyIAPManager:MyDebug(String)
    MyIAPManager:processPurchase(PurchaseEventArgs)
    UnityEngine.Purchasing.PurchasingManager:processPurchaseIfNew(Product)
    UnityEngine.Purchasing.JSONStore:OnPurchaseSucceeded(String, String, String)
    UnityEngine.Purchasing.Extension.UnityUtil:Update()

    (Filename: /Users/builduser/buildslave/unity/build/Runtime/Export/Debug.bindings.h Line: 43)

    As you can see, the product mustang.avi.benl.de_bal_van_boe is run through ProcessPurchase twice.

    Product mustang.avi.nlnl.op_weg_met_spiet
    Is and older product from a previous test, not included anymore, but is still called because it has never been set to complete either.
     
    Last edited: Dec 12, 2018
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    8,119
    Yes, pending purchases will invoke the ProcessPurchase callback on IAP initialization on the next app launch. Please use this sample project to confirm the behavior, it is designed to allow returning Pending or Complete at run time. https://forum.unity.com/threads/sample-iap-project.529555/
     
  9. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    As said previously, these logs come from the sample project from that thread, with only a different product ID, and always returning a Pending state.

    When the IAP get initialized the ProcessPurchase callback will be invoke twice for the same product, as seen here:

    First time being when IAP is initialized, second time when UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments gets called.

     
  10. unityjingyao

    unityjingyao

    Unity Technologies

    Joined:
    Feb 20, 2017
    Posts:
    220
    Hi @cmdNickyG ,
    Please update Unity IAP to the latest version and give it a try.
    I tested it with the latest version(1.20.1) and it works well.
    [Windows -> General -> Services -> In-App Purchasing -> Update]
     
  11. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    I'm using the package manager, which says my latest version is 2.0.3
     
  12. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    So, I've run things again, and I'm still seeing this issue with 1.20.1

    This is the first run where I do my purchase:
    Purchase state is left in a Pending state, I then close the app, and run it again giving this result:

    As you can see, the ProcessPurchase is called right after Initialization, and again right after Request to initiate queued payments
     
  13. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    I'm going to list my steps to reproduce again.

    1. Start with a clean sample project (as linked in this thread by @JeffDUnity3D )
    2. Edit the
    private Boolean return_complete = false;
    , to simulate not being able to reach the server for example.
    3. Edit the
    public static string NO_ADS = "mustang.dadk.hekselien_en_elfje_fien";
    to a product which hasn't been bought yet.
    4. Run this code once and buy this product, you should now see
    ProcessPurchase: Pending. Product:<ProductID> - <TransactionID>
    being logged.
    5. Kill the app
    6. Restart the app
    7. You should now see
    ProcessPurchase: Pending. Product:<ProductID> - <TransactionID>
    right after
    OnInitialized: PASS

    8. You should now also see
    UnityIAP UnityEarlyTransactionObserver: Request to initiate queued payments
    followed by again
    ProcessPurchase: Pending. Product:<ProductID> - <TransactionID>
     

    Attached Files:

  14. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    8,119
    It does not reproduce on Android. Can you test on Android also? I will test on iOS next.
     
  15. CMDi-admin

    CMDi-admin

    Joined:
    Jul 23, 2013
    Posts:
    15
    Just tested it, I can confirm on Android this doesn't happen and the ProcessPurchase only gets called once. It seems to be an iOS only issue.
     
unityunity