document current_gamer
[ouya-store-api.git] / api / devs.ouya.tv / api-v1-games-xxx-purchases.rst
index 849d649a97f4f052a16681b002dfdfbd80091053..a755ea56680c214424329b3a5cd03ad54f66792f 100644 (file)
@@ -2,14 +2,21 @@
 ``GET https://devs.ouya.tv/api/v1/games/xxx/purchases``
 =======================================================
 
-FIXME: Check which features have been bought in an app, or if the app has been
-bought.
+Check which features have been bought in an app (if the app has been
+bought).
+
+Each game may have multiple products that can be bought.
+One of them may be the "promotedProduct" in the discover section, and
+that one can be bought in the discover store / play menu app details.
 
 
 Usage
 =====
 - When an app/game is featured and shown on the main menu ("home"),
   it is checked if the app has already been purchased.
+- When opening the game details the "buy" button is shown if the
+  "promotedProduct" is in the list of purchases
+- When a game starts it checks if it has been bought.
 
 
 HTTP request
@@ -23,7 +30,8 @@ Host
 Path
   ``/api/v1/games/xxx/purchases``
 
-  ``xxx`` is the app package name.
+  ``xxx``
+    app package name
 
   Example: ``/api/v1/games/com.ChrisChung.CatlateralDamage/purchases``
 Headers
@@ -46,8 +54,53 @@ Status code
 Content-type
   ``application/json; charset=utf-8``
 
+The response is a JSON objec containing three properties:
+
+``iv``
+  Base 64 encoded initialization vector for encryption
+``key``
+  Base 64 encoded FIXME. Must be 128/192/256 bits long.
+``blob``
+  Base64 encoded encrypted data
+
+The decrypted ``blob`` contains again a JSON object with three properties:
+
+- ``iv``
+- ``key``
+- ``blob``
+
+This blob is again base64-encoded JSON and contains the actual data:
+A JSON with a single property "purchases" whose value is
+an array of receipts/purchases.
+
+Each receipt has the following properties:
+
+``purchaseDate``
+  Required. Milliseconds.
+``generateDate``
+  Optional. Milliseconds.
+``identifier``
+  Product key. Required. Alternative name: ``sku``.
+``gamer``
+  User name. Required.
+``uuid``
+  User UUID. Required.
+``priceInCents``
+  Integer. Optional.
+``localPrice``
+  Float. Optional.
+``currency``
+  Optional. Default ``USD``.
+
 Example
 -------
 
+Encrypted response:
+
 .. include:: api-v1-games-xxx-purchases.response.json
    :code:
+
+Decrypted receipt list:
+
+.. include:: api-v1-games-xxx-purchases.response-decrypted.json
+   :code: