[Closed] Problem with undoing purchase

For this particular project I am working on, there seems to be something wrong with the IAP. I have tried to make a test purchase on an android tablet, it said “Connection Timed Out” and when I came back later, it said I already own this item but the particular game remained unlocked. One or two months later, I opened the app again, (was working on other things so I took this long) and the game was able to be unlocked only after I go to the purchase screen without touching any of the purchase buttons. So I wanted to try the whole process again and wanted to undo the purchase. I tried using UnityPurchasing.ClearTransactionLog. I discovered some button labelling was wrong and changed it. After that, errors started to appear as in the attached screenshot. Every time I opened the project, Unity will crash, and I deleted the Library folder and opened it again. This time it can open, but with the same errors, and the Services tab cannot load.

I am now using Unity 5.6.0f3.

Any help will be much appreciated, thank you!

Hi Claris,

I’m sorry to hear that you are experiencing these issues.

I can definitely relate to the issue where you are unable to purchase a non-consumable after already purchasing it in test mode. I would “over consume” the non-consumable by temporarily treating it as a consumable. Then restore the product type to non-consumable in my code when I was ready to do a final test.

Are you still unable to connect to the services window when opening the editor? It could have been caused by a small period of downtime. I had some connection trouble earlier but it seems fine now.

In regards to the errors, I suspect that you will need to download the IAP Store package. I cannot see your project window, so I cannot be sure that you have already imported it into your project.

Let me know if this helps.

Hi,

Those errors are consistent with IAP being disabled in the Services window or project settings. Can you confirm if the Services window is just slow loading (there’s a reload button if you right-click on the tab) or is really broken? Is it working better on other projects? If you can get the Services window to show then re-enabling IAP should fix this. That said, you may also want to update your IAP plugin to a newer release once you get past this issue.

@Benvictus and @JayR

Thank you for your replies. The project was able to be opened a few hours ago, the Services windows could load and I turned on Analytics and In-App Purchases. I don’t understand how they were turned off in the first place. It also prompted me to update the package so I did.

But after my lunch, the Services tab showed that I do not have permissions for this action. Is this because of downtime at Unity and it will be back to normal after some time?

@Benvictus , I will try to make my product as consumable and change back to non-consumable when it’s ready for production. Thanks.

@claris Are you still getting this “You do not have permissions for this action” error in the services window? It appears when you open a project that is attached to an organisation that you may not have access to. Are you able to re-select the organisation and project?

Please let me know if you are still seeing errors in your project.

@Benvictus Thanks for asking. The error message is intermittent; it appeared yesterday but now it doesn’t appear and I can reselect the organisation and project.

There’s another issue that I am facing with the IAP. I am testing if the purchases can be restored if a user uninstalls and reinstalls the app. I downloaded my app from Google Play as an alpha tester. There are 3 non-consumable items in the app, and I purchased one of them. Then I uninstalled and reinstalled the app and purchased another item. After that I did the uninstallation and reinstallation and the app did not restore the first item, but the second item was fine. I read that the ProcessPurchase is the function that’s supposed to restore purchases. I am not sure if there’s anything wrong with my code so that it cannot restore formerly purchased items. Here’s the code:

public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
{
    if (String.Equals(args.purchasedProduct.definition.id, ProductIDLearn, StringComparison.Ordinal))
    {
        Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));

        starcontrol.control.unlockLearn = true;

        validproduct = true;
    }
    
    if (String.Equals(args.purchasedProduct.definition.id, ProductIDPlay, StringComparison.Ordinal))
    {
         Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));

         starcontrol.control.unlockPlay = true;

         validproduct = true;
    }
    
    if (String.Equals(args.purchasedProduct.definition.id, ProductIDChallenge, StringComparison.Ordinal))
    {
         Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id));
   
         starcontrol.control.unlockChallenge = true;

         validproduct = true;
    }

    starcontrol.control.Save();

    if (validproduct == false)
    {
         Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id));
    }

    return PurchaseProcessingResult.Complete;
}

@claris

Was the first non-consumable restored when after you reinstalled the first time or was it also missing then too?

Yes, the first non-consumable was restored when I reinstalled the first time. But in the second reinstallation, it was not restored.

@claris I have not been able to reproduce the issue. Are the non-consumables the same or are they individual non-consumables defined in the builder like so?

builder.AddProduct(“Product_01”, ProductType.NonConsumable);
builder.AddProduct(“Product_02”, ProductType.NonConsumable);

@Benvictus , thanks for helping to test. Yes, the non-consumables are individual products, like your example.