Skip to content

grandrole/PayPal-iOS-SDK-PhoneGap

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

PayPal iOS SDK PhoneGap Plug-in

Integration

  1. Download the PayPal iOS SDK

  2. Read the iOS Integration Guide for conceptual information that will be useful during integration.

  3. Follow the "Initial setup" instructions in the iOS Integration Guide to add the required files, linker flags, frameworks, and acknowledgments to your app.

  4. Add PayPalMobilePGPlugin.[h|m] to your project, in the Plugins group

  5. Copy PayPalMobilePGPlugin.js to your project's www folder

  6. Add the following to config.xml, for PhoneGap version 3.0+:

      <feature name="PayPalMobile">
        <param name="ios-package" value="PayPalMobilePGPlugin" />
      </feature>

    for older versions under the plugins tag:

    <plugin name="PayPalMobile" value="PayPalMobilePGPlugin" />

Sample code

// for simplicity we have defined a simple buyButton in our index.html
// `<button id="buyButton" disabled>Buy Now!</button>`
// and we defined a simple onclick function in our `deviceready` event
var buyButton = document.getElementById("buyButton");
buyButton.onclick = function(e) {

  // See PayPalMobilePGPlugin.js for full documentation
  // set envrionment you want to use
  window.plugins.PayPalMobile.setEnvironment("PayPalEnvironmentNoNetwork");

  // create a PayPalPayment object, usually you would pass parameters dynamically
  var payment = new PayPalPayment("1.99", "USD", "Awesome saws");
  
  // define a callback when payment has been completed
  var completionCallback = function(proofOfPayment) {
    // TODO: Send this result to the server for verification;
    // see https://developer.paypal.com/webapps/developer/docs/integration/mobile/verify-mobile-payment/ for details.
    console.log("Proof of payment: " + JSON.stringify(proofOfPayment));
  }

  // define a callback if payment has been canceled
  var cancelCallback = function(reason) {
    console.log("Payment cancelled: " + reason);
  }
  
  // launch UI, the PayPal UI will be present on screen until user cancels it or payment completed
  window.plugins.PayPalMobile.presentPaymentUI("YOUR_CLIENT_ID", "YOUR_PAYPAL_EMAIL_ADDRESS", "[email protected]", payment, completionCallback, cancelCallback);
}

About

PhoneGap plugin for the PayPal iOS SDK

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published