Quantcast
Channel: Appcelerator Developer Center Q&A Unanswered Questions 20
Viewing all articles
Browse latest Browse all 8068

Catch asynchronous response from in-app billing module for android

$
0
0

I can get to work the in-app billing module for android. I try to catch the response event when a purchase is made. I can catch it when it's synchronous by triggering a InAppBilling.restoreTransactions(); what I'm trying to get is to catch the response from play store when a purchase is made with requestpurchase() and then upgrade my app with the purchase. To catch the asynchronous response I did code

InAppBilling.addEventListener(InAppBilling.PURCHASE_STATE_CHANGED_EVENT, function(e){
 
    Ti.API.info("purchase state changed");
    if (e.signedData != null) {
 
        var response = JSON.parse(e.signedData);
 
        if (response.orders[0] && response.orders[0].purchaseState==0 response.orders[0].purchaseState == 0 && response.orders[0].productId == "testa") {
        Ti.API.info("it's bought now do something");
        }
    }
});
It does work on a restoreTransaction() but not when I purchase successfully from the Play store. Thanks for any help

Viewing all articles
Browse latest Browse all 8068

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>