I am using the Google Play Billing Library 5 and have a subscription product with different base plans.
When processing the purchases in the PurchasesUpdatedListener or in the callback of queryPurchasesAsync, I receive a list of Purchase objects which contain inter alia the product IDs, purchase time and whether it's auto-renewing.
But how do I know which base plan was selected by the user, and when it expires?
The PurchaseHistoryRecord returned from queryPurchaseHistoryAsync also seems not to contain this info.
I know the Play Developer API returns the expiry time
with purchases.subscriptionsv2.get, but is the inconvenience of using the API directly necessary?
The conclusion I am coming to is that it is best to ignore the whole multiple base plans feature.
Create the subscriptions individually instead so you have
Silver_Plan_Monthly --> Silver_Monthly_Base --> Silver_monthly_free_trial_offer.
Then a separate subscription.
Silver_Plan_Yearly --> Silver_Yearly_Base --> Silver_yearly_free_trial_offer.
And so on for however many subscription levels you want Silver, Gold, Platinum etc.
This way when you get the users purchases you can immediately tell what sub/level/renewal period they bought by the productId which will be the subscription name (Silver_Plan_Monthly).
This is annoying in having to create all these subs but the billing library doesn't give enough info otherwise.
And you should be able to now easily upgrade/downgrade user between these levels and the billing periods.
Related
Recently Google introduces base plans to subscriptions. Base plans are used to introduce different billing period (you end up with single subscription and couple of base plans for example: monthly, weekly, yearly) https://support.google.com/googleplay/android-developer/answer/12154973?hl=en
When I verify subscription on backend I would like to know which base plan user selected but I cannot find any way to get that. Previously I was getting all necessary informations from:
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptions
when Google introduced Base plans they also released purchases.subscriptionsv2:
https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2
but both only returns productId which is subscription id and no base plan id. Any idea how to get that with service account authentication?
On the other hand I can see on Google Play Console under order details productId and selected base plan, so I know subscription is configured correctly
Google added new field offerDetails with basePlanId, offerId and offerTags into lineItems (https://developer.android.com/google/play/billing/compatibility#subscriptionpurchasev2-fields). Fields not documented yet in https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.subscriptionsv2, but already come in response.
I have developed an android app which is paid, now i want to sell my app. I have few vendors who will sell for me, I want to validate which vendor sold how many. How can i do it through my app.
To help you start with, I think you need this official documentation for you to understand well the concept.
The In-app Billing API makes it easier for you to integrate In-app
Billing into your applications. The In-app Billing API supports a
synchronous purchase flow, APIs to let you easily track ownership of
consumable goods, and local caching of in-app purchase data.
To manage 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.
If you are using the In-app Billing API, you can also consume managed
items within your application. You would typically implement
consumption for items that can be purchased multiple times (such as
in-game currency, fuel, or magic spells). Once purchased, a managed
item cannot be purchased again until you consume the item, by sending
a consumption request to Google Play. To learn more about in-app
product consumption, see Consuming Items.
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.
Before I explain my question, let me give an example situation.
A user of a magazine app subscribes to the monthly subscription on the month of August and September. If the user reformats the phone, the app should be able to restore both August and September month's magazines.
The problem with this is that, the In-App Billing API returns only the latest subscription and whether the subscription is active.
Also, I want the users to be able view the previous months' magazines even if they have canceled their subscription.
Is there a way to keep track of all payments made by the user?
This likely would involve your own independent servers and "developer payload" information. As stated in this Subscriptions link:
Include business logic in your app to notify your backend servers of subscription purchases, tokens, and any billing errors that may occur. Your backend servers can use the server-side API to query and update your records and follow up with customers directly, if needed.
In other words, you should be keeping track of this--unfortunately.
Further, you can check this api reference as to whether a user's subscription purchase is valid.
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