Can't re-buy in-app billing item on Google Play after it was refunded

后端 未结 4 1831
一生所求
一生所求 2021-02-09 13:46

I implemented in-app billing into my app and am now testing its handling of refunds.

I bought my app\'s managed in-app billing item with a test account and refunded it.

4条回答
  •  悲&欢浪女
    2021-02-09 14:32

    In case somebody needs android and not kotlin code. All the explanation that smitty wrote:

    When starting up the application , You have to check queryPurchases and look for the refunded items. like that:

    if (purchase.getPurchaseState() != Purchase.PurchaseState.UNSPECIFIED_STATE)
    {
         handleConsumablePurchasesAsync(purchasesList);
         return false;
    }
    

    Than you CONSUME this item. smitty1 is a Genius

    private void handleConsumablePurchasesAsync(List consumables) {
        Log.d(TAG, "handleConsumablePurchasesAsync");
        for (Purchase purchase : consumables) {
            ConsumeParams params = ConsumeParams.newBuilder()
                    .setPurchaseToken(purchase.getPurchaseToken())
                    .build();
    
            billingClient.consumeAsync(params, (billingResult, purchaseToken) -> {
                if (billingResult.getResponseCode() == OK) {
                    Log.d(TAG, "Consumed the old purchase that hasn't already been acknowledged");
                } else {
                    Log.d(TAG, "Error consume the old purchase that hasn't already been acknowledged -> %s" + String.valueOf(billingResult.getResponseCode()));
                }
            });
        }
    }
    

提交回复
热议问题