I have working app that sells in-app products (InApp billing v3).
Recently I've made an update for this app and made a terrible mistake there: I consumed some of purchases I didn't want to consume.
I issued an update and users updated the app and then wrote me they have no purchased access. (As I found later, I consumed wrong items).
So I have some questions now:
Is there a way to restore consumed purchases or I should return payments to my users?
Is there a way to find out how many and which purchases were consumed?
If returning payments, is there a way to find out if user still has the product or is it consumed with out changing the app (through google services)?
Thanks.
According to what I have understood from your question, It seems like you want to purchase product only once.
What I wished to ask: is there a way to request information about consumed products like about owned products.
you can get response or it's information in any type(Managed Product, Unmanaged Product, Subscription) in the onActivityResult method() check my below link.
In-app billing-v3 error in activity result
but I would not prefer you to manage it customly as you told for one time purchase product(not consumable product). You should go with the Manage product.
Managed In-app Products:
Managed in-app products are items that have their ownership
information tracked and managed by Google Play. When a user purchases
a managed in-app item, Google Play stores the purchase information for
each item on a per-user basis. This enables you to later query Google
Play at any time to restore the state of the items a specific user has
purchased. This information is persistent on the Google Play servers
even if the user uninstalls the application or if they change devices.
for more information about product type
you can query any time you want and you will get the product information, and even you don't need to manage if user has already purchase this product or not.
Is there a way to restore cnsumed purchases or I should return payments to my users?
Better option is you should give the payments back to the user and for the next time check the whole app once using dummy product "android.test.purchased" and update your app.
Is there a wat to find out how many and which purchases were consumed?
You have to check in the Google wallet because all transaction should be handle by the it, check if it gives you product type or not. Using your google developer console credential you can signed into google wallet.
If returning payments is there a way to find out if user stil has the product or is it consumed with out changing the app (through google services)?
as per above answer you have to check in google wallet, according to my knowledge they are provide us all of information about product type with user detail.
Let me know if I have not properly understood your question.
Hope it will solve your problem.
Related
I have developed an app in which I want to give a premium version of an app with ad removal and some extra features in-app products.
So, my question is how to verify if a user had purchased already; Then, when a user opens the app, I know if I should give them a premium interface.
Here's the documentation overview for In App Billing, where it says:
Google Play tracks and manages the ownership information of managed products. When a user purchases a managed product, Google Play stores the purchase information for each product on a per-user basis. This enables you to later query Google Play at any time to restore the state of the products a specific user has purchased. This information is persistent on the Google Play servers even if the user uninstalls the application or if they change devices.
To provide premium content, you'll need to create a managed product that doesn't get consumed in the app when the user purchases it. In order to query the user's in-app purchases, send a getPurchases() request, that will return all the current un-consumed products owned by the user.
If you find the premium content in this response, you know the user has purchased it and can grant them the premium interface.
Google Play Billing AIDL is now deprecated and will be removed in a future release. To implement Google Play Billing features, use the Google Play Billing library and to get purchases details for all the items bought within your app use: queryPurchases(skuType).
I'm not specifically looking to have the option to refund a user for an in app purchase of a consumable, but just in the odd case that a user asks for a refund, either through google, or through the developer of an in app purchase of a consumable.
There does not seem any way of handling refunds through the In App Billing api V3. All documentation points to V2 of the api using broadcast receivers. This does not help me in least bit.
So how are refunds handled in the In App Billing v3 api? I'm assuming for a non consumable, the refund is processed, and then google handles the processing through their backend, and then when a getPurchaseState() is conducted, it would return a value of 2 (refunded). If so, this works great for a NON CONSUMABLE product.
When a getPurchaseState() call to a consumable purchase is made, it returns null. That's assuming if the purchase was previously successful, and that the item was consumed and provisioned. I figure I could store the purchase items locally within the app, but then there is still no way of receiving a refund notification for that product. I can check for purchase state, but again, it will return null, as long as it was consumed and provisioned already.
A slight workaround I can think of right now, is to not consume the purchase on provisioning. So that it remains "unconsumed" according to google, and remains in their database. Now, if a refund is requested, I am assuming a call to getPurchaseState() for that consumable will return refunded, thus the application logic can then subtract/deduct the provisioned consumable from user's inventory. If a user would want to repurchase that consumable again, then before the IAB api call is made for the purchase, get the purchaseState() and/or hasPurchase(), and if there is already a purchase there, consume that item without provisioning, this will let the user repurchase that consumable. Only issue with this workaround, is that if A user wants to re purchase the same consumable product, as soon as the select the option to repurchase, the item must be consumed regardless of whether they successfully repurchase the product or not. So if the user does not complete the purchase, the product is already consumed, and I end up back where I am now with inability to check for refund state on the consumable.
I can't think of any other way to do a refund for a consumable in app product, and that is what I ask here. Is the way I thought of sufficient, or is there a proper way to handle refunds using IAP v3 on consumables?
I was thinking I have 3 options:
Don't offer refunds for consumables, no/little exceptions, but the issue with this is if a user requests refund through google, and not through developer, leading to option 3 below)
Find a workaround (either properly through the api, or with my proposed workaround)
Offer refunds, but have no application logic to subtract/deduct the consumable. In this scenario, users could end up taking advantage of free purchases.
I know this is a super late response to this issue, but it took me quite some time to track down info on this issue, so hopefully it can help someone else out. There are a few ways of doing this... In the Google Play Developer console you can click on the left nav saying "Order Management" which will bring up a list of all recent orders though your app. If you need to refund one you can click on it, or multi select them and refund them in this view. Just a heads up... you will most likely need permissions from your account admin to see this view and refund users.
Your other option is though the API docs here. You will need to set up your API account though the Android console, which I will say is a massive pain and not clear. But once that's set up and your "Server Applications" is set up you will need to make sure it has proper permissions as well. Then you should be able to use a library such as this to do the heavy lifting for you, because from what I've read the JWT auth process though the google API is not super straightforward, and their docs are a mess. I hope this helps someone and comment if you have questions... I will do my best to answer.
This same API also can be used to find items that were purchased by users and then refunded, so you can remove these items from those users' apps. Also you can do server side purchase validation through this as well, which is highly recommended, because rooted phones can inject fake purchase requests making your app believe that it's hearing back from the google play store, but in reality it's not. You then send back to your server the purchase token and SKU of the item being purchased and then on your server you just run this. This will give you back a 400 error if it's invalid, and a 200 with a some JSON data if it's a successful purchase.
I have an application and I am trying to understand in-app billing. I want to do this : If a user buys an item with in-app billing. user can use this item with same account in different device without paying again. So my scenerio is this:
Assume that I have a application and it has in-app billing V3 service. And then a user purchases an "Managed Product" item and the user has an another device then the user wants to install this purcashed item in other device without paying again. But I read here, people talk about this problem:
BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED
At this point I am thinking to consume this product as soon as it is purchased. with this code:
mHelper.consumeAsync(inventory.getPurchase(SKU_MY_ITEM), mConsumeFinishedListener);
if it right way. what will the user see after clicking buy button in another device.(is it possible free purchase)
Also I am not sure what will happen, if the user uninstall and install again my app. what will user see if click a buy button. (purchase again or free purchase or a ERROR)
Can you give advice about in app-billing service for 1 account and many device and also about what will see a user if try to purchase in another device even everything goes right.
From here http://developer.android.com/google/play/billing/api.html :
Managed In-app Products
Managed in-app products are items that have their ownership
information tracked and managed by Google Play. When a user purchases
a managed in-app item, Google Play stores the purchase information for
each item on a per-user basis. This enables you to later query Google
Play at any time to restore the state of the items a specific user has
purchased. This information is persistent on the Google Play servers
even if the user uninstalls the application or if they change devices.
What you want to do is ( like in the example app ) query the inventory on successful setup of your in app service and consume any managed item thus granting access to it.
I use consumable purchases (user may buy one item many times, in my app it convert to digital good) and need ability to restore purchases in future.
I think, there is only way to do this is save user email on server side and when I need to restore purchases, I request user autorization thru Google Play Services, send email to server and restore all data.
It is possible to get user email by which the user makes a purchase after purchase flow?
Or, it may be, there is another method for restoring consumable purchases?
Authorization in the application is not desirable, even though it would solve all problems!
It is possible to get user email by which the user makes a purchase after purchase flow?
When a user purchases an in-app item, Google Wallet assigns the transaction a unique and permanent order number. Google Play provides that order number to you at the conclusion of the purchase flow, as the value of the orderId field of the PURCHASE_STATE_CHANGED intent.
In your app, you can use the order number as a general-purpose identifier for the in-app purchase transaction. After the purchase, you can use the order number as a means of tracking the transaction in reconciliation reports and for customer support.
see Working With Order Numbers for more information
My suggestion would be to link the user to the orderId.
I'm going to guess a few follow up questions you may have:
How to link the user to the orderId?
Probably a simple login / authentication. You could use their Google Account (every Android user has one) - see Android Account Manager. This is a nice approach since your application does not have to handle any passwords - yay!
I want the same user on another phone to get those purchases/user data...
Not really possible without a login - see above (or something to uniquely identify that user) that syncs user data from the cloud to the new/other device.
Or, it may be, there is another method for restoring consumable purchases?
You cannot restore a consumed purchase with Google IAP. Double check whether you want to be using non-consumable purchases instead :)
additional source: IAP v3 API documentation.
I am building an app that I want to use Google in app billing for. Does Google track in-app purchase history for me, so that I can query history and get data, say, by date or by item, etc. Or must my app itself store user's purchase history on my own backend? Also, if you can please provide a link so I can verify this info.
For your question answer is both YES and NO Google will take care of all purchases based on product type. If you are using Non-consumable or Subscription based products Google will keep records, in other case if you are using Consumable products Google will keep it's record till your app consumes that product.
If your app sends a purchase request Google will associate it with primary gmail account registered on android device and will not allow to purchase same product twice.
NOTE:- If You are using IAB-2 then above product type and flow will slightly different
Non-consumable ** is known as **Managed Products
*Subscription* is same as Subscription
*Consumable* is known as Unmanaged products
In case of IAB-2 google will never keep record of Unmanaged products and it is your responsibility to keep records if you want.
For more details see below link to developer guide.
Developer guide