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 Testin
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) {
showPremiumVersion();
} else {
showFreeVersion();
}