import {Component, OnInit} from '@angular/core'; import {ActivatedRoute, Router} from '@angular/router'; declare var window: any; const Paygilant = window.Paygilant; @Component({ selector: 'app-my-shop', templateUrl: './my-shop.page.html', styleUrls: ['./my-shop.page.scss'], }) export class MyShopPage implements OnInit { requestId = ''; constructor(private router: Router, private _route: ActivatedRoute) { } ngOnInit() { this._route.queryParams.subscribe(params => { if (params && params.requestId) { this.requestId = params.requestId; if (window.Paygilant) { window.Paygilant.updateCheckPointStatus(window.Paygilant.CheckpointType.TRANSACTION, this.requestId, window.Paygilant.CheckPointStatus.APPROVED).then((result) => { console.log('updateCheckPointStatus result is ', result); }, error => { alert('updateCheckPointStatus error ' + error); }); } } }); } /** * Fired when the component routing to has finished animating. */ ionViewDidEnter(){ if (window.Paygilant) { window.Paygilant.startScreenListener(window.Paygilant.ScreenListenerType.PAYMENT_SCREEN).then((result) => { console.log('startScreenListener result is PAYMENT_SCREEN', result); }, error => { console.log('startScreenListener error PAYMENT_SCREEN', error); }); } } /** * Fired when the component routing from is about to animate. */ ionViewWillLeave(){ if (window.Paygilant) { Paygilant.pauseListenToSensors().then((pauseResult) => { console.log('pause ok', pauseResult); }, (pauseError) => { console.error('pause error', pauseError); }); } } actionLogout() { this.router.navigate(['/']); } }