Recurring subscriptions on Android
Asked Answered
F

2

7

I've implemented a recurring subscription for Android In App Billing, but I'm wondering how the apps knows that the subscription is renewed. In testing, at least, the subscription is ended after 1 day. Will it be continued when the app is published on the store?

On iOS the testing subscription is renewed a couple of times. Enough to let you test when the subscription is renewed, but what is the best way to do this on Android?

Can I use the purchaseToken to let my server query Google Play API or do ever renewed subscription get a new purchaseToken?

Flyspeck answered 18/1, 2017 at 15:45 Comment(1)
You probably already know about this, but have a look at Real-time Developer Notifications. Hope it helps!Manipulate
S
4

In android IAP, The purchase token expires when the user manually cancels the subscription or disables the auto-renew. Otherwise, you will get a valid purchase token every time. In test mode, the tester's subscription automatically gets expired after 5 minutes but in production, it will work fine. So don't get worried about the production behavior. If you are running the app as a tester, you will get the below payment modes on the payment flow start. Subscription-test-instruments

You will have 2 options to test your implementation

  1. Test Card(Always Approves)
  2. Test Card(Always Declines)

By testing both of the cards, you can be sure about the implementation. Your app should be capable of handling both responses from IAP. If both flows goes well, You shouldn't be worried about it. You are ready to roll-out it on production. Here is the Official Docs, may help you to understand the entire flow.

If you designed custom flow to manage IAP, You can verify the IAP Token from backend using the Google Play Developer API and allow the user to consume the feature accordingly. For the custom flow, You can send custom JWT token from backend according to IAP Token expiry and set custom JWT Token exp claim. By using this method you can check the custom token is expired or not in the client-side, If it's happened so, You can fetch the new IAP token and send it to your backend. Your backend should validate that IAP token and issue new JWT token to user and cycle goes on. Let me know if you want the custom flow, I'll post it here.

Sneaker answered 30/9, 2019 at 17:10 Comment(0)
B
0

You simply periodically query the Google Play server to check the items that the user own, if it is a subscription, it will reply that he/she owns it while it is active and therefore has not expired.

Do not forget to verify the signature of the received data, and much better using a server side verification Android - protecting in app purchases with server side verification

Bulgaria answered 30/9, 2019 at 17:31 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.