Usage

1. Add Required HTML Elements

Include a Buy Now button, a modal dialog, and an iframe container:

Root element id must be tb_root (This is where your iframe will initialize)

<button id="buynow">Buy Now</button>
<button id="close_button">&#215;</button>
<div id="tb_root"></div>

2. Initialize and Use TBIframe

Create an instance and handle the payment session:

const payUrl = "https://www.example.com"; // your session url
const tbIframe = new TBIframe();

// Callback on iframe close
function onCloseIframe() {
    // do somthing...
}

// Handle session updates
function getSessionData(sessionData) {
    console.log("Session Data:", sessionData);
}

// Handle transaction updates
function getTxnData(txData) {
    console.log("Transaction Data:", txData);
}

// Open payment iframe
function startIframe() {
    tbIframe.init(payUrl, getSessionData, onCloseIframe, getTxnData);
}

document.getElementById('buynow').addEventListener('click', ()=>startIframe());