Reputation: 523
My question is, on Android, does the p.purchase() method fire the implemented method (for non-consumable IAPs), in the main class, below, or is this just IOS?
@Override
public void itemPurchased(String sku) {
Background info: My app uses non-consumable in-app purchases, and is released to IOS and Android. I store the IAP 'receipt' in my cloud database so i know if they have purchased the full version or not. If they have not purchased it then after x days use then it will prompt them on entry, before issuing the IAP purchase logic.
public void askAndProcessMainIap() {
if (Dialog.show("", "Your trial period has finished. Please upgrade to the Full Version", "Ok", null)) {
Purchase p = Purchase.getInAppPurchase();
p.purchase("main_app_iap_paid");
}
On IOS all works, but on Android all my customers are reporting it not working - they are able to purchase the IAP from Google and the Google receipt does find the correct non-consumable IAP (as i have seen the name of it in screenshots). But my app is not storing the 'receipt' in my database. So when they go back into the app it asks them again, and then issues an error that they have already purchased it.
I need the itemPurchased() method to fire as this stores the database receipt entry. I ask this as the CN1 javadoc for the purchase() method says 'On Android you must use subscribe(java.lang.String) for play store subscription products'.
For ref, my build hints for android.nonconsumable should be correct as it is finding the Google Play IAP display name ok. Users aren't reporting any errors when they first make the purchase. Thanks
Upvotes: 2
Views: 260
Reputation: 4716
does the p.purchase() method fire the implemented method (for non-consumable IAPs), in the main class, below,
Yes. Android will fire the itemPurchased() method in your main class.
In app purchase can be really hard to get right. There are numerous steps on the Google Play side that need to be completed, and missing even one step, can cause things to just not work. The best strategy is to test it step by step. Test in the simulator, to ensure that your workflow works and that receipts are correctly submitted to your cloud database.
Then you need to test on an actual Android device. Create an internal release in the Play store, and set yourself up as a tester so that you can make purchases with a "test/dummy" credit card and ensure that the flow works properly. This page includes some instructions on this testing process. The important steps are:
I usually put in System.out.println statements into all of my purchase callback methods to help track the progress when testing. Then I can check my device log to see if/when/which callback is called.
Don't leave it to your users to test the IAP, as Murphy's law runs strong in IAP.
Upvotes: 2