'Fucntion not working inside razorpay ondismiss callback in Angular 12

I have a function inside ondissmiss callback

options.modal.ondismiss = () => {
  console.log("its working");
  this.detectChanges();
  this.isPaying = false
};

console.log is working fine but value ispaying is not rendered on the ui because of which loader keeps running even after i close my razorpay modal.

I am using Angular 12.



Solution 1:[1]

Modal dismiss will return error code 2. You can handle it in the error handler or wrap it with promise

Example:

const promise = new Promise((resolve, reject) => {
       options.modal.ondismiss = () => {
         this.ngZone.run(() => {
       reject({code: 2, description: 'Payment cancelled by user'});
   });
};

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Bozhinovski