Google Play计费库2.0确认购买测试购买的时限

时间:2019-05-21 23:19:37

标签: android in-app-purchase in-app-billing play-billing-library acknowledgepurchase

我一直在测试新版Google计费库。发行说明指出“必须在三天内确认购买”。

Release notes

在测试过程中,我注意到如果我不确认购买,则在几分钟之内,该购买将自动退款。

是不是Google对待测试订单的处理方式不同,只允许几分钟来确认测试订单(而不是3天),还是我错过了某些东西?

这是我用来确认购买的代码。 PurchaseHolder是一个类,其中包含购买和SKU以及来自我的后端服务器的响应代码

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");
        }
    }
}

...以及acceptPurchases方法

public void acknowledgePurchases(Purchase purchase, AcknowledgePurchaseResponseListener listener){

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

    billingClient.acknowledgePurchase(params, listener);
}

2 个答案:

答案 0 :(得分:2)

从文档中我们可以看到,购买测试的时间较短,可以帮助测试:https://developer.android.com/google/play/billing/billing_testing#testing-renewals

如果在5分钟内续订一周的订阅,我想在开发过程中3天的购买确认限额将减少到几分钟。

答案 1 :(得分:2)

实际上,来自Google Play结算库文档

  

对于由许可证测试人员进行的购买,确认窗口较短。如果没有在五分钟之内确认购买,则退货并撤销交易,而不是三天

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