PayPal Cordova plugin

It complained ‘Supplied parameters do not match any signature of call target.

import {PayPal, PayPalPayment, PayPalConfiguration, PayPalConfigurationOptions} from 'ionic-native';

// ...

export class PayPage {
  paymentdata: PayPalPayment;

  constructor(private navCtrl: NavController) {
      // It complained 'Supplied parameters do not match any signature of call target.'
      this.paymentdata = new PayPalPayment("50.00", "USD", "Awesome Sauce", "Sale");
  }
}

I can’t test it ATM so I’m not sure what’s the right way to call it, but hopefully @ihadeed could shed some light on the topic.

Hi,

I preferred the old style from PayPal JS SDK, Because I think the native support is not ready yet for prod. use. :disappointed:

Here is my solution.

Install the paypal typescript from DefinitelyTyped.

typings install dt~paypal-cordova-plugin --global

And put that code in your controller / provider /…

    let env = <PayPalCordovaPlugin.PayPalClientIds> {
        PayPalEnvironmentProduction: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
        PayPalEnvironmentSandbox: 'XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX'
    };

    let conf = <PayPalConfiguration>(<PayPalConfigurationOptions> {
        merchantName: 'Your app name',
        merchantPrivacyPolicyUrl: 'https://privacyUrl',
        merchantUserAgreementUrl: 'https://agreementUrl',
        acceptCreditCards: true,
        rememberUser: true,
        disableBlurWhenBackgrounding: true,
        presentingInPopover: true
    });

    PayPalMobile.init(env, () => {

        PayPalMobile.prepareToRender(
            'PayPalEnvironmentSandbox',
            conf,
            () => {

                let payment = {
                    amount: '25.00',
                    currency: 'EUR',
                    shortDescription: 'Prod. Desc.',
                    intent: 'Sale',
                    details: {
                        subtotal: '25.00',
                        shipping: '0.00',
                        tax: '0.00'
                    }
                };

                PayPalMobile.renderSinglePaymentUI(
                    <PayPalPayment>payment,
                    (result: PayPalCordovaPlugin.SinglePaymentResult) => {
                        console.log('payed:', JSON.stringify(result));
                    },
                    (reason: string) => {
                        console.log('payed canceled:', reason);
                    }
                )
            });
    });

I hope that helps you and of course the other also. :smile:

Best regards,
chmmou

Just seeing this, haven’t been on the forums lately.

Sorry guys I made a mistake while writing the wrapper for this plugin, I will fix it soon and update you here once it’s fixed.

The way it is now is:

export declare class PayPalPayment {
  // constructor 
  new( ... );
  
  // other methods
  invoiceNumber(...);
  
  ...
}

It should be something like this:


export interface PayPalPayment {
   // other methods
  invoiceNumber(...);
  ...
}

export declare var PayPalPayment {
  // constructor
  new(...): PayPalPayment;
}

This issue is fixed now. Please update to latest version of Ionic Native. npm i --save ionic-native@latest

I have this installed. But still I am getting these errors.

I could see the updated codes in my npm modules as well.

C:\myapps\ionic2-tests\mmsapp>ionic info

Your system information:

Cordova CLI: 6.3.1
Ionic Framework Version: 2.0.0-rc.0
Ionic CLI Version: 2.1.0
Ionic App Lib Version: 2.1.0-beta.1
OS:
Node Version: v6.7.0


package.json snippet:
     "dependencies": {
        "@ionic/storage": "1.1.2",
        "angular2-moment": "^1.0.0-beta.3",
        "ionic-angular": "^2.0.0-rc.0",
        "ionic-native": "^2.1.3",
        "ionicons": "^3.0.0"
      },

Ok this should be fixed now.

Please update to ionic-native@2.1.6 and try again.

errors are gone and app is executing.

Haven’t tested for paypal working though. THanks a lot.

Is there a way to make it work in browser?
I get cordova.js not found and use a device to test in browser.

The PayPal plugin doesn’t have browser support, nothing we can do on our end. Your best bet is to use livereload.

aw. okay… thanks a lot for the quick fix… saved my day.

After removing all errors and doing a test in device
i get JSON error :frowning:

import { Injectable } from '@angular/core';
//import { Paypal, PaypalPayments } from 'ionic-native';

import {PayPal, PayPalPayment} from 'ionic-native';
//import {PayPal} from 'ionic-native';


@Injectable()
export class Payments {

paymentdata : any;
paymentdetails: any;

constructor() {
    
}

initiatePaypal(){
PayPal.init({
        "PayPalEnvironmentProduction": "YOUR_PRODUCTION_CLIENT_ID",
        "PayPalEnvironmentSandbox": "AFcWxV21C7fd0v3bYYYRCpSSRl31ACxTIGBF1mQyNN7DjU1eCzpAZer8"
        })
    .then(onSuccess => {
        console.log("init success")
    })
    .catch(onError => {
        console.log("init failed", Error)
    });
}


initiatePayment(){

    this.paymentdata = new PayPalPayment("10.00","SGD", "MMS tickets", "MMS sale");

    PayPal.renderSinglePaymentUI(this.paymentdata)
    .then(onSuccess => {
         console.log('OnSuccess Render: ' + JSON.stringify(onSuccess));
         alert('OnSuccess Render: ' + JSON.stringify(onSuccess));
       })
    .catch(onError=> {
       console.log('onError Render: ' + JSON.stringify(onError));
       alert('onError Render: ' + JSON.stringify(onError));
         });
}



}

This works with ionic-native 2.2.2 thanks a lot @ihadeed

1 Like

Hello, I am new to use the Paypal plugin. I put your code in a button to trigger and test it in an android device. However, after press the button, the app crashed. So could you please provide me more detailed code for reference? thanks

I am using Ionic2, and need to integrate PayPal into my app.

My app needs to be able to send and receive payments to/from other PayPal accounts.

Is there a way for a Mobile App (Facilitator) to allow a Payer to make a payment to a Payee?

I have looked at the PayPal API’s, and I can find how to facilitate a Payer to make a payment a Payee, if the Payee is the Facilitator. As then it can register the Payees PayPal client Id. But in my case, the Payee does not supply their PayPal client Id (Facilitator & Payee are separate entities). i.e. The Payee is another PayPal Account.

enter image description here

UPDATE

It looks like PayPal Payouts allow payments to another PayPal account.

Do any Ionic compatible plugins provide an interface to this functionality?

UPDATE

This looks like it may be an option that can make payouts and is in nodejs, so will probably plug into an ionic app. I need to investigate a little further. Does anyone have any experience with this api? https://github.com/paypal/PayPal-node-SDK

Thanks

I cannot install com.paypal.cordova.mobilesdk on my ionic app.
I had built android and ios platform.
During executing app,it shows this error message.
WARN: Install the PayPal plugin: 'ionic cordova plugin add com.paypal.cordova.mobilesdk’
So I tried this cli commmand but not working,any progress or bug not showing.
'ionic cordova plugin add com.paypal.cordova.mobilesdk’
Help me!

sir its working with static value but i pass dynamic value i got error " Payment not processable " in the console.
below we pass payment object:

amount: "200" bnCode: "PhoneGap_SP" currency: "INR" details: undefined intent: "Health Record With Conditioncjn dfgh" shortDescription: "Description"

sir its working with static value but i pass dynamic value i got error " Payment not processable " in the console.
below we pass payment object:

amount: "200" bnCode: "PhoneGap_SP" currency: "INR" details: undefined intent: "Health Record With Conditioncjn dfgh" shortDescription: "Description"

@ ihadeed : sir i got error "Payment not processable error in console please sir tell me how to fix?