magento2.3 – how to return external js function?

I am integrating custom payment. The payment provider gives a script from their side.
need to call a function from their script with the generated token. By calling that function, it will redirect to payment site.

How can I return the js function?
can Someone guide me.