Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Am I getting these steps right for checking a user's in-app billing subscription?

I am making an Android app that sells an in-app monthly subscription. Before I dive into it too much, does this outline of how this should be done seem about right? I am using the Google Play Android Developer API.

The first time the app is installed, send the following in sendBillingRequest():

  • CHECK_BILLING_SUPPORTED. If not, don't bother making the "buy" UI.
  • RESTORE_TRANSACTIONS. If there were transactions, save the user's purchase token.

When the user makes a purchase:

  • Save the purchase token.
  • Send a GET request with the purchase token to the Google Play Developer API to verify the subscription.
    • If subscription is valid, save the subscription expiration and initiation dates. Provide access to purchased data.
    • If subscription is not valid, remove the purchase token. Do not provide access to purchased data and draw "not purchased" version of the UI.

Each time the app is started up, check if you have a saved purchase token.

If the purchase token doesn't exist:

  • Do not provide access to purchased data and draw "not purchased" version of the UI.

If the purchase token exists, check the expiration date and initiation time:

  • If (expired) or (initiation was over one month ago)
    • Send a GET request with the purchase token to the Google Play Developer API to verify the subscription.
    • If purchase is valid, update the saved expiration and initiation dates. Provide access to purchased data.
    • If purchase is not valid, remove saved purchase token and expiration and initiation data. Do not provide access and draw "not purchased" version of the UI.
  • Else
    • Provide access to purchased data.
like image 393
Kalina Avatar asked Sep 28 '12 17:09

Kalina


People also ask

How to test subscription on Android?

Open the Google Play app. Choose Account -> Subscriptions & Payments -> Subscriptions. Click your test subscription and change the payment method to “Test card, always declines.” After five minutes, payment should be declined.

How do I check in app purchases on Android?

When you are testing in app purchases on Android, you must use a signed version of the app. Your Google Play email must be listed in the Google Play Console as a tester. The easiest way to do this is to publish your app to a Beta release with open testing.


1 Answers

Yes I am.

I have successfully implemented in-app billing this way.

like image 185
Kalina Avatar answered Oct 12 '22 23:10

Kalina