My experience with implementing worldpay on my one-page Angular app (Angular 1.x) has been mostly positive. I have been using the useTemplateForm() method to generate a credit card form and retrieve a token successfully. However, I have encountered an issue where my callback function, set in useTemplateForm, is being called multiple times after retrieving the token.
This problem arises from the fact that I am calling useTemplateForm every time the payment window pops up. It seems that Worldpay.js is stacking these callbacks instead of clearing them, and I am unsure of how to prevent this behavior. Unfortunately, I am required to call useTemplateForm each time the window appears because the element (div) containing the iframe is destroyed when the payment window closes, but destroying this element does not reset the stacked callbacks.
There are various ways I could handle this issue, but I would prefer to find a method to prevent the infinite stacking of callbacks as it will ultimately consume unnecessary resources.
If anyone has any suggestions on how to address this problem, I would greatly appreciate it.