How do I use Cranberry CordovaIAP (Android)?

0 favourites
  • 13 posts
  • I've been using C2 for a few months now, but have recently started getting into IAP testing. My goal is to have consumable purchases within my app. Since IAP within C2 doesn't support consumable items, I downloaded Cranberry CordovaIAP since it seems to be pretty popular and seems fairly easy to use.

    I recently purchased Cranberry Cordova IAP and am uploading a test application to the Google Play Store but am having two problems:

    1. The app doesn't appear to test correctly in C2. The button doesn't respond to purchase an item. I receive no popup error messages or anything. Just nothing when I click the button to purchase.

    2. When I use intel XDK and upload to the Google Play Store, I download on my phone to test but am met with a brief white flash before it's forever just a black screen.

    I have spent countless hours scouring forums, online tutorials, etc, to no avail. Everything I seem to find is at least a year old - I'm not sure if there have been changes since these older posts I've come across but nothing has seemed to work.

    Is there a tutorial or guide out there that shows how to use Cranberry CordovaIAP that is current?

  • Well there is nothing complex. It works the same way as C2 IAP plugin just the diference is that you have to call "consume" action after product has been succesfully purchased.

    If you post a screen of your implementation it would be much easier to say anything.

    Besides the implementation in C2 you need to set license property of Cordova IAP opbject (you can find it in Google Developer console) and import IAP Cordova JS library into IntelXDK plugin section.

  • Hopefully this image posts correctly. I'm omitting the ovo100 product currently so don't mind the events I've disabled. I'm only focused on making "ovo10" work for now.

    I've included the billing key from my Android developer account.

    I've also included the Cordova IAP library in the plugin section of Intel XDK.

    It's so strange how nothing is responding when I test. I normally get an error message because it can't connect to Play store obviously, but since I switched to Cranberry CordovaIAP it does nothing. And when I download from Google Play, a brief white screen flash followed by an infinite black screen.

    Thank you for helping me with this!!!

  • Allright... you have a mess there mate...

    * Line 3: you call purchase product twice there... first when someone touch the "Button_ovo10" and then on line 3. This logic is not logic .

    * Consume product should be under line 6 condition. So simply once it is successful, then you consume it.

    * Line 13 should not exist. It is being checked 60 times per second (if product is not restored/bought) for no reason. You should add those actions under observers.

    But I doubt that this is the reason your app actually go black screened. I suggest removing and adding again the JS plugin in Intel XDK.

  • My responses in bold.

    * Line 3: you call purchase product twice there... first when someone touch the "Button_ovo10" and then on line 3. This logic is not logic . Eep. I was messing around with it and forgot to fully undo some stuff I was trying.

    * Consume product should be under line 6 condition. So simply once it is successful, then you consume it. Cool. Fixed that. Didn't think of consuming it immediately after the user purchases it. Kind of a "doh" moment here.

    * Line 13 should not exist. It is being checked 60 times per second (if product is not restored/bought) for no reason. You should add those actions under observers. Is the Request store listing action only required to be used once at the start of the layout? It's not required to be used again after a purchase is purchased and consumed?

    But I doubt that this is the reason your app actually go black screened. I suggest removing and adding again the JS plugin in Intel XDK. I tried doing this, but it seems like I'm having problems still. I think I'm going to try rebuilding it in a brand new project. When I'm testing with Cranberry CordovaIAP in C2, is it normal for me to get zero response from touch events? The IAP object in C2 always gave me an error message at least to let me know it was there... This acts like I haven't included any events when I test.

  • You have to restore purchases only once at the start and it is only usable for non consumables. Like the premium account. So in such case you check if user bought it already in the past or not.

    If you use APK directly from the IntelXDK or IAP license it not set up (or is wrong i suppose) then you won't get any response. The APK must be downloaded from Google with correct license.

  • Ok, so I rebuilt the project from scratch (just testing the IAP function so it was easy) and I'm posting screenshots of my events, the files I've exported from C2 as well as the plugin I've added in Intel XDK. It's weird because when I use the emulator in XDK, it now gives me a popup window warning me about the IAP function (since it obviously can't link to the Google Play Store) but then displays a black screen. Maybe it won't do this when I upload the .apk to the Google Play Store...?

    Also, I'm building using Android Crosswalk - would this cause any problems?

    There's something I'm doing wrong but can't really put my finger on it.

    Btw, thank you so much for taking the time to look at this! I've been trying to figure this out for days.

  • 1. Just after Adding product IDS (at start of layout) you have to Request store listing. Otherwise C2 has no information about your products.

    2. "Consume product" action should be under "On purchase succeeded". You can't consume product which is not purchased yet.

    3. You should have a subfolder for your C2 export. I use "www" so the IntelXDK project directory should have 3 directories: plugins, xdk and It is not mandatory but right now you ave overwriting your "intelxdk.config.additions.xml" file everytime you export from C2.

    So what you should do now is edit this file (intelxdk.config.additions.xml). Remove everything what is there. and paste the following:

    <preference name="debuggable" value="false" />
    <intelxdk:crosswalk xwalk-command-line="--ignore-gpu-blacklist" />
    <intelxdk:crosswalk xwalk-command-line="--disable-pull-to-refresh-effect" />
    <preference name="CrosswalkAnimatable" value="false" />
    [/code:6f2cqxqm]
    
    And since you export your project directly into Intel XDK project directory, you will have to do it everytime you export from C2, because C2 is generating this file.
    
    4. Why you have only one plugin? Do you export as Cordova from C2? And have you selected "cordova project"  in the beginning?
    You should have minimum:
    * cordova-plugin-device 
    * cordova-plugin-splashscreen
    
    You can add them manually.
    1. Add Plugins to this project > core plugins > Device
    1. Add Plugins to this project > core plugins > Splashscreen
    
    5. Crosswalk is the one you should use.
    
    EDIT: Also I'm not sure if Cordova IAP does not require "com.google.playservices" plugin as well. But in other hand... IntelXDK should have added it automatically as a dependency.
  • Sorry it's taken me a bit to get back here. I've added everything (it's weird, device and splashscreen plugins disappeared after I added IAP - I had to re-add them), and the app opens.

    However, when I attempt to tap on the button to purchase I receive the error message: "Authentication is required. You need to sign into your Google Account."

    I tried adding the "com.google.playservices" but I still received the error message.

    Thoughts?

  • Hey guys. I bought the Cranberry plugins today and installed them.

    So what is the associated plugin I have to fetch in XDK for the Cranberry CordovaIAP pluin to work?

  • Allright... you have a mess there mate...

    * Line 3: you call purchase product twice there... first when someone touch the "Button_ovo10" and then on line 3. This logic is not logic .

    * Consume product should be under line 6 condition. So simply once it is successful, then you consume it.

    * Line 13 should not exist. It is being checked 60 times per second (if product is not restored/bought) for no reason. You should add those actions under observers.

    But I doubt that this is the reason your app actually go black screened. I suggest removing and adding again the JS plugin in Intel XDK.

    I'd like to give this one a bump. My IAP is not a "Subscription" but a "managed" product.

    A simple ad-disabler. Should I still "consume" the product after purchase or will the product just be detected without "consuming" ???

  • By consuming a purchased product you basically allow user to purchase it second time (like extra coins which they can buy how many they want for instance). So in your case you don't want to consume the product. Once it is purchased it should not be possible to buy it second time as user already owns it and it has its "has" state set to "true".

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • By consuming a purchased product you basically allow user to purchase it second time (like extra coins which they can buy how many they want for instance). So in your case you don't want to consume the product. Once it is purchased it should not be possible to buy it second time as user already owns it and it has its "has" state set to "true".

    I see. Thank you for clearing that up.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)