Some details info
[ouya-store-api.git] / api / devs.ouya.tv / api-v1-games-xxx-purchases.post.rst
1 ========================================================
2 ``POST https://devs.ouya.tv/api/v1/games/xxx/purchases``
3 ========================================================
4
5 Buy a game.
6
7 After buying the game shows up in 
8 `GET https://devs.ouya.tv/api/v1/premium_purchases`_.
9
10
11 Usage
12 =====
13 - When the user buys an app/game.
14
15
16 HTTP request
17 ============
18 Protocol
19   ``https``
20 Method
21   ``POST``
22 Host
23   ``devs.ouya.tv``
24 Path
25   ``/api/v1/games/xxx/purchases``
26
27   ``xxx``
28     app package name
29
30   Example: ``/api/v1/games/com.ChrisChung.CatlateralDamage/purchases``
31 Headers
32   Standard headers
33
34   ``Content-Type``
35     ``application/x-www-form-urlencoded``
36 GET parameters
37   ``auth_token``
38     Same as ``X-OUYA-AuthToken``
39   ``user_agent``
40     ``launcher`` (at least when bought through the OUYA UI)
41 POST parameters
42   ``blob``
43     Base64-encoded encrypted data
44   ``iv``
45     Base64-encoded initialization vector for the cryptographic function
46   ``key``
47     Base64-encoded key used to encrypt the ``blob``.
48     Encrypted with FIXME: gamer key or developer key.
49   ``auth_token``
50     Same as ``X-OUYA-AuthToken``
51
52 The decrypted ``blob`` again contains ``blob``, ``key`` and ``iv``.
53
54 The decrypted inner ``blob`` contains a JSON object:
55
56 ``identifier``
57   Product key
58 ``testing``
59   Unknown. Always "true".
60 ``uuid``
61   Random number that is used by the game for this purchase request.
62   Must be returned in the response to this request.
63
64 Raw request (without encryption):
65
66 .. include:: api-v1-games-xxx-purchases.post.request-nocrypt.json
67    :code:
68
69 Decrypted:
70
71 .. include:: api-v1-games-xxx-purchases.post.request-decrypted.json
72    :code:
73
74
75 HTTP response
76 =============
77 Status code
78   ``200 OK``
79 Content-type
80   ``application/json; charset=utf-8``
81
82 Again the base-64 encoded keys: ``iv``, ``key`` and ``blob``.
83
84 ``blob`` is a JSON object that needs to contain the ``uuid`` property.
85 Most games do not want any other properties.
86
87 "God of Blades" requires:
88
89 - ``identifier``
90 - ``name``
91 - ``priceInCents``
92
93 Example
94 -------
95
96 .. include:: api-v1-games-xxx-purchases.post.response.json
97    :code: