ERROR WITH IONIC INTEGRATION
dhren
New Community Member
Options
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Posted on
Jun-16-2019
11:21 AM
Hello, I am trying to integrate payment with paypal in my ionic app. Then I have this code
import { Component, OnInit } from '@angular/core';
import { IoncabServicesService } from '../ioncab-services.service';
import { PayPal, PayPalPayment, PayPalConfiguration} from '@ionic-native/paypal/ngx';
import { ToastController } from '@ionic/angular';
import { Router } from '@angular/router';
@Component({
selector: 'app-paypalpago',
templateUrl: './paypalpago.page.html',
styleUrls: ['./paypalpago.page.scss'],
})
export class PaypalpagoPage implements OnInit {
totalFare: number;
paymentAmount= 'totalFare' ;
currency: string = 'EUR';
/*currencyIcon: string = '$';*/
constructor(public serviceProvider: IoncabServicesService,
private payPal:PayPal,public toastController: ToastController,public route:Router, ) { }
ngOnInit() {
this.totalFare = Math.round(this.serviceProvider.tripDistance * this.serviceProvider.farePerKm + this.serviceProvider.tarifaBase);
}
payWithPaypal(){
this.payPal.init({
PayPalEnvironmentProduction: '',
PayPalEnvironmentSandbox: 'ASdoJu_T3ORqC2AI-Hx2UYTa8afcSOmyVZMr_KDdaXvufeX6-S7CuTjgyhEYy1_uaSSsjkgtD4qbQS3o'
}).then(() => {
// Environments: PayPalEnvironmentNoNetwork, PayPalEnvironmentSandbox, PayPalEnvironmentProduction
this.payPal.prepareToRender('PayPalEnvironmentSandbox', new PayPalConfiguration({
acceptCreditCards:true,
})).then(() => {
console.log(this.totalFare);
let payment = new PayPalPayment( this.paymentAmount, 'EUR', 'Descripción', 'sale');
this.payPal.renderSinglePaymentUI(payment).then(()=>{
this.route.navigate(['/bookingconfirmation']);
})
})
})
}
}
totalfare calculates an operation that is the distance * km this would have to give a number that is the price that the user would have to pay.
I have put paymentAmount = 'totalfare'.The problem is that I do not open paypal when the button is clicked
I have put paymentAmount = 'totalfare'.The problem is that I do not open paypal when the button is clicked
0 REPLIES 0
Haven't Found your Answer?
It happens. Hit the "Login to Ask the community" button to create a question for the PayPal community.
Related Content
- help me with PayPal with google pay integration in Braintree Client-side Integration (JS, iOS, Android SDKs)
- Suddenly receiving "Authorization failed due to insufficient permissions" intermittently in REST APIs
- PayPal Redirection Issue After Successful Payment in Photobooth Integration in Sandbox Environment
- Credit card payment error in woocommerce in PayPal Payments Standard
- EDD in PayPal Payments Standard