Giter Site home page Giter Site logo

paypal-cordova-plugin's Introduction

Important: PayPal Mobile SDKs are Deprecated. The APIs powering them will remain operational long enough for merchants to migrate, but the SDKs themselves will no longer be updated. Please use Braintree Direct in supported countries. In other countries, use Express Checkout and choose the Braintree SDK integration option.

PayPal SDK Cordova/Phonegap Plugin

Disclaimer

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.

Updating from earlier versions < 3.0.0

Please remove your local copies of the native sdks, the Plugin now includes sdks distributions as part of the source code to make integration and version parity easier to maintain.

Installation

The PayPal SDK Cordova/Phonegap Plugin adds support for the PayPal SDK on iOS and Android platforms. It uses the native PayPal Mobile SDK libraries, which you must also download. Cordova plugin management will set up all the required capabilities/frameworks for the project. The only bit left for you to do is to add necessary files, as described below.

  1. Follow the official Cordova documentation to install command line tools or Phonegap.
  2. Create project, add plugin and platforms:
   $ cordova create MyShop com.mycompany.myshop "MyShop"
   $ cd MyShop
   # using cordova repository (many thanks to @Ramneekhanda for helping with this)
   $ cordova plugin add com.paypal.cordova.mobilesdk
   # or you can also install directly from github
   #$ cordova plugin add https://github.com/paypal/PayPal-Cordova-Plugin
   $ cordova platform add ios
   $ cordova platform add android
   # optional for console.log etc
   $ cordova plugin add org.apache.cordova.console
  1. Follow Your app integration section below.
  2. Run cordova build to build the projects for all of the platforms.

Phonegap Build

If you using phonegap build just add <gap:plugin name="com.paypal.cordova.mobilesdk" source="npm" /> to your config.xml. To specify a particular version use <gap:plugin name="com.paypal.cordova.mobilesdk" version="3.1.8" />. For more details check http://docs.build.phonegap.com/en_US/configuring_plugins.md.html#Plugins

Your app integration

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
   <script type="text/javascript" src="js/paypal-mobile-js-helper.js"></script>

to your MyShop/www/index.html file, after the cordova.js import.

Documentation

  • All calls to PayPalMobile are asynchronous.
  • See cdv-plugin-paypal-mobile-sdk.js and paypal-mobile-js-helper.js for details and functionality available.
  • For complete documentation regarding the PayPal SDK Cordova Plugin, please refer to the documentation for the underlying PayPal Mobile SDK.
  • 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. The implementation is shown below in the samples.

