Search code examples
androidin-app-billingplay-billing-library

Updating google play billing library to version 2 is not working, purchase is always refunded


I had a functioning Android implementation in-app billing, using the billing client 1.0.2 library and everything worked fine. I have a simple premium upgrade, without subscriptions.

Now I tried to upgrade to 2.0.3, I made all the necessary changes to my code (using official documentation, release notes, and StackOverflow) and it doesn't work. I know I must recognize all purchases within three days. Failure to correctly recognize purchases will result in reimbursement for these purchases. And that's what I did.

The entire purchase workflow looks okay, the behavior is like before the library is updated. But in the end my purchase is always refunded after 5 minutes (using a trial account, so it's 5 minutes instead of 3 days).

this is inside onPurchasesUpdated:

     if (purchase.getPurchaseState() == Purchase.PurchaseState.PURCHASED) {
        if (!purchase.isAcknowledged()) {

            AcknowledgePurchaseParams acknowledgePurchaseParams = AcknowledgePurchaseParams.newBuilder().setPurchaseToken(purchase.getPurchaseToken()).build();

            AcknowledgePurchaseResponseListener acknowledgePurchaseResponseListener = new AcknowledgePurchaseResponseListener() {
                @Override
                public void onAcknowledgePurchaseResponse(BillingResult billingResult) { 
                    Toast.makeText(getContext(), "Purchase acknowledged", Toast.LENGTH_LONG);
                }
            };

            mBillingClient.acknowledgePurchase(acknowledgePurchaseParams, acknowledgePurchaseResponseListener);
        }
    }

The debugger performs recognition and in onAcknowledgePurchaseResponse, I can see that my billingResult response code is 5 (developer error), the debug message is empty. And I have no idea what's wrong. Please, someone can help me find out what's missing. Many thanks!


Solution

  • After updating the billing client library to 3.0.0 everything works fine!