PayPal
PayPal plugin for Cordova/Ionic Applications
https://github.com/paypal/PayPal-Cordova-Plugin
Stuck on a Cordova issue?
If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic’s experts offer premium advisory services for both community plugins and premier plugins.
Installation#
- Capacitor
- Cordova
- Enterprise
$ npm install com.paypal.cordova.mobilesdk $ npm install @ionic-native/paypal $ ionic cap sync$ ionic cordova plugin add com.paypal.cordova.mobilesdk $ npm install @ionic-native/paypal Ionic Enterprise comes with fully supported and maintained plugins from the Ionic Team. Learn More or if you're interested in an enterprise version of this plugin Contact Us
Supported Platforms#
- Android
- iOS
Usage#
React#
Learn more about using Ionic Native components in React
Angular#
import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal/ngx';
constructor(private payPal: PayPal) { }
...
this.payPal.init({ PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID', PayPalEnvironmentSandbox: 'YOUR_SANDBOX_CLIENT_ID'}).then(() => { // Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({ // Only needed if you get an "Internal Service Error" after PayPal login! //payPalShippingAddressOption: 2 // PayPalShippingAddressOptionPayPal })).then(() => { let payment = new PayPalPayment('3.33', 'USD', 'Description', 'sale'); this.payPal.renderSinglePaymentUI(payment).then(() => { // Successfully paid
// Example sandbox response // // { // "client": { // "environment": "sandbox", // "product_name": "PayPal iOS SDK", // "paypal_sdk_version": "2.16.0", // "platform": "iOS" // }, // "response_type": "payment", // "response": { // "id": "PAY-1AB23456CD789012EF34GHIJ", // "state": "approved", // "create_time": "2016-10-03T13:33:33Z", // "intent": "sale" // } // } }, () => { // Error or render dialog closed without being successful }); }, () => { // Error in configuration });}, () => { // Error in initialization, maybe PayPal isn't supported or something else});