The PhoneGap plugin will be deprecated in favour of a new Cordova / PhoneGap plugin which is compatible with our Mobile SDK v2.


As promised in my previous post we’ve got all those cross-platform developers out there covered too. Just a few days ago we released a first version of the Android SDK PhoneGap plugin. In this post I want to highlight the most important steps for getting started and making sure your project will be able to accept payments.

Compatibility We’ve tested the plugin itself with PhoneGap 2.6 and 2.7. You should be fine running the plugin with these versions.

Prerequisites Please make sure to read my previous blog post in order to understand and execute the following 4 steps:

  • Getting credentials for your project
  • Adding the PayPal Android SDK lib to your project
  • Requesting the right permissions
  • Adding the required Service and Activities Once you’ve got those 4 steps completed we can start working with our plugin.

Obtaining and setting up the plugin The plugin can be obtained

over at GitHub. Please make sure to move the contained files to the following paths: * PayPalMobilePGPlugin.js to assets/www/PayPalMobilePGPlugin.js * PayPalMobilePGPlugin.java to src/com/paypal/android/sdk/phonegap/PayPalMobilePGPlugin.java

And add an entry for the plugin in your

config.xml (which can be found at res/xml/config.xml):

Making payments In order to trigger a payment your UI should contain some kind of trigger like a button. Therefore we’re going to add the following button:

Now define the following function being triggered by the button: If you’re interested in what else you’re enabled to do with the plugin already: Have a look at the code of the <a href="https://github.com/paypal/PayPal-Android-SDK-PhoneGap/blob/master/PayPalMobilePGPlugin.js" target="_blank">PayPalMobilePGPlugin.js</a>!

That’s it This is all you need to get started. The plugin wraps away all the other code and makes accepting payments as smooth as possible. We’re going to add more and more functionality over time to make sure you can make the most out of your (web-)app.

About Tim Messerschmidt

As a long time mobile and web developer specializing in Android, Tim channels his knowledge and experience as Developer Evangelist across Europe for PayPal’s Developer Network. Tim is very passionate about startups, and serves as a mentor of Seedcamp, Wayra, Startup Wise Guys & Rockstart. In his spare time, he leads and creates training classes in all sorts of Android related topics, and is the author of the Android chapter of the Mobile Developer's Guide to the Galaxy, as well as numerous articles published in magazines like web&mobile developer.


9 Responses to Android SDK PhoneGap Plugin

  1. Deepak says:


    Thanks for the wonderful work you have done. But I tested with my sandbox account and what i got was Payment from this device was not allowed. Am I missing something? I did everything as you menntioned above except I don’t know where to put acknowledgement.md in my app.

  2. Tim Messerschmidt says:

    Hi Deepak,
    you don’t need to put the .md file in your app.
    In which country are you based? The SDK is US-only right now.


  3. Mat says:

    Hi there,
    I really like what you guys have done with the PhoneGap plugin, but as I’m a developer in Australia I was wondering if this PG Plugin will connect to the MPL or if it only works with the Android SDK.

  4. Jason King says:

    Is it possible to use this in the UK? If not can you give me an alternative to use please?

  5. Adam Harris says:

    Is there an update for phonegap 3.x?

  6. Aviral Jain says:


    I am able to scan card in sample app provided in android sdk, but in phonegap it open a new screen for providing card details manually.
    Is card.io not available for phonegap ?

    Please let me know what I am missing.

  7. Fan Winston says:

    Hi Tim, thank you for your post. I’d really like to see the Windows Phone 8 Version Paypal SDK. Could you please let me know is this on your radio?

  8. Akmal Javed says:


    I am using paypal plugin in my phonegap android application When i make a payment i have got error “the payment information is invalid please correct and submit again” please see the image for more detail.

    please help me in this issue

    this is my code
    var paymentDetails = new PayPalPaymentDetails(“0.0”, “0.00”, “0.00”);
    var payment = new PayPalPayment(“234”, “SGD”, “… Payment Order #5649”, “Sale”, paymentDetails);

  9. jeet says:

    as per instruction , i add all files after run i will face java.lang.ClassNotFoundException: com.paypal.android.sdk.phonegap.PayPalMobilePGPlugin error can you help me how to solve is issue