Basic Example of the app

  1. A complete example code can be checked from here https://github.com/romk1n/MyCordovaShop

  2. In MyShop/www/index.html add the following to lines after <p class="event received">Device is Ready</p>:

       <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>
  3. Replace MyShop/www/js/index.js with the following code:

    /*
     * 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.
     */
    var app = {
        // Application Constructor
        initialize: function() {
            this.bindEvents();
        },
        // Bind Event Listeners
        //
        // Bind any events that are required on startup. Common events are:
        // 'load', 'deviceready', 'offline', and 'online'.
        bindEvents: function() {
            document.addEventListener('deviceready', this.onDeviceReady, false);
        },
        // deviceready Event Handler
        //
        // The scope of 'this' is the event. In order to call the 'receivedEvent'
        // function, we must explicity call 'app.receivedEvent(...);'
        onDeviceReady: function() {
            app.receivedEvent('deviceready');
        },
        // Update DOM on a Received Event
        receivedEvent: function(id) {
            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();
        },
        initPaymentUI : function () {
          var clientIDs = {
            "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
            "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));
        },
        createPayment : function () {
          // for simplicity use predefined amount
          // optional payment details for more information check [helper js file](https://github.com/paypal/PayPal-Cordova-Plugin/blob/master/www/paypal-mobile-js-helper.js)
          var paymentDetails = new PayPalPaymentDetails("50.00", "0.00", "0.00");
          var payment = new PayPalPayment("50.00", "USD", "Awesome Sauce", "Sale", paymentDetails);
          return payment;
        },
        configuration : function () {
          // for more options see `paypal-mobile-js-helper.js`
          var config = new PayPalConfiguration({merchantName: "My test shop", merchantPrivacyPolicyURL: "https://mytestshop.com/policy", merchantUserAgreementURL: "https://mytestshop.com/agreement"});
          return config;
        },
        onPrepareRender : function() {
          // buttons defined in index.html
          //  <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
          // use PayPalEnvironmentNoNetwork mode to get look and feel of the flow
          PayPalMobile.prepareToRender("PayPalEnvironmentSandbox", app.configuration(), app.onPrepareRender);
        },
        onUserCanceled : function(result) {
          console.log(result);
        }
    };
    
    app.initialize();
  4. execute cordova run ios or cordova run android to install and run your sample code.

License

Code released under BSD LICENSE

Contributions

Pull requests and new issues are welcome. See CONTRIBUTING.md for details.

paypal-cordova-plugin's People

Contributors

avidas avatar bluk avatar braebot avatar burnto avatar guysopher avatar igor-lkm avatar jaypatel512 avatar linagee avatar mattjacunski avatar rknell avatar romk1n avatar sankarbhavanib avatar zp1ke avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

paypal-cordova-plugin's Issues

Basic Example Doesn't Work

Hi,
I have followed the instructions for the basic example.
However, when it goes in the app.initPaymentUI() method, it just stops at PayPalMobile.init.
I have error message saying that there is no init function in PayPalMobile and I have even tried changing the PayPalMobile to PayPalMobile.prototype with reference to cdv-plugin-paypal-mobile-sdk.js but it still doesn't work.
Error like "paypal cordova module is not defined" appears as well.
(../cdv-plugin-paypal-mobile-sdk.js: Line 126 : Uncaught ReferenceError: module is not defined)

Is the plugin still working on both Android and iOS as of date?

Currently using: Eclipse, Cordova 3.6.3-0.2.13, Android

Cannot find symbol Version

Hello,
I've downloaded and installed this plugin on my cordova project.
When I try to build the project I get this error:

-compile:
    [javac] Compiling 4 source files to /home/guy/Projects/TreatsForLife/mobile/platforms/android/ant-build/classes
    [javac] /home/guy/Projects/TreatsForLife/mobile/platforms/android/src/com/paypal/cordova/sdk/PayPalMobileCordovaPlugin.java:67: error: cannot find symbol
    [javac]         this.callbackContext.success(Version.PRODUCT_VERSION);
    [javac]                                      ^
    [javac]   symbol:   variable Version
    [javac]   location: class PayPalMobileCordovaPlugin
    [javac] 1 error

I've did some search and found this line in the plugin.xml file
<engines> <engine name="cordova" version="&gt;=3.0.0" /> </engines>

I changed it to what I think is supposed to be there:
<engines> <engine name="cordova" version=">=3.0.0" /> </engines>

But still, the same error occurs.

Does someone know how to fix this?

Is this plugin compatible with Phonegap 3+ ?

Is this plugin compatible with Phonegap 3.0 and later releases? I tried it, but it is not generating cdv-plugin-paypal-mobile-sdk.js and cdv-plugin-paypal-mobile-sdk.js files.

paypal payment plugin with cordova on android devices

I'm trying to use paypal payment in my cordova application. For that I used this Paypal cordova plugin exemple :https://github.com/paypal/PayPal-Cordova-Plugin. I followed all the instructions mentioned there, but I get these errors:

01-13 05:18:06.650: E/PluginManager(2112): Uncaught exception from plugin
01-13 05:18:06.650: E/PluginManager(2112): android.content.ActivityNotFoundException: Unable to find explicit activity class {com.example.hello/com.paypal.android.sdk.payments.PaymentActivity}; have you declared this activity in your AndroidManifest.xml?
01-13 05:18:06.650: E/PluginManager(2112): at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:1628)
01-13 05:18:06.650: E/PluginManager(2112): at android.app.Instrumentation.execStartActivity(Instrumentation.java:1424)
01-13 05:18:06.650: E/PluginManager(2112): at android.app.Activity.startActivityForResult(Activity.java:3424)
01-13 05:18:06.650: E/PluginManager(2112): at android.app.Activity.startActivityForResult(Activity.java:3385)
01-13 05:18:06.650: E/PluginManager(2112): at org.apache.cordova.CordovaActivity.startActivityForResult(CordovaActivity.java:748)
01-13 05:18:06.650: E/PluginManager(2112): at com.paypal.cordova.sdk.PayPalMobileCordovaPlugin.renderSinglePaymentUI(PayPalMobileCordovaPlugin.java:226)
01-13 05:18:06.650: E/PluginManager(2112): at com.paypal.cordova.sdk.PayPalMobileCordovaPlugin.execute(PayPalMobileCordovaPlugin.java:54)
01-13 05:18:06.650: E/PluginManager(2112): at org.apache.cordova.CordovaPlugin.execute(CordovaPlugin.java:84)
01-13 05:18:06.650: E/PluginManager(2112): at org.apache.cordova.PluginManager.exec(PluginManager.java:147)
01-13 05:18:06.650: E/PluginManager(2112): at org.apache.cordova.CordovaBridge.jsExec(CordovaBridge.java:59)
01-13 05:18:06.650: E/PluginManager(2112): at org.apache.cordova.ExposedJsApi.exec(ExposedJsApi.java:40)
01-13 05:18:06.650: E/PluginManager(2112): at com.android.org.chromium.base.SystemMessageHandler.nativeDoRunLoopOnce(Native Method)
01-13 05:18:06.650: E/PluginManager(2112): at com.android.org.chromium.base.SystemMessageHandler.handleMessage(SystemMessageHandler.java:27)
01-13 05:18:06.650: E/PluginManager(2112): at android.os.Handler.dispatchMessage(Handler.java:102)
01-13 05:18:06.650: E/PluginManager(2112): at android.os.Looper.loop(Looper.java:136)
01-13 05:18:06.650: E/PluginManager(2112): at android.os.HandlerThread.run(HandlerThread.java:61)

