Get in-app billing user account details - android

I'm creating an Android application that implements subscriptions to digital content on my backend server. What I wish to do is obtain the name and email associated with the Play account that made the purchase, namely the same information I can get if I go to my Merchant account and view an order.
Using the TrivialDrive in-app billing example, I'm able to access the INAPP_PURCHASE_DATA and send that information to my backend server as the "Checking Subscription Documentation" recommends: http://developer.android.com/google/play/billing/v2/billing_subscriptions.html
The documentation lists a typical implementation workflow and says:
When the user successfully purchases a new subscription, your app
notifies a backend server, which stores the purchase token, user name,
and other information in a secure location.
Although I can store the purchase token, and other INAPP_PURCHASE_DATA how do I obtain the user name or email for that matter. From what I can piece togehter I suspect the account details like user name, email, subscripion expiration date must be requested from my back end server. It seems using the purchase token on my backend server is the key to accessing order information, but at this point I haven't found any clear way to go about doing this.
Any suggestions would be appreciated.
Regards

There is an example on the Android Developer site here: Google Play In-app Billing
Testing In-app Billing
Administering In-app Billing
After that Adding items one at a time to a product list
like this
In-app Billing Reference
Then review this Agreement
Helpful links refund policy, In-app Billing, Implementing In-app Billing
Pls tell if you still facing the some problem :)
Thanks

Related

What information can my server get about an app's in-app purchases?

I'm trying to implement in-app purchases (consumable) using the Google Play Billing Library.(which is proving less straightforward that I would like...).
In order to plan the workflow I'd like to know what information is available to a backend server (or to the app, and then can be verified by the server) about an app's purchases. For example: can I get the date and time of purchase?
Yes, you definitely can get the date and time of purchase, order id, state, purchase token and so on. All information about purchase data is described here:
(Table 7) https://developer.android.com/google/play/billing/billing_reference
Concerning server verification, official doc says
Successful purchases also generate a purchase token, which is a unique identifier representing the user and the product ID for the in-app product they purchased. Your apps can store the purchase token locally or, ideally, pass it to your secure backend server where it can be used to verify the purchase and protect against fraud.
The process steps of server verification you need to implement:
https://developer.android.com/google/play/billing/billing_library_overview#Verify-purchase
Google Play In-app Billing samples for more clarity:
https://github.com/googlesamples/android-play-billing

Why Google in-app billing return proper orderId in case of Test Purchase ?

Google says you will receive empty orderId if purchase is test purchase. But we are getting proper orderId, so the question is how to check if the purchase made is a Test Purchase or Not. And why are getting orderId ?
I guess you're checking the json response and not the Google Play order receipt on email which includes an order number.
The JSON response is not supposed to include orderId if it was a test purchase. Have confirmed this few times. Make sure the account you're using to test purchase is included in the licence test accounts in the Google Play Developer Console > App Settings > Account details, then in the License Testing section.
Check here
When your In-app Billing implementation is ready, you can test
purchasing of your in-app SKUs in two ways:
Test purchases, which let your selected license-test users purchase
your in-app products without any resulting charges to the user. Test
purchases can be used in alpha/beta releases only.
Real purchases,
which let regular users make real purchases of your in-app products
with actual charges to the user’s payment instruments.
The problem gets solved on it own, I really didn't do any special but after sometime I start receiving empty orderId.

Use Purchase Status API to validate NON InApp Purchase

According to this topic: Can I use Purchase Status API to validate if app was bought via Play Store the Google Play Developer API provides a Purchase Token which can be fetched any time. So I imagine to send this purchase token to my backend server to ensure this user has already paid for my app, like it is written here: https://developer.android.com/google/play/developer-api.html#practices
Since the first comment on the posted anwer (see above first link) is, that there is no way to check if the playstore confirms the purchase I am confused.
I dont want to use InApp Purchases. I want my users to be able to buy an app and receive a piece of information for validating this google user has purchased it - in order to store set a flag in my own backend: "UserA: has_paid = true"
How can I achieve this?

Android in-app billing developer payload

I would like to implement in-app billing in my android app, but I am not sure how should I create for a developer payload. I don't have any information about user, only unique identifier created in the app to recognize it.
Is it possible to restore the purchase when the user buy a product, then uninstall the app and install it again? How to test it, because I didn't get any events when I tried to test it?
Yes, you can check the completed purchase after uninstall app and install it again.
All purchased items stored on the Play Server and particularly in your installed Google Play app. So after item is purchased once the information about purchase is stored and you can request it at any time untill you "consume" this purchase. "Consume" means reset the information about purchase to allow make new purchase with same ID. This is only for v3 if Android Billing Library, because all purchases in v3 are one-off (you can buy it only once) and have to be "consumed" to be purchased again.
The identifier of the purchase item is a simple string that you define in the Google Developer Console. You should login to the developer console, create new project for the future app, upload signed .apk (necessary), after that you have to select the project, move to "In-App products" section and there you can create necessary purchase items with purchase IDs. While purchase action in the application you should pass the matched purchaseID to the launchPurchaseFlow() method on the IabHelper object (these are all from v3 Billing Library). The information about purchased items can also be received by using matched purchaseID.
Official Google developer documentation has pretty decent amount of information about implementing and using Billing Library:
Implementing billing library guide
Administering In-App products in the developer console
Testing In-app billing. Sorry, cannot post link because of lack of reputation (2 links in answer only), but you can also find this section in the official android documentation. This section also has information about testing with special android test purchase IDs which doesn't require signed and uploaded .apk or any actual money-transfers

Android In app billing purchase history query

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

Categories

Resources