Closed ewpdesign closed 10 years ago
I've got the same problem, I followed the documenation to the letter and constantly getting the following error:
file:///android_asset/www/plugins/com.smartmobilesoftware.inappbilling/www/inappbilling.js: Line 104 : Uncaught ReferenceError: module is not defined
When I put an alert into the inappbilling.js, I can see it is loaded using the cordova_plugins.js. But it is not getting into the init function and gives the above error.
What am I doing wrong and why is the documentation not up-to-date, even the example code doesn't make sense, it's just the copy of the v2 decumentation..
Have you "installed" the plugin? I have done so many things and spent so many hours getting this to work that I cannot remember everything I tried, but I made major progress by installing the plugin:
get to the directory where your app lives and type: phonegap local plugin add
Also, make sure you reference the javascript functions literally, i.e. InAppBilling.prototype.init(initSuccessHandler, initErrorHandler,{showLog:true}), not how you see it in the out-dated documentation.
I know the developer of this plugin doesn't "owe" us anything, but I was completely dependent on this plugin for success and he is either in jail, in a coma, dead or just doesn't give a $%#@ anymore. I offered to pay for help and still did not receive a reply. Perseverance paid off, granted I've only gotten as far as the init function, but if the plugin actually works, I should be able to take it from here.
Good Luck!
I haven't used the plugin installer, I did the manual steps, for some reason it doesn't want to install plugins using the command-line.
I was wondering if I needed the add the inappbilling.js as an javascript-include in my index file, but using the cordova_plugins.js construction it was loading the inappbilling.js, since I put an alert at the top of the page.
My problem now lies in the module.exports = new InAppBilling(); function. It does not start the init-function, and gives that error, module is not defined.
Haven't got further yet..but I will not give up.
I got this plugin working fine in a freshly created (3.1) PhoneGap app, and I installed it through the CLI rather than manually including it.
I also didn't edit the plugins JS file to remove "prototype" from declarations.
However, including it in a pre-made project is becoming problematic. I simply get a "inappbilling is not defined" error.
Further update: Having tried to incorporate it in to an existing PhoneGap project and hitting the error I mentioned above, I downgraded Cordova from 3.1 to 3.0 and everything is working.
When I get more time I'll see if it is a compatibility issue with 3.1 or something I'm doing differently.
@leeDav When you will have finish to test the plugin, please update the documentation. Thank you!
Ok, I got it to work, this is what I had to change:
var InAppBilling = cordova.require("cordova/plugin/InAppBilling"); InAppBilling.init(successHandler, errorHandler, {showLog:true});
This was the only way I could make it to work..not sure if it is the correct way.
Thank you ahbruinsma for sharing. However, as the normal installation is working, I am closing the ticket. I will write in the documentation that the "manual steps" are not recommended.
@ahbruinsma Thanks for your solution, it works for me.
I am using Phonegap 3.3 and tried to install it through the CLI, but still get error "inappbilling.js: Line 104: Uncaught ReferenceError: module is not defined" and "inappbilling is not defined". Is it a compatibility issue?
Alright, I'm far too often in this mess. But oh well, I managed to correct the situation (with most likely deprecated code), here's a fix, for it is still working for me.
2 things needs to be done:
It will look like this...
(function(cordova) { ... rest of JS file... //module.exports = new InAppBilling(); cordova.addConstructor(function() { if(!window.plugins) window.plugins = {}; window.plugins.inappbilling = new InAppBilling(); }); })(window.cordova || window.Cordova);
so now, from where you normally initialize the plugin, you just need to declare as follow: var inappbilling = window.plugins.inappbilling; inappbilling.init(successHandler, errorHandler, {showLog:false});
From there given your plugin was correctly referenced in your project it will work.
Feel free to make a pull request.
On Tue, Feb 3, 2015 at 9:28 PM, Godlike- notifications@github.com wrote:
Alright, for I'm far too often in this mess. But oh well, I managed to correct the situation (with most likely deprecated code), here's a fix, for it is still working for me.
2 things needs to be done:
- use the .JS, and put a wrapper around (as shown below):
- rem the module.exports thingie. it will be of no need in the future.
It will look like this...
(function(cordova) { ... rest of JS file... //module.exports = new InAppBilling(); cordova.addConstructor(function() { if(!window.plugins) window.plugins = {}; window.plugins.inappbilling = new InAppBilling(); }); })(window.cordova || window.Cordova);
so now, from where you normally initialize the plugin, you just need to declare as follow: var inappbilling = window.plugins.inappbilling; inappbilling.init(successHandler, errorHandler, {showLog:false});
From there given your plugin was correctly referenced in your project it will work.
— Reply to this email directly or view it on GitHub https://github.com/poiuytrez/AndroidInAppBilling/issues/32#issuecomment-72727792 .
Hi, is it possible to use this pluggin with phonegap remote build, if yes please share the steps how?
if no, please share how to add this to an existing remote phone gap project.
here is my project,
1) i have a single html file like following and config file has this setting
2) here is the index file i am using
<!DOCTYPE html>
A function is triggered when the button is clicked. The function outputs some text in a p element with id="demo".
Solution for the issue :Uncaught ReferenceError: module is not defined Modify the "inappbilling.js" like:
// "inappbilling.js" file begins here cordova.define("com.smartmobilesoftware.inappbilling.InAppBilling", function(require, exports, module) { //content of the "inappbilling.js" goes here });
// end of file......all the best!
First, thank you so much for the work you have done in developing this plugin!
It seems like the new v3 release does not match the documentation. I opened up the inappbilling.js file and removed the "prototype." and at least got the init function to fire. Also, the case has changed in the new .js file and my program had to be changed accordingly (the sample documentation is still all lower case).
Aside from the alert I placed in the .js file firing. I am not getting any success or error responses from the function. I have checked the setup a million times and cannot see anything that I could have missed.
I'm so close.....