THe same code works on ios devices. On android platforms when I click on the buy now button it crashed showing the above error messages.
Do you have any idea about this strange behaviour?

Production Vulnerability

I ran the following to initialize PayPalMobile (note, there is no production client id):

var clientIDs = {
    "PayPalEnvironmentProduction": "123",
    "PayPalEnvironmentSandbox": "MySandboxClientId"
};
PayPalMobile.init(clientIDs,function(){
    var config = new PayPalConfiguration({merchantName: "Test", merchantPrivacyPolicyURL: "https://test.com/policy", merchantUserAgreementURL: "https://test.com/agreement"});
    PayPalMobile.prepareToRender("PayPalEnvironmentProduction", config, function(){
    });
});

and then ran

var payment = new PayPalPayment("1.00", "USD", "Donation");
PayPalMobile.renderSinglePaymentUI(payment, completionCallback, cancelCallback);

and used my credit card and it turns out my card was actually charged to some random store and shows up on my bank history as "KINDAFOREVER 818-632-4501 CA".

There may be some kind of issue in how production client ids are used if using such a short production client id to test results in a random store creating an actual charge.

Issues with payment using sandbox. (debug_id: 2579eb0870184 )

I have did a round of testing using PayPalEnvironmentNoNetwork and moved to trying PayPalEnvironmentSandbox.

So I realised I can only get a UK business account to Pro, although I am in Singapore and hope that does not happen when I go live.

Now after putting in the Client ID for sandbox and leaving "PayPalEnvironmentProduction": "production_client_id" as it is.
After pressing "Pay with Paypal" and logging in, I encountered the error popup: "There was a problem processing your payment. Please try again.". No matter how many times I press "Try Again", it doesnt go through.

I have been wrecking my brain to solve this but still unable to. Hope I can get some help on this.
Do let me know if you need anymore details. Thank you.

screenshot_2014-12-16-14-03-48

JSON error

Whenever I tried to launch the paypal plugin with renderSinglePaymentUI, it kept calling the failure callback with "JSON error" with nothing in the logcat logs.

I ran across this error and tore my hair out trying to figure it out. In the end I went thought the commits and saw that you guys added the invoice number in some commits: cfbdd31, 84a6788, 9b798f8, eb0b49d

I didn't change my javascript code so I couldn't figure out why it wasn't working. Turns out if I just add any invoice number it starts working.

payment.invoiceNumber = '12';

Probably need to make it non-mandatory.

Cheers

Service state invalid. Did you start the PayPalService?

I have tried https://github.com/paypal/paypal-cordova-plugin
using cli but when i click on buy now its give me error like

here is my js code

initPaymentUI : function () {
var clientIDs = {
// "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
"PayPalEnvironmentSandbox": "ASnmwxCoYqQfAIyigiMBaQGxpeZwEV1PGXqYElbYe92pbXHj68nqDtywthxx" //hre i have used my cliend id
};
PayPalMobile.init(clientIDs, app.onPayPalMobileInit);

},

ERROR

04-02 16:49:24.603: E/PaymentActivity(30153): Service state invalid. Did you start the PayPalService?

04-02 16:49:40.423: D/CordovaLog(30153): file:///android_asset/www/js/index.js: Line 102 : An invalid Payment was submitted. Please see the docs.

Please help me

Donation

Does it support donation button? Could it be managed so the user could cancel the donation request and go back? This is the problem I'm actually facing with using the

