简体   繁体   中英

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!

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM