Android In-App-Purchase, how to check if user have purchased one item

virsir picture virsir · Oct 8, 2013 · Viewed 7.8k times · Source

is that OK and safe to set a value in SharedPreference to flag that the user have purchased this item? What if user hack this value in SharedPreference. Or I need to connect IAP service everytime to check that before user can use it?

(1) What is the best practice when I use Google Android IAP V3?

(2) And also if user's device have no Google Play installed, I may want to use paypal to make the payment, but how to track the purchase and unlock the features for users if I ask user to use simple paypal payment to get a license key? I do not want to use any other billing SDK, if with Paypal web page to buy the license, How to implement this?

Answer

Maulik picture Maulik · Oct 12, 2013

(1) What is the best practice when I use Google Android IAP V3?

--> official document says that only payment transaction will be handle by google play itself, but in the application you have to set your business logic how you handle UI integration and other things after product purchase. You can also go with the in app purchase v3.

(2) And also if user's device have no Google Play installed, I may want to use paypal to make the payment, but how to track the purchase and unlock the features for users if I ask user to use simple paypal payment to get a license key? I do not want to use any other billing SDK, if with Paypal web page to buy the license, How to implement this?

--> You can ask user to update google play version dynamically. Google developer doc says more than 90% device using 2.2 os with installed google play store. I could not say any thing about paypal transaction because I haven't use it before, but yes in app purchase using v3 is very simple to implement and understand the payment process.

How to use in your application

Three way to manage your application's product data.

1) SharedPrefrence: you can use the share prefrence value and check whether it is purchased or not. if in case user uninstalled the app and then re-install the app then you can check whether user has purchased or not, at this you get the item is already purchased. And you have to manage the user to access your application data.

2) local database: you can also use local sqlite database to store the purchase detail and purchase status. and same as above if user clear data or uninstall the app then request for the purchase item again and check whether user purchased item or not.

or

2) Server database: It is the better way compare to above if you are using web server to store the user data. In this type, you doesn't even need to manage for the second time for the case if user uninstall the app or clear the application data.

3) obfuscation: (Most efficient way compare to shared prefrence)

EDIT:

is that OK and safe to set a value in SharedPreference to flag that the user have purchased this item? What if user hack this value in SharedPreference. Or I need to connect IAP service everytime to check that before user can use it?

While I am searching on internet I found Nikolay Elenkov's answer like below:

If you just save a flag in shared preferences, any user with a rooted device can flip the flag at will and be 'subscribed' without paying. So you should at least do some obfuscation. Here's a sample way to do it. Additionally, there is an API to check for subscription state, so you should check periodically to make sure the subscription is valid.

more information check Nikolay Elenkov's answer

What is the best for billing Either In app purchase or Paypal?

It is depends on the product type,

--> In app billing: Best for google in app billing,

For the digital products including downloadable content such as media files or photos, virtual content such as game levels or potions, premium services and features, and more.

http://developer.android.com/google/play/billing/index.html

--> Paypal: Best for Paypal billing,

For physical content or product do you want to share. You are not permitted to sell physical goods or services using 'In-App Purchasing' since the goods purchased via this method must relate directly to the app using them.

Purchase physical product from iPhone app without Apple in app purchase

Hope it will help you.