Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Android: is there a way to recognize test purchases at runtime?

According to this https://support.google.com/firebase/answer/6317485?hl=en in_app_purchase event will be automatically tracked when a user completes an in-app purchase.

The problem occurs with test users. They are not charged (since they are entered in "Test Accounts" list in google developer console) but in_app_purchase events are tracked for them too. So, there are discrepancies between analytics and real payments.

Is there a way to separate somehow real and 'test' purchases?

Either, maybe a way to disable automatically tracking for certain events and send them manually? And how to recognize 'test' purchases in this case at runtime (in order to don't send in_app_purchase event)

like image 359
papirosnik Avatar asked Oct 30 '22 20:10

papirosnik


1 Answers

I know it's a bit late, but putting down my 2-cents here:

I think you might already know that test purchases for Android in Firebase Analytics are accounted for, as mentioned here(see in_app_purchases), "Note: paid app-purchase revenue, subscription revenue (Android only), and refunds are not automatically tracked. Your reported revenue may differ from the values you see in the Google Play Developer Console. Events that are flagged as being invalid or as sandbox (test) are ignored. Only iOS events are flagged as sandbox".

That said, there isn't a way to recognize such purchases at runtime and avoid them from being reported for Android and populating your prod app data. However, there are only a couple of ways to deal with it currently(in my opinion):

  1. Separate your prod data from test data: Look into this document on how to set up a separate app in Firebase to record your test data.
  2. Disable collection of analytics for your test app: As shown here, you can temporarily or permanently disable collection of Firebase Analytics data. It includes the option to be able to disable and enable it at runtime.

Although, I would consider option #2 a little counter-intuitive given your case and go with #1 instead.

Disabling reporting of test purchase data to Analytics at runtime would require 2 things:

  1. Knowledge of how the Google Play system recognizes a test purchase, what event is sent from the user device for such an event, and the ability to recognize/intercept that event.
  2. The option of preventing an event from being reported to Firebase Analytics at runtime.

In this case, #2 definitely does not seem like an option currently. Hence, all we can do here is reach out to Firebase Support and request that feature. But until then, I don't see another way. But I'm curious and open to suggestions if somebody else has. :)

like image 94
pointNclick Avatar answered Nov 11 '22 10:11

pointNclick