Test Subscription Feature of In-app Billing

2020-08-09 08:37发布

问题:

Is it possible to test subscription feature of In-app Billing? I tried using reserved product IDs for testing(android.test.purchased), But it gave error like 'item not found'.I am using In-app Billing Version 3.I could not find a conclusive answer from the web. Any help is appreciated.

回答1:

As of February/March 2015, in-app subscriptions can also be tested on Android. Now, Google accounts with testing access (configured in the Settings Menu of the Developer Console) will receive the message

This is a test subscription. It will recur daily. You will not be charged when trying to buy in-app subscriptions.

This also means that all subscriptions seem to be "billed" daily. You will still receive a normal Google Play Order Receipt Email but it will be prefixed by the word Test:

Test: Your Google Play Order Receipt from Mar 12, 2015

Also, if you look inside this email, you will notice that the order number is a random string of letters, instead of a regular order number as described at http://developer.android.com/google/play/billing/billing_subscriptions.html#payment.

Order number: lhjelkffelbnmmcmklbkhkbd



回答2:

Some points that may help.

  1. If your published application does not have in-app, you dont need to publish your next inapp version to test it.
  2. You need to upload the apk with in app feature to your developer console (dont hit publish), install the same app on your phone
  3. Create in app products (unmanaged) and ensure that the code refers to these unmanaged product id's
  4. Make the product cheap for testing purpose
  5. Purchase your product from your application
  6. From your merchant account refund yourself (you wont be charged if you refund before 24 hours, and you get a full refund. (i think, just confirm this, it keeps changing).
  7. After you are happy, hit publish.
  8. You can add email id's of friends as test accounts, to help them purchase the product and not get charged. Infact you can also mock them for "failure" :)

I hope this helps.



回答3:

This is the answer from my personal experience.

There's not a proper way to test inapp with a dev sandbox. This is how I really test inapp.

  • Create a test application to test inapp and configure it.
  • Remember to put your developer public key where needed and all manifest permission needed
  • Add some inapp purchase to test with
  • Make the app NOT debuggable
  • Upload it on android market as draft

Now you have to wait some hours because Android Market need to push all changes or you will get an error when you try to make purchases

Now launch the app locally on your device (you have to put debuggable false) and test your inapp purchase buying something. After all tests I go into my google wallet merchant account and I also make all other purchase flow test for:

  • Refund
  • Cancel Inapp-Subscription

If you find a better way to test it with a real sandbox please tell me :)



回答4:

Use android.test.purchased as a product ID.



回答5:

Create a class to mock out the apis you are using from Google Play services.