Is there a way to consume google play in-app products from backend server?
Asked Answered
K

3

24

Consuming google play in-app products can easily be done from the client application (http://developer.android.com/google/play/billing/api.html#consume).

However I can't find any information about doing this consume request from a backend server. The Purchase Status API (http://developer.android.com/google/play/billing/gp-purchase-status-api.html) is designed to be used from backend servers, however it doesn't provide any methods to consumes in-app products.

Is there a way to consume google play in-app products from backend server?

Korey answered 26/3, 2014 at 17:21 Comment(3)
Did you find an answer to this?Tibbitts
I did not find any solution to consumes in app product. I think this might be design like this on purpose.Korey
Did you find any answer for this ? I need itAetolia
C
8

It's now possible to at least Acknowledge using the Android Publisher V3 API, see:

https://developers.google.com/android-publisher/getting_started

https://developers.google.com/android-publisher/api-ref/purchases/products/acknowledge

Looks like Consume is still only possible from the client.

Curran answered 29/4, 2020 at 9:24 Comment(1)
I think it is good that you can acknowledge from backend but I guess you should not call it for consumables? The documentation is sparse on this. I think there is no way around tracking on your own Database which products have already been purchased. And as long as the client does not consume the IAP. Google Play won't allow that another item is purchased.Valdes
K
7

I'm trying to implement something that sounds similar to your approach. In our case our target audience is children, hence we're not expecting the consumer to be the person paying, and that the parent might buy several copies, one for each child. Hence the normal model (of one thing per customer) doesn't work.

As licencing (per child) is actually dealt with by our servers, any payments (we're handling them as a consumables), have to be actioned on the app, then the token passed to the server to be verified, then the server updates the licenses, and the next time the child concerned interrogates their licences, they perceive the payment to have been actioned. The app then has to mark them as consumed, even though activation is not something it has direct control of. Instead it seems the only option is to manage a table of all of the purchaseTokens, and mark them internally as consumed, and so the app has to periodically ask if any of the tokens pending for the current (google) user, need consuming, and tick them off when they do. As an extension to this, we have to over complicate the payment process by checking ourselves if the child requesting (or the google user that's paying) should be blocked from proceeding, in case they have payments that might be pending from another child.

It would be so much simpler, if google were to allow the server to mark the consumable as used, but I've yet to find a solution. Lets hope APIv4 has it.

Keheley answered 16/10, 2014 at 11:21 Comment(0)
S
1

The purchases.products.consume of the Android Publisher V3 API could consume a purchase for an inapp item.

https://developers.google.com/android-publisher/api-ref/rest/v3/purchases.products/consume

POST https://androidpublisher.googleapis.com/androidpublisher/v3/applications/{packageName}/purchases/products/{productId}/tokens/{token}:consume
Syncopate answered 15/3, 2023 at 7:55 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.