Choosing a Purchase Type
An item's purchase type controls how Google Play manages the purchase of the item. There are two purchase types: "managed per user account" and "unmanaged."
Items that are managed per user account can be purchased only once per user account. When an item is managed per user account, Google Play permanently stores the transaction information for each item on a per-user basis.This enables you to query Google Play with theRESTORE_TRANSACTIONS
request and restore the state of the items a specific user has purchased.
If a user attempts to purchase a managed item that has already been purchased, Google Play displays an "Item already purchased" error. This occurs during checkout, when Google Play displays the price and description information on the checkout page. When the user dismisses the error message, the checkout page disappears and the user returns to your user interface.As a best practice, your application should prevent the user from seeing this error. The sample application demonstrates how you can do this by keeping track of items that are managed and already purchased and not allowing users to select those items from the list. Your application should do something similar—either graying out the item or hiding it so that it cannot be selected.
The "manage by user account" purchase type is useful if you are selling items such as game levels or application features. These items are not transient and usually need to be restored whenever a user reinstalls your application, wipes the data on their device, or installs your application on a new device.
Items that are unmanaged do not have their transaction information stored on Google Play, which means you cannot query Google Play to retrieve transaction information for items whose purchase type is listed as unmanaged. You are responsible for managing the transaction information of unmanaged items. Also, unmanaged items can be purchased multiple times as far as Google Play is concerned, so it's also up to you to control how many times an unmanaged item can be purchased.
The "unmanaged" purchase type is useful if you are selling consumable items, such as fuel or magic spells. These items are consumed within your application and are usually purchased multiple times.
RESTORE_TRANSACTIONS
This request retrieves a user's transaction status formanaged purchases. You should send this request only when you need to retrieve a user's transaction status, which is usually only when your application is reinstalled or installed for the first time on a device.
今天继续这个功能,关于RESTORE_TRANSACTIONS ,官方的论述是这样的,这个请求是用来取得以前的交易的记录----防止用户
无故购买两次item。例如当用户重新安装apk时,那么我们必须要保证用户已经买的item应该正常显示。我使用Dungeons Sample来验
证,发现如果我清空程序的数据,再打开(这其实相当于重新安装一次),我发现我已经购买过的,如“android.test.purchased"还是需
要再买一次,而不自动隐藏或者被自动enable.
查了一下文档,原来RESTORE_TRANSACTIONS 这个接口就是用来追踪以前的交易记录的,当你重新安装(Dungeons
sample)后,调用restor_transactions接口,得到的log如下:
04-13 13:18:51.708: I/Security(3264):signedData: {"nonce":4937678692489462368,"orders":[]}
04-13 13:18:51.718: I/Security(3264): signature: jFc2uRlAOQ+lrSGT95ikNH0Yohax702hPt8prKwpXHkfneIi7sR2QMbwb8nMK1F0+oiHvOsJdcQotUtNnrw9Vh6qh3NlqYCzxSFohcgd+KUmOh0q3A1a9I7xqPDvI/OjuMnG5bcdnlPxkeAsZ+fSvBhsERMb2V3FGtSUIn/AFc35GZaddaHxCU7GMjOlCB5p44g4EaVtqVgBlQhbXEE/CBc0z3UaRErIiivDXv15n1JnouX+VhnEzBYvo+O76Ms5C+/C1p5XYRRYYQlh6MOzSpcwfdh+DvnsisscrtXWyqd36TpHJIgjstzdRkiDTLrfe72Lxy1ABzKnWd0I9//I1w==
网上查询资料:
I have been experimenting with In-app billings andI discovered that RESTORE_TRANSACTIONS works with only managed items(this is explicitly confirmed on Google In-app billing site). Further, you cannot restore transactions for reserved Product IDs. I had to purchase a real item to test how restore works.
I may be wrong but that is what I found.
====》
得到的结果是,Google只为managed per user account类型的item存储交易信息,而“android.test.purchased"这个是unmanaged,尽管我已
经在代码里换了类型,
new CatalogEntry("android.test.purchased", R.string.android_test_purchased,
Managed.MANAGED),
可是还是没有作用,而且对于保留的productId是无法取得交易信息的。难道只能实际支付一次!!!
signedData: {"nonce":4937678692489462368,"orders":[]} 得不到任何以前的交易信息, orders为空
那该怎么办呢?
参考资料:
http://groups.google.com/group/android-developers/browse_thread/thread/408ec3205bbb4256?pli=1
Question:
For a managed item, how do I get order number for itemthat was once purchased and the app is installed on new device ????
Thanks
Answer:
You'll get that in onPurchaseStateChange in the sample app (calledafter RESTORE_TRANSACTIONS):
{"nonce":4728283427316410369,"orders":
[{"orderId":"1694851887421222","packageName":"tv.app","productId":"tv.optio ns","purchaseTime":
1302452718521,"purchaseState":2,"developerPayload":"null"},
{"orderId":"509818957061234","packageName":"tv.app","productId":"options"," purchaseTime":
1302718834942,"purchaseState":0,"developerPayload":"null"}]}
On 14 апр, 22:40, Andrei <gml...@gmail.com> wrote:
谢谢吧
文档布局怎么变形成这样了????