In app purchase displays message “you already own this item.” in android

烂漫一生 提交于 2019-12-19 07:43:43

问题


I am trying to implement in-app. In android, in-app is working perfectly.But, when I remove the app from device and reinstall it, then after if I try to purchase, it displays this message (product is Managed and in-app API Version 2)

and in log, I have an error RESULT_DEVELOPER_ERROR , then I googled and I found the Version 3 has more number of response codes like BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED

So if product is already purchased, the response must be like BILLING_RESPONSE_RESULT_ITEM_ALREADY_OWNED and this is not possible in Version 2.

Then what should I do ? Do I need to implement Version 3 ?


回答1:


if you want force to buy product by every time then product should be Unmanaged.

Products can be of 3 types

1) Managed

2) Unmanaged

3) Subcription

Managed means google it self keep record. so by using same email id user not have to paid its charge e.g. remove ads

Unmanaged means user have to buy every time and will be a charged. e.g. Pocker chips

This 2 example i have read on developer site..

and refer http://developer.android.com/google/play/billing/billing_admin.html




回答2:


Have you looked into RESTORE_TRANSACTIONS?

I had pretty much the same problem you describe above. My code is, for the most part, taken from the Market Billing Sample Application.

I added a RESTORE button to my purchase activity which calls the BillingService.restoreTransactions routine.

If you search for RESTORE_TRANSACTIONS within this page: https://developer.android.com/google/play/billing/v2/api.html, you'll find that calling that routine re-triggers the PURCHASE_STATE_CHANGED broadcast.

Which, in my code, triggered the onPurchaseStateChange routine and it worked the same way it would on the initial purchase with the PurchaseState was set to PURCHASED.




回答3:


I ended up with calling BillingService.restoreTransactions() after catching RESULT_DEVELOPER_ERROR. Looks odd, but works fine.



来源:https://stackoverflow.com/questions/14039778/in-app-purchase-displays-message-you-already-own-this-item-in-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!