Question

I am attempting to test In-App Purchases in Android.

I have uploaded a privately signed apk to Google Player Developer Console. It is currently a Draft in the "Alpha Testing" section.

When I attempt to purchase an item, I get the following error:

The publisher cannot purchase this item.

enter image description here

This is confusing to me, because I am using a test account, not the account used to publish this app.

enter image description here

enter image description here

I suspect that it may be failing because I have the developer account on the phone at all but this is my personal phone, so I don't want to delete the account off the phone (especially if I am not sure it will solve the issue).

Can anyone confirm if the publisher account must be completely removed from the phone to test in-app purchases?

Thanks!

Was it helpful?

Solution

First thing you should make note in your mind that

Testing Account:

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.

for more information:

1) http://developer.android.com/training/in-app-billing/test-iab-app.html#PlayItemTest

2) http://developer.android.com/google/play/billing/billing_testing.html#billing-testing-test

More than one account:

Note: To make test purchases, the license test account must be on the user’s Android device. If the device has more than one account, the purchase will be made with the account that downloaded the app. If none of the accounts has downloaded the app, the purchase is made with the first account.Users can confirm the account that is making a purchase by expanding the purchase dialog.

check this link:

http://developer.android.com/google/play/billing/billing_testing.html#testing-purchases

Hope it will solve your problem. Let me know if you wanna get more information.

OTHER TIPS

This method works only if you have at least one version of your app released to google play!

I do the following to test in app purchases:

I use a second phone with a separate google account. For payments I use a google play vouchers. I create a signed release apk, like for the app store, and load it on the device using adb install. This way I can make real purchases from the device, and watch the debug output in the console. The advantage of this method is that I can build and replace the apk within seconds, without having to upload it to the app store and wait until it gets published. I strongly recommend to log one real money purchase receipt through the console output, and store it in a text file for later use. Having this you can easily implement server side receipt validation, sending your stored receipt over and over again until everything works. Making real money purchases for testing does not hurt so bad, 70% of the money you spend comes back to you.

FWIW I am able to use Android Studio and ADB bridge to test a debug build with in-app purchases on one device with a second xxxxxxxxx.gmail.com to work around the publisher being blocked from purchasing his own wares.

1) Do everything you need to do to where you install the app from the Play Store (I used TrivialDrive sample in Android Studio) and get the error message "The publisher cannot purchase this item".

2) On my desktop I signed out of my publisher gmail address and then created a new gmail account for testing.

3) On Android device (mine is Lollipop) go to settings:accounts:google and add the gmail acccount you just created as a second account. It will prompt you to add a payment method. You have to do it. Credit card, paypal, something. You need a valid second account for the Play Store that can buy stuff.

4) In developer console make sure to add the new gmail address as a tester in two places; APK section of the specific app and in your account settings under license testing.

5) In developer console in App's APK section copy the tester opt-in URL and mail it to your new gmail address so you can open it from inside the email on the Android device.

6) Go to play store app on Android. Click on the triple bar upper left. Slide out menu near top has the account that will be billed to purchase things. Change it to the new gmail account you added.

7) On Android log in to read new gmail and find waiting for you the opt-in URL you mailed to yourself. Click it and follow it through to get the app installed. Choose Play Store, not a browser, to install from when it gets to there.

8) Now try an in-app purchase. No more publisher can't purchase error. In alpha test it says you won't actually be billed. You may have to wait a while for changes done in developer console to propagate through the system. So if first try at in-app purchase doesn't work wait a half hour and try again.

After that you can rebuild the signed release version in Android Studio and install it via adb bridge. In-app purchase keeps working. You can also build a debug version and that will work for IAP testing too. You must add your keystore info in build.gradle to for the debug version to work.

    android {
signingConfigs {
    release {
        storeFile file("MyAndroidKey.keystore")
        storePassword "mypassword"
        keyAlias "MyAndroidKey"
        keyPassword "mypassword"
    }
    debug {
        storeFile file("MyAndroidKey.keystore")
        storePassword "mypassword"
        keyAlias "MyAndroidKey"
        keyPassword "mypassword"
    }
}

As of Google Play v4.9.13 on a phone running stock KitKat, you can swap between Google accounts from within the Play store. In the application menu, right at the top-right corner there's a drop-down where you can select the active account to use for Google Play. Note that the accounts have to have been added to the device first (in Device Settings > Accounts).

I still need to test my app's IAP implementation, but this seems to be a better option than a factory reset for folks who don't maintain a separate "developer device".

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top