solution (i've tried to make an ajax post and to make target='someIframeName')

Push notification

Hi Roman,
Does this plugin use apple push notification

Regards,
Suhas

onSuccesfulPayment callback not called for Android

The callback onSuccesfulPayment does not get called in case of Android. It is working fine for iOS, but fails to get called for Android.
I am using the sample index.js provided in Basic Example of the app. Is this an issue or do we need to do something extra in order to make it work for Android.
Following is the snippet of js::
onSuccesfulPayment : function(payment) {
//alert does not get called even when payment is complete,
alert("Payment Successful for:" + JSON.stringify(payment, null, 4));
console.log("payment success: " + JSON.stringify(payment, null, 4));
},
...
PayPalMobile.renderSinglePaymentUI(app.createPayment(), app.onSuccesfulPayment, app.onUserCanceled);
...
Note:- I am using Sandbox mode and verified that the payment is being made proper in Android as well.

IOS crashes with EXC_BAD_ACCESS

I am having problems rendering the Single payment UI on IOS (iphone 5). Whenever i click on the buy with paypal button this happens (app closed if not attached to debugger):

EXC_BAD_ACCESS (code=1, address=0x4)

screen shot 2014-07-28 at 5 02 31 pm
screen shot 2014-07-28 at 5 02 50 pm

With the same cordova code, it runs perfectly on android.

i am building with:
Cordova 3.5.0-0.2.4
IonicFrameworh (with angularjs)

any workaround for this?

What is expected in clientIDs

Hi Roman,
what is expected in client ids, everytime I got success message after doing payment on sandbox environment however with same transaction id, is this is hardcoded?

Regards,
Suhas

Failed JSON Plugin

Hi Im having issues with the implementation of this plugin.

I am getting a message saying

2015-03-02 14:47:37.926 myapp[37783:80b] CDVPlugin class PayPalMobileCordovaPlugin (pluginName: PayPalMobile) does not exist.
2015-03-02 14:47:37.927 myapp[37783:80b] ERROR: Plugin 'PayPalMobile' not found, or is not a CDVPlugin. Check your plugin mapping in config.xml.
2015-03-02 14:47:37.927 myapp[37783:80b] -[CDVCommandQueue executePending] [Line 158] FAILED pluginJSON = [
"PayPalMobile891313998",
"PayPalMobile",
"init",
[
{
"PayPalEnvironmentProduction" : "YOUR_PRODUCTION_CLIENT_ID",
"PayPalEnvironmentSandbox" : "AE4nT93xH2RxRYviN6q1JC6-TYnzAy-tiVtvcQif59w8sLVr75ine1qh"
}
]
]

I have tried to add the project via NPM and manually and have had no luck.
I have also added the plugin to my config.xml which hasn't mad any difference.

Has anyone had the same error that may have any idea whats wrong

Thanks

Card.io app token?

Hi there,
I'm using your plugin to accept paypal payments through my app, but my app can't scan any of the credit cards that i have.

By looking over the internet i've found that one app token must be used in card.io scans, so i'm wondering if we must provide such token somewhere in your plugin or if its not necessary.
If yes, how can i provide it? I've not found any reference in any of the .js files of your plugin.

Thanks

PayPalEnvironmentSandbox not working

I am trying to change the

PayPalEnvironmentNoNetwork

in

onPayPalMobileInit : function() {
// must be called
// use PayPalEnvironmentNoNetwork mode to get look and feel of the flow
PayPalMobile.prepareToRender("PayPalEnvironmentSandbox", app.configuration(), app.onPrepareRender);
},

But the app stays in "Mock Data" please any help would be apreciated

Integrating the Plugin in Intel XDK

I followed all instructions and made a Cordova project containing both platform and this plugin in plugin directory. Then I am trying to import this plugin in my Intel XDK project but on build getting "Build not successful error" . And when I remove this plugin from my project ,project gets build. Any help regarding this issue?

Unable to run in android

Hi,
I tried to implement the solution to my project, it works fine on the iOS but I will encounter a runtime error when executing it in android. and I've screenshot the error message.

Any help will be appreciated!
Thanks!
screen shot 2015-02-25 at 3 55 16 pm

Update:
I think I called the function at the wrong place, please close the issue.
Thanks :)

Invoice data support

Hi, Could you please let me know how to tweak singlepaymentUI function so that I can send invoice data to paypal. As per the example given, there is single transaction only however in real world there can be n number of items added to the cart which needs to be paid

Regards,
Suhas

After starting android app logCat return ERROR unknown type 0x238e0a (glSizeof,73)

when i start the app logCat return me infinit times this

10-15 20:34:18.325: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:34:18.385: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:34:18.773: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:34:18.821: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:34:18.861: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:34:18.897: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)

and when i simulate a payment

