2

I have in-app billing subscriptions available to users which I would like to test and ensure the logic works as expected. However, I am unable to do so.

Note:

There are a number of SO questions relating to In-App Billing not working, specifically for this error:

Error while retrieving information from server [DF-AA-20]

Such as can be found: - here, and - [here][2], and - here, and - here

Summarised, all solutions relate to some missing part of the requirements.

A prominent issue is the issue of the app being tested without being published to atleas the Alpha test track (which I have done). This is detailed later in the post.


Documentation:

Implementation

The requirements for implementing In-App Billing into an Android app is as follows:

  • Add the latest BillingClient in your module level gradle file:

The tutorial suggests:

`implementation 'com.android.billingclient:billing:1.2.1`

which cannot be found by Gradle (02 Feb 2019)

Mine works with:

`implementation group:'com.android.billingclient', name:'billing', version:'1.2'`
  • Implement the BillingClient providing an interface to the Android (Google) Billing Service for making purchases.

This is defined in a detailed step-wise tutorial here

Testing:

The requirements for testing your In-App Billing in an Android app is as follows:

For Solo tests

  • For In-App purchases solo tests, one can test these using the static test responses defined here

  • Subscriptions cannot be solo tested, they need have other conditions

Note: Static responses cannot be used to test subscriptions.

For Testing with Testers (see here for more)

  • Create a Open/Closed track for testing and add the testers you wish to allow for testing. Upload the app to the relevant test track and you MUST publish. Uploading the app as a draft does not work anymore

Note: Previously you could test an app by uploading an unpublished "draft" version. This functionality is no longer supported. However, you can test your app with static responses even before you upload it to the Google Play Store. For more information, see Test with static responses.

See here for more details,

  • One-Time subscriptions are explained in further detail here

  • Subscription purchases work as expected, but the subscription times are heavily shortened to emulate the subscription times. Read in further detail here.

Note: To allow for testing, the app must be published, in atleast the test track. This makes the subscriptions available to that version of the app.

Note 2: It appears that various users have had issues testing on the same Google account as their developer account. Make sure to use a different tester account which is not the same as your developer account. See here for details

Note 3 I saw the documentation made mention of a public key use for licensing, but the in-app purchase tutorial did not require it during implementation. I am not sure if this is causing my issue

Problem:

Having followed all of these steps above, I am unable to successfully purchase a subscription.

  • I download the test app to an emulator (with Google Play services active).

The test account also has a card payment method setup prior to downloading.

  • I proceed to purchase the subscription, then the following is shown:

enter image description here

Am I missing something?

CybeX
  • 2,060
  • 3
  • 48
  • 115
  • I have not familiar with issue, but we always use public license key with implementation. – Abhay Koradiya Feb 02 '19 at 08:34
  • @AbhayKoradiya could you provide me an example of where and how the public license key would be implemented into the `BillingClient` or otherwise. – CybeX Feb 02 '19 at 08:38
  • Did you add testers before publishing the app? If not, then it might be an issue as well. – Sneha Sarkar Feb 02 '19 at 13:12
  • @SnehaSarkar testers were added on initial release. To confirm they could access the test app, they could see the updated description I added when publishing the test app. – CybeX Feb 02 '19 at 13:44
  • Does it work if you download the app to a real phone rather than an emulator? And how are you installing the app - via sideload or from the play store? If it is via sideload, what happens if you install it from the Play store? – Nick Fortescue Feb 04 '19 at 08:11
  • Hi, @KGCybeX did you manage to resolve the issue? I have tried everything and can't get to know what the problem is! – Kartik Apr 22 '19 at 08:09
  • @KGCybeX Hi, do your emulator has multiple google account? If yes, then remove others and make sure the tester account is added as the primary account in your device before proceeding. I had the same issue and this solved my problem. – Sneha Sarkar Aug 21 '19 at 13:59
  • @SnehaSarkar thanks for the advice, but I had only 1 account on my emulator. This was tested on my physical device too, which had multiple accounts – CybeX Aug 21 '19 at 14:19

1 Answers1

0

For testing, use SKU_ID or Product_ID as "android.test.purchased",

there is also library that's easy to use, have a look

https://github.com/anjlab/android-inapp-billing-v3

M. Bilal Asif
  • 675
  • 7
  • 19
  • Yes, but as mentioned in my post under the `solo-tests`, the `android.test.purchased` is used only for in-app purchases (one time purchases). The bullet point following the brief solo-test one time purchase explanation shows that `Static responses cannot be used to test subscriptions.`. My app uses subscriptions as already stated, not one time purchases. – CybeX Feb 02 '19 at 08:40
  • I understand sir, Have a look at library link, they provide subscription support too also they store history too. Hope it helps – M. Bilal Asif Feb 02 '19 at 11:18
  • I have implemented my own wrapper for the BillingClient. The code is not the problem. The problem lies with the response on Google's side, where the subsciptions are not available or some other code-UNrelated issue. So, no matter the code/library I use, it will not be solved. – CybeX Feb 02 '19 at 13:46