Search code examples
androidin-app-billingin-app-subscription

Android anjlab in-app billing - chargeable


I am using Android anjlab in-app billing Library, and have noticed this behavior:

When a purchase (they are all subscriptions) is made and the card is charged right away, everything works fine:

the method onProductPurchased() gets called, and I can then call my server to give the user Premium access to my app.

But, looking into the transaction logs at the Merchant tools (Google console), I noticed that a lot of the times, the credit cards are not immediately charged - they stay in a chargeable state for some hours to a couple days, when they actually move to charged.

The problem is, when the payment goes into this chargeable state, the onProductPurchased() method does not get called and thus neither my server.

In these cases, my users get charged (hours after having bought the subscription in my app) but they never get the Premium access as I can't identify the payments in my app (just by looking into the merchant logs)!!

How to fix this?

Do I need some sort of check running on my app, to verify if the user bought the subscription??


Solution

  • In general, your app should always check, whenever possible, like at startup, if the user has valid receipts in their wallet, that haven't been converted to an upgrade yet.

    This is useful also in case of errors during the purchase process, or to restore the purchases when a user changes his phone, or uninstalls and reinstalls the app.

    It's been a while since I last dealt with this stuff, but I think that, according to the Google Play Policy, you are actually required to provide a restore mechanism.