StansAssets / com.stansassets.android-native

Android Native Plugin Wiki
https://api.stansassets.com/android-native/
10 stars 1 forks source link

Clarification About Ultimate Mobile Pro Unity #37

Closed Ardito closed 3 years ago

Ardito commented 3 years ago

Premise: In my game you can buy gems with which you can buy other items in the game.

1) Gems are a consumer product, right?

2) In your guide: https://unionassets.com/android-native-pro/purchase-flow-675 You say "After use has successfully purchased the product, it will stay inside the user inventory, until you consume it. Also if the user will not able to purchase the same product before you consume it from the inventory", but I bought more times the same product. Why? https://drive.google.com/file/d/1IforDeQjmEgGXPqKaWCpaYmWeXr3MY3H/view?usp=sharing

3) It is possible that the client is not able to correctly send the purchase token to my server, to solve this problem what should I do? If I use PlayerPrefs and all PlayerPrefs are deleted in the meantime, how can I recover the user's purchase?

4) I found this thread on the web: https://stackoverflow.com/questions/56289258/how-does-acknowledgepurchase-really-work-on-android

stan-osipov commented 3 years ago

Hey, @Ardito sorry for the slow replay on this one.

Gems are a consumer product, right?

Yes, gems should be consumable products.

In your guide: https://unionassets.com/android-native-pro/purchase-flow-675 You say "After use has successfully purchased the product, it will stay inside the user inventory, until you consume it. Also if the user will not able to purchase the same product before you consume it from the inventory", but I bought more times the same product. Why? https://drive.google.com/file/d/1IforDeQjmEgGXPqKaWCpaYmWeXr3MY3H/view?usp=sharing

Let's go to the Ultimate Mobile plugin documentation. Here is a typical flow for consumable products.

but I bought more times the same product. Why? Consumable products can be bought as many times as your user wants. The only limitation you can not buy the same consumable product if you haven't finished an active transaction for it.

It is possible that the client is not able to correctly send the purchase token to my server, to solve this problem what should I do? If I use PlayerPrefs and all PlayerPrefs are deleted in the meantime, how can I recover the user's purchase?

On iOS, you can Restore purchases. but that will only restore non-consumable products. There is a very simple rule. Do not call FinishTransaction until you made all the verification and provided user with items he paid for. FinishTransaction - tells that you completed the transaction and all is good. Until you do this, the transaction will "hang". So you can explain user that your server is down or his internet is bad, or any other reason why you can not finish the transaction.

Or you can just give users and items and validate the transaction later without finishing it.

Do I have to confirm user purchases?

That's up to you. There is local receipt validation built-in into the plugin. But only server validation would give you 100% protection from fraud transactions.

How can I validate purchases?

The flow is like this:

How can I use the items in the inventory? I think this was outdated documentation. There is no inventory anymore. Now plugin API matches and API provided by Apple / Google. And it basically translates to:

There are also some features provided by Native API. On iOS You have the dedicated Restore Transaction call. It will restore all the transactions made by the user. So you should always have a "Restore purchases" button in your game if you have non-consumable items.

On Android When you connect to the billing server google provides all the user-owned non-consumable items. The Ultimate Mobile plugin will check for the local purchase record and if it does not exists, it will send transaction to your observer. But sometimes those products can come with a delay.

And once you are done processing and validating the transaction you can call FinsihTransaction.

Ardito commented 3 years ago

Thanks everything works!