Ionic framework 如何在Ionic 3中使用PayPal修复“对象(…)不是函数错误”
我在我的Ionic应用程序中工作,我在我的Ionic应用程序中使用了PayPal 这是我的结帐。ts: 这是我的checkout.html: 我已经导入了运行PayPal所需的所有内容,但是当我运行PayPal代码时,它会显示错误 对象。。。不是PayPal.init index.js中的函数:28Ionic framework 如何在Ionic 3中使用PayPal修复“对象(…)不是函数错误”,ionic-framework,paypal,ionic3,Ionic Framework,Paypal,Ionic3,我在我的Ionic应用程序中工作,我在我的Ionic应用程序中使用了PayPal 这是我的结帐。ts: 这是我的checkout.html: 我已经导入了运行PayPal所需的所有内容,但是当我运行PayPal代码时,它会显示错误 对象。。。不是PayPal.init index.js中的函数:28 非常感谢您的帮助。由于您使用的是Ionic v3,您应该从“@Ionic native/PayPal”而不是从“@Ionic native/PayPal/ngx”导入PayPal 如果您使用npm安
非常感谢您的帮助。由于您使用的是Ionic v3,您应该从“@Ionic native/PayPal”而不是从“@Ionic native/PayPal/ngx”导入PayPal
如果您使用npm安装@ionic native/PayPal,请使用npm卸载@ionic native/PayPal并使用npm安装-save@ionic native重新安装/paypal@4我已经使用以下方法安装了paypal:ionic cordova插件添加com.paypal.cordova.mobilesdk,以及:npm install@ionic native/paypalAnd,当我使用来自“@ionic native/paypal”;它显示了错误。ionic cordova插件add com.paypal.cordova.mobilesdk是正确的,但在安装npm软件包时,您应该在末尾添加@4。请阅读我的答案。所以,我希望你能在这方面帮助我。两天以来我一直在使用Ionic v3,所以我会不会影响我的代码。
import { PayPal, PayPalPayment, PayPalConfiguration } from '@ionic-native/paypal/ngx';
constructor(private PayPalMobile: PayPal) { }
makepaymentp()
{
//console.log("Payment");
this.PayPalMobile.init({
PayPalEnvironmentProduction: 'YOUR_PRODUCTION_CLIENT_ID',
PayPalEnvironmentSandbox: 'asasasasasasasasasas',
}).then(() => {
// Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
this.PayPalMobile.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', 'INR', 'Description', 'sale');
this.PayPalMobile.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
});
}
<button class="myaddto22" [disabled]="!RadioValue" (click)="makepaymentp()" full ion-button round="true">
Make Payment
</button>
import { PayPal } from '@ionic-native/paypal/ngx';
providers: [PayPal]