10-15 20:55:39.713: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:39.741: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:39.781: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:39.861: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:39.921: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:39.961: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:39.997: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:40.045: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:40.081: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:40.149: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:41.005: D/dalvikvm(1255): GC_FOR_ALLOC freed 1158K, 21% free 10644K/13316K, paused 4ms, total 4ms
10-15 20:55:41.061: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:41.077: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:43.509: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:44.069: D/CordovaActivity(1255): Incoming Result
10-15 20:55:44.069: D/CordovaActivity(1255): Request code = 1
10-15 20:55:44.069: D/CordovaActivity(1255): We have a callback to send this result to
10-15 20:55:44.073: D/CordovaActivity(1255): Resuming the App
10-15 20:55:44.081: W/EGL_genymotion(1255): eglSurfaceAttrib not implemented
10-15 20:55:44.089: D/CordovaLog(1255): file:///android_asset/www/js/index.js: Line 61 : payment success: {
10-15 20:55:44.089: D/CordovaLog(1255): "response": {
10-15 20:55:44.089: D/CordovaLog(1255): "state": "approved",
10-15 20:55:44.089: D/CordovaLog(1255): "id": "PAY-6PU626847B294842SKPEWXHY",
10-15 20:55:44.089: D/CordovaLog(1255): "create_time": "2014-07-18T18:46:55Z",
10-15 20:55:44.089: D/CordovaLog(1255): "intent": "sale"
10-15 20:55:44.089: D/CordovaLog(1255): },
10-15 20:55:44.089: D/CordovaLog(1255): "client": {
10-15 20:55:44.089: D/CordovaLog(1255): "platform": "Android",
10-15 20:55:44.089: D/CordovaLog(1255): "paypal_sdk_version": "2.5.6",
10-15 20:55:44.089: D/CordovaLog(1255): "product_name": "PayPal-Android-SDK",
10-15 20:55:44.089: D/CordovaLog(1255): "environment": "mock"
10-15 20:55:44.089: D/CordovaLog(1255): },
10-15 20:55:44.089: D/CordovaLog(1255): "response_type": "payment"
10-15 20:55:44.089: D/CordovaLog(1255): }
10-15 20:55:44.089: I/chromium(1255): [INFO:CONSOLE(61)] "payment success: {
10-15 20:55:44.089: I/chromium(1255): "response": {
10-15 20:55:44.089: I/chromium(1255): "state": "approved",
10-15 20:55:44.089: I/chromium(1255): "id": "PAY-6PU626847B294842SKPEWXHY",
10-15 20:55:44.089: I/chromium(1255): "create_time": "2014-07-18T18:46:55Z",
10-15 20:55:44.089: I/chromium(1255): "intent": "sale"
10-15 20:55:44.089: I/chromium(1255): },
10-15 20:55:44.089: I/chromium(1255): "client": {
10-15 20:55:44.089: I/chromium(1255): "platform": "Android",
10-15 20:55:44.089: I/chromium(1255): "paypal_sdk_version": "2.5.6",
10-15 20:55:44.089: I/chromium(1255): "product_name": "PayPal-Android-SDK",
10-15 20:55:44.089: I/chromium(1255): "environment": "mock"
10-15 20:55:44.089: I/chromium(1255): },
10-15 20:55:44.089: I/chromium(1255): "response_type": "payment"
10-15 20:55:44.089: I/chromium(1255): }", source: file:///android_asset/www/js/index.js (61)
10-15 20:55:44.133: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.529: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.577: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.613: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.657: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.689: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.733: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)
10-15 20:55:44.769: E/eglCodecCommon(1255): **** ERROR unknown type 0x238e0a (glSizeof,73)

Windows Phone Integration

Will this plugin support Windows phone?

I'm using this plugin in a Phonegap App that needs to be multi-platform (Android, iOS and Windows Phone).

Play store and App store - Is there any issue?

There are lots of articles on third party payment related issues with the Android and iOS apps. Is there any requirement or consequence for/of using this plugin? Can I safely assume that the app will not be rejected due to this plugin by those stores. Does this comply all requirements of Play and Apple stores?

I am sorry if I sound stupid or details regarding this is written already somewhere - but I just want to confirm the above before I proceed any further.

iPhone 6 Plus UI Kit Crash

Hi,

I tried this plugin on iPhone 4S, 5S & iPhone 6 Plus. On 4S & 5S it is work well. But on iPhone 6 Plus there is an error. I get this error when renderSinglePaymentUI works.

Console error;
error-paypal
2015-02-09 13:59:13.919 testApp[208:13303] bool _WebTryThreadLock(bool), 0x17420c390: Tried to obtain the web lock from a thread other than the main thread or the web thread. This may be a result of calling to UIKit from a secondary thread. Crashing now...
1 0x18fcaedac WebThreadLock
2 0x186e06130
3 0x10007e270 -[CDVViewController shouldAutorotateToInterfaceOrientation:]
4 0x10006a32c -[MainViewController shouldAutorotateToInterfaceOrientation:]
5 0x10007e38c -[CDVViewController supportedInterfaceOrientations]
6 0x186aa4d38
7 0x186aa48f4
8 0x18712226c
9 0x186d2c900
10 0x186d45ba4
11 0x186d46e3c
12 0x186d48d34
13 0x186b1e3d4
14 0x10006df7c __51-[PayPalMobileCordovaPlugin renderSinglePaymentUI:]_block_invoke
15 0x100868e30 _dispatch_call_block_and_release
16 0x100868df0 _dispatch_client_callout
17 0x1008759a0 _dispatch_root_queue_drain
18 0x100876f18 _dispatch_worker_thread3
19 0x1931f52e4 _pthread_wqthread
20 0x1931f4fa8 start_wqthread
(lldb)

Error highlight In CDVViewController.m;
NSString* res = [webView stringByEvaluatingJavaScriptFromString:jsCall];

How can I fix that?

Error image attached.

paypal-mobile-js-helper.js

@romk1n I update to the latest changes, when I run cordova build, paypal-mobile-js-helper.js is not copy to the js folder automatically. I manually copy it.

Duplicate Transaction

I have had a few users complaining about a "Duplicate transaction" error. Does this have to do with the new invoice # that was added? And does this invoice # have to be unique? Right now I'm using their user number for it. Have not been able to duplicate the bug myself.

