IInAppBillingService.aidl 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281
  1. /*
  2. * Copyright (C) 2012 The Android Open Source Project
  3. *
  4. * Licensed under the Apache License, Version 2.0 (the "License");
  5. * you may not use this file except in compliance with the License.
  6. * You may obtain a copy of the License at
  7. *
  8. * http://www.apache.org/licenses/LICENSE-2.0
  9. *
  10. * Unless required by applicable law or agreed to in writing, software
  11. * distributed under the License is distributed on an "AS IS" BASIS,
  12. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13. * See the License for the specific language governing permissions and
  14. * limitations under the License.
  15. */
  16. package com.android.vending.billing;
  17. import android.os.Bundle;
  18. /**
  19. * InAppBillingService is the service that provides in-app billing version 3 and beyond.
  20. * This service provides the following features:
  21. * 1. Provides a new API to get details of in-app items published for the app including
  22. * price, type, title and description.
  23. * 2. The purchase flow is synchronous and purchase information is available immediately
  24. * after it completes.
  25. * 3. Purchase information of in-app purchases is maintained within the Google Play system
  26. * till the purchase is consumed.
  27. * 4. An API to consume a purchase of an inapp item. All purchases of one-time
  28. * in-app items are consumable and thereafter can be purchased again.
  29. * 5. An API to get current purchases of the user immediately. This will not contain any
  30. * consumed purchases.
  31. *
  32. * All calls will give a response code with the following possible values
  33. * RESULT_OK = 0 - success
  34. * RESULT_USER_CANCELED = 1 - User pressed back or canceled a dialog
  35. * RESULT_SERVICE_UNAVAILABLE = 2 - The network connection is down
  36. * RESULT_BILLING_UNAVAILABLE = 3 - This billing API version is not supported for the type requested
  37. * RESULT_ITEM_UNAVAILABLE = 4 - Requested SKU is not available for purchase
  38. * RESULT_DEVELOPER_ERROR = 5 - Invalid arguments provided to the API
  39. * RESULT_ERROR = 6 - Fatal error during the API action
  40. * RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned
  41. * RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned
  42. */
  43. interface IInAppBillingService {
  44. /**
  45. * Checks support for the requested billing API version, package and in-app type.
  46. * Minimum API version supported by this interface is 3.
  47. * @param apiVersion billing API version that the app is using
  48. * @param packageName the package name of the calling app
  49. * @param type type of the in-app item being purchased ("inapp" for one-time purchases
  50. * and "subs" for subscriptions)
  51. * @return RESULT_OK(0) on success and appropriate response code on failures.
  52. */
  53. int isBillingSupported(int apiVersion, String packageName, String type);
  54. /**
  55. * Provides details of a list of SKUs
  56. * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
  57. * with a list JSON strings containing the productId, price, title and description.
  58. * This API can be called with a maximum of 20 SKUs.
  59. * @param apiVersion billing API version that the app is using
  60. * @param packageName the package name of the calling app
  61. * @param type of the in-app items ("inapp" for one-time purchases
  62. * and "subs" for subscriptions)
  63. * @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
  64. * @return Bundle containing the following key-value pairs
  65. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
  66. * on failures.
  67. * "DETAILS_LIST" with a StringArrayList containing purchase information
  68. * in JSON format similar to:
  69. * '{ "productId" : "exampleSku",
  70. * "type" : "inapp",
  71. * "price" : "$5.00",
  72. * "price_currency": "USD",
  73. * "price_amount_micros": 5000000,
  74. * "title : "Example Title",
  75. * "description" : "This is an example description" }'
  76. */
  77. Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
  78. /**
  79. * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,
  80. * the type, a unique purchase token and an optional developer payload.
  81. * @param apiVersion billing API version that the app is using
  82. * @param packageName package name of the calling app
  83. * @param sku the SKU of the in-app item as published in the developer console
  84. * @param type of the in-app item being purchased ("inapp" for one-time purchases
  85. * and "subs" for subscriptions)
  86. * @param developerPayload optional argument to be sent back with the purchase information
  87. * @return Bundle containing the following key-value pairs
  88. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
  89. * on failures.
  90. * "BUY_INTENT" - PendingIntent to start the purchase flow
  91. *
  92. * The Pending intent should be launched with startIntentSenderForResult. When purchase flow
  93. * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
  94. * If the purchase is successful, the result data will contain the following key-value pairs
  95. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response
  96. * codes on failures.
  97. * "INAPP_PURCHASE_DATA" - String in JSON format similar to
  98. * '{"orderId":"12999763169054705758.1371079406387615",
  99. * "packageName":"com.example.app",
  100. * "productId":"exampleSku",
  101. * "purchaseTime":1345678900000,
  102. * "purchaseToken" : "122333444455555",
  103. * "developerPayload":"example developer payload" }'
  104. * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
  105. * was signed with the private key of the developer
  106. */
  107. Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,
  108. String developerPayload);
  109. /**
  110. * Returns the current SKUs owned by the user of the type and package name specified along with
  111. * purchase information and a signature of the data to be validated.
  112. * This will return all SKUs that have been purchased in V3 and managed items purchased using
  113. * V1 and V2 that have not been consumed.
  114. * @param apiVersion billing API version that the app is using
  115. * @param packageName package name of the calling app
  116. * @param type of the in-app items being requested ("inapp" for one-time purchases
  117. * and "subs" for subscriptions)
  118. * @param continuationToken to be set as null for the first call, if the number of owned
  119. * skus are too many, a continuationToken is returned in the response bundle.
  120. * This method can be called again with the continuation token to get the next set of
  121. * owned skus.
  122. * @return Bundle containing the following key-value pairs
  123. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
  124. on failures.
  125. * "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs
  126. * "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information
  127. * "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures
  128. * of the purchase information
  129. * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
  130. * next set of in-app purchases. Only set if the
  131. * user has more owned skus than the current list.
  132. */
  133. Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);
  134. /**
  135. * Consume the last purchase of the given SKU. This will result in this item being removed
  136. * from all subsequent responses to getPurchases() and allow re-purchase of this item.
  137. * @param apiVersion billing API version that the app is using
  138. * @param packageName package name of the calling app
  139. * @param purchaseToken token in the purchase information JSON that identifies the purchase
  140. * to be consumed
  141. * @return RESULT_OK(0) if consumption succeeded, appropriate response codes on failures.
  142. */
  143. int consumePurchase(int apiVersion, String packageName, String purchaseToken);
  144. /**
  145. * This API is currently under development.
  146. */
  147. int stub(int apiVersion, String packageName, String type);
  148. /**
  149. * Returns a pending intent to launch the purchase flow for upgrading or downgrading a
  150. * subscription. The existing owned SKU(s) should be provided along with the new SKU that
  151. * the user is upgrading or downgrading to.
  152. * @param apiVersion billing API version that the app is using, must be 5 or later
  153. * @param packageName package name of the calling app
  154. * @param oldSkus the SKU(s) that the user is upgrading or downgrading from,
  155. * if null or empty this method will behave like {@link #getBuyIntent}
  156. * @param newSku the SKU that the user is upgrading or downgrading to
  157. * @param type of the item being purchased, currently must be "subs"
  158. * @param developerPayload optional argument to be sent back with the purchase information
  159. * @return Bundle containing the following key-value pairs
  160. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response codes
  161. * on failures.
  162. * "BUY_INTENT" - PendingIntent to start the purchase flow
  163. *
  164. * The Pending intent should be launched with startIntentSenderForResult. When purchase flow
  165. * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
  166. * If the purchase is successful, the result data will contain the following key-value pairs
  167. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, appropriate response
  168. * codes on failures.
  169. * "INAPP_PURCHASE_DATA" - String in JSON format similar to
  170. * '{"orderId":"12999763169054705758.1371079406387615",
  171. * "packageName":"com.example.app",
  172. * "productId":"exampleSku",
  173. * "purchaseTime":1345678900000,
  174. * "purchaseToken" : "122333444455555",
  175. * "developerPayload":"example developer payload" }'
  176. * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
  177. * was signed with the private key of the developer
  178. */
  179. Bundle getBuyIntentToReplaceSkus(int apiVersion, String packageName,
  180. in List<String> oldSkus, String newSku, String type, String developerPayload);
  181. /**
  182. * Returns a pending intent to launch the purchase flow for an in-app item. This method is
  183. * a variant of the {@link #getBuyIntent} method and takes an additional {@code extraParams}
  184. * parameter. This parameter is a Bundle of optional keys and values that affect the
  185. * operation of the method.
  186. * @param apiVersion billing API version that the app is using, must be 6 or later
  187. * @param packageName package name of the calling app
  188. * @param sku the SKU of the in-app item as published in the developer console
  189. * @param type of the in-app item being purchased ("inapp" for one-time purchases
  190. * and "subs" for subscriptions)
  191. * @param developerPayload optional argument to be sent back with the purchase information
  192. * @extraParams a Bundle with the following optional keys:
  193. * "skusToReplace" - List<String> - an optional list of SKUs that the user is
  194. * upgrading or downgrading from.
  195. * Pass this field if the purchase is upgrading or downgrading
  196. * existing subscriptions.
  197. * The specified SKUs are replaced with the SKUs that the user is
  198. * purchasing. Google Play replaces the specified SKUs at the start of
  199. * the next billing cycle.
  200. * "replaceSkusProration" - Boolean - whether the user should be credited for any unused
  201. * subscription time on the SKUs they are upgrading or downgrading.
  202. * If you set this field to true, Google Play swaps out the old SKUs
  203. * and credits the user with the unused value of their subscription
  204. * time on a pro-rated basis.
  205. * Google Play applies this credit to the new subscription, and does
  206. * not begin billing the user for the new subscription until after
  207. * the credit is used up.
  208. * If you set this field to false, the user does not receive credit for
  209. * any unused subscription time and the recurrence date does not
  210. * change.
  211. * Default value is true. Ignored if you do not pass skusToReplace.
  212. * "accountId" - String - an optional obfuscated string that is uniquely
  213. * associated with the user's account in your app.
  214. * If you pass this value, Google Play can use it to detect irregular
  215. * activity, such as many devices making purchases on the same
  216. * account in a short period of time.
  217. * Do not use the developer ID or the user's Google ID for this field.
  218. * In addition, this field should not contain the user's ID in
  219. * cleartext.
  220. * We recommend that you use a one-way hash to generate a string from
  221. * the user's ID, and store the hashed string in this field.
  222. * "vr" - Boolean - an optional flag indicating whether the returned intent
  223. * should start a VR purchase flow. The apiVersion must also be 7 or
  224. * later to use this flag.
  225. */
  226. Bundle getBuyIntentExtraParams(int apiVersion, String packageName, String sku,
  227. String type, String developerPayload, in Bundle extraParams);
  228. /**
  229. * Returns the most recent purchase made by the user for each SKU, even if that purchase is
  230. * expired, canceled, or consumed.
  231. * @param apiVersion billing API version that the app is using, must be 6 or later
  232. * @param packageName package name of the calling app
  233. * @param type of the in-app items being requested ("inapp" for one-time purchases
  234. * and "subs" for subscriptions)
  235. * @param continuationToken to be set as null for the first call, if the number of owned
  236. * skus is too large, a continuationToken is returned in the response bundle.
  237. * This method can be called again with the continuation token to get the next set of
  238. * owned skus.
  239. * @param extraParams a Bundle with extra params that would be appended into http request
  240. * query string. Not used at this moment. Reserved for future functionality.
  241. * @return Bundle containing the following key-value pairs
  242. * "RESPONSE_CODE" with int value: RESULT_OK(0) if success,
  243. * {@link IabHelper#BILLING_RESPONSE_RESULT_*} response codes on failures.
  244. *
  245. * "INAPP_PURCHASE_ITEM_LIST" - ArrayList<String> containing the list of SKUs
  246. * "INAPP_PURCHASE_DATA_LIST" - ArrayList<String> containing the purchase information
  247. * "INAPP_DATA_SIGNATURE_LIST"- ArrayList<String> containing the signatures
  248. * of the purchase information
  249. * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
  250. * next set of in-app purchases. Only set if the
  251. * user has more owned skus than the current list.
  252. */
  253. Bundle getPurchaseHistory(int apiVersion, String packageName, String type,
  254. String continuationToken, in Bundle extraParams);
  255. /**
  256. * This method is a variant of {@link #isBillingSupported}} that takes an additional
  257. * {@code extraParams} parameter.
  258. * @param apiVersion billing API version that the app is using, must be 7 or later
  259. * @param packageName package name of the calling app
  260. * @param type of the in-app item being purchased ("inapp" for one-time purchases and "subs"
  261. * for subscriptions)
  262. * @param extraParams a Bundle with the following optional keys:
  263. * "vr" - Boolean - an optional flag to indicate whether {link #getBuyIntentExtraParams}
  264. * supports returning a VR purchase flow.
  265. * @return RESULT_OK(0) on success and appropriate response code on failures.
  266. */
  267. int isBillingSupportedExtraParams(int apiVersion, String packageName, String type,
  268. in Bundle extraParams);
  269. }