简体   繁体   中英

Getting subscription data in Android in-app billing

I am integrating the Google in-app billing, especially subscriptions, into our application.

Now I just can not figure out how to get the following data from IMarketBillingService (Google Play) to my app:

  • price information

  • subscription expiry date (of the currently paid period)

  • notification if the user cancels an on-going subscription

The following code parses the JSON object that results from get purchase information, but there is no price field in it. Yet the Google IAP documentation says price is available!?

JSONObject jElement = jTransactionsArray.getJSONObject(i);
int response = jElement.getInt("purchaseState");
PurchaseState purchaseState = PurchaseState.valueOf(response);
String productId = jElement.getString("productId");
String packageName = jElement.getString("packageName");
long purchaseTime = jElement.getLong("purchaseTime");
String orderId = jElement.optString("orderId", "");
String purchase_token = jElement.optString("purchaseToken", "");
String notifyId = null;
if (jElement.has("notificationId")) {
  notifyId = jElement.getString("notificationId");
}
String developerPayload = jElement.optString("developerPayload", null);

Any help?

  • price information

Google Play's Billing Service does not provide pricing information. If you really need it, you can provide that information yourself by keeping a record of your item prices and guessing the user's currency.

  • subscription expiry date (of the currently paid period)

Read Checking subscription validity in the Subscriptions API Guide . There is a HTTP-based API to poll Google Play for the current purchase state of a subscription.

  • notification if the user cancels an on-going subscription

None is provided. From the Subscriptions API Guide :

If a user cancels a subscription, Google Play considers the subscription valid until the end of the current billing cycle. The user continues to enjoy the content for the rest of the cycle and is not granted a refund.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM