Reputation: 2151
I've set up Google Analytics so that every successful transactions will be sent to it. Now, while comparing Google Analytics and Merchant data, I found out that SOME transactions reflected as success in Google Analytics weren't credit to my merchant account. Here's how I set up my OnIabPurchaseFinishedListener:
private static final OnIabPurchaseFinishedListener purchaseListener = new OnIabPurchaseFinishedListener() {
@Override
public void onIabPurchaseFinished(IabResult result, final Purchase info) {
if (result.isSuccess())
sendHit(cPREM, "success", info.getSku()); // send to GA
else
sendHit(cPREM, "failure", result.getMessage());
if (result.isFailure()) {
if (result.getResponse() != IABHELPER_USER_CANCELLED)
toast(true, "Unknown error occurred: " + result.getMessage());
return;
}
if (info.getSku().equals(SKUs[FULL_PREM])) {
premiumOn = true;
laneOn = true;
storeEditor.putBoolean(SKUs[PREM], true);
storeEditor.putBoolean(SKUs[LANE], true);
toast(true, ct.getString(R.string.please_restart));
} else if (info.getSku().equals(SKUs[PREM])) {
premiumOn = true;
storeEditor.putBoolean(SKUs[PREM], true);
toast(true, ct.getString(R.string.please_restart));
} else if (info.getSku().equals(SKUs[LANE])) {
laneOn = true;
storeEditor.putBoolean(SKUs[LANE], true);
toast(true, ct.getString(R.string.download_restart));
} else if (info.getSku().equals(SKUs[DONATE5]) || info.getSku().equals(SKUs[DONATE10])) {
try {
iabHelper.queryInventoryAsync(queryListener);
} catch (Throwable e) {
e.printStackTrace();
}
toast("Thank You.");
}
storeEditor.apply();
}
};
Also, my app is just 2 months old thus I only get about 3 purchases per week. Further, I've checked my GA and it says that it's not being sampled.
My question is, what am I doing wrong here? Or is it a google play bug? Thank you.
Upvotes: 0
Views: 136
Reputation: 942
It can't be claimed as google play bug. Once you got the payment is success, query Google Play back regarding the feature/SKU. If the feature is purchased it gives you a purchase bundle. Doing so, you can make sure the purchase happened.
One more thing you can do is, If a purchase is successful, keep the purchase Order ID with you in your databases. The Order ID only is the key thing you can cross check the purchase. If any mis match happens, query Google Play Customer services using the Order ID.
The code seems to be like you have used IabHelper
to do the purchase flow and the purchase check result.isFailure()
. If my guess is correct you have used the TrivalDriveSample util provided in Billing SDK.
The IabHelper util is handling the RESPONSE CODES after purchase. There might be the fishy happening.
Please do a recheck in IabHelper how it's launching the purchase and how it's handling the response codes?
Other wise implement your own code instead of using util.
Upvotes: 1
Reputation: 884
In general, I would trust your Merchant account over Google Analytics. There will always be fringe cases with an analytics platform; expired or blocked cards, cancelled transactions and dropped connections are all unexpected for Google Analytics. Your Merchant account will be significantly more robust, because it's tailored for your situation, and actually directly sending money to someone; this elicits higher security and greater interest from involved parties.
Upvotes: 0