You can interact with our widget using java script api in real-time, without the need to develop complex backend integration.
Copy <! DOCTYPE html >
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title >Verification</ title >
</ head >
< body >
< div id = "transactionlink-widget" />
< script >
window . transactionlink_ready = () => {
transactionlink .setOptions ({ token })
transactionlink .open ()
}
</ script >
< script type = "text/javascript" src = "https://widget.transactionlink.io/transactionlink-widget.umd.js" ></ script >
</ body >
</ html >
Copy <! DOCTYPE html >
< html lang = "en" >
< head >
< meta charset = "UTF-8" >
< meta name = "viewport" content = "width=device-width, initial-scale=1.0" >
< title >Add Widget on Button Click</ title >
</ head >
< body >
<!-- Button to trigger the addition of the widget -->
< button id = "open-widget" >Open Widget</ button >
< transactionlink-widget />
< script >
let transactionLinkReady = false
function openWidget () {
if ( ! transactionLinkReady) {
window . transactionlink_ready = () => {
transactionLinkReady = true
transactionlink .setOptions ({ token })
transactionlink .open ()
}
const script = document .createElement ( 'script' );
script .src = 'https://widget.transactionlink.io/transactionlink-widget.umd.js' ;
document . head .appendChild (script);
} else {
transactionlink .setOptions ({ token })
transactionlink .open ()
}
}
// Get the button element
const addButton = document .getElementById ( 'open-widget' );
// Add a click event listener to the button
addButton .addEventListener ( 'click' , openWidget);
</ script >
</ body >
</ html >
To enhance security, include the following Content Security Policy (CSP) directive headers in the index.html
file, within the tag:
Copy Content-Security-Policy default-src 'self' *.transactionlink.io;
connect-src 'self' *.transactionlink.io wss://*.transactionlink.io *.sentry.io;
script-src 'self' *.transactionlink.io;
img-src blob: 'self' *.transactionlink.io data:;
frame-src 'self' *.transactionlink.io;
style-src 'self' *.transactionlink.io fonts.googleapis.com;
font-src 'self' *.transactionlink.io fonts.gstatic.com data: