3

I have set up subscription-based products in our Android app using the Andoid's InApp billing mechanism. We are logging the purchases when the user purchases an item. The problem we are facing is that while testing our app, the test purchases are also getting logged into our system. I want to know as to how to differentiate between a test purchase and a non-test purchase so that I can selectively remove them from being logged. I have already tried reading the data as follows:

final String purchaseData = data.getStringExtra("INAPP_PURCHASE_DATA");

This gives me a null. Any ideas on this would be of great help.

Swapnil
  • 1,870
  • 2
  • 23
  • 48
  • you can check this link https://stackoverflow.com/questions/48662787/how-to-get-email-id-or-order-id-to-database-when-user-purchases-my-app-from-play/48801818#48801818 – Amjad Khan Jan 02 '19 at 10:11
  • How about comparing product id with this **"android.test.purchased"** in your response? – Jeel Vankhede Jan 02 '19 at 13:47
  • @JeelVankhede, this testing is not for the test product. It is for a real product but with a test card. I want to detect if the user has purchased through a test card as soon as it finishes the purchase. – Swapnil Jan 07 '19 at 06:18
  • @AmjadKhan, thank you for suggesting this. This is one of the ways but what I need is a field in the data payload inside `onActivityResult` soon after I finish the purchase with the test card. – Swapnil Jan 07 '19 at 06:20

1 Answers1

0

Hey if you are using an in app billing you can compare the sku details. The Play Billing Library stores the query results in a List of SkuDetails objects which can be compared if they originated from your test case. Refer the original docs https://developer.android.com/google/play/billing/billing_library_overview