How to navigate success page once payment is success using ionic 4

hi i am using razorpay payment integration and i have implemented when my payment success it returns to same page but i want to navigate to success page so how to achive this i am using ionic 4 angular 8

Whatever you get as the results of the payment is what you use to determine what route to follow next which can be done simply using ifelse and routerlink

 // Go to success page
routerLink='link to the success page';
} else {
 // Go to failed page
 routerLink='link to failed page';

async payWithRazor() {
console.log(“invoice details=”,this.invoiceDetails.InvoiceMst_Id);
let data;
})//do u have username and password whre u can use ur mobile number
var options = {
description: ‘MedV’,
image: ‘’,
currency: this.currency,
key: this.razor_key,
amount: this.paymentAmount,
name: ‘MedV’,
// OrderID:this.invoiceDetails.InvoiceMst_Id,
prefill: {
email: ‘’,
contact: data.mobNo,

theme: {
  color: '#004a8e'
modal: {
  ondismiss: function () {

let incId=this.invoiceDetails.InvoiceMst_Id;
var successCallback = (payment_id) => {
alert(‘payment_id: ’ + payment_id);//only payment id will show if success means?yes this code shows payment id
console.log(“invoide id=”,incId.InvoiceMst_Id);
console.log(“payment id=”,payment_id);
let data=JSON.parse(res[’_body’]);


var cancelCallback = (error) =>{
alert(error.description + ’ (Error ‘+error.code+’)’)
}, successCallback, cancelCallback)
this our code let me know where to call router

Sorry but i can barely figure out what your code is doing but here is what i can suggest.

You need to have separation of tasks.

  1. Create a service that handles all related authentication issues this will code away the need to call storage requests here plus username and password issues.
  2. Create a service to handle payment tasks. This will help deal with successful and failed payment and help to give feedback in order to route to desired locations
  3. Create service to deal with invoices and related tasks like pending invoices, payment status et al
1 Like

thank you soo much for your response…