How to change ClientId and merchant configuration at runtime

Hi!

I'm developing an application that requires to pay to different merchants depending on the item, but:

  • ClientId information is sent to PayPalMobile.init.
  • Merchant information is sent to PayPalMobile.prepareToRender call.
  • PayPalMobile.init should be called on the deviceReady event according to your examples.

How can I change/set this later at runtime?

I've tested setting it by running initialization process every time instead of doing it just on DeviceReady and it seems to be working fine, but I don't know if this is correct of there is something missing in the plugin.

Thank you in advance.

Unable to build application

paypal

I follow the steps mentioned below:

Download the PayPal Android SDK.
Follow the official Cordova documentation to install command line tools and create a project.
Run cordova plugin add https://github.com/paypal/PayPal-Cordova-Plugin.
Run cordova platform add ios or/and cordova platform add android.
For iOS, open the Xcode project in the platforms/ios folder and add the PayPalMobile folder from step 1. Make sure to read https://github.com/paypal/PayPal-iOS-SDK#add-the-sdk-to-your-project in case of linking errors
For Android, copy the libs folder from step 2 to the libs folder in platforms/android.
Run cordova build to build the projects for all of the platforms.

But i am unable to build the application. I have also attached the screenshots for the same.Can anyone please tell me what must be going wrong? Alteast can any one let me know what are the possible reasons for this to happen, so that I can check each of the points on code level.

Integration issue

Hi Everyone,I done the payment integration in cordova (3.5) but it is not working .I did not get any transaction in sendbox .And also it is call success but showing payment as undefined.

Can any body have an idea what the problem in that.

Many Thanks

Suddenly stopped working

Hello! Thanks for the great plugin!

So... yesterday everything worked.

With PayPalEnvrionmentNoNetwork - I get the flow
With PayPalEnvironmentSandbox payments were successfully.

