I'm trying to add the seamless payment integration method of Wirecard into my Ionic 3 application. After the form is created, a callback method (this.formCreated
) is called.
There is some logic that needs to be done there, but for now its only purpose is to dismiss the loading animation.
Here is my code:
import { Component } from '@angular/core';
import { Loading, LoadingController, NavController, NavParams } from 'ionic-angular';
import { TranslateService } from '@ngx-translate/core';
import { PaymentService } from '../../providers/payment';
declare var WirecardPaymentPage;
@Component({
selector: 'page-payment-add-creditcard',
templateUrl: 'payment-add-creditcard.html'
})
export class PaymentAddCreditcardPage {
public loader: Loading;
constructor(public navCtrl: NavController,
public navParams: NavParams,
private paymentService: PaymentService,
private translateService: TranslateService,
private loadingCtrl: LoadingController) {
console.log('PaymentAddCreditcardPage');
this.loader = this.loadingCtrl.create();
this.loader.present();
}
ionViewDidLoad() {
let requestData = this.paymentService.generateCreditCardRequest();
WirecardPaymentPage.seamlessChangeLocale(this.translateService.currentLang);
WirecardPaymentPage.seamlessRenderForm({
requestData: requestData,
wrappingDivId: 'wirecard-cc-target',
onSuccess: this.formCreated,
onError: this.processErrorResult
});
}
formCreated(data) {
this.loader.dismiss();
console.log(data);
}
processErrorResult(data) {
console.log(data)
}
}
When testing this, it got this error:
Runtime Error
Cannot read property 'dismiss' of undefined
I figured, that also other variables are undefined, so I guess the class context is gone.
So now I'm a bit lost. How do I get my context back or is there another solution for this problem?