mirror of
https://github.com/purplecabbage/phonegap-plugins.git
synced 2026-04-24 03:00:11 -04:00
Updated PayPal Plugin for Android to work with Cordova 2.0.0
This commit is contained in:
@@ -1,28 +1,41 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.phonegap.plugin" android:versionCode="1"
|
||||
android:versionName="1.0">
|
||||
|
||||
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||
package="com.example.paypalplugin"
|
||||
android:versionCode="1"
|
||||
android:versionName="1.0" >
|
||||
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-sdk
|
||||
android:minSdkVersion="8"
|
||||
android:targetSdkVersion="15" />
|
||||
|
||||
<application android:debuggable="true" android:icon="@drawable/icon"
|
||||
android:label="@string/app_name">
|
||||
<activity android:configChanges="orientation|keyboardHidden"
|
||||
android:name=".pppactivity" android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.paypal.android.MEP.PayPalActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:configChanges="keyboardHidden|orientation" />
|
||||
|
||||
</application>
|
||||
<uses-sdk android:minSdkVersion="2" />
|
||||
<supports-screens
|
||||
android:largeScreens="true"
|
||||
android:normalScreens="true"
|
||||
android:smallScreens="true"
|
||||
android:resizeable="true"
|
||||
android:anyDensity="true" />
|
||||
<uses-permission android:name="android.permission.READ_PHONE_STATE" />
|
||||
<uses-permission android:name="android.permission.INTERNET" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
|
||||
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
|
||||
|
||||
</manifest>
|
||||
<application
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
android:theme="@style/AppTheme" >
|
||||
<activity
|
||||
android:configChanges="orientation|keyboardHidden|keyboard|screenSize|locale"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/title_activity_main" >
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN" />
|
||||
<category android:name="android.intent.category.LAUNCHER" />
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name="com.paypal.android.MEP.PayPalActivity"
|
||||
android:theme="@android:style/Theme.Translucent.NoTitleBar"
|
||||
android:configChanges="keyboardHidden|orientation" />
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
@@ -3,6 +3,7 @@ The MIT License
|
||||
|
||||
Copyright (C) 2011 Mobile Developer Solutions
|
||||
Copyright (C) 2011, Appception, Inc.
|
||||
Copyright (C) 2012, Bucka IT, Tomaz Kregar s.p.
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
# PhoneGap PayPal-Plugin #
|
||||
by Paul Beusterien, Mobile Developer Solutions and Carl Stehle, Appception Inc.
|
||||
by Paul Beusterien, Mobile Developer Solutions, Carl Stehle, Appception Inc. and Tomaz Kregar, Bucka IT
|
||||
|
||||
|
||||
## Adding the Plugin to your project ##
|
||||
|
||||
Using this plugin requires Android PhoneGap and the PayPal Mobile Payments Library. The PayPal Mobile Payments Library can be downloaded [here](https://www.x.com/community/ppx/xspaces/mobile/mep).
|
||||
Using this plugin requires Android Cordova (PhoneGap) and the PayPal Mobile Payments Library. The PayPal Mobile Payments Library can be downloaded [here](https://www.x.com/community/ppx/xspaces/mobile/mep).
|
||||
|
||||
1. Create an Android PhoneGap project. Details at http://www.mobiledevelopersolutions.com/home/start
|
||||
1. Create an Android Cordova project. Details at http://docs.phonegap.com/en/2.0.0/guide_getting-started_android_index.md.html
|
||||
2. Put PayPal_MPL.jar into your project's libs directory and add it to the build path. In Eclipse, right click on PayPal_MPL.jar and select Add to Build Path.
|
||||
3. Copy assets/www/ files into your project's assets/www/ directory
|
||||
4. Copy src/com/phonegap/plugin/ files into your project's src/com/phonegap/plugin/ directory
|
||||
5. Make sure your AndroidManifest.xml includes a superset of the permissions shown in the reference AndroidManifest.xml
|
||||
6. Add the com.paypal.android.MEP.PayPalActivity as shown in the reference AndroidManifest.xml
|
||||
7. Make sure the phonegap.{version}.js filename in index.html matches the filename in your www directory.
|
||||
8. Deploy and test the app. The default environment is ENV_NONE.
|
||||
7. Include the plugin registration in /res/xml/config.xml as shown in the reference config.xml
|
||||
8. Make sure the cordova.{version}.js filename in index.html matches the filename in your www directory.
|
||||
9. Deploy and test the app. The default environment is ENV_NONE.
|
||||
|
||||
## Using the PayPal Sandbox ##
|
||||
|
||||
@@ -24,7 +25,10 @@ Using this plugin requires Android PhoneGap and the PayPal Mobile Payments Libra
|
||||
|
||||
## RELEASE NOTES ##
|
||||
|
||||
### 201100618 ###
|
||||
### 20120829 ###
|
||||
* Added suppport for Cordova 2.0.0
|
||||
|
||||
### 20110618 ###
|
||||
* Initial release
|
||||
* By default the PayPalPlugin-Host runs in ENV_NONE (offline) with a dummy PayPal ID. Change to ENV_SANDBOX or ENV_LIVE
|
||||
* Only tested with ENV_NONE and ENV_SANDBOX
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
<html>
|
||||
<head>
|
||||
<meta name="viewport" content="width=320; user-scalable=no" />
|
||||
<script type='text/javascript' src='phonegap.0.9.5.js'></script>
|
||||
<script type='text/javascript' charset='utf-8' src='cordova-2.0.0.js'></script>
|
||||
<script type='text/javascript' src='paypal.js'></script>
|
||||
<script type='text/javascript' src='demo.js'></script>
|
||||
</head>
|
||||
|
||||
@@ -2,13 +2,13 @@
|
||||
*
|
||||
* Copyright (C) 2011, Appception, Inc.. All Rights Reserved.
|
||||
* Copyright (C) 2011, Mobile Developer Solutions All Rights Reserved.
|
||||
* Copyright (C) 2012, Bucka IT, Tomaz Kregar s.p. All Rights Reserved.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @return Instance of PayPal
|
||||
*/
|
||||
var PayPal = function() {
|
||||
};
|
||||
var PayPal = function() {};
|
||||
|
||||
/**
|
||||
* @param directory
|
||||
@@ -29,7 +29,7 @@ var fail = function(e) {
|
||||
PayPal.prototype.invoke = function(callee, arg, successFunction) {
|
||||
|
||||
var succ = successFunction ? successFunction : genericSuccess;
|
||||
return PhoneGap.exec(succ,
|
||||
return cordova.exec(succ,
|
||||
fail,
|
||||
'PayPalPlugin', // Telling PhoneGap that we want to run "PayPal Plugin"
|
||||
callee, // Telling the plugin, which action we want to perform
|
||||
@@ -38,34 +38,40 @@ PayPal.prototype.invoke = function(callee, arg, successFunction) {
|
||||
|
||||
/**
|
||||
* <ul>
|
||||
* <li>Register the Directory Listing Javascript plugin.</li>
|
||||
* <li>Also register native call which will be called when this plugin runs</li>
|
||||
* <li>Register native call which will be called when this plugin runs</li>
|
||||
* <li>Plugin must be registered in /res/xml/config.xml : <plugin name="PayPalPlugin" value="com.phonegap.plugin.PayPalPlugin"/></li>
|
||||
* </ul>
|
||||
*/
|
||||
PhoneGap.addConstructor(function() {
|
||||
// Register the javascript plugin with PhoneGap
|
||||
PhoneGap.addPlugin('PayPal', new PayPal());
|
||||
|
||||
// Register the native class of plugin with PhoneGap
|
||||
PluginManager.addService("PayPalPlugin", "com.phonegap.plugin.PayPalPlugin");
|
||||
});
|
||||
if(cordova.addPlugin) { //versions before 2.0.0
|
||||
cordova.addConstructor(function() {
|
||||
// Register the javascript plugin with PhoneGap
|
||||
cordova.addPlugin('PayPal', new PayPal());
|
||||
});
|
||||
} else {
|
||||
// Creating the native object of plugin
|
||||
if(!window.plugins)
|
||||
window.plugins = {};
|
||||
if (!window.plugins.PayPal)
|
||||
window.plugins.PayPal = new PayPal();
|
||||
}
|
||||
|
||||
var mpl = {
|
||||
construct : function(str) {
|
||||
window.plugins.PayPal.invoke('construct', str);
|
||||
},
|
||||
prepare : function(ptype) {
|
||||
window.plugins.PayPal.invoke('prepare', ptype);
|
||||
},
|
||||
getStatus : function() {
|
||||
return window.plugins.PayPal.invoke('getStatus', null, getStatusCallback);
|
||||
},
|
||||
setPaymentInfo : function(arg) {
|
||||
window.plugins.PayPal.invoke('setPaymentInfo', arg);
|
||||
},
|
||||
payButton : function(btype) {
|
||||
window.plugins.PayPal.invoke('pay', btype);
|
||||
}
|
||||
construct : function(str) {
|
||||
window.plugins.PayPal.invoke('construct', str);
|
||||
},
|
||||
prepare : function(ptype) {
|
||||
window.plugins.PayPal.invoke('prepare', ptype);
|
||||
},
|
||||
getStatus : function() {
|
||||
return window.plugins.PayPal.invoke('getStatus', null, getStatusCallback);
|
||||
},
|
||||
setPaymentInfo : function(arg) {
|
||||
window.plugins.PayPal.invoke('setPaymentInfo', arg);
|
||||
},
|
||||
payButton : function(btype) {
|
||||
window.plugins.PayPal.invoke('pay', btype);
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
|
||||
56
Android/PayPalPlugin/res/xml/config.xml
Normal file
56
Android/PayPalPlugin/res/xml/config.xml
Normal file
@@ -0,0 +1,56 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!--
|
||||
Licensed to the Apache Software Foundation (ASF) under one
|
||||
or more contributor license agreements. See the NOTICE file
|
||||
distributed with this work for additional information
|
||||
regarding copyright ownership. The ASF licenses this file
|
||||
to you under the Apache License, Version 2.0 (the
|
||||
"License"); you may not use this file except in compliance
|
||||
with the License. You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing,
|
||||
software distributed under the License is distributed on an
|
||||
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
KIND, either express or implied. See the License for the
|
||||
specific language governing permissions and limitations
|
||||
under the License.
|
||||
-->
|
||||
<cordova>
|
||||
<!--
|
||||
access elements control the Android whitelist.
|
||||
Domains are assumed blocked unless set otherwise
|
||||
-->
|
||||
|
||||
<access origin="http://127.0.0.1*"/> <!-- allow local pages -->
|
||||
|
||||
<!-- <access origin="https://example.com" /> allow any secure requests to example.com -->
|
||||
<!-- <access origin="https://example.com" subdomains="true" /> such as above, but including subdomains, such as www -->
|
||||
<!-- <access origin=".*"/> Allow all domains, suggested development use only -->
|
||||
|
||||
<log level="DEBUG"/>
|
||||
<preference name="useBrowserHistory" value="false" />
|
||||
<plugins>
|
||||
<plugin name="App" value="org.apache.cordova.App"/>
|
||||
<plugin name="Geolocation" value="org.apache.cordova.GeoBroker"/>
|
||||
<plugin name="Device" value="org.apache.cordova.Device"/>
|
||||
<plugin name="Accelerometer" value="org.apache.cordova.AccelListener"/>
|
||||
<plugin name="Compass" value="org.apache.cordova.CompassListener"/>
|
||||
<plugin name="Media" value="org.apache.cordova.AudioHandler"/>
|
||||
<plugin name="Camera" value="org.apache.cordova.CameraLauncher"/>
|
||||
<plugin name="Contacts" value="org.apache.cordova.ContactManager" />
|
||||
<plugin name="File" value="org.apache.cordova.FileUtils"/>
|
||||
<plugin name="NetworkStatus" value="org.apache.cordova.NetworkManager"/>
|
||||
<plugin name="Notification" value="org.apache.cordova.Notification"/>
|
||||
<plugin name="Storage" value="org.apache.cordova.Storage"/>
|
||||
<plugin name="Temperature" value="org.apache.cordova.TempListener"/>
|
||||
<plugin name="FileTransfer" value="org.apache.cordova.FileTransfer"/>
|
||||
<plugin name="Capture" value="org.apache.cordova.Capture"/>
|
||||
<plugin name="Battery" value="org.apache.cordova.BatteryListener"/>
|
||||
<plugin name="SplashScreen" value="org.apache.cordova.SplashScreen"/>
|
||||
<plugin name="MECLPayPalPlugin" value="com.phonegap.plugins.paypal.MECLPayPalPlugin"/>
|
||||
<plugin name="PayPalPlugin" value="com.phonegap.plugin.PayPalPlugin"/>
|
||||
</plugins>
|
||||
</cordova>
|
||||
|
||||
Reference in New Issue
Block a user