Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Testing Android In App Billing real purchases

What are the conditions to properly test real purchases, when i already have tested my app using test product like android.test.purchased?

like image 853
cyborg86pl Avatar asked Apr 22 '14 09:04

cyborg86pl


People also ask

How do you test in-app billing?

Test in-app billing and subscriptions Once you've set up application licensing, authorized users can also purchase in-app products and subscriptions without charging the users' accounts. When making a purchase from a license test user, you will see two choices for payment method: “Test card, always approves”

How do I test in-app purchases on Android emulator?

Yes, You can test. Login into Google play with google account. Now purchase the in-app products. The purchase made in an emulator device will be a Sandbox Purchase or it will be a real purchase .


1 Answers

There are few steps that you need to pass, remembering, that some of them need some time to update on Google Play servers.

For this example, let's use com.example.product as our real product Id. Any time it shows up in this example change it to your own.

UPLOAD APK FILE

You CAN'T test REAL PURCHASES in DEBUG mode. You need to download an app from Beta, so Google know it's ok to make purchases in the app.

  1. Check if you have BILLING permission in AndroidManifest.xml:

     <uses-permission android:name="com.android.vending.BILLING" /> 
  2. Change android.test.purchased to com.example.product,

  3. Export *.apk file. It MUST BE SIGNED!

  4. Publish APK in Beta,

  5. You can now go to the next steps, but you'd need some time for your Beta to be ready for download.

ADD NEW PRODUCT

You CAN'T add new product until you have published a beta.

You CAN'T test subscriptions, only products. Now you CAN also test subscriptions (they are renewed every 24h)

  1. Go to products section in Google Play Developer Console,
  2. Click Add new product button and define new product with com.example.product Id,
  3. Wait FEW HOURS until it's published.

TESTERS

You CAN'T test purchases being signed-in on your device with a developer account. You CAN'T make purchases from yourself.

  1. Create testing group on Google Groups, or Google Plus,
  2. Add gmail accounts of your testers to that group,
  3. Set your group as testers in Google Play Developer Console > APP > BETA
  4. Copy testers emails in Google Play Developer Console > SETTINGS > LICENSE TESTING - this will make testing purchases enabled for their accounts.

TESTING

As a tester, you WON'T be charged

When testing from downloaded app Beta, you'll see a testing information on first IAP dialog.

You'll see both your product's name and price set in dev console.

You'll be testing with your real payment options. Don't be scared of seeing your credit card. As i mentioned before - you won't be charged.

When you successfully make a test purchase, you'll get a confirmation e-mail, which looks like a real purchase confirmation.

CLEANING TEST PURCHASES

To repeat the same purchases, you'll need to consume products, cancel purchases, or simply wait 2 weeks until testing purchases will expire.

To cancel purchases:

  1. As a Developer, go to Google Wallet, choose purchases, and cancel them (remember to manage calceled purchases in your app),
  2. As a Tester, go to app manager on your device, and clear Google Play cache. Despite of canceling on developer side, your device stores the purchase information locally.
like image 166
cyborg86pl Avatar answered Sep 18 '22 15:09

cyborg86pl