gpt4 book ai didi

Cordova InAppBilling 只能购买一次

转载 作者:行者123 更新时间:2023-12-01 08:13:53 26 4
gpt4 key购买 nike

我正在使用 Cordova 和这个插件,我目前正在 Google Play 上测试应用内购买。

这是插件地址:

LINK HERE

当我使用时效果很好:

function buy(){
// make the purchase
inappbilling.buy(successHandler, errorHandler,"myProduct");
}

但是,它只允许我购买一次产品...第一次购买后如果我再次尝试,我会收到错误消息:

"ERROR: Error purchasing: labResult: Unable to buy item. (response 7:Error)

所以,我现在正在尝试:

function consumePurchase(){

inappbilling.consumePurchase(successHandler, errorHandler, "myProduct");

}

但这也给我一个错误:

"ERROR: myProduct is not owned so it cannot be consumed"

希望我能得到它,以便我可以多次购买相同的产品吗?

最佳答案

由于看不到有关您的产品的详细信息,但您的产品似乎是非消耗品,因此这是一种大胆的猜测。关于消耗品和非消耗品,引用here (在副标题 非消耗性和消耗性应用内产品 下),其中包含以下内容:

非消耗品

Typically, you would not implement consumption for in-app products that can only be purchased once in your application and provide a permanent benefit. Once purchased, these items will be permanently associated to the user's Google account. An example of a non-consumable in-app product is a premium upgrade or a level pack.

消耗品

In contrast, you can implement consumption for items that can be made available for purchase multiple times. Typically, these items provide certain temporary effects. For example, the user's in-game character might gain life points or gain extra gold coins in their inventory. Dispensing the benefits or effects of the purchased item in your application is called provisioning the in-app product. You are responsible for controlling and tracking how in-app products are provisioned to the users.

推理

为什么您的产品目前看起来像是非消耗品?当您尝试第二次购买该产品时,它会给您 error code 7 .这个错误码是

BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED: Failure to purchase since item is already owned

这只发生在根据定义只能购买一次的非消耗品上。

虽然这些非消耗品不能购买超过一次,但正如名称所示,它们也不能被消耗掉。这会导致您收到关于无法使用该产品的第二条错误消息。

如何修复

简单:将您想要消耗的元素更改为消耗品而不是非消耗品。如果您找不到如何执行此操作,请告诉我。我只能告诉你(因为我以前从未读过应用内结算)是它应该在 Google Play Developer Console 中完成,如指定的 here :

You can specify these types of products for your In-app Billing application — managed >in-app products and subscriptions. Google Play handles and tracks ownership for in-app >products and subscriptions on your application on a per user account basis.

关于Cordova InAppBilling 只能购买一次,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27626571/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com