Adding <script> javascript code to appstudio

I need to add this to my app - where do I put it?

<script async type='text/javascript'
    src='https://static-na.payments-amazon.com/OffAmazonPayments/us/sandbox/js/Widgets.js'>
</script>

I’m not sure exactly what platforms you are targeting, but you’ll most likely have cross domain issues with code from a different domain than the base app code. You’re best bet is to copy the widget.js to your appstudio dev computer in the project and include it in the project for distribution. That get’s rid of cross domain issues.

This also means: Anytime Amazon changes the payment API, of which they give lots of notice, you’ll have to create a new distribution of your app. I’m not familiar with this API, but the others for AWS only change at most once a year. And the old versions are mostly supported after new releases. Their APIs I use have a version that you specify the API level you are using. Hope this helps.

OK thanks!

To be complete, I should mention that you can do what you originally asked. I don’t know enough about appstudio to do it. I know it would require you to setup CORS on both your app distribution server as well as in your app. If you are unfamiliar with CORS and the implications, I’d avoid it. :):upside_down_face:

Now that I’m thinking about this, you are going to need a contentSecurityPolicy for your project, as the Amazon will do HTTPS calls. You didn’t dodge the bullet completely. You’ll need a connect-src with the Amazon payment domain specified. Sorry. It would look something like:

connect-src 'self' https://static-na.payments-amazon.com/ ;

Search the board for CORS and cross domain. There’s a lot of info there.

You can put this code in extraheaders. It’s a Project Property.

Decided to go with Paypal - there is a simple way to integrate it that I found - https://elfsight.com/ - pretty easy for beginners.