We assuming the dlocal/adyen/google script is fully loaded before we their Instance:
Suggested if we should replace the script we're adding in DlocalGateway with a preload link (https://www.keycdn.com/blog/resource-hints) and ensure all this logic gets loaded after it is run by putting it in a callback to mw.loader.load() https://doc.wikimedia.org/mediawiki-core/master/js/#!/api/mw.loader.
We don't seem to be ensuring that external scripts are loaded before using them. We are just assuming that functions which run on pageready will have access to things defined in external scripts added as script tags in the <head>.
Let's maybe use mw.loader.load() to make sure things are loaded before we run dependent scripts. We could probably keep adding the script tag in the head (or maybe a link rel=prefetch? ) so we don't slow anything down.