android – Handling In-App Billing Refunds in v3-ThrowExceptions

Exception or error:

I am trying to implement in-app billing into my application, I have the buying part working right but how do I take care of issuing a refund?

Under the Testing In-App Billing section it says that you have to watch for IN_APP_NOTIFY but when you click about that it takes you to v2 of the api where you have to register a broadcast receiver. In v3 however it gives no information on what to do or if even IN_APP_NOTIFY is still used the same or supported.

The sample app does not handle refunds either so how am I suppose to handle refunds in v3?

How to solve:

You are supposed to handle them the same way as in v2: when a user requests a refund, cancel or refund the order via the Checkout console. Then the app should check the status of the purchase when starting up, etc. and do the right thing (typically allow access for refunded purchases, and deny for cancelled ones). Unfortunately the provided sample doesn’t bother doing this, so you will have to add it yourself. Even more unfortunate is the fact that due to local caching and/or bugs on the server side, purchases will stay in the purchased state long after you cancel or refund them. There is not much you can do about it though ATM.

Assuming you are using the Trivial Drive sample, you might want to add something like this to your app:

Purchase purchase = inventory.getPurchase(product);
Log.d(TAG, "Purchase state: " + purchase.getPurchaseState());
// 0 (purchased), 1 (canceled), or 2 (refunded).
if (purchase.getPurchaseState() == 0
     || purchase.getPurchaseState() == 2) {
} else {

Leave a Reply

Your email address will not be published. Required fields are marked *