But today morning (nothing was changed) it stopped working. (version on phone was not updated. It was yesterday's version, which worked.

With PayPalEnvrionmentNoNetwork - nothing appears.
With PayPalEnvironmentSandbox - interface appears, login worked (if login wrong we get the error). Next screen works too, but when we send payment we goes to login screen again without error.

Then I've created new app from example in this repo - the same problems.

Thanks you for the help!

Direct credit card payment not working in sandbox

Just a heads up, Direct Credit Card payments don't work in Sandbox mode. It says

"One moment..."

For about 30 seconds, then I'm guessing it times out. You get an alert which says

"System error, Please try again later."

I ended up just testing live, and refunding the payments.

Possible to have a few merchant to pay?

Hi,

Im trying to direct payments to different merchants.

Trying to direct to company1:
What I did over here is, I did an init of the payment, which includes specifying the App ID and Ssandbox ID and I did a rendering of Single Payment. Everything seems to be working fine.

Trying to direct to company2:
so after making payment, Im trying to direct the payment to another company, so I did an init, which specify the app and sandbox ID of another company, and I render the single payment screen.

Both payment seems to be successful, but the result is that both payments are directed to company 1, instead of 1 payment for company 1 and another for company 2.

Is that the right way to do it? or is there anyway that I can recreate PaypalMobile object then I initialize a new payment?

Thank you ๐Ÿ‘

Unable to callback upon successful payment and payment cancellation in Android

Hi,

I've adapted the code from the sample. However when I tried to run it on android, upon successful payment or payment cancellation, it does not callback to the respective functions. Ive done the init in another class upon clicking a button.

I've attached my code for reference

var paymentObj = {
    initPaymentUI: function() {
        var clientIDs = {
            "PayPalEnvironmentProduction": "MyProductionID",
            "PayPalEnvironmentSandbox": "MySandboxID"
        };
        PayPalMobile.init(clientIDs, paymentObj.onPayPalMobileInit);
    },
    onSuccesfulPayment: function(payment) {
        alert("Completed the payment process");
        console.log("payment success: " + JSON.stringify(payment, null, 4));
    },
    onAuthorizationCallback: function(authorization) {
        console.log("authorization: " + JSON.stringify(authorization, null, 4));
    },
    createPayment: function() {
        // for simplicity use predefined amount
        var paymentDetails = new PayPalPaymentDetails("50.00", "0.00", "0.00");
        var payment = new PayPalPayment("50.00", "SGD", "Testing Payment", "Sale",
            paymentDetails);

        return payment;
    },
    configuration: function() {
        // for more options see `paypal-mobile-js-helper.js`
        var config = new PayPalConfiguration({
            merchantName: "TestPay",
            merchantPrivacyPolicyURL: "https://mytestshop.com/policy",
            merchantUserAgreementURL: "https://mytestshop.com/agreement"
        });
        return config;
    },
    onPrepareRender: function() {
        // buttons defined in index.html
        //  <button id="buyNowBtn"> Buy Now !</button>
        //  <button id="buyInFutureBtn"> Pay in Future !</button>
        //  <button id="profileSharingBtn"> ProfileSharing !</button>
        var buyNowBtn = document.getElementById("buyNowBtn");
        // var buyInFutureBtn = document.getElementById("buyInFutureBtn");
        // var profileSharingBtn = document.getElementById("profileSharingBtn");
        //
        buyNowBtn.onclick = function(e) {
            // single payment
            PayPalMobile.renderSinglePaymentUI(paymentObj.createPayment(), paymentObj.onSuccesfulPayment,
                paymentObj.onUserCanceled);
        };
        //
        // buyInFutureBtn.onclick = function (e) {
        // // future payment
        // PayPalMobile.renderFuturePaymentUI(paymentObj.onAuthorizationCallback, paymentObj
        // .onUserCanceled);
        // };
        //
        // profileSharingBtn.onclick = function (e) {
        // // profile sharing
        // PayPalMobile.renderProfileSharingUI(["profile", "email", "phone",
        // "address", "futurepayments", "paypalattributes"
        // ], paymentObj.onAuthorizationCallback, paymentObj.onUserCanceled);
        // };
    },
    onPayPalMobileInit: function() {
        // must be called
        // use PayPalEnvironmentNoNetwork mode to get look and feel of the flow
        //PayPalEnvironmentProduction
        PayPalMobile.prepareToRender("PayPalEnvironmentSandbox", paymentObj.configuration(),
            paymentObj.onPrepareRender);
    },
    onUserCanceled: function(result) {
        alert("User has cancelled payment");
        console.log(result);
    }
};

Here's the output from logcat in eclipse:

Request code = 1
We have a callback to send this result to

Attempted to send a second callback for ID: PayPalMobile217023636
Result was: {"response":{"state":"approved","id":"PAY-36C4483279322301AKTXHYGI","create_time":"2015-02-26T01:51:21Z","intent":"sale"},"client":{"platform":"Android","paypal_sdk_version":"2.8.5","product_name":"PayPal-Android-SDK","environment":"sandbox"},"response_type":"payment"}

can't locate file for: -lPayPalMobile

I removed this plugin and reinstalled everything. now when trying to build I got above error, please let me know why this error is occurring

Regards,
Suhas

Changing page in JQM app stops renderSinglePaymentUI from working again

Hi all,

This a great plugin but I have a problem implementing this correctly into a Jquery Mobile Cordova/Phonegap app.

I have a button on the payment page of our app which works great. You can click the payment button and the PayPal window opens everytime you click the button. However, if the user clicks a button which navigates to another data-role="page" within the same app and the user navigates back to the page that contains the payment button then the payment button no longer appears to work. I have console.log entries throughout the process and I can see that on the attempts tried when the user has switched back to the payment page the code gets right to the renderSinglePaymentUI call and appears to do nothing. The PayPal window does not open or report any kind of failure and there are no errors in the debug windows in XCode or the WebInspector.

Does anyone know what the problem is here as it appears to work almost perfectly until I switch pages and then back again.

One other problem I have noticed is that on an iOS device when the PayPal window is cancelled then white space begins to appear at the bottom of the app thus effecting the Jquery Mobile layout. The more you click cancel the taller the white space and the rest of the app shrinks in height. Has anyone else had this issue or know what is going on here ?

My app code is very large so I am going to try and make a small app that contains this plugin so that I can give you some code samples that can demonstrate the problems.

Thanks,

Chris

Redirect URLs and/or Callback to Server

Is there a way to get the PayPal REST redirect_urls working with this, or am I missing something?

I wanted to not only return the response via the SDKs and Plugins, but also have PayPal respond back to the server itself via the redirect_urls, like a webhook after a payment is made.

Tried to add them into the query being sent, but not luck. Thanks for any insight.

Integration With Ionic framework?

Has anyone managed to successfully integrate this plugin with Ionic framework.
my app doesn't have a Index.js , creating one doesn't work.
I have tried to add the Script into the App.js also with no luck.
I am not sure how I can integrate this plugin as I can find very little documentation.

thanks any help is appreciated.

Angularjs Service & PaypalMobile

I am trying to use this plugin with AngularJs service. I added the js files to my js directory manually because during installation they were not copied there by cordova.

<script type="text/javascript" src="js/components/paypal/cdv-plugin-paypal-mobile-sdk.js"></script>
<script type="text/javascript" src="js/components/paypal/paypal-mobile-js-helper.js"></script>

Below is the service for AngularJs. When I am testing it gives me an error in the console
undefined is not a function (evaluating 'PayPalMobile.prepareToRender("PayPalEnvironmentNoNetwork", configuration(), onPrepareRender())')

angular.module('services.wallet', [])

    .factory('Wallet', function ($q, $ionicPlatform, $window) {
        var service = {
            initPaymentUI: initPaymentUI,
            onSuccesfulPayment: onSuccesfulPayment,
            onFuturePaymentAuthorization: onFuturePaymentAuthorization,
            createPayment: createPayment,
            configuration: configuration,
            onPrepareRender: onPrepareRender,
            onPayPalMobileInit: onPayPalMobileInit,
            onUserCanceled: onUserCanceled,
            makePayment: makePayment
        };


        function initPaymentUI() {
            var clientIDs = {
                "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
                "PayPalEnvironmentSandbox": "YOUR_SANDBOX_CLIENT_ID"
            };
            PayPalMobile.init(clientIDs, onPayPalMobileInit());

        }

        function onSuccesfulPayment(payment) {
            console.log("payment success: " + JSON.stringify(payment, null, 4));
        }

        function onFuturePaymentAuthorization(authorization) {
            console.log("authorization: " + JSON.stringify(authorization, null, 4));
        }
        function createPayment() {
            // for simplicity use predefined amount
            var paymentDetails = new PayPalPaymentDetails("1.50", "0.40", "0.05");
            var payment = new PayPalPayment("1.95", "USD", "Awesome Sauce", "Sale", paymentDetails);
            return payment;
        }
        function configuration() {
            // for more options see `paypal-mobile-js-helper.js`
            var config = new PayPalConfiguration({merchantName: "My Test Shop", merchantPrivacyPolicyURL: "https://mytestshop.com/policy", merchantUserAgreementURL: "https://mytestshop.com/agreement"});
            return config;
        }
        function onPayPalMobileInit() {
            // must be called
            // use PayPalEnvironmentNoNetwork mode to get look and feel of the flow
            PayPalMobile.prepareToRender("PayPalEnvironmentNoNetwork", configuration(), onPrepareRender());
        }
        function onUserCanceled(result) {
            console.log(result);
        }
        function onPrepareRender() {}

        function makePayment() {
            PayPalMobile.renderSinglePaymentUI(createPayment(), onSuccesfulPayment(), onUserCanceled());
        }

        return service;
    });

What am I doing wrong with this setup?

Crash in login Paypal with plugin and Paypal app installed in device

Hi,

I have a problem with login Paypal. If I have installed Paypal app in my device, when I'm going to buy a product in my app (developed for me), the paypal cordova plugin jump to Paypal app (com.paypal.android.p2pmobile) and doesn't work to next step (confirm payment).

Log:
12-10 14:10:40.968: E/Parcel(822): Class not found when unmarshalling: com.paypal.android.sdk.payments.PayPalPayment
12-10 14:10:40.968: E/Parcel(822): java.lang.ClassNotFoundException: com.paypal.android.sdk.payments.PayPalPayment
12-10 14:10:40.968: E/Parcel(822): Caused by: java.lang.NoClassDefFoundError: com/paypal/android/sdk/payments/PayPalPayment
12-10 14:10:40.968: E/Parcel(822): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.paypal.android.sdk.payments.PayPalPayment" on path: DexPathList[[directory "."],nativeLibraryDirectories=[/vendor/lib, /system/lib]]

I have uninstalled Paypal app in my device, and then my app with Paypal works successfully (environment production).

I try with Sample App in this repository (2.8.1 version) and nothing, don't work if I have installed Paypal app.

Any idea?

PD: Sorry for my english :)

