j3k0 / cordova-plugin-purchase

In-App Purchase for Cordova on iOS, Android and Windows
https://purchase.cordova.fovea.cc
1.3k stars 537 forks source link

IAP.onPurchase not firing #24

Closed ahbruinsma closed 10 years ago

ahbruinsma commented 10 years ago

I've got a problem with the callback function when doing a purchase, In the console of Xcode, it gives me an ok on the purchase, the product gets purchased and I get an succes.

When I look at the InAppPurchase.prototype.purchase function, it never gets into the purchaseOk or purchaseFailed function, which should be called by the exec purchase command.

Any ideas where this can go wrong?

ahbruinsma commented 10 years ago

Turns out, I did not define the window.storekit. Because I don't use the auto-plugin construnction (just does not work on my projects, don't know why...). I'm doing a require in my js like: cordova.require("cordova/plugin/InAppPurchase");

Needed to do: window.storekit = cordova.require("cordova/plugin/InAppPurchase"); Instead of what I was doing: InAppBilling = cordova.require("cordova/plugin/InAppPurchase");

Apperantly, the .m file required the window.storekit to be there so it can call the callbaks defined in the init.