I have a React app which the components are controlled by a Store.ts file.
I followed some steps in other threads here on Stack Overflow. I've already included the script tag in my index.html
like this:
<script type="text/javascript" src="https://stc.sandbox.pagseguro.uol.com.br/pagseguro/api/v2/checkout/pagseguro.directpayment.js"></script>
Then, as stated in here, in my Store, before using one of the functions, I declared the library as part of window
as follow:
declare global {
interface Window { PagSeguroDirectPayment: any; }
}
window.PagSeguroDirectPayment = window.PagSeguroDirectPayment || {};
window.PagSeguroDirectPayment.setSessionId('620f99e348c24f07877c927b353e49d3');
But when I run the app I get the error window.PagSeguroDirectPayment.setSessionId is not a function
. And when I call the function directly in the index.html
it seems to work.
Am I declaring it in the wrong place or in the wrong way? I appreciate any help. Thanks in advance