Skip to content
This repository has been archived by the owner on Jan 16, 2019. It is now read-only.

Commit

Permalink
Merge pull request #179 from paypal/card-io-cordova-dependency
Browse files Browse the repository at this point in the history
Created dependency on card.io cordova plugin
  • Loading branch information
Jay committed May 13, 2016
2 parents c0e5bcb + 33856e0 commit a9195f7
Show file tree
Hide file tree
Showing 14 changed files with 44 additions and 545 deletions.
50 changes: 38 additions & 12 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

Disclaimer
-----------
The intention for this plugin is to make it community driven.
The intention for this plugin is to make it community driven.
We have created the initial version of the plugin to show how easy it is to use our native SDKs (iOS and Android) on the Cordova/Phonegap platforms.
As features are added to the mSDK, we will be happy to review and merge any Pull Requests that add these features to the plugin.

Expand Down Expand Up @@ -32,7 +32,7 @@ The PayPal SDK Cordova/Phonegap Plugin adds support for the PayPal SDK on iOS an
$ cordova platform add android
# optional for console.log etc
$ cordova plugin add org.apache.cordova.console
```
```
3. Follow Your app integration section below.
4. Run `cordova build` to build the projects for all of the platforms.

Expand All @@ -48,7 +48,7 @@ The PayPal SDK Cordova/Phonegap Plugin adds 2 JavaScript files to your project.

