В новой библиотеке выставления счетов 8 у вас есть код < /p>
mBillingClient.queryProductDetailsAsync(
params,
new ProductDetailsResponseListener() {
public void onProductDetailsResponse(@NonNull BillingResult billingResult,
@NonNull QueryProductDetailsResult queryProductDetailsResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
for (ProductDetails productDetails : queryProductDetailsResult().getProductDetailsList()) {
// Process success retrieved product details here.
}
for (UnfetchedProduct unfetchedProduct : queryproductDetailsResult.getUnfetchedProductList()) {
// Handle any unfetched products as appropriate.
}
}
}
);
Как писать QueryProductDetailSresult () в java?mBillingClient.queryProductDetailsAsync(
params,
new ProductDetailsResponseListener() {
public void onProductDetailsResponse(BillingResult billingResult, List productDetailsList) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
if (productDetailsList != null && productDetailsList.size() > 0) {
// Set the parameters for the offer that will be presented
// in the billing flow creating separate productDetailsParamsList variable
ImmutableList productDetailsParamsList =
ImmutableList.of(
BillingFlowParams.ProductDetailsParams.newBuilder()
.setProductDetails(productDetailsList.get(0))
.setOfferToken(offerToken)
.build()
);
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setProductDetailsParamsList(productDetailsParamsList)
.build();
// Launch the billing flow
BillingResult billingResult2 = mBillingClient.launchBillingFlow(MainActivity.this, billingFlowParams);
}
else{
Toast.makeText(getApplicationContext(),"Purchase Item not Found",Toast.LENGTH_SHORT).show();
}
} else {
Toast.makeText(getApplicationContext(), " Error "+billingResult.getDebugMessage(), Toast.LENGTH_SHORT).show();
}
}
}
);
Подробнее здесь: https://stackoverflow.com/questions/797 ... -to-use-it