Testing of in-app billing with test accounts - android

I need to verify how my in-app billing works.
Would like to test that with test accounts.
If I buy my in-app item with usage of test account, do I need to pay for it?

Ok, I've tested that - even if test account is used, you have to buy your own item.
Will check later on if it is possible to reverse amount paid (and if google 30% charge would be applied).
Upd. reversal is possible, the whole amount is reversed.

You can reverse your transaction by using
There are four reserved product IDs for testing static in-app billing responses:
http://developer.android.com/guide/market/billing/billing_testing.html
android.test.purchased
When you make an in-app billing request with this product ID, Android Market 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.
android.test.canceled
When you make an in-app billing request with this product ID Android Market responds as though the purchase was canceled. This can occur when an error is encountered in the order process, such as an invalid credit card, or when you cancel a user's order before it is charged.
android.test.refunded
When you make an in-app billing request with this product ID, Android Market responds as though the purchase was refunded. Refunds cannot be initiated through Android Market's in-app billing service. Refunds must be initiated by you (the merchant). After you process a refund request through your Google Checkout account, a refund message is sent to your application by Android Market. This occurs only when Android Market gets notification from Google Checkout that a refund has been made. For more information about refunds, see Handling IN_APP_NOTIFY messages and In-app Billing Pricing.
android.test.item_unavailable
When you make an in-app billing request with this product ID, Android Market responds as though the item being purchased was not listed in your application's product list.

It seems that Google has improved testability of in-app purchases so that you can test purchases with your products (not just the four reserved product ids) without charging your credit card:
When your In-app Billing implementation is ready, you can test purchasing of your in-app SKUs in two ways:
Test purchases, which let your selected license test users purchase your in-app products before the app is published, but without any resulting charges to the user, and
...
http://developer.android.com/google/play/billing/billing_testing.html#testing-purchases

Related

Why Google in-app billing return proper orderId in case of Test Purchase ?

Google says you will receive empty orderId if purchase is test purchase. But we are getting proper orderId, so the question is how to check if the purchase made is a Test Purchase or Not. And why are getting orderId ?
I guess you're checking the json response and not the Google Play order receipt on email which includes an order number.
The JSON response is not supposed to include orderId if it was a test purchase. Have confirmed this few times. Make sure the account you're using to test purchase is included in the licence test accounts in the Google Play Developer Console > App Settings > Account details, then in the License Testing section.
Check here
When your In-app Billing implementation is ready, you can test
purchasing of your in-app SKUs in two ways:
Test purchases, which let your selected license-test users purchase
your in-app products without any resulting charges to the user. Test
purchases can be used in alpha/beta releases only.
Real purchases,
which let regular users make real purchases of your in-app products
with actual charges to the user’s payment instruments.
The problem gets solved on it own, I really didn't do any special but after sometime I start receiving empty orderId.

Can a test account be created on the developer's phone?

In my game I have InApp Purchases. I want to test my game before publishing, so I uploaded it to alpha. I would love to test it on my phone, but google refuse, saying a developer can't buy his own products. Google also refuse to allow emulators to purshase items.
Yesterday I added a google account to my phone, and added it to the list of people allowed to download my app (Gmail accounts with testing access).
My problem is that I can't access my game (We're sorry, the requested URL was not found on this server). My game is available (I checked it from another phone and its good). I simply can't access it from my test account.
What can I do? Should I do something, or I will not be able to test my game on my phone no matter what?
Here is the android developer help for testing in-app purchases. The second account you added should be able to access the game shortly. In my experience, it usually takes up to about 24 hours to access alpha/beta testing once a user has been added.
Here's some specific stuff from that post:
Test Purchases (In-app Billing Sandbox)
Test purchases offer a secure, convenient way to enable larger-scale testing of your In-app Billing implementation during development or in preparation for launch. They let authorized user accounts make purchases of your in-app products through Google Play without incurring any actual charges to the user accounts.
Once authorized for testing access, those users can make purchases without being charged. 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.
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 and that your application is able to verify signatures correctly. You can do this even if the app hasn't been published yet.
To test your implementation with static responses, you make an In-app Billing request using a special item that has a reserved product ID. Each reserved product ID returns a specific static response from Google Play. No money is transferred when you make In-app Billing requests with the reserved product IDs. Also, you cannot specify the form of payment when you make a billing request with a reserved product ID.