1. `cdv-plugin-paypal-mobile-sdk.js`: a wrapper around the native SDK. The `PayPalMobile` object is immediately available to use in your `.js` files. You DON'T need to reference it in index.html.
2. `paypal-mobile-js-helper.js`: a helper file which defines the `PayPalPayment`, `PayPalPaymentDetails` and `PayPalConfiguration` classes for use with `PayPalMobile`.
3. You must add
3. You must add
```javascript
<script type="text/javascript" src="js/paypal-mobile-js-helper.js"></script>
```
Expand All @@ -62,6 +62,11 @@ Documentation
- For complete documentation regarding the PayPal SDK Cordova Plugin, please refer to the documentation for the underlying [PayPal Mobile SDK](https://developer.paypal.com/webapps/developer/docs/integration/mobile/mobile-sdk-overview/).
- Not all features available in native sdks have been implemented.

Using card.io scanning abilities independently
----------------------------------------------

PayPal SDK Cordova Plugin now allows you to directly invoke card.io scanning abilities as provided by [card.io Cordova Plugin](https://github.com/card-io/card.io-Cordova-Plugin). The implementation is shown below in the samples.


Basic Example of the app
------------------------
Expand All @@ -73,11 +78,12 @@ Basic Example of the app
<button id="buyNowBtn"> Buy Now !</button>
<button id="buyInFutureBtn"> Pay in Future !</button>
<button id="profileSharingBtn"> Profile Sharing !</button>
<button id="cardScanBtn">Advanced: Use card.io scan only</button>
```

2. Replace `MyShop/www/js/index.js` with the following code:
```javascript

/*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
Expand Down Expand Up @@ -120,12 +126,12 @@ Basic Example of the app
var parentElement = document.getElementById(id);
var listeningElement = parentElement.querySelector('.listening');
var receivedElement = parentElement.querySelector('.received');

listeningElement.setAttribute('style', 'display:none;');
receivedElement.setAttribute('style', 'display:block;');

console.log('Received Event: ' + id);

// start to initialize PayPalMobile library
app.initPaymentUI();
},
Expand All @@ -135,11 +141,15 @@ Basic Example of the app
"PayPalEnvironmentSandbox": "YOUR_SANDBOX_CLIENT_ID"
};
PayPalMobile.init(clientIDs, app.onPayPalMobileInit);

},
onSuccesfulPayment : function(payment) {
console.log("payment success: " + JSON.stringify(payment, null, 4));
},
// This code is only used for independent card.io scanning abilities
onCardIOComplete: function(card) {
console.log("Card Scanned success: " + JSON.stringify(card, null, 4));
},
onAuthorizationCallback : function(authorization) {
console.log("authorization: " + JSON.stringify(authorization, null, 4));
},
Expand All @@ -160,24 +170,40 @@ Basic Example of the app
// <button id="buyNowBtn"> Buy Now !</button>
// <button id="buyInFutureBtn"> Pay in Future !</button>
// <button id="profileSharingBtn"> ProfileSharing !</button>
// <button id="cardScanBtn">Advanced: Use card.io scan only</button>
var buyNowBtn = document.getElementById("buyNowBtn");
var buyInFutureBtn = document.getElementById("buyInFutureBtn");
var profileSharingBtn = document.getElementById("profileSharingBtn");

var cardScanBtn = document.getElementById("cardScanBtn");

buyNowBtn.onclick = function(e) {
// single payment
PayPalMobile.renderSinglePaymentUI(app.createPayment(), app.onSuccesfulPayment, app.onUserCanceled);
};

buyInFutureBtn.onclick = function(e) {
// future payment
PayPalMobile.renderFuturePaymentUI(app.onAuthorizationCallback, app.onUserCanceled);
};

profileSharingBtn.onclick = function(e) {
// profile sharing
PayPalMobile.renderProfileSharingUI(["profile", "email", "phone", "address", "futurepayments", "paypalattributes"], app.onAuthorizationCallback, app.onUserCanceled);
};

cardScanBtn.onclick = function(e) {
// card.io scanning independent of paypal payments.
// This is used for cases where you only need to scan credit cards and not use PayPal as funding option.
CardIO.scan({
"requireExpiry": true,
"requireCVV": false,
"requirePostalCode": false,
"restrictPostalCodeToNumericOnly": true
},
app.onCardIOComplete,
app.onUserCanceled
);
};
},
onPayPalMobileInit : function() {
// must be called
Expand All @@ -188,7 +214,7 @@ Basic Example of the app
console.log(result);
}
};

app.initialize();
```
3. execute `cordova run ios` or `cordova run android` to install and run your sample code.
Expand Down
12 changes: 3 additions & 9 deletions plugin.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,13 @@
<engine name="cordova" version="&gt;=3.0.0" />
</engines>


<js-module src="www/cdv-plugin-paypal-mobile-sdk.js" name="PayPalMobile">
<clobbers target="PayPalMobile" />
</js-module>

<!-- adding card.io cordova plugin dependency -->
<dependency id="card.io.cordova.mobilesdk" version="2.0.1" />

<asset src="www/paypal-mobile-js-helper.js" target="js/paypal-mobile-js-helper.js" />

<!-- ios -->
Expand All @@ -40,10 +42,6 @@
<header-file src="src/ios/PayPalMobile/PayPalProfileSharingViewController.h" />

<source-file src="src/ios/PayPalMobile/libPayPalMobile.a" framework="true" />
<source-file src="src/ios/PayPalMobile/libCardIO.a" framework="true" />
<source-file src="src/ios/PayPalMobile/libopencv_core.a" framework="true" />
<source-file src="src/ios/PayPalMobile/libopencv_imgproc.a" framework="true" />


<framework src="Accelerate.framework" />
<framework src="AudioToolbox.framework" />
Expand All @@ -65,10 +63,6 @@

<framework src="libc++.dylib" />
<framework src="libPayPalMobile.a" />
<framework src="libCardIO.a" />
<framework src="libopencv_core.a" />
<framework src="libopencv_imgproc.a" />

</platform>

<!-- android -->
Expand Down
4 changes: 3 additions & 1 deletion src/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,7 @@ repositories{
}

dependencies {
compile('com.paypal.sdk:paypal-android-sdk:2.14.2')
compile('com.paypal.sdk:paypal-android-sdk:2.14.2') {
exclude group: 'io.card'
}
}
15 changes: 0 additions & 15 deletions src/ios/PayPalMobile/CardIO.h

This file was deleted.

84 changes: 0 additions & 84 deletions src/ios/PayPalMobile/CardIOCreditCardInfo.h

This file was deleted.

18 changes: 0 additions & 18 deletions src/ios/PayPalMobile/CardIODetectionMode.h

This file was deleted.

Loading

0 comments on commit a9195f7

Please sign in to comment.