I am getting error code 5 which I believe is 'Developer Error'. The mDebugMessage in the BillingResult is Invalid Token. (I have checked the name and I am sure it is correct.)
I am calling consumeAsync("noadverts"); where "noadverts" is the name of my in app product.
When I check my purchases, it records the following:
Unusually, when I call:
then val1 is 1 and not 0 as it suggested in the purchase JSON.
I am using much of the TestDrive example, but without the BillingUpdatesListener.
Any ideas what might be the issue?
If I try and purchase "noadverts" again I get the error code Item is already owned.
I am calling consumeAsync("noadverts"); where "noadverts" is the name of my in app product.
When I check my purchases, it records the following:
Code:
{"orderId":"GPA.1111-1111-1111-1111",
"packageName":"myname.com.myname",
"productId":"noadverts",
"purchaseTime":1565188785096,
"purchaseState":0,
"purchaseToken":"edited for length",
"acknowledged":true}
Unusually, when I call:
Code:
int val1 = purchase.getPurchaseState();
then val1 is 1 and not 0 as it suggested in the purchase JSON.
I am using much of the TestDrive example, but without the BillingUpdatesListener.
Code:
public void consumeAsync(final String purchaseToken) {
// If we've already scheduled to consume this token - no action is needed (this could happen
// if you received the token when querying purchases inside onReceive() and later from
// onActivityResult()
if (mTokensToBeConsumed == null) {
mTokensToBeConsumed = new HashSet<>();
} else if (mTokensToBeConsumed.contains(purchaseToken)) {
//Log.i(TAG, "Token was already scheduled to be consumed - skipping...");
return;
}
mTokensToBeConsumed.add(purchaseToken);
// Generating Consume Response listener
final ConsumeResponseListener onConsumeListener = new ConsumeResponseListener() {
@Override
public void onConsumeResponse(BillingResult response, String purchaseToken) {
@BillingClient.BillingResponseCode int responseCode = response.getResponseCode();
// THIS IS WHERE I GET ERROR CODE 5
}
};
// Creating a runnable from the request to use it inside our connection retry policy below
Runnable consumeRequest = new Runnable() {
@Override
public void run() {
// Consume the purchase async
//mBillingClient.consumeAsync(purchaseToken, onConsumeListener);
ConsumeParams consumeParams = ConsumeParams.newBuilder().setPurchaseToken(purchaseToken).build();
// Consume the purchase async
mBillingClient.consumeAsync(consumeParams, onConsumeListener);
}
};
executeServiceRequest(consumeRequest);
}
Any ideas what might be the issue?
If I try and purchase "noadverts" again I get the error code Item is already owned.