9

Scenario: I am on the verge of completing my google playstore in-app billing implementation. I am using a monthly or yearly subscription in order to charge my consumers.

Problem: I can't seem to find a way to remove a subscription from active state, since cancellation simply stops the billing from occurring. This doesn't allow QA to thoroughly test the purchase procedure without creating an account for each test, or waiting until the subscription period ends.

Question: Have I missed or am wrong about something? If so, what is it? If not, what should be done to allow QA to do proper testing?

Maulik
  • 3,316
  • 20
  • 31
Ben Barkay
  • 5,473
  • 2
  • 20
  • 29
  • check my answer below and let me know what you are exactly looking for either the below answer or anything more. – Maulik Oct 14 '13 at 13:35
  • 1
    Ben, I have read through the chat with Maulik below. It seems you never came to a solution from that chat. Did you come to a solution to your problem? I am trying to test subscriptions and running into the same issue. I can't wait a year to make another debug run. :) Any solution you found would be greatly appreciated. – Michael Stoner Aug 02 '14 at 05:49
  • 1
    @MichaelStoner We tested with trial subscriptions and well, for tests that this wouldn't work with, we simply waited. It's a real shame. – Ben Barkay Aug 03 '14 at 07:17

4 Answers4

7

According to what I have understood from your question,

you can not test subscription from the test account. Google play doesn't provide subscription testing using dummy product. you have to test on the real product.

Now question arises how can I test subscription

you can check subscription by purchasing real product and check product status or purchase cancellation using the purchase status api from your server.

you can also get more information from the given link below for the step by step cancellation purchase status:

1) link1 2) link2

you can simply query every day and check your subscription is valid or not and also get it's expiration date.

I also have one other option with out pay for any charges on your real product, you can set trial period in the Google console and before trial period ends up cancel subscription from the Google play store Menu -> MyApp -> Subsciption and cancel product and check above procedure given in the links.

EDIT:

Important: In all cases, you must continue to offer the content that your subscribers have purchased through their subscriptions, for as long any users are able to access it. That is, you must not remove any subscriber’s content while any user still has an active subscription to it, even if that subscription will terminate at the end of the current billing cycle. Removing content that a subscriber is entitled to access will result in penalties. Please see the policies document for more information.

more information check below links:

1) http://developer.android.com/google/play/billing/billing_subscriptions.html#cancellation

2) https://support.google.com/googleplay/answer/2476088?hl=en

3) https://support.google.com/googleplay/android-developer/answer/140504?hl=en

You can not done this with out waiting until the subscription process cycle completes after cancellation of subs product, the only way remaining which is Free trial version it's only the way to provide us to test for the product cancellation in which product cancel immediately after you cancel subscription trial period, it will not continue until even trial periods ends.

more information check below link:

http://developer.android.com/google/play/billing/billing_subscriptions.html#administering

And I think it is better way because in the trial period you should go with the actual credit card payment process but you doesn't need to pay anything for it. Google play record the transaction as $0.00 for the subscription process. And if you cancel the subscription the you should not pay anything for testing, but yes I am not sure free trial version is worked before you publish the app but it is only get by efforts only.

Conclusion:

In the current api it is not possible to test subcription product like normal products and if user has been cancel the subscription product then you have to wait to purchase the same product until the subscription cycle has been expired, there is no another way if the subscription cycle is going on and you can test for the same product again before subscription cycle ends. And if you still want to test for the same product then you have to choose another account for testing it or another way is Free trials, you will not be any charged until your Free trials period expired or cancel subscription in that period and for the testing account before publish the app you will be refunded automatically after 14 days of purchased product according to my knowledge.

Hope it will solve your problem.

Community
  • 1
  • 1
Maulik
  • 3,316
  • 20
  • 31
  • This doesn't really solve my problem since I need Google Play to actually clear the purchase for me to continue testing the flow of the application. After I make a subscription, my application will see the user as active for the next 30 days, even if they cancelled during that period. – Ben Barkay Oct 14 '13 at 14:40
  • to my understanding, you are saying that if I cancel a subscription that is in trial period, Google Play will drop the user's active trial period along with their subscription in a way that getPurchases will no longer render the user entitled to premium services? – Ben Barkay Oct 15 '13 at 05:53
  • you mean user wants to purchase the subscription trial period again after cancel the trial period of subs product? – Maulik Oct 15 '13 at 06:05
  • I need QA to be able to test the process of subscription purchase, this means allowing them to subscribe to the same product repeatedly. – Ben Barkay Oct 15 '13 at 06:10
  • why you want to purchase subscription product repeatedly? make sure you know about the recurring billing of the same product until user cancels subscription. check my edited ans link no. 3). – Maulik Oct 15 '13 at 06:23
  • And if you mean user wants to purchase again after he canceled subs then google play will allow user to use their product until the end of the cycle and after that google will not allow that user. And According to my knowledge user still wants to purchase the subscription again after cancellation then he has to purchase as a new subscription as done purchase at first time. – Maulik Oct 15 '13 at 06:32
  • this has nothing to do about the users, it's about QA testing. I think you understood my question wrong or perhaps I worded it incorrectly. – Ben Barkay Oct 15 '13 at 06:43
  • let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/39240/discussion-between-maulik-and-ben-barkay) – Maulik Oct 15 '13 at 06:44
3

I have a horribly clunky workaround for this problem. Here is what I do every time I want to do a test of in-app subscriptions:

  1. Create a new in-app subscription product in the google play developer console.
  2. Point the android app at the new subscription product you just created.
  3. In your code to check for active subscriptions, add a line to specifically ignore the order number of the previous subscription that you tested.
  4. Export a release build of the app and transfer it directly to your testing device.
  5. After testing, return to step #1 to test the next time.
  6. Don't forget to fix your change from step #2 before deploying the app!

You might want to create many subscriptions in step #1 so you don't have to continually wait hours for them to propagate. Please comment if you know of a better way!

UPDATE: Google now has test subscriptions and is making it easier to use them! https://android-developers.googleblog.com/2018/01/faster-renewals-for-test-subscriptions.html

Tyler
  • 6,741
  • 3
  • 22
  • 19
  • I hate that I'm upvoting this, but I'm upvoting this. There doesn't seem to be a more effective way of handling this at the moment. – sammysounder Mar 24 '16 at 22:55
2

It seems that nowadays there is better solution:

  1. Open your app page in Google Play Store application
  2. Click "Manage subscriptions"
  3. Click "Cancel subscription"
  4. Go to "Settings", "Apps" in your phone.
  5. Find Google Play Store and clear application data.

You should now be able to re-buy subscription.

  • Does it clear the subscription's active state from the in-app API call? Or will the application still recognize the user as subscribed despite the cancellation? – Ben Barkay Apr 13 '17 at 19:12
  • Yes, but it usually takes some time- from minutes to hours. And then inventory purchase state is diffrent than 0 : inv.getPurchase(SUBSCRIPTION_SKU).getPurchaseState() != 0 . – Paweł Czarnik Apr 14 '17 at 07:33
  • It's not ideal, but it sounds like the best bet at the moment. – Ben Barkay Apr 17 '17 at 11:48
-2

Create a mock class that mocks out the Google Play methods that you are using.

Johann
  • 27,536
  • 39
  • 165
  • 279