Unable to detach callback method from window object

Hi Everyone,

So I am required to execute a Payment script with callback methods upon entering PaymentView.ts file. These callbacks method [cancelCallback, errorCallback etc…] needs to be written with absolute uri. So I wrote them in the below fashion.

(window).cancelCallback = ()=>{
console.log(“Cancel callback was created with window instance”);

Now when I exit the PaymentView, and reenter the PaymentView, these methods gets piled up, as in the number of times I enter PaymentView, that number of times the callbackMethods will be fired. This is really serious issue, kindly post your thoughts on urgency.


Seems oddly familiar.

Okay so I am supposed to integrate Mastercard Payment HostedCheckout.
I tried to dynamically add the script in my Payment.ts file and execute the callbackMethods() as stated in the question above. Since that didn’t work, I went the traditional way of including the script and callbacks in the index.html and ran into the below pool of confusion.

I get a result in my index.html file upon executing a script from a certain .ts file. Now I need to compare this result and perform necessary action.

  1. Should I make a check in the index.html file, if so, how should I pass data from .ts file ?
  2. Should I make a check in the .ts file , if so, how should I pass data from index.html ?

Kindly let me know if this is a potential bug at IONIC for me to extend the same to my immediate supervisor. Its been days we are stuck at this.

Swift response is much appreciated.

This is not a bug in Ionic, as Ionic is only the UI.

Honestly, I don’t know :smile:
The mastercard API setup seems super old and not like it’s meant to integrate with single page apps.
PLUS, if you’re planning on deploying a native app to iOS and Android, you’ll not be able to use this.
You’ll need to integrate with their payments system instead.

Thanks mike.
I don’t know what the issue is at first time.
After talking with him, I see the issue is not with ionic but jquery inself.
The issue is using jquery callback code in page.ts : So the jquery callback is called again when entering the view. He said that he can resolve it after move the jquery callback code into index.html from some view.page.ts.

I will remove my same issue because I didn’t know that he already posted his issue.