Testing non-consumable IAP items in Google Play

I'm using Google Play IABv3 and want to be able to easily test what I do (not surprisingly). Since IABv3 all items are managed and it's up to the application to consume the items that it considers consumables.
I'm not sure what the expected work flow is with testing non-consumable products. To be able to test the purchase flow more than once you need to be able to remove the previous purchase. However, the purchase is intended to be non-consumable so we obviously don't want to add any code that consumes it (since it could accidentally slip through and remove real users purchases).
I would like some way of clearing a test users account from purchases, which I doubt is possible since there is no "real" test users.
What is the suggested way to do this?
You can use test product IDs instead of real items. Remember to use it only in debug builds.
https://developer.android.com/google/play/billing/billing_testing.html
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.
android.test.canceled
When you make an In-app
Billing request with this product ID Google Play responds as though
the purchase was canceled. This can occur when an error is encountered
in the order process, such as an invalid credit card, or when you
cancel a user's order before it is charged.
android.test.refunded
When
you make an In-app Billing request with this product ID, Google Play
responds as though the purchase was refunded. Refunds cannot be
initiated through Google Play's in-app billing service. Refunds must
be initiated by you (the merchant). After you process a refund request
through your Google Wallet merchant account, a refund message is sent
to your application by Google Play. This occurs only when Google Play
gets notification from Google Wallet that a refund has been made. For
more information about refunds, see Handling IN_APP_NOTIFY messages
and In-app Billing Pricing.
android.test.item_unavailable
When you make an In-app Billing request with this product ID, Google Play
responds as though the item being purchased was not listed in your
application's product list.

Android in-app billing developer payload

I would like to implement in-app billing in my android app, but I am not sure how should I create for a developer payload. I don't have any information about user, only unique identifier created in the app to recognize it.
Is it possible to restore the purchase when the user buy a product, then uninstall the app and install it again? How to test it, because I didn't get any events when I tried to test it?
Yes, you can check the completed purchase after uninstall app and install it again.
All purchased items stored on the Play Server and particularly in your installed Google Play app. So after item is purchased once the information about purchase is stored and you can request it at any time untill you "consume" this purchase. "Consume" means reset the information about purchase to allow make new purchase with same ID. This is only for v3 if Android Billing Library, because all purchases in v3 are one-off (you can buy it only once) and have to be "consumed" to be purchased again.
The identifier of the purchase item is a simple string that you define in the Google Developer Console. You should login to the developer console, create new project for the future app, upload signed .apk (necessary), after that you have to select the project, move to "In-App products" section and there you can create necessary purchase items with purchase IDs. While purchase action in the application you should pass the matched purchaseID to the launchPurchaseFlow() method on the IabHelper object (these are all from v3 Billing Library). The information about purchased items can also be received by using matched purchaseID.
Official Google developer documentation has pretty decent amount of information about implementing and using Billing Library:
Implementing billing library guide
Administering In-App products in the developer console
Testing In-app billing. Sorry, cannot post link because of lack of reputation (2 links in answer only), but you can also find this section in the official android documentation. This section also has information about testing with special android test purchase IDs which doesn't require signed and uploaded .apk or any actual money-transfers

How to test android app using test account with android in-app purchase

I have added my email id to the android in-app purchase testing account.
But When I am going to test the in-app purchase in to android device with this email id account, it is opening to ask to buy with the credit card details and purchase. So I am confused that how can I test the app in proper manner? Am I missing something to test?
Unfortunately to test in-app billing you actually have to buy your item. Aside from static responses using fake item IDs there's no way to test the purchase with "fake money".
The good news is you can go into your merchant account and immediately issue yourself a refund, so you'll never actually be charged.

Categories

Resources