PayPal
PayPal plugin for Cordova/Ionic Applications
联系我们?
If you're building a serious project, you can't afford to spend hours troubleshooting. Ionic's experts offer official maintenance, support, and integration help.
Ionic PayPal插件的安装(Installation)
Ionic EE comes with fully supported and maintained plugins from the Ionic Team. Learn More or Contact Us
Ionic PayPal插件支持的平台(Supported Platforms)
- Android
- iOS
Ionic PayPal插件的用法(Usage)
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
});