Undefined symbols for architecture arm64:

I am encountering below issues when doing build for publish

Undefined symbols for architecture arm64:
"_CVPixelBufferGetBaseAddressOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libPayPalMobile.a(libCardIO.a-arm64-master.o)
"_CVPixelBufferGetBytesPerRowOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libPayPalMobile.a(libCardIO.a-arm64-master.o)
"_CVPixelBufferGetWidthOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libPayPalMobile.a(libCardIO.a-arm64-master.o)
"_CVPixelBufferGetHeightOfPlane", referenced from:
+[CardIOIplImage imageFromYCbCrBuffer:plane:] in libPayPalMobile.a(libCardIO.a-arm64-master.o)
"_CVPixelBufferLockBaseAddress", referenced from:
-[CardIOVideoFrame process] in libPayPalMobile.a(libCardIO.a-arm64-master.o)
"_kCVPixelBufferPixelFormatTypeKey", referenced from:
-[CardIOVideoStream addInputAndOutput] in libPayPalMobile.a(libCardIO.a-arm64-master.o)
"_CVPixelBufferUnlockBaseAddress", referenced from:

Could you please help me, how should I resolve this. I am targeting iOS 7.1 build

Implementing android plugin

after trying unsuccessfully for more than 15 hour to implement paypal plugin into android platform, i've decided to follow the instruction step by step creating a new cordova project with the typical built in example and it's full of errors.
Can you help me?

Is there any plans for Windows Phone/Windows

Is there any plan for supporting Windows Phone or Windows?

I am in the process of building an app, which will be Windows centric, and i will like to take advantage of this plugin.

Include iOS and Android SDKs

Any plans to include the android and ios sdks? I already got this together in a separate forked repo, but wanted to see if this is something you would approve of before I make the pull request.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.