Load internet js script inside home page to load a form

I have a payment button. developed just for the web and I have to adapt it to work in ionic

  1. I have a function to send some parameters to the server of my provider of the payment button. and this returns an id = checkoutId. this works well.

  2. with the Id checkout I have to load the following script: <script src = “https://test.example.com/v3/file.js?checkoutId={checkoutId}”> </ script>

-I can not place it in index.html because I need to get a dynamic id in home and load the script with that id. Any suggestions or recommendations?