New Member
Posts: 1
Registered: ‎02-16-2017

How to load Accept js dynamically based on your environment

[ Edited ]
<script type="text/javascript" src="" charset="utf-8"></script>


 Works, however hard coding this is a really bad practice (just think if someone left the jstest url and deployed to prod!), and my Aurelia app has the ability to check which environment I'm in. So here's what I did 




addAuthNetScriptTag() {
let element = document.createElement('script')
element.charset = 'utf-8'
if (environment.debug || environment.testing) {
element.src = ''
} else {
element.src = ''


^^^ This code puts the correct tag in the <head> element, but when I call Accept.dispatchData(), it returns the error code E_WC_14:Accept.js encryption failed. Surley there must be some way to switch CDN's based on environment. 

Posts: 143
Registered: ‎11-03-2016

Re: How to load Accept js dynamically based on your environment

Hi @Coletrane,


I'm afraid that's a known issue with Accept.js for now. "Lazy loading", conditional loading, or anything causing the Accept.js script to be loaded after the page load will cause problems. The good news is that the fix has been made on our end, and it's just winding its way through the release process. Expect an announcement of its availability soon.


Aaron Wright
Developer Evangelist - Authorize.Net

Follow Authorize.Net developer news on Twitter!