Method to destroy SDK #181
-
Hi everyone! I'm developing an Angular implementation of the SDK-JS of Mercado Pago. Just we need tokenize the credit card and this implementation it's going well, but we have a problem once we initialize by twice the SDK. I'll try to explain by the calls of components:
In the same session and instace (without refresh the page I mean), we can add another credit card, so we call the reusable component which again initialize the SDK and the fields of the form. In this point, all the validations that the SDK does in the fields are wrong. The validyChanges event do not retrieve any error when there is an explicit error, so we can't validate anymore the fields and we can't follow the normal flow. To use again the SDK we need to refresh the page and therefore our entire app. In resume, the first time that we initialize the SDK we don't have problem with it, but the second time that we initialize it we have the issues described. So, is there any function or way to kill the SDK instance from the memory or anything that we can implement? I'll hope that you understand our case, please let me know if you need more details (in english or spanish) Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 2 replies
-
Hello @copEquifax! We understand your situation Instead of always creating the SDK in this reusable component you could have a single instance for your entire application (have a look about this pattern here) In summary:
|
Beta Was this translation helpful? Give feedback.
Hello @copEquifax!
We understand your situation
Currently there isn't a method to destroy the SDK instance, but there is a possible alternative
Instead of always creating the SDK in this reusable component you could have a single instance for your entire application (have a look about this pattern here)
With this single instance you can create and "destroy" instances of Bricks, Card Form or even Fields, because each one of them has the mount and unmount methods.
In summary: