Restore purchase (DEF-2738) SOLVED

Works the same on an iPhone 6(7?) Plus with iOS 10.0.2.

1 Like

Did you call just iap.set_listener() ? Without buing product one more time?

Yes, Iā€™m calling iap.set_listener() in the init function of a gui_script. I do not try to buy the product again. Calling iap.set_listener() should trigger a callback of any purchase that hasnā€™t been finished in a previous run of the application.

1 Like

From Apple docs:

Finishing a transaction tells StoreKit that youā€™ve completed everything needed for the purchase. Unfinished transactions remain in the queue until theyā€™re finished, and the transaction queue observer is called every time your app is launched so your app can finish the transactions. Your app needs to finish every transaction, regardless of whether the transaction succeeded or failed.

The restore process does not return a product if it has an unfinished transaction in the payment queue.

If you donā€™t finish Appleā€™s transactions, it will mess up things.

https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/DeliverProduct.html
https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/Chapters/Restoring.html

It works!!! :joy: Thank you!!!

As you can see on my sad example current manual doesnā€™t help with non-consumable purchase at all.
I think it need to make some changes about it in manual:

  • different way of restore purchaise (TRANS_STATE_PURCHASED only on ios even if iap.restore recive true on android) - is it still right behavior?;
  • no need to finish transaction on android if user want non-consumable item (But still need on ios);
  • if purchase was not finished ios will call callback on start of the app for continue purchase;
  • have no callback on ios if you try to buy non-consumable product one more time (but has this callback on android).

This is confusing when I saw that it works the same way on ios and android with consumable purchases. When I try to use non-consumable and has many difference.

I really happy that it was not an engine bug.
And I hope that my pain will help to some developers in future =)))

3 Likes

And one more question about this theme:
Do you have plans to implement callback when purchase was refunded?

Yes, this is a bit unfortunate, but I believe itā€™s likely caused by the fact that we do not have any non-consumable items in our King games. I will see what we can do to improve the documentation.

Yes, I believe this is an oversight on our part. I would expect a callback to be invoked in this case. Iā€™ll look into it.

1 Like

@sicher this looks like @AGulev may want to contribute to our IAP manual =] I bet if it is not clear for him, then other Defold users will be unhappy as well.

4 Likes