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();
}
});
Related
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.
I'm trying to implement an InAppBilling in my Android app.
I'm almost there, but there is still one part missing.
I've followed the documentation (http://developer.android.com/google/play/billing/billing_integrate.html#Subs) and replicate the logic used in the sample app provided by Google.
I have this application published in alpha mode, with one test account and an integrated product (subscription) created.
String payload = "";
mHelper.launchPurchaseFlow(Settings.this, SKU_PREMIUM, IabHelper.ITEM_TYPE_SUBS,null, 1000, mPurchaseFinishedListener, payload);
If SKU_PREMIUM variable is the real product id defined in google console, everything is fine. I windows appears in my application telling me to buy the subscription, and its price. However, given that I do not have a visa card associated to my test account, I cannot proceed. Thus, I'm trying to use Static Responses.
However, if I change SKU_PREMIUM to "android.test.purchased", I'm given an error saying The item you requested is not available for purchase..
And even if I change reserved code to android.test.canceled, android.test.refuned or android.test.item_unavailable the outcome is the same.
What am I missing here?
Thanks!
The problem is that you cannot use reserved product ids on subscription testing. They are only suitable for "normal" purchases. For subscriptions you to use the right subscription id defined by you in google play settings page. You should:
Upload an apk to store (it can be in alfa or beta testing);
Be the application tester (the email should be different from the developer email);
Have a credit card associated to your test account.
If you have this setup, you won't be charged by Google. Note that in-app subscriptions auto-renew every 24h.
As far as I know, there is no easy way to test the android in-app billing. You really have to follow theses steps.
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.
I want to test the in app subscription mechanism on android devices(In app billing V3. api).
How can I do this? I saw that testing with static responses is works only with the in app products. The beta/alpha testing supports the in app subscriptions?
Thank you.
You can test your app with in app purchase feature. you have to follow below steps for testing
Upload you final signed apk file to Google play.
Dont publish it
Add in app products
get in app products id and add to code
get base 64 key and add to product
sign apk and upload again
your app should be in draft mode
in you Google play account setting add your test account id
use the device which should have the primary account id similar to the one you have added on Google play test account.
Install signed apk you have uploaded to Google play to your device.
run application and test your features
Since there's no effective way to test subscription cancellation/renewal, I'm trusting Google's documentation that an expired subscription won't appear in purchased items (otherwise, whether cancelled but still valid, original or renewed, I don't care in my case).
To test the rest of my work flow I created a test consumable object so that I can re-buy/cancel it at will in the sandbox. This consumable simulates an active subscription. It's not full end-to-end testing, but given that Google's given us no better way to test subscriptions, it will at least give me a fair amount of confidence that my app behaves as expected, otherwise.
A few notes:
1) You can only test with a signed build. I added android:debuggable="true" to my AndroidManifest.xml (under
<application android:debuggable="true"...)
2) This way I can still connect and debug with breakpoints after installing via adb (you can attach to the process under the Devices view, normally visible in the DDMS perspective, look for the little green bug icon.)
So far, it's behaving as expected. I'm still in the process of testing but if I hit any snags I'll update.
In adittion to #Vaibhav-Agarwal if you only want test your app, you could have problems with the IDs (I have experienced with an app for a client).
In my case, to avoid this situation, I had to add a testing project with another special package (test.xxxx.xxxx.xxxx) and here add some in-app product with a trial of 7 days, then when I canceled a purchase I "only" had to wait 7 days to purchase again this subscription.
In this way also,you never had to make a refund, because the subscription with trial time, you haven't to pay until this trial time finish.
NOTE:
Draft Apps are No Longer Supported, you must use Alpha/Beta tester option
In spanish, you will read: "no se ha podido encontrar el elemento que intentabas comprar"
Google has been enhanced theirs In-app Billing testing options. I write this answer for those who coming through . Now, you can test In-app Billing in Sandbox as other platforms do. In order to do that you have to 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.
Notes :
Test subscription purchases recur daily, regardless of the product's subscription period.
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.
After you publish your app to an alpha or beta channel, your testers need to opt-in to your app’s alpha or beta test using the provided opt-in URL before they can make test purchases.
License test accounts 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.
For more visit the official documentation.
But you can test Google Play functionality with an unpublished app using static responses.
In Android In-app billing version 2 subscription static response is not working, This static response like android.test.purchased is working for inapp products, but the same is not working for subscriptions
1) IS there any other of testing it( we would like to do a static response testing which save our time
2) Can any please share a working code of in-app billing subscription
Testing inapp subscription billing is horrible. You can test out of your SDK for the adroid.test.purchased to make sure you are parsing responses properly. To test the subscription, add a test product to the subscription products on the developer console and publish the product. You must publish the products for this to work. Get up google groups and add test email accounts to the group. Invite the testers. THEN upload your .apk to an ALPHA and publish it. you must publish it as an alpha for the test phones and logins to find it.
Go to the link provided under the ALPHA tab to set up testers and log in from the phone using one of the test emails. Buy the inapp product to make sure all your code works. You can cancel the test product purchases in the Google Wallet and re-use the products until the code is correct. THEN set up a test subscription product. You will only be able to test the subscription once per test email. There is no way to remove the test subscription. Be sure to change the product names in your apk before you upload. Also, change the version code in the AndroidManifest, and turn off debugging.
If you try to install the app twice on a device, you may need to clear the data from these apps under settings in the phone: chrome, play store, play services, or it will continue to think you have it installed and won't download it. You must access the test .apk from a browser, NOT through the play store.
This is the most onerous testing I have ever experienced. Also, watch for errors from Google IABilling response, since the "already owned" response for a product is different for a subscription. I am still trying to figure out what the response is for the already owned subscription. Will update if I find out. This explanation is the ONLY information available anywhere that I have found, and this was weeks of trial and error. If you have more data on this, please share!!!