1

I'm unable to consume the android.test.purchased product id.

Below is my code where I'm handling the purchase.

public void handlePurchase(Purchase purchase) {
    try {
        if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
            consumeSKU(purchase.getPurchaseToken(), purchase.getDeveloperPayload());
        }
    } catch (Exception e) {
        e.printStackTrace();
    }
}

And below is my consumeSKU method:

public void consumeSKU(String purchase_token, String developer_payload) {
    ConsumeParams consumeParams =
            ConsumeParams.newBuilder()
                    .setPurchaseToken(purchase_token)
                    .setDeveloperPayload(developer_payload)
                    .build();

    billingClient.consumeAsync(consumeParams, this);
}

and my consume response listener:

@Override
public void onConsumeResponse(BillingResult billingResult, String purchaseToken) {
    Toast.makeText(context, "onConsumeResponse: " + billingResult.getResponseCode() + ", purchase token: " + purchaseToken, Toast.LENGTH_LONG).show();
}

I'm getting Response Code: 6 from billingResult everytime the consumeSKU method is called.

Where am I going wrong?

Sid
  • 327
  • 1
  • 2
  • 13

0 Answers0