Question

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

Était-ce utile?

La solution

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.
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top