Android In-App billing subscriptions test not working - android

I'm trying to test In-App billing subscriptions. My personal account and my developer account are the same. I can't buy my own products with this account, so, I need to test with another account. Here are the steps I followed:
created a new account (lets call it account B)
added account B on Google Play on my phone
uploaded a signed apk for beta test
created a beta testers list and added account B
connected to account B on my phone in Firefox, went to the test link, opted-in, and installed the app (from Firefox, not from Play Store)
bought an item
been charged (and auto-refunded myself -_- ...)
So, seems like its not exactly working. After reading again the developer guide, I saw that when an account is set as a tester account, it is clearly stated in the in-app billing popup that you will not been charged:
However, Google Play marks test purchases with a notice across the center of the purchase dialog, for easy identification
There is nothing like this in my popups. Does anyone know where can be the mistake?
I saw on some questions on stackoverflow that it might not be possible to have a phone set up for testing if the testing account is not the primary account on Google Play app, is that true?
EDIT: I added a friend's account to the list and asked him to test. He has only one account on his phone. Like me, nothing indicates that he would not be charged (and so, I guess that, like me, he would).
EDIT: I see this in the guide:
Note: For test subscription purchases, leave the orderId field blank. You can use the purchaseToken field to identify test purchases.
What does they mean by "For test subscription purchases, leave the orderId field blank"? Do I need to do something here, or does they mean that in the response, the field is left blank?

However, Google Play marks test purchases with a notice across the
center of the purchase dialog, for easy identification
The purchase dialog should display a message as shown in the image below:
Note: For test subscription purchases, leave the orderId field blank.
You can use the purchaseToken field to identify test purchases.
It means orderId field for test purchases is blank in the response. This is because a real order wasn't placed and so no order id is created for the test purchase.
Update
For test purchase, create license test accounts for authorized users. In the Developer Console, go to Settings > Account details, then in the License Testing section, add the addresses to Gmail accounts with testing access field.

Related

How to test IAB without being charged

I am trying to testIn App Purshase without being charged on Unity by reading this https://developer.android.com/google/play/billing/billing_testing.html
My application is published as an Alpha version, signed with a real key. I downloaded it with an other Google account that the one I used to publish the app. This account is both added in the testers list of Google Play Service and my app Alpha testers list.
The problem is, when I want to buy an item, I never see the word "test" as the documentation says.
Can someone explain to me which extra steps shall I do in order to be sure to test my In App Billing without being charged?
Thanks a lot.
A new version of Google Play Console was released the 17th April, and I think that the french version of the Google Play Console was not completely implemented.
Right now the section "Test de licence" is available.
Follow the Testing In-app Purchases:
Setting up test purchases
It’s easy to set up test purchases—any user account can be chosen to
be a test account, and any user of a test account can make test
purchases with any available payment method (even though there’s no
charge to the payment method).
First, upload and publish in-app products that you want testers to be
able to purchase. You can upload and publish in-app products in the
Developer Console. Note that you can upload and publish your in-app
items before you publish the APK itself.
Next, create license test accounts for authorized users. In the
Developer Console, go to Settings > Account details, then in the
License Testing section, add the addresses to Gmail accounts with
testing access field. For more information, see Setting Up for Test
Purchases.
Once you’ve added the users as license tester accounts and saved the
change, within 15 minutes those users can begin making test purchases
of your in-app products.

Testing IN-APP PURCHASE With Another account on same device

Good day.I have implemented the in-app purchase flow in my application,added everything necessary to the console but i am failing to test it.Issue is that the android i dont know why uses the non-testing account (developer account) as on the purchase dialog it says 'The publisher can not purcahse this item' but although i have added test account to the device,switched account in the google play but i keep getting this error.Can anyone please tell me what is wrong with it?
If you want to test in-app purchase, you need to account on https://play.google.com, publish your app in alpha version. In IN-APP PRODUCTS, you add products you want, add emails you want to test (only emails in the list can test). You follow this link:
https://developer.android.com/google/play/billing/billing_testing.html

Test Google In App Purchase paying real money

So, I have implemented IAP(in app purchase) in my application and successfully tested it with real product ids. My app is published to Alpha and everything worked fine (payments were not real of course).
I have then closed my Alpha testing. Now, instead of making either real or testing methods, I only see an error message: The item you requested is not available for purchase..
When the app will start to make real payments instead of testing? What do I need to do for that? Do I need to publish it to the production for that to happen?
You can do real purchase even if your app is in Alpha testing.
The real purchases will be reflected in Google merchant page with an Order Id.
App does not have any knowledge of purchase type, if it a real or test. Play Store is the master which knows all the deatils of a purchase.
For a test purchase you will be adding you test mail with test access in LICENSE TESTING.
To make a real purchase with the account, remove that account from the list showing Gmail accounts with testing access in developer console. Thus you can make real purchases.
Over All,
If your account is in Settings->Account Details->LICENSE TESTING group, the purchases will be test purchases else it is a Real Purchase.

Android In App Billing... Why is there contradicting info?

I, like so many others, am just trying to test my in app purchases after verifying that the static responses are working. But as I read the docs, the posts, and the answers, nothing seems to add up. And I'm getting very frustrated.
My ultimate goal is to find out whether I can do testing without being charged.
This doc says I can - link
Once authorized with testing access, those users can side-load your app and test the full merchandising, purchase, and fulfillment flow for your products. Test purchases are real orders and Google Play processes them in the same way as other orders. When purchases are complete, Google Play prevents the orders from going to financial processing, ensuring that there are no actual charges to user accounts, and automatically canceling the completed orders after 14 days.
and same link
During a test purchase, users can test the actual merchandising, purchase, and fulfillment flow in your app. During purchase, the inapp item is displayed as a normal item with an actual price. However, Google Play marks test purchases with a notice across the center of the purchase dialog, for easy identification
But then on this page, it say - link
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. Remember to refund the purchases if you don’t want your testers to be actually charged!
WTF... so does anyone know? Can do testing without being charged? And if so, how?
if you are using In App Billing version 3 then you can simply use product id="android.test.purchased". It is dummy product and you should not add it in your developer console. you can buy that product with out any charges.
android.test.purchased
When you make an In-app Billing request with this product ID, Google Play responds as though you successfully purchased an item. The response includes a JSON string, which contains fake purchase information (for example, a fake order ID). In some cases, the JSON string is signed and the response includes the signature so you can test your signature verification implementation using these responses.
Hope it will help you.
Yes: You can make test purchases, involving no payment being made, for real items (SKUs) you have actually defined yourself in the Console. I have just successfully done this myself.
Contrary to the advice given in the presently accepted answer, there is no need to use the dummy SKU android.test.purchased as you would with static testing.
The OP quotes this paragraph:
During a test purchase, users can test the actual merchandising, purchase, and fulfillment flow in your app. During purchase, the inapp item is displayed as a normal item with an actual price. However, Google Play marks test purchases with a notice across the center of the purchase dialog, for easy identification
This, so far, is correct and agrees with what I have been able to achieve.
But the subsequent paragraph the OP quotes:
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. Remember to refund the purchases if you don’t want your testers to be actually charged!
This, as far as I am concerned (particularly the last sentence) is not correct.
What you can do is as per the first paragraph. That is, as long as the test account is added to the Console as a tester, then when attempting to make a purchase, the dialogue (which shows you the price, etc.) should also have a special string across the centre of it (as mentioned in the first paragraph) stating "This is a test order, you will not be charged".
However, to actually make that work, it's also necessary for the actual APK the tester (or test device) is using to be one that is uploaded to the alpha channel.
So, the steps I had taken were as follows:
Create a separate Google Group for the purpose of alpha channel testing.
Add your IAP test user gmail account to that group.
Upload an APK (exported and signed with release certificate) with in-app purchase code to the alpha channel.
Wait perhaps an hour or two for the alpha build to become active.
In the meantime, set up a separate test device with just the test gmail account set up on it.
Opt-in for alpha channel testing by navigating to the opt-in URL on the test device while logged in as the test user.
Sign into Play with that tester account and install the application from Play. At this point (or after an hour or two) the latest alpha you uploaded should be the one now installed.
Attempt to make a purchase. When the dialogue appears with the price, it should have an additional "This is a test order, you will not be charged" string across it.
In fact, to be completely accurate, the test device does not necessarily seem to need to have had the alpha APK installed from Play. From my tests, what is important is that you do have an APK uploaded as alpha, and that the APK you're running on the test device has the same version number. Furthermore, test user needs to be opted-in for alpha builds and added as a tester in the Console (as stated above). I just exported another tweaked version of my APK and loaded into my test device using adb install, and I can still attempt purchases for real SKUs with the "...you will not be charged" message.
You have to Consume Once purchased.
consume.setOnClickListener(new View.OnClickListener() {
#Override
public void onClick(View view) {
Thread t = new Thread(new Runnable() {
#Override
public void run() {
String purchaseToken = "inapp:" + getPackageName() + ":android.test.purchased";
try {
Log.d("","Running");
int response = mService.consumePurchase(3, getPackageName(), purchaseToken);
if(response==0)
{
Log.d("Consumed","Consumed");
}else {
Log.d("","No"+response);
}
}catch (RemoteException e)
{
Log.d("Errorr",""+e);
}
}
});
t.start();
}
});

Can I turn my own Google Play account into a test account without any problems?

I'm developing our first app that uses in app purchases, and need to test that it's working correctly.
Currently if I try to make a purchase on the "android.test.purchased" item, I get an error message back saying "invalidClient". I'm led to believe that this is because my account is not a test user.
I found this page:
http://developer.android.com/google/play/billing/billing_admin.html#billing-testing-setup
which tells me how to set up a test user. I could set up a new user account, but I only have the one Android device to hand, which means doing a factory reset to make this the primary account, and I'd rather avoid that if possible.
Alternatively, can I make my own personal account double up as a test user?
The link above says that test users have limitations, one of which is:
Test accounts can only be used to purchase items that are listed (and
published) in an application's product list.
That seems to imply that I could only use my account to buy things in my in-development apps, and not from other apps as normal.
So can I turn my own personal account into a test user, without any problems when using the account to purchase other apps as normal?
It won't affect your abilities to use the test account as a normal account for other apps on Google Play.
So simply you can use your own account as a test account. (Actually if your account is the publisher account, you don't need to add it as a test account.)
The limitations mentioned in the documentation is a comparison to the publisher account.
Unfortunately there's no way around it. If you just have one device you have to wipe the device and then first sign in with the email address that you want to use as a test account. Only then will you be able to test in-app billing. You can also download other items from the Google Play store. I've done this without any problems.

Categories

Resources