Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android in-app billing refund

This is the first time I am implementing in-app billing in android app and I took most of the code straightly from guideline and everything forget perfectly til I thought about refunding. The example app has already refunding implemented, but in a weird way! Refund is received on app as purchase but with state of refund which is totally understandable but the original source looks like this:

        // Count the number of times the product was purchased
        while (cursor.moveToNext()) {
            int stateIndex = cursor.getInt(2);
            PurchaseState state = PurchaseState.valueOf(stateIndex);
            // Note that a refunded purchase is treated as a purchase. Such
            // a friendly refund policy is nice for the user.
            if (state == PurchaseState.PURCHASED || state == PurchaseState.REFUNDED) {
                quantity += 1;
            }
        }

        // Update the "purchased items" table
        updatePurchasedItem(productId, quantity);

its adding item even if it was refunded and I got no idea why is this? Does refunded item has special id or what am i missing? I've only tried this yet with the testing products so I got no idea.

updatePurchasedItem method removes entry from table if quantity is 0 which seems totally right, so I changed my code to this

        while (cursor.moveToNext()) {
            int stateIndex = cursor.getInt(2);
            PurchaseState state = PurchaseState.valueOf(stateIndex);
            // Note that a refunded purchase is treated as a purchase. Such
            // a friendly refund policy is nice for the user.
            if(Consts.DEBUG)
                Log.v(TAG, state == PurchaseState.PURCHASED ? "purchase" : "refund");

            if (state == PurchaseState.PURCHASED) {
                quantity += 1;
            } else if(state == PurchaseState.REFUNDED) {
                quantity = 0;
            }
        }

        // Update the "purchased items" table
        updatePurchasedItem(productId, quantity);

but I doubt there would be wrong code in the example app so I am totally unsure if I am doing it right!

How should i handle this? Please help me!

like image 986
Ruuhkis Avatar asked Jul 11 '12 12:07

Ruuhkis


People also ask

Can you charge back in app purchases?

But, like all other types of sales, in-app purchases can lead to chargebacks. These in-app purchase chargebacks can negatively impact your chargeback-to-transaction ratio — especially if you experience a high volume of disputes due to the microtransaction-based nature of IAPs.

Can I cancel an app subscription and get my money back?

Once you cancel a subscription, you won't be charged for future subscription fees. Past subscription fees won't be refunded. If you have questions, contact the developer through Google Payments.

How do I get a refund for an app I downloaded?

Within 48 hours of purchasing an app you can request a refund from Google by logging into your Play Store account, going to Order History, selecting Request a Refund on the app you want to return, and explaining why. If you miss that 48-hour window, you have to contact the developers directly.

How do I get a refund from an accidental purchase on app Store?

Step 1: Open the web browser and go to Apple's report page with following address: reportaproblem.apple.com and access with your Apple ID. Step 2: Choose the faulty product you purchased and want a refund for, and tap on Report a Problem.


1 Answers

History table has a single entry per purchase. This means that a purchase which was later refunded will have, after the refund, a single history record for the product with a status of "refunded".

When counting purchases, a "Refunded" state suggests the item has been purchased. It is then up to the developer to decide whether the user should have access to refunded products. (There is an example on this site of a developer wanting to refund purchases made by people who have already donated money, and would like to allow them to keep using the product).

If you don't want refunds to count, You should change your code to add quantity for a purchase, but do nothing for a refund. (Do not set quantity to zero).

In app products come in 3 varieties:

  1. Managed item: Google does not allow to purchase such products more than once. Total quantity can add up to zero or one only.

  2. Unmanaged item: Users can buy such products many times. Total quantity can be zero or more

  3. Subscriptions: The same as managed items.

like image 190
OferR Avatar answered Oct 18 '22 05:10

OferR