I got my current app in test with some items to testpurchase. And I´ve done that now but I need to do further testing on those items. Is there a way to simply "restore" those purchases so that I dont get that error "You already own this item" ?
There is a way:
Once an in-app product is purchased, it is considered to be "owned".
In-app products in the "owned" state cannot be purchased from Google
Play. You must send a consumption request for the "owned" in-app
product before Google Play makes it available for purchase again.
Consuming the in-app product reverts it to the "unowned" state, and
discards the previous purchase data.
Related
I am testing the refund workflow for my in-app purchases. I am verifying the purchase receipt using the Google Play Developer API https://developers.google.com/android-publisher/api-ref/purchases/products/get. If a user has asked for a refund of the purchase, this API returns the purchaseState as 1 which is correct. At that point, I remove the purchase from my app and the user can no longer avail the benefits of the in-app purchase. But now if a user wants to buy the in-app purchase again, I get the Item already owned error while buying it.
I am not sure how to allow the user to buy the in-app purchase again. I can consume the item once the purchase is reported as canceled in which case I don't get the Item already owned error but I don't think that would be the correct thing to do though.
Please let me know how to handle this use-case.
I'm using Google Play IABv3 and want to be able to easily test what I do (not surprisingly). Since IABv3 all items are managed and it's up to the application to consume the items that it considers consumables.
I'm not sure what the expected work flow is with testing non-consumable products. To be able to test the purchase flow more than once you need to be able to remove the previous purchase. However, the purchase is intended to be non-consumable so we obviously don't want to add any code that consumes it (since it could accidentally slip through and remove real users purchases).
I would like some way of clearing a test users account from purchases, which I doubt is possible since there is no "real" test users.
What is the suggested way to do this?
You can use test product IDs instead of real items. Remember to use it only in debug builds.
https://developer.android.com/google/play/billing/billing_testing.html
android.test.purchased
When you make an In-app Billing request with
this product ID, Google Play responds as though you successfully
purchased an item. The response includes a JSON string, which contains
fake purchase information (for example, a fake order ID). In some
cases, the JSON string is signed and the response includes the
signature so you can test your signature verification implementation
using these responses.
android.test.canceled
When you make an In-app
Billing request with this product ID Google Play responds as though
the purchase was canceled. This can occur when an error is encountered
in the order process, such as an invalid credit card, or when you
cancel a user's order before it is charged.
android.test.refunded
When
you make an In-app Billing request with this product ID, Google Play
responds as though the purchase was refunded. Refunds cannot be
initiated through Google Play's in-app billing service. Refunds must
be initiated by you (the merchant). After you process a refund request
through your Google Wallet merchant account, a refund message is sent
to your application by Google Play. This occurs only when Google Play
gets notification from Google Wallet that a refund has been made. For
more information about refunds, see Handling IN_APP_NOTIFY messages
and In-app Billing Pricing.
android.test.item_unavailable
When you make an In-app Billing request with this product ID, Google Play
responds as though the item being purchased was not listed in your
application's product list.
I am using in-app version 3 in my app. I want to purchase an already owned item from play store. But I saw that managed products can be purchased only once per user account and in Version 3, all in-app products are managed. What should I do?
You need to consume the in-app product within your app by sending a consumePurchase call. Afterwards the item can be purchased again. See https://developer.android.com/google/play/billing/api.html#consume for details.
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 need to verify how my in-app billing works.
Would like to test that with test accounts.
If I buy my in-app item with usage of test account, do I need to pay for it?
Ok, I've tested that - even if test account is used, you have to buy your own item.
Will check later on if it is possible to reverse amount paid (and if google 30% charge would be applied).
Upd. reversal is possible, the whole amount is reversed.
You can reverse your transaction by using
There are four reserved product IDs for testing static in-app billing responses:
http://developer.android.com/guide/market/billing/billing_testing.html
android.test.purchased
When you make an in-app billing request with this product ID, Android Market responds as though you successfully purchased an item. The response includes a JSON string, which contains fake purchase information (for example, a fake order ID). In some cases, the JSON string is signed and the response includes the signature so you can test your signature verification implementation using these responses.
android.test.canceled
When you make an in-app billing request with this product ID Android Market responds as though the purchase was canceled. This can occur when an error is encountered in the order process, such as an invalid credit card, or when you cancel a user's order before it is charged.
android.test.refunded
When you make an in-app billing request with this product ID, Android Market responds as though the purchase was refunded. Refunds cannot be initiated through Android Market's in-app billing service. Refunds must be initiated by you (the merchant). After you process a refund request through your Google Checkout account, a refund message is sent to your application by Android Market. This occurs only when Android Market gets notification from Google Checkout that a refund has been made. For more information about refunds, see Handling IN_APP_NOTIFY messages and In-app Billing Pricing.
android.test.item_unavailable
When you make an in-app billing request with this product ID, Android Market responds as though the item being purchased was not listed in your application's product list.
It seems that Google has improved testability of in-app purchases so that you can test purchases with your products (not just the four reserved product ids) without charging your credit card:
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 before the app is published, but without any resulting charges to the user, and
...
http://developer.android.com/google/play/billing/billing_testing.html#testing-purchases