Reputation: 31
I refer to google sample BillingRepository.kt to implement my BillingRepository; As Google advises that developer should call BillingClient.queryPurchases() at onResume() callback;
So when I purchase an item successfully, I got the following code path:
Then I found the wired things:
one of the two acknowledgePurchase() will get a DEVELOPER_ERROR(respond code 5), and the debug message is "Server error! Please try again!";
possible cases:
testing with billing client library version is 3.0.0/2.2.0/2.1.0;
Can anyone explain this? Thanks
Upvotes: 3
Views: 2694
Reputation: 4964
As far as I remember, only one acknowledge can be given per purchase. If an acknowledge is given to a purchase that has already been acknowledged, an error will occur.
Remember to verify if the purchase is already acknowledged before trying to acknowledge it.
if (purchase.purchaseState == Purchase.PurchaseState.PURCHASED) {
if (!purchase.isAcknowledged){
val acknowledgePurchaseParams = AcknowledgePurchaseParams
.newBuilder()
.setPurchaseToken(purchase.purchaseToken)
.build()
billingClient.acknowledgePurchase(acknowledgePurchaseParams) {
// result here
}
}
}
If your code triggers two calls of acknowledgePurchase
to the same purchase at "the same time", there might be the problem.
For further information please refer to https://developer.android.com/google/play/billing/integrate
Upvotes: 5