IAP Button: Should On Purchase Fail and On Purchase Complete work in editor?

I’m setting up IAP Buttons for the first time, and while testing in the editor I seem to have things working well based on Debug and Fake Store… however, the final piece of the puzzle isn’t doing what I expected. Specifically, when the purchase fails due to Fake Store not actually having the item for purchase, I’m not getting the “On Purchase Fail” methods to respond. Maybe it will help if I post an image or two of what I have in the editor and console:

The IAP Button in question is configured as so:

86708-capture.png

The console reads as follows when I activate that IAP button:

86709-capture.png

Now, shouldn’t the On Purchased Failed section kick in? Those two things by the way just set UI panels to active or inactive, nothing fancy. But they are not doing what they should… or what I THOUGHT they should in this situation.

Also:
Is there anyway to test in editor with FakeStore and get the On Purchase Complete to trigger successfully?

My guess would be that as time var is not local it is common to different instances of the couroutine or maybe you manipulate it on different part of the script or what Mr. Bunny said. Or maybe you destroy the Object from where you call the Coroutine. I ll stop guessing here, if it isn't any of the above you got to give more info.

Probably some racing condition; Different timings in development vs android environment yield different results. Can you post the way you are invoking the co-routine (not just the invocation but the whole context)?

1 Answer

1

(I’m sure this is way too late to help the OP, but for others who come across this question…)

Your success and failure methods need to handle the specific arguments that the IAP button script wants to return, e.g.:

	public void BuyComplete(UnityEngine.Purchasing.Product product)
	{
		//purchase was successful
	}

	public void BuyFailed(UnityEngine.Purchasing.Product product, UnityEngine.Purchasing.PurchaseFailureReason failureReason)
	{
		//purchase was unsuccessful
	}

Once you have hook those up to your IAP button, they will be called, even in the Editor.

-Scott