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. Dismiss Notice

Bug Amazon store: Unity IAP doesn't fire any callback if non consumable product is purchased twice

Discussion in 'Unity IAP' started by Knbmedia, Nov 26, 2021.

  1. Knbmedia

    Knbmedia

    Joined:
    Dec 8, 2014
    Posts:
    18
    On Amazon store, if a non consumable product is purchased twice, Unity IAP doesn't fire any callback.
    On Google Play, OnPurchaseFailed is called with PurchaseFailureReason.DuplicateTransaction.
    See attached log screenshot : Unity Purchasing Amazon log "ALREADY_PURCHASED" but OnPurchaseFailed is not called.
    Tested on Unity 2020.3.21f1 and IAP 4.0.3 bug_amazon.png
     
  2. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Interesting. Can you share the purchasing code that you are using? Is this Codeless or Scripted IAP?
     
  3. Knbmedia

    Knbmedia

    Joined:
    Dec 8, 2014
    Posts:
    18
    I use the Scripted IAP the common way.
    Below is an extract of my purchase manager (simplified):

    Code (CSharp):
    1. public class PurchaseManager : Singleton<PurchaseManager>, IStoreListener
    2.     {
    3.         protected IStoreController m_StoreController;
    4.         protected IExtensionProvider m_Extensions;
    5. ...
    6.       void Start()
    7.         {
    8.             InitializePurchasing();
    9.         }
    10.  
    11.         void InitializePurchasing()
    12.         {
    13.             var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    14.             builder.AddProduct("XXXXXX", ProductType.NonConsumable);
    15.             UnityPurchasing.Initialize(this, builder);
    16.         }
    17.  
    18.       public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    19.         {
    20.             m_StoreController = controller;
    21.             m_Extensions = extensions;
    22.  
    23.             if (Application.platform == RuntimePlatform.IPhonePlayer)
    24.                 m_Extensions.GetExtension<IAppleExtensions>().RegisterPurchaseDeferredListener(OnDeferred);
    25.         }
    26.  
    27.         public void OnInitializeFailed(InitializationFailureReason error)
    28.         {
    29.             Debug.Log($"In-App Purchasing initialize failed: {error}");
    30.         }
    31.  
    32.        public void Purchase(string packName)
    33.         {
    34.                m_StoreController.InitiatePurchase(packName);
    35.         }
    36.  
    37.        public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    38.         {
    39.             Product product = args.purchasedProduct;
    40. ...
    41.             return PurchaseProcessingResult.Complete;
    42.         }
    43.         public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    44.         {
    45.             Debug.Log($"Purchase failed - Product: '{product.definition.id}', PurchaseFailureReason: {failureReason}");
    46.         }
    47. }
     
  4. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Looks correct, we will need to test on Amazon.
     
  5. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    @Knbmedia Just checking in, we haven't had a chance to reproduce yet. However, and not to minimize or dismiss the issue, you would want to disable the purchase button if the user has already purchased a non-consumable. You don't want users to purposely hit an error, even if the OnPurchaseFailed method is called or not. So the work around in the meantime would be to properly disable the purchase button when they've already purchased a non-consumable or subscription.
     
  6. Knbmedia

    Knbmedia

    Joined:
    Dec 8, 2014
    Posts:
    18
    Yes of course.
    The only situation that may need this to work is if you have 2 devices and you have purchased an item on one of them.
    The only way to unlock the purchase on the second device is to purchase it again (and then, with the "ALREADY_PURCHASED" error, we can unlock it as a restore solution)...
     
  7. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    Ah good point. We will follow up.
     
  8. JeffDUnity3D

    JeffDUnity3D

    Unity Technologies

    Joined:
    May 2, 2017
    Posts:
    14,446
    I am starting to test this. On my Amazon developer portal, I'm creating a new IAP product. I see "Consumable", "Entitlement", and "Subscription" as the options. Which one did you use?
     
  9. Remstam

    Remstam

    Joined:
    Oct 6, 2017
    Posts:
    22
    @JeffDUnity3D I have a little bit outdated setup to play with Amazon (2018 LTS, asset store 2.2.7 + com.unity.purchasing 2.2.2), but if you want to take some more info into consideration, my subsequent purchase of non-consumable product (which is known as "Entitlement" at IAP dashboard) also results in "ALREADY_PURCHASED" log from Unity Purchasing Amazon sender, but instead of @Knbmedia 's no-reaction result I do get ProcessPurchase called, but with an empty transaction id.

    I guess there had to be PurchaseFailed call with DuplicateTransaction reason equal to GooglePlay behaviour.

    The same goes for subsequent subscription purchase.
     
    JeffDUnity3D likes this.