j3k0 / cordova-plugin-purchase

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

Usable with Phonegap build? #96

Closed janober closed 9 years ago

janober commented 9 years ago

Hello,

just found this plugin and was very happy that there is something that works with Android&iOS. However I am wonedering if it can be used with Phonegap build? In the setup there is a step to put the BILLING_KEY into an xml file. How can that be done in Phonegap build?

I tried different things like adding the xml to the zip, adding config-file, preference, .. to the config.xml. Nothing worked for me (quite possible that I do it wrong).

Is it possible to set it up like the plugin "com.mcm.plugins.androidinappbilling". It adds the billing key simply as a parameter:

  <gap:plugin name="com.mcm.plugins.androidinappbilling" version="3.0.6">
    <param name="BILLING_KEY" value="MII...AB" />
  </gap:plugin>

Thanks!

janober commented 9 years ago

Hm should be not ot hard. Tried to do it myself. Looks like the only changes needed to make it work should be in the plugin.xml. However if I make the changes (to work like the androidinappbilling-plugin) it does not work for some reason. Even though the config.xml in res/xml/ in the build apk is totally identical if build the normal way and when build with the changed code.

Never changed anything in a phonegap-plugin so not sure why it does not work. Maybe anybody else who knows what wrong or could make it work? Would be very appreciated!

macfam commented 9 years ago

According to todays Phonegap Blog post apps no longer need to be reviewed and approved for inclusion into Phonegap Build.

Phonegap Build users can use any plugin available from the Cordova Plugin Registry. This plugin appears to be available. This will be the first plugin I test with the new "source" attribute.

janober commented 9 years ago

Hello,

thanks for the answer! Yes I saw that and that will make life definetly easier for phonegap build users like me. However I am not sure if that will help here. Because the plugin is already in it: https://build.phonegap.com/plugins/661

The problem I am facing is to get my Android-Billing-Key into the build which I will still not be able to. However this enables now at least a work around I guess. Meaning creating a fork and then I can hardcode the value. But being able to set the biling-key simply in the config.xml would still be nice. Not just for phonegap build users, also for everybody else. Is just cleaner in my eyes to have it in the config.xml rather than in an xml file somewhere would be great. Espeically because it is currently in a folder that should normally not be in the git reprository of the app anyway.

j3k0 commented 9 years ago

Hey @janober

On Cordova, you can have the private key being copied to the right location using a hook. I suppose (hope) it's possible on PB also.

Something like hooks/after_platform_add/010_install_license_key.js, check this out for more details.

The plugin on PhoneGap Build is an older version, that doesn't support Android. For some reason Adobe wants me to upgrade my Adobe PB Account to be able to submit a newer version... So better use the one from the Cordova Plugin Registry.

janober commented 9 years ago

Thanks but no that is sadly not supported: https://github.com/phonegap/build/issues/279

The only way is really what I described. Still think having it in the config file would be the proper and clean solution for everybody no matter what they use.

But by seeing that it got closed I am apparently the only one...

janober commented 9 years ago

Ok overlooked a part before.

Created a fork (https://github.com/janober/cordova-plugin-purchase) and copied the regarding code from: https://github.com/poiuytrez/AndroidInAppBilling

Published it as a cordova plugin: http://plugins.cordova.io/#/package/de.4brains.cordova.purchase

Tested it with phonegap build and seems to work fine. Just in the case somebody else has the some problem I had.

j3k0 commented 9 years ago

Hey @janober

Sorry I may have closed a bit in a hurry.

If you can submit a pull request I'd happily integrate it. Actually it would be nice if both solutions were working (either put the license in a separate file or in the config.xml) so it doesn't break anyone's project.

janober commented 9 years ago

Sure, will look into it...

macfam commented 9 years ago

@janober got ya - nice to see you found a solution. Has this been merged in?

janober commented 9 years ago

Sorry had no time and then I sadly forgot. Created the pull request.

yarontt commented 9 years ago

Hey, I'm not clear if this should be working and what to do to get it to?

Would adding something like this be enough?

<gap:plugin name="com.mcm.plugins.androidinappbilling" version="3.0.6">
    <param name="BILLING_KEY" value="MII...AB" />
  </gap:plugin>

If so, what name/version should I use?

thanks.

Fortuitous commented 9 years ago

@janober Hi janober -- I see you worked on getting this plugin functional with PhoneGap Build - thanks! I'm able to attach the billing key through the config.xml file:

<gap:plugin name="com.smartmobilesoftware.inappbilling">
  <param name="BILLING_KEY" value="MIIB ... AB" />
</gap:plugin>

But my android app crashes as described in #103 Many have mentioned a fix involving installing manually from the repo (not the listed plugin) and editing a file -- impossible from PG Build.
Wondering if the plugin is working for you, and if you have found a way around this issue in PGB?

Thanks --

janober commented 9 years ago

@Fortuitous Sorry did not work on anything Android related since than so not really up to date. But do not have any problems with crashes. However back than I ended up using my fork and just stayed with it because it worked fine and did not see a reason to switch:

  <gap:plugin name="de.4brains.cordova.purchase" version="3.9.1-dev" source="plugins.cordova.io">
    <param name="BILLING_KEY" value="MIIB...." />
  </gap:plugin>

Do not remember that I did anything else special. Looked through the config.xml and through my gulpfile which copies all the stuff together and packs it for PGB. Nothing special in there (just the above). You can just give it a try and see if that works for you.

Fortuitous commented 9 years ago

@janober Will check it out and report back, thanks!

Fortuitous commented 9 years ago

@janober Hey guess what, your fork doesn't crash after Android purchase, using PGBuild. What a nice feature. :)

janober commented 9 years ago

@Fortuitous Very glad to hear! Confirms then also my experience. Guess PGB people should then temporary use that one till somebody figured out what is going on here. Probably some features will be missing because it did never get updated but if they are not needed it should be ok for a temp workaround.

ghost commented 8 years ago

I'm having trouble finding the plugin you published. Is it gone? "Published it as a cordova plugin: http://plugins.cordova.io/#/package/de.4brains.cordova.purchase"

Fortuitous commented 8 years ago

@janober So I used your fork for my first iteration and got nice coin from Play and App store users (thanks!). I'm working on my next version, but of course Phone Gap Build no longer likes your plugin since it no longer supports plugins.cordova.io.

Did you port your plugin over to npm? Or did @j3k0 merge your code making your fork redundant? (And if so, will I need to make any changes to my code making calls to your fork, or should it all just still work?)
Curious what path you're using these days. Thanks.