Android的应用内结算退款 [英] Android in-app billing refund

查看:234
本文介绍了Android的应用内结算退款的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我第一次实施Android应用程序的应用内计费,我把大部分的code直线距离的guideline ,一切都忘了完美直到我想过退还。该示例应用程序已经包退实施,但在一个奇怪的方式!退款收到有关应用程序的购买,但与退款状态,这是完全可以理解的,但原始来源是这样的:

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方法删除表项,如果数量为0,这似乎是完全正确的,所以我改变了我的code本

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);

但我怀疑会有错误code中的示例应用程序,所以我完全不能确定,如果我这样做是正确的!

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!

推荐答案

历史表中有每购买一台入门。这意味着,在购买以后被退还将有,退款后,对产品的单个历史记录中包含退还的状态。

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).

如果你不想退款来算,你应该​​改变你的code添加量购买,但也无可奈何退款。 (不要设置数量为零)。

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).

在应用产品均在3个品种:

In app products come in 3 varieties:

  1. 管理的项目:谷歌不允许购买此类产品超过一次。总数量最多可以添加零或只有一个。

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

未管理项目:用户可以购买这样的产品很多次。总数量可以是零个或多个

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

订阅:同为管理项目

这篇关于Android的应用内结算退款的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