After upgrading the BillingClient to 3.0.0, I started getting about 20% users seeing SERVICE_UNAVAILABLE
when querying for in-app purchase. The skuDetailsList is also empty. According to the docs, SERVICE_UNAVAILABLE
implies network is down, but how is the client returning OK
with the startConnection
and sending this after trying to query the SKU details? Additionally, I'm seeing a few ERROR
, which is code 6. Did I have some incorrect implementation or do I just show the user some "An error occurred. Try later" message? I also don't see any warning for any countries in the Play Console or anything that may cause this.
BillingClient billingClient = BillingClient.newBuilder(getContext())
.enablePendingPurchases()
.setListener((billingResult, list) -> {})
.build();
mBillingClient.startConnection(new BillingClientStateListener() {
@Override
public void onBillingSetupFinished(@NonNull BillingResult billingResult) {
if (billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
createSkus(mBillingClient);
}
}
@Override
public void onBillingServiceDisconnected() {}
});
private void createSkus(BillingClient billingClient) {
List<String> skuList = new ArrayList<>();
skuList.add("pro");
SkuDetailsParams.Builder params = SkuDetailsParams.newBuilder();
params.setSkusList(skuList).setType(BillingClient.SkuType.INAPP);
billingClient.querySkuDetailsAsync(params.build(),
(billingResult, skuDetailsList) -> {
// skuDetailsList empty with BillingResult code 2 (SERVICE_UNAVAILABLE)
BillingFlowParams billingFlowParams = BillingFlowParams.newBuilder()
.setSkuDetails(skuDetailsList.get(0))
.build();
billingClient.launchBillingFlow(activity, billingFlowParams);
});
}