I am using a payment merchant in my React app which requires that I import their v1.js script and then use it to create an object.
First I tried to download the script and import it via import ./v1.js
, but that left me with plenty of errors:
I've then imported the script in my index.html
file instead via <script type="text/javascript" src="https://tpgw.trustpay.eu/js/v1.js"></script>
.
This didn't incur any errors, however, the next step requires me to create an object referenced in the script using var trustPayApi = new TrustPayApi({secrets});
.
When I run this code in my React app (substituting secrets
for the correct value), I get an error saying
'TrustPayApi' is not defined
How can I correctly implement the script and use the TrustPayApi
object defined within it?