valueerror Posted February 17, 2015 Share Posted February 17, 2015 I still didn't find any tutorial out there on how to properly implement in app purchases (in my case with android && crosswalk) so this is some sort of tutorial for in app purchases (but it isn't finished yet - that's why i need your help ) i'm using this plugin http://plugins.cordo...ordova.purchase (it seems to be the right choice for this since it's the most used plugin in the database)i added the permissions "com.android.vending.BILLING" to my project settings (this is needed for the google developer console to recognize the apk as "billing enabled" and allow adding an "in-app product")i added the plugin "cc.fovea.cordova.purchase" to my game using intel xdk crosswalk > 3rd party plugins > get plugin from the web (plugin is located in the apache cordova plugin registry) ATTENTION: this doesn't work due to a bug in the current version 3.10.1 where $BILLING_KEY is not properly set you have to download the plugin from the git repo : https://github.com/j3k0/cordova-plugin-purchase and install it manually (see next step - adding local plugin over the UI will not work!)i created a file called "intelxdk.config.additions.xml" in the same directory as the other xdk files (this file will be included in the actual build files - it's a way to include additional parameters for plugins like "billing_key)i added the following xml code to the xml file: (MIIB... is the Licence Key! you'll find it in the developer console under Services & APIs) <intelxdk:plugin intelxdk:name="cc.fovea.cordova.purchase" intelxdk:value="cc.fovea.cordova.purchase" intelxdk:type="local"> <intelxdk:param intelxdk:name="BILLING_KEY" intelxdk:value="MIIB........DAQAB" /></intelxdk:plugin> now you need to edit one file in the plugin to make up for the BUG ! edit the file plugin.xml and find the section that says <string name="billing_key_param"> and add your Licence Key instead of the variable $BILLING_KEY so it looks like this:<config-file target="res/values/billing_key_param.xml" parent="/*"> <string name="billing_key_param">MIIBIj..................DAQAB</string> </config-file>i was then able to build the project and upload the apk with the right permissions and the plugin (and the additional parameter) as "alpha" release to the playstore and also add my first "in-app product" (id: "noads") https://play.google.com/apps/publish/i defined a price and activated it.. i published my app as alpha release !!!i added the example code from the github plugin website to my code so the "device ready" signal should do some sort of "appstore" setupdocument.addEventListener('deviceready', initializeStore, false); function initializeStore() { // Let's set a pretty high verbosity level, so that we see a lot of stuff // in the console (reassuring us that something is happening). store.verbosity = store.WARNING; // We register a dummy product. It's ok, it shouldn't // prevent the store "ready" event from firing. "noads" is the current id store.register({ id: "noads", alias: "no ads", type: store.NON_CONSUMABLE }); // When everything goes as expected, it's time to celebrate! store.ready(function() { console.log("STORE READY"); }); // When purchase is approved show some logs and finish the transaction. store.when("noads").approved(function(order) { console.log("PURCHASE APPROVED"); order.finish(); }); store.when("noads").owned(function() { console.log("PRODUCT PURCHASED"); alert('You purchased the ad-free version! Please restart the application to finish.'); disableADS(); // custom function triggered }); // After we've done our setup, we tell the store to do // it's first refresh. Nothing will happen if we do not call store.refresh() store.refresh(); } it seems that i need to setup a testing google account because i'm not allowed to use my google dev account for testpurchases ?! so i added another account as "Gmail accounts with testing access" in the settings section of the developer console AND i had to create a google group and invite those testers AND add the group as allowed apha testers in the apk section !! (make sure the app version code is the same otherwise the purchase will not work !)i now have my button in place that should trigger the purchase by calling the following function:function buyADS(){ store.order('noads');}i installed an apk file i built in intel xdk (not the one i uploaded to the store because i made some changes to the store script) with a user thats in the "alpha test group" (developer is not allowed to purchase) !!then i started the game and clicked on my "buy-button" it actually loads the store inside my app and let me complete a test-purchase (add creditcardnumber and so on...) Yeeehaaa !! Olle, Titoine and shohan4556 3 Link to comment Share on other sites More sharing options...
valueerror Posted February 20, 2015 Author Share Posted February 20, 2015 So there are a few questions left. for now i store the succesfull purchase in the local storage so the next time the app is loaded it first checks the local storage and disables the ads. seems a little bit unprofessional to me.. how would you do it ?? i want to provide additional assets like skins or levels via inapp purchases.. how do i upload them to the store (i don't see any option for that) and how do i make sure those assets are then downloaded and stored into the right folder or that current local assets are replaced by the new ones? hopefully there is someone in this forum with a little bit more insight.. thx in advance !! Link to comment Share on other sites More sharing options...
valueerror Posted February 22, 2015 Author Share Posted February 22, 2015 so it looks like i'm going to stick with the method i used for #1 i thought about always checking the store for the purchased item to prevent tempering with the local storage to circumvent the purchase but i guess that's not really necessary.. as for the 2nd problem.. i guess i will include those assets (extra levels, skins, etc) in the original package and de/activate them with another variable stored in the local storage.. so i'm basically doing it exactly like #1i was hoping to find a way to NOT have to include everything to keep the filesize small but i didn't find anything on how to do this.. it seems like i have to create a second app that shares the same developer key because if it does those two apps can share resources .. and then find a way to access those resources from the original app .. but this is a bit complicated for me to find out by trial and error and i still couldn't find any tutorials on this... Link to comment Share on other sites More sharing options...
Gods Posted March 4, 2015 Share Posted March 4, 2015 Do I need to wrap my app in cordova/crosswalk to test? I would hate to make small changes and keep wrapping my app and reinstalling it just to testAnyway to use intel xdm live preview to test? also can I test ads without wrapping? Link to comment Share on other sites More sharing options...
valueerror Posted March 4, 2015 Author Share Posted March 4, 2015 you definitely can not use the internal emulator and as far as i know ads are not working in the app preview either..i think i read something about this and they said it will definitely come but is not finished yet.. therefore you need to build and install your app everytime you want to test something related to thirdparty plugins Link to comment Share on other sites More sharing options...
Nigy Posted April 9, 2015 Share Posted April 9, 2015 Hi, I'm using the same plugin to build my app with phonegap, but I have problem to retrieve product from the store.I have followed your guide step by step but its doesn't work and I don't understand why.Have I to build or compile the project? because if I build it, the project is reseated thanks Link to comment Share on other sites More sharing options...
Titoine Posted April 13, 2015 Share Posted April 13, 2015 Hi, thanks for your tutorial. But unfortunatly It's does't work for me.. So I'm pretty sure I followed correctly your tutorial (after reading over and over).This is what i did : 1. Downloaded the plugin https://github.com/j3k0/cordova-plugin-purchase2. Put in the my www xdk app folder3. Add it as a third party plugin from local folder 4. Add permissions : com.android.vending.BILLING5. Add/modify intelxdk.config.additions.xml6. Modify plugin.xml in the plugin folder (in my www app) to add my billing key.. But this is what happen : Don't really know what I did wrong or what's happening..Thanks in advance, any help or advice is welcome. ps: I use the Intel XDK 1826ps2: I would like to thanks you again for taking time to write your tutoriel! Link to comment Share on other sites More sharing options...
valueerror Posted April 13, 2015 Author Share Posted April 13, 2015 well.. you obviously missed that part of the tutorial ;-) ATTENTION: this doesn't work due to a bug in the current version 3.10.1 where $BILLING_KEY is not properly set you have to download the plugin from the git repo : https://github.com/j...plugin-purchase and install it manually (see next step - adding local plugin over the UI will not work!) that means.. do not add it as 3rd party plugin.. it will not complile.. so instead of step 3 - you do 4 and 5 -- the lines you added to config.additions are enough Link to comment Share on other sites More sharing options...
Titoine Posted April 13, 2015 Share Posted April 13, 2015 Omg, I lost my after noon for that...and I had the solution under my eyes.. you should add a line-through "i added the plugin "cc.fovea.cordova.purchase" to my game using intel xdk crosswalk > 3rd party plugins > get plugin from the web (plugin is located in the apache cordova plugin registry) ". Thanks! Link to comment Share on other sites More sharing options...
Titoine Posted April 13, 2015 Share Posted April 13, 2015 Still have a problem with the permission.How do you add "com.android.vending.BILLIN" ?When I add it like this : I have this :Added permission "android.permission.com.android.vending.BILLING"When I add Billing I got "android.permission.BILLING". Trying to add it by intelxdk.config.additions.xml but still not successful. Link to comment Share on other sites More sharing options...
valueerror Posted April 14, 2015 Author Share Posted April 14, 2015 thx for the suggestion.. i edited the line android.permission.com.android.vending.BILLING looks quite right to me.. is there a problem with it.. does it work??i think i read the same thing somewhere.. what if you add android.permission.com.android.vending.BILLING instead of com.android.vending.BILLINGis it rewritten to android.permission.android.permission.com.android.vending.BILLING then ?? this is how it looks like on my screen.. Link to comment Share on other sites More sharing options...
Titoine Posted April 14, 2015 Share Posted April 14, 2015 Can't test android.permission.com.android.vending.BILLING right now but I think it will rewrite it like you said. In my developer console I have the BILLING permissions ; But I can't add in-app product.. So I don"t think I have the good permissions. Link to comment Share on other sites More sharing options...
valueerror Posted April 14, 2015 Author Share Posted April 14, 2015 android.permission.ACCESS_NETWORK_STATE android.permission.ACCESS_WIFI_STATE android.permission.com.android.vending.BILLING android.permission.INTERNET com.android.vending.BILLING this is what my developer console tells me Link to comment Share on other sites More sharing options...
Titoine Posted April 14, 2015 Share Posted April 14, 2015 Witch version of Intel XDK do you have ?I do the same thing as you and doesn't have the same result Link to comment Share on other sites More sharing options...
valueerror Posted April 14, 2015 Author Share Posted April 14, 2015 currently using 1878 (i'm always using the newest one i can get .. i don't think this is related to the version i am using because it worked with every version in the last months) i definetly only added "com.android.vending.BILLING" in intel xdk gui.. in the automatically created intelxdk.config.crosswalk.xml it says :<preference name="android-permission" value="com.android.vending.BILLING"/> what happens when i build for crosswalk and upload the apk to the playstore is unclear.. i don't know why there is android.permission.com.android.vending.BILLINGANDcom.android.vending.BILLINGand if its even needed to add an inapp product Link to comment Share on other sites More sharing options...
Titoine Posted April 16, 2015 Share Posted April 16, 2015 Can you tell me what do you have in your "intelxdk.config.additions.xml" ?Thanks again for you help. Link to comment Share on other sites More sharing options...
valueerror Posted April 16, 2015 Author Share Posted April 16, 2015 <intelxdk:plugin intelxdk:name="cc.fovea.cordova.purchase" intelxdk:value="cc.fovea.cordova.purchase" intelxdk:type="local"> <intelxdk:param intelxdk:name="BILLING_KEY" intelxdk:value="MIIBIjA..................AQAB" /> </intelxdk:plugin> Link to comment Share on other sites More sharing options...
valueerror Posted April 16, 2015 Author Share Posted April 16, 2015 oh.. did you edit the plugin properly ? (plugin.xml) because your key is not included automatically. its a known bug.. Link to comment Share on other sites More sharing options...
Titoine Posted April 16, 2015 Share Posted April 16, 2015 Yeah I edited the plugin.xml to add the key like you said :<config-file target="res/values/billing_key_param.xml" parent="/*"> <string name="billing_key_param">MIIBIj..................DAQAB</string> </config-file> Do you put the plugin in the www folder ? And what's the plugin folder name ? "cc.fovea.cordova.purchase" ? Link to comment Share on other sites More sharing options...
valueerror Posted April 16, 2015 Author Share Posted April 16, 2015 i've got everything in the same folder.. pluginfolder (with the exact same name as you wrote) index.html, phaser.min.js, xdk files (intelxdk.config.additions.xml and so on) Link to comment Share on other sites More sharing options...
fariazz Posted July 28, 2015 Share Posted July 28, 2015 Do you know if the plugin is still broken for Android in the XDK on it's latest version 3.11.1? https://github.com/j3k0/cordova-plugin-purchase/releases/tag/v3.11.1 Link to comment Share on other sites More sharing options...
Recommended Posts