MonkeyStore: handling interrupted purchases

Monkey Forums/Monkey Bug Reports/MonkeyStore: handling interrupted purchases

secondgear(Posted 2015) [#1]
As far as I can tell, there is a deficiency in BBMonkeyStore design:

If a user purchases a consumable item and for some reason doesn't return to the game, the store doesn't receive the fulfillment confirmation. The next time the game is launched, this purchase is consumed in OpenStoreAsync without notifying the rest of the game, so the game has no way of delivering purchased items to the user.

Although this is an unlikely scenario, this issue was noticed by Microsoft testers, and they asked me to fix my Windows Phone game. Here is my least invasive fix: I'll set BBProduct->owned even for consumables and query the results in the game code after BBMonkeyStore is successfully opened.

The issue isn't limited to WinRT target, so maybe a more permanent solution is needed.


marksibly(Posted 2015) [#2]
Will this work though?

Since you can buy consumables multiple times, wont checking for 'owned' result in multiple purchases? How will the app be able to test if 'owned' is related to a successful purchase or not?

For some weird reason, none of these store APIs seem to track how many consumables you've bought (I think) so I'm not sure what the right way to handle this is.


marksibly(Posted 2015) [#3]
Ok, looking at the winrt code, I think what's supposed to happen is that user can make the purchase again, but wont be charged for it.

This is not ideal, but at least the user isn't ripped off!

I'll have a look for a better solution...


secondgear(Posted 2015) [#4]
My ugly plug relies on the game to reset "owned" to False after the item is awarded to the user. This way when BBMonkeyStore opens and detects an unfinished purchase, it notifies the app store that the purchase is finalized, and sets "owned" field to True. After my game code gets a callback from BBMonkeyStore, it retrieves consumable products and checks if any one of them is "owned". If it finds one, the game awards coins to the user and sets "owned" to False (I had to add a getter and a setter to the Product class).

Maybe a better approach would be to have a separate field for "unfinished" and reset in internally in MonkeyStore in some king of GetUnfinishedPurhcases() method? I don't know, I just went for a quick and dirty fix.


marksibly(Posted 2015) [#5]
> GetUnfinishedPurchases()

Yeah, that sounds pretty good.

Actually, there will only ever potentially be one unfinished purchase at most, correct? I guess it could be passed to IOnOpenStoreComplete, eg:

Method OnOpenStoreComplete:Void( result:Int,unfinished:Product )


secondgear(Posted 2015) [#6]
> Method OnOpenStoreComplete:Void( result:Int,unfinished:Product )

There should be only one, but to be on the safe side, it could be
Method OnOpenStoreComplete:Void( result:Int,unfinished:Product[] )

Otherwise, this is more elegant approach. Thank you, Mark.