简体   繁体   中英

Google Play Billing Library 2.0 Acknowledge Purchase Time Limit for Test Purchases

I have been testing the the new Google billing library release. The release notes state that "Purchases must be acknowledged within three days".

Release notes

During testing, I noticed that if I don't acknowledge the purchase, within a few minutes, the purchase gets automatically refunded.

Is it the case that Google treats test orders differently and only allows a few minutes to acknowledge an order as opposed to 3 days or am I missing something?

Here is the code I am using to acknowledge the purchase. PurchaseHolder is a class that holds the purchase and SKU along with a response code from my back end server

for (IABManager.PurchaseHolder pm : purchaseHolders){
    if(pm.getSku().equals(SKU)) {//found matching SKU
        if (pm.getActionResult() == IABManager.BillingActionResult.VALID_PURCHASE) {//valid purchase made
            if(!pm.getPurchase().isAcknowledged()) {//purchase not yet acknowledged
                iabManager.acknowledgePurchases(pm.getPurchase(), (billingResult) -> {
                    Log.d(TAG, "AcknowledgedPurchaseResponse received from Google");
                    if(billingResult.getResponseCode() == BillingClient.BillingResponseCode.OK) {
                        unlockFeatures();
                    }
                });
            }else{
                unlockFeatures();
            }

        } else if (pm.getActionResult() == IABManager.BillingActionResult.NON_VALID_PURCHASE){
            lockFeatures();
        }else{
            Log.d(TAG, "BILLING_ACTION_RESULT = " + pm.getActionResult() + " doing nothing");
        }
    }
}

...and the acknowledgePurchases method

public void acknowledgePurchases(Purchase purchase, AcknowledgePurchaseResponseListener listener){

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

    billingClient.acknowledgePurchase(params, listener);
}

From the docs we can see that test purchases operate on a much shorter time scale to aid testing: https://developer.android.com/google/play/billing/billing_testing#testing-renewals

If a one week subscription is renewed in 5 minutes, I imagine the 3 day purchase acknowledgement limit will be reduced to a couple minutes during development.

Indeed, from the Google Play Billing Library docs

For purchases made by license testers, the acknowledgement window is shorter. Instead of three days, purchases are refunded and revoked if they are not acknowledged within five minutes

https://developer.android.com/google/play/billing/billing_library_overview#test_acknowledging_purchase_with_license_testers

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