You can use AuthGuard in angular 2 to suffice your requirement. You just need to implement CanActivate and write your business logic
import { Injectable } from '@angular/core';
import { Router, CanActivate, CanDeactivate } from '@angular/router';
import { Observable } from 'rxjs/Observable';
@Injectable()
export class AuthGuard implements CanActivate {
constructor(private router: Router) { }
canActivate() {
if (localStorage.getItem('payment')) { //key to indicate that user has visited payment gateway (you can change as per your needs)
return false;
}
return true;
}
}
Routing
{
path: 'home',
component: homeComponent,
canActivate: [AuthGuard]
}
Hope it helps!!