Я реализовал подписку согласно официальному руководству. Но возможно ли получить информацию о подписке, когда пользователь подтвердил ее на стороне Google Api? Потому что здесь ничего не возвращается. Как я могу получить доступ к этой транзакции?
private void startConnection(String type) {
//Call newBuilder() to create an instance of BillingClient You must also call setListener()
//passing a reference to a PurchasesUpdatedListener to receive updates on purchases initiated
// by your app, as well as those initiated by the Google Play Store.
BillingClient billingClient = BillingClient.newBuilder(this).enablePendingPurchases().setListener(this).build();
billingClient.isFeatureSupported(BillingClient.FeatureType.SUBSCRIPTIONS);
billingClient.isFeatureSupported(BillingClient.FeatureType.SUBSCRIPTIONS_UPDATE);
//Establish a connection to Google Play. The setup process is asynchronous, and you must
//implement a BillingClientStateListener to receive a callback once the setup of the client
//is complete and it’s ready to make further requests.
billingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(BillingResult billingResult) {
String s = billingResult.getDebugMessage();
String ss = String.valueOf(billingResult.getResponseCode());
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
//specifies a list of product ID strings and a SkuType
List<String> skuList = new ArrayList<>();
skuList.add(type);
// skuList.add("vip");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
//IMPORTANT The SkuType can be either SkuType.INAPP for one-time products or SkuType.SUBS for subscriptions
params.setSkusList(skuList).setType(BillingClient.SkuType.SUBS);
billingClient.querySkuDetailsAsync(params.build(),
new SkuDetailsResponseListener() {
@Override
public void onSkuDetailsResponse(BillingResult billingResult,
List<SkuDetails> skuDetailsList) {
// Process the result.
//Retrieving a product’s price is an important step before a user can purchase a product because
// the price is different for each user based on their country of origin.
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK && skuDetailsList != null) {
for (SkuDetails skuDetails : skuDetailsList) {
String sku = skuDetails.getSku();
String price = skuDetails.getPrice();
BillingFlowParams flowParams = BillingFlowParams.newBuilder()
.setSkuDetails(skuDetailsList.get(0))
.build();
billingClient.launchBillingFlow(RewardVideoActivity.this, flowParams);
}
}
}
});
}
}
@Override
public void onBillingServiceDisconnected() {
String s = "error";
// Try to restart the connection on the next request to
// Google Play by calling the startConnection() method.
}
});
}