IInAppBillingService.aidl 8.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  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_BILLING_UNAVAILABLE = 3 - this billing API version is not supported for the type requested
  36. * RESULT_ITEM_UNAVAILABLE = 4 - requested SKU is not available for purchase
  37. * RESULT_DEVELOPER_ERROR = 5 - invalid arguments provided to the API
  38. * RESULT_ERROR = 6 - Fatal error during the API action
  39. * RESULT_ITEM_ALREADY_OWNED = 7 - Failure to purchase since item is already owned
  40. * RESULT_ITEM_NOT_OWNED = 8 - Failure to consume since item is not owned
  41. */
  42. interface IInAppBillingService {
  43. /**
  44. * Checks support for the requested billing API version, package and in-app type.
  45. * Minimum API version supported by this interface is 3.
  46. * @param apiVersion the billing version which the app is using
  47. * @param packageName the package name of the calling app
  48. * @param type type of the in-app item being purchased "inapp" for one-time purchases
  49. * and "subs" for subscription.
  50. * @return RESULT_OK(0) on success, corresponding result code on failures
  51. */
  52. int isBillingSupported(int apiVersion, String packageName, String type);
  53. /**
  54. * Provides details of a list of SKUs
  55. * Given a list of SKUs of a valid type in the skusBundle, this returns a bundle
  56. * with a list JSON strings containing the productId, price, title and description.
  57. * This API can be called with a maximum of 20 SKUs.
  58. * @param apiVersion billing API version that the Third-party is using
  59. * @param packageName the package name of the calling app
  60. * @param skusBundle bundle containing a StringArrayList of SKUs with key "ITEM_ID_LIST"
  61. * @return Bundle containing the following key-value pairs
  62. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
  63. * failure as listed above.
  64. * "DETAILS_LIST" with a StringArrayList containing purchase information
  65. * in JSON format similar to:
  66. * '{ "productId" : "exampleSku", "type" : "inapp", "price" : "$5.00",
  67. * "title : "Example Title", "description" : "This is an example description" }'
  68. */
  69. Bundle getSkuDetails(int apiVersion, String packageName, String type, in Bundle skusBundle);
  70. /**
  71. * Returns a pending intent to launch the purchase flow for an in-app item by providing a SKU,
  72. * the type, a unique purchase token and an optional developer payload.
  73. * @param apiVersion billing API version that the app is using
  74. * @param packageName package name of the calling app
  75. * @param sku the SKU of the in-app item as published in the developer console
  76. * @param type the type of the in-app item ("inapp" for one-time purchases
  77. * and "subs" for subscription).
  78. * @param developerPayload optional argument to be sent back with the purchase information
  79. * @return Bundle containing the following key-value pairs
  80. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
  81. * failure as listed above.
  82. * "BUY_INTENT" - PendingIntent to start the purchase flow
  83. *
  84. * The Pending intent should be launched with startIntentSenderForResult. When purchase flow
  85. * has completed, the onActivityResult() will give a resultCode of OK or CANCELED.
  86. * If the purchase is successful, the result data will contain the following key-value pairs
  87. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
  88. * failure as listed above.
  89. * "INAPP_PURCHASE_DATA" - String in JSON format similar to
  90. * '{"orderId":"12999763169054705758.1371079406387615",
  91. * "packageName":"com.example.app",
  92. * "productId":"exampleSku",
  93. * "purchaseTime":1345678900000,
  94. * "purchaseToken" : "122333444455555",
  95. * "developerPayload":"example developer payload" }'
  96. * "INAPP_DATA_SIGNATURE" - String containing the signature of the purchase data that
  97. * was signed with the private key of the developer
  98. * TODO: change this to app-specific keys.
  99. */
  100. Bundle getBuyIntent(int apiVersion, String packageName, String sku, String type,
  101. String developerPayload);
  102. /**
  103. * Returns the current SKUs owned by the user of the type and package name specified along with
  104. * purchase information and a signature of the data to be validated.
  105. * This will return all SKUs that have been purchased in V3 and managed items purchased using
  106. * V1 and V2 that have not been consumed.
  107. * @param apiVersion billing API version that the app is using
  108. * @param packageName package name of the calling app
  109. * @param type the type of the in-app items being requested
  110. * ("inapp" for one-time purchases and "subs" for subscription).
  111. * @param continuationToken to be set as null for the first call, if the number of owned
  112. * skus are too many, a continuationToken is returned in the response bundle.
  113. * This method can be called again with the continuation token to get the next set of
  114. * owned skus.
  115. * @return Bundle containing the following key-value pairs
  116. * "RESPONSE_CODE" with int value, RESULT_OK(0) if success, other response codes on
  117. * failure as listed above.
  118. * "INAPP_PURCHASE_ITEM_LIST" - StringArrayList containing the list of SKUs
  119. * "INAPP_PURCHASE_DATA_LIST" - StringArrayList containing the purchase information
  120. * "INAPP_DATA_SIGNATURE_LIST"- StringArrayList containing the signatures
  121. * of the purchase information
  122. * "INAPP_CONTINUATION_TOKEN" - String containing a continuation token for the
  123. * next set of in-app purchases. Only set if the
  124. * user has more owned skus than the current list.
  125. */
  126. Bundle getPurchases(int apiVersion, String packageName, String type, String continuationToken);
  127. /**
  128. * Consume the last purchase of the given SKU. This will result in this item being removed
  129. * from all subsequent responses to getPurchases() and allow re-purchase of this item.
  130. * @param apiVersion billing API version that the app is using
  131. * @param packageName package name of the calling app
  132. * @param purchaseToken token in the purchase information JSON that identifies the purchase
  133. * to be consumed
  134. * @return 0 if consumption succeeded. Appropriate error values for failures.
  135. */
  136. int consumePurchase(int apiVersion, String packageName, String purchaseToken);
  137. }