Is there any way to see if an in-app transaction concerns with an item already owned by a user? Our reports get a bunch of duplicate transactions due to people re-purchasing stuff (after removing the app or switching user accounts) – they don't get charged on Google side for purchasing the unconsumed items multiple times and we need a way to know that.
We tried the following ways:
OrderId field from purchase receipt – seems to be unique every time,
even if the item is already owned.
PurchaseToken – despite having a
number of formats, it seems to be the same for transactions that
involve purchasing the same item by the same person, however a
few of our users still get unique purchase tokens every time they
"purchase".
Is there any way to tell if in-app purchase of this product has already happened in the past (like referring to transaction_id field from original iTunes receipt in Apple ecosystem)?
Is there any way to tell if in-app purchase of this product has
already happened in the past?
AFAIK the In-app billing API doesn't provide such info for consumed products (I assume you use products and not subscriptions).
The cases are:
For non consumed products you should get RESPONSE_CODE with value 7 - ITEM_ALREADY_OWNED from the getBuyIntent method, so you might just not consume the products on the client side and just keep them indefinitely.
For consumed products you might want to save the product SKU (productId) on your app, or associate it with some kind of user account if your system uses user sessions. That way, with the next attempt to buy the product you can match the SKU and just programatically disallow the app to start the intent sender for buying a specified SKU product.
Both orderId and purchaseToken should be unique for a given transaction. They are for further use, for example with the Google Developer API, ie: https://developers.google.com/android-publisher/api-ref/purchases/products/get (see token in request params).
Alternatively you might use the said developer API and optional developerPayload field (however you wish to do that) to match users of your system and play store transactions.
Related
All of the following is for a subscription product, not a buy-one-get-one-free product.
An application has two subscription options: monthly-basic-plan and monthly-full-plan.
The monthly-full-plan is the top plan of the monthly-basic-plan, and users have three different states, including not subscribed to a plan.
The iOS App Store receipt has a value called original_transaction_id.
This value is essentially a hash of the AppleID and subscription_group_identifier that made the purchase.
Once a user has purchased a product, as long as it is the same AppleID, the user will always get the same value, even if the purchase is interrupted, purchased on a different device, or the subscription is automatically renewed.
How can I get the value equivalent to original_transaction_id with Android's GooglePlayDeveloperAPI?
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2
I am retrieving data from SubscriptionPurchaseV2, but there is no value that is the same when a purchase is completed once and the same Google account is used to make the purchase.
When aggregating the data, is it possible to determine if the same user is continuing to purchase subscriptions or not?
When aggregating the data, it is not possible to determine whether the same user is continuing to purchase subscriptions or whether multiple users are changing their purchases.
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.
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
I can't test this myself, because there is no way to completely terminate subscription, apparently.
So, I want to test the following use case: user buys subscription, cancel's it (or it expires), than user buys same subscription.
What will I get with RESTORE_TRANSACTIONS response? Will I get two items with same item id, different purchase tokens and different state? Or purchaseToken will remain the same? I'm afraid that there will be only one subscription with different order ID and purchase token, and the information on previous subscriptions will be lost, but I can't confirm it right now. Also, will orderId be changed with every recurring purchase inside a subscription?
Why I need this - subscription will supply user with new content daily, so when user cancel subscription (subscription A) and later buys a new one (subscription B) I need to show to user content released during time-frame of subscription A,and content in a time-frame of subscription B, but not the content released in period used didn't had active subscription.
Note: You should use the RESTORE_TRANSACTIONS request type only when your application is installed for the first time on a device or when your application has been removed from a device and reinstalled.
Using RESTORE_TRANSACTIONS on a regular basis is not recommended because of performance impacts.
Taken right from Android Developers http://developer.android.com/guide/google/play/billing/billing_overview.html
Although I do understand your concern for the Subscription Billing. Google is pretty good about their API and how you should interact with purchases.
When you send a RESTORE_TRANSACTIONS request you will get two broadcast back. A RESPONSE_CODE and a PURCHASE_STATE_CHANGED. Here's the table from Google stating the different values you could receive.
Coming back to your question about buying two subscriptions: you should check to see if the user has bought a subscription with the GET_PURCHASE_INFORMATION request, if the Subscription is in the list check the Purchase State of the Subscription to see if you should continue with the purchase.
As for what you would get if you "Could" buy two of the same subscriptions, its (I want to say impossible) unlikely... But you will get two order transactions.
As long as you're always aware of the user transactions on your part, Google's API will do the rest. Good luck!