21

I want to test in-app payments and I have Google Play App Signing (GPAS) enabled.

To test payments, I need an apk signed with real key (signing key in terms of GPAS).

But I do not have private key for signing certificate. It was generated by Google and stored in Google Play.

How can I avoid necessity to upload apk to Google Play each time I want to test in-app payments?

How can I download signing private key somewhere?

IlyaGulya
  • 957
  • 6
  • 18

2 Answers2

5

I have an app in alpha channel and "Google Play App Signing" enabled and I have been able to test in-app billing without major problems using a few tester accounts.

In Google Dev Console >> Release Management >> App Release >> Manage Alpha >> Manage Testers you can create a list of tester accounts, after that passing to them a web link they can install and test the app.

The publisher (developer) account can't buy items but I created another account for tests that I use in emulators (Genymotion + Gapps) without problems.

The only mishap found is that some testers when they buy the product the system ask them for a real payment !, they should not be charged as Google documents say, I have solved it by creating in the console a few promotion codes for them.

Maybe your problem is that you already have the app in production and not in alpha or beta?

Hope it will help.

UPDATE:

You said in a commnent to another answer : "But I don't want to wait a few hours each time I make any change in my Application. That is the point."

You don't need to upload another release each time you make a change, you can continue debugging your app via USB or on an emulator with Play Store installed, as long as the debugging device uses a google tester account and she/he has accepted to be a tester on the received web link.

Of course this tester can be yourself using a google account other than the one of the app publisher

UPDATE 2

If the doubt is due to believe that in-app billing purchases are signed with the same key that the application then it is not true. Purchases are signed with a key different than the application, you can get the Base64-encoded RSA public key in the developer console in Development Tools >> Services & APIs

from56
  • 3,976
  • 2
  • 13
  • 23
  • 1
    In order to perform a test purchase using a tester account I should possess an application, that is installed on my device with the release key. Now imagine a scenario, when I have successfully uploaded my app into an alpha channel, Google successfully signs my app. I am downloading it (release version of app). I successfully install it and perform test purchase. Now I want to change my source code a bit and perform another test purchase. I cannot, because I need a release build type, but I do not have the key, with which my app is signed. The question is how to build my app in release mode? – azizbekian Sep 13 '17 at 15:19
  • You can uninstall the application that was installed from Google Play and then reinstall and continue working with a debug version via USB on the same device and continue to test the purchases, I assure you that it work for me without problems. Uninstallation is necessary due the debug version has another key signature. – from56 Sep 13 '17 at 15:59
  • 1
    If I uninstall app, that means that I could even not have installed it previously, which means no need to create an alpha release: I could test purchases in debug mode straight away without all that hassle. Then what's the purpose of creating an alpha release? I happen to remember that purchases would work only when app is signed in release mode. Thanks for the info, would keep that in mind. – azizbekian Sep 13 '17 at 16:12
  • A debug build can also make purchases, as a far as I know it doesn't depend on the app signature. You need to create an alpha (or beta) in order to have a list of testers and to create some in-app products, and also to understand how the whole thing works on the side of the Google Play Console too. You are welcome. – from56 Sep 13 '17 at 16:19
  • 4
    It does not matter, debug or release build you are using. We are talking about another problem. To make In-app purchase you need to use application signed with release key. But you do not have real release key. It is stored in Google Play. And the only way to sign your application with real key is to upload it to Google Play. – IlyaGulya Sep 19 '17 at 03:18
  • In the application that I'm working I use two keys, a key for test that is the one I use with debug build at work, the second is the key with which I sign the APK that I upload to the Play Console. With both keys I can test in-app purchases without problems. As I said before for me it doesn't depend on the app signature. Maybe your debug build is not signed? – from56 Sep 19 '17 at 13:32
  • @LluisFelisart So, you was able to sign the application with any key and test purchases locally, without uploading apk file to alpha? – IlyaGulya May 17 '18 at 09:05
  • 2
    That seems really strange, because i can not do the same with my application. Google play rejects to make a purchase if app has wrong signature (read: not the same as in the google play) – IlyaGulya May 17 '18 at 09:06
  • Create a signature key, in your app build.gradle add the signature key on `signingConfigs`, on `buildTypes` add `signingConfigs.mykey`in both release & debug build – from56 May 19 '18 at 12:21
2

if you need to test real transactions, the only way is to public at least an alpha version of your application, as mentioned here

Because Google Play does not allow you to use your developer account to directly purchase in-app products that you have created yourself, you'll need to create test acccounts under your developer account profile. To create a test account, simply enter a valid Google email address. Users with these test accounts will then be able to make in-app-billing purchases from uploaded, unpublished applications that you manage.

To test your In-app Billing Version 3 application using your own product IDs:

In the Play Console, add one or more tester accounts to the developer account that you are using to publish your application. Login to the Play Console with your developer account. Click Settings > Account details, then in the License Testing section, add the Google email addresses for your tester accounts. Build a signed APK file for your In-app Billing application. To learn how to build and sign your APK, see Building Your Application for Release. Make sure that you have uploaded the signed APK for your application to the Play Console, and associated one or more in-app products with your application. You don't need to publish the application on Google Play to test it. Warning: It may take up to 2-3 hours after uploading the APK for Google Play to recognize your updated APK version. If you try to test your application before your uploaded APK is recognized by Google Play, your application will receive a ‘purchase cancelled’ response with an error message “This version of the application is not enabled for In-app Billing.”

Install the APK file to your physical test device by using the adb tool. To learn how to install the application, see Running on a Device. Make sure that your test device is running on Android 2.2 (API level 8) or higher and is installed with Google Play client Version 3.9.16 or higher. Login to the test device by using a tester account. Test your In-app Billing application by purchasing a few items, and fix any issues that you encounter. To learn more about how you can perform large-scale testing of your In-app Billing app, see Test Purchases (In-app Billing Sandbox).

But, if you need just to check if your payment flow is correct you can use static requests, which allows you to test payments without publishing.

We recommend that you first test your In-app Billing implementation using static responses from Google Play. This enables you to verify that your application is handling the primary Google Play responses correctly. You can do this even if the app hasn't been published yet.

Another way of testing was Draft app, but as you can read in the second link,

Draft Apps are No Longer Supported

Previously, you could publish a "draft" version of your app for testing. This functionality is no longer supported. Instead, there are two ways you can test how a pre-release app functions on the Google Play Store:

You can publish an app to the alpha or beta distribution channels. This makes the app available on the Google Play Store, but only to the testers you put on a "whitelist".

In a few cases, you can test Google Play functionality with an unpublished app. For example, you can test an unpublished app's in-app billing support by using static responses, special reserved product IDs that always return a specific result (like "purchased" or "refunded").

So, in short words.. you can set up static payments all over your application (to test calls) and check this way if they work or not. Once the tests are done, replace static Requests with the final form and use your alpha version to test it. Sadly, no other ways are available (officially) since, as posted above, google doesn't allow developer account to purchase your own products.

Afaik, you can't retrieve the keystore from google play

Community
  • 1
  • 1
Pier Giorgio Misley
  • 5,305
  • 4
  • 27
  • 66
  • 1
    Came here looking for a solution to the problem mentioned in the question, but it turns out that adding a 'License Tester' is the right way to go. Thanks @Pier – Michael Hathi Oct 06 '19 at 09:52