Setup your development
To manually load Checkout.js, simply add the script link to the <head> of any page.Overview
TBIframe v1.1 introduces an event-driven architecture using.on() and .off().
This version supports:
- Multiple event listeners
- KYC lifecycle tracking
- Popup & redirection handling
- Better iframe lifecycle control
Required HTML Elements
Make sure to add the following elements to your page:
Note: Root container must have the ID tb_root.
Quick Start Example
⚠️ Important Note on Mandatory Handlers
Currently, the following handlers are mandatory parameters when callinginit():
onSessionUpdateonCloseonTransactionUpdate
🔄 Upcoming Change (Future Versions)
In a future release, these handlers will no longer be required in theinit() method.
Instead, all event subscriptions will be handled exclusively using the event-driven pattern:
1. Create Instance ( Constructor ).
2. Initialization & Its Behavior
Theinit() method can only be executed once per TBIframe instance.
If you need to load a new session, create a new instance.
Parameters for init(...):
| Name | Type | Description |
|---|---|---|
url | string | The URL of the payment session. |
onSessionUpdate | (data: object) => void | Triggered when payment session updates (e.g., success, failure). |
onClose | (data: object) => void | Triggered when iframe is closed manually or automatically. |
onTransactionUpdate | (data: object) => void | Triggered when a transaction is initiated. Returns transaction IDs. |
options | TBIframeOptions | Object to customize iframe style and behavior. |
Options (TBIframeOptions)
| Property | Type | Description |
|---|---|---|
frameStyles | Partial<CSSStyleDeclaration> | CSS styles to apply to the iframe. |
redirectionTarget | _self | _blank | Target for bank page. |
3. Register Handlers using on
| Event | Description |
|---|---|
sessionUpdate | Payment status updates |
transactionUpdate | Transaction creation |
close | Iframe closed |
kycStatusUpdate | KYC lifecycle updates |
Parameters for on(...):
| Parameter | Type | Description |
|---|---|---|
handlerName | sessionUpdate | kycStatusUpdate | close | transactionUpdate | Handler Name |
callbackFn | function | Custom function to set with handler name. |
4. Remove Handlers using off
Parameters for off(...):
| Parameter | Type | Description |
|---|---|---|
handlerName | sessionUpdate | kycStatusUpdate | close | transactionUpdate | Handler Name |
close()
Closes the iframe manually and triggers the onClose callback (if set).
Handler Reference
Functions that can be registered using the on method.
| Name | Type | Description |
|---|---|---|
sessionUpdate | (data: object) => void | Triggered when payment session updates (e.g., success, failure). |
close | (data: object) => void | Triggered when iframe is closed manually or automatically. |
transactionUpdate | (data: object) => void | Triggered when a transaction is initiated. Returns transaction IDs. |
kycStatusUpdate | (data: object) => void | Triggered during the life cycle of KYC. Returns KYC Status. |
Example Output
Notes
- The
tb_rootcontainer must be present in your DOM for the iframe to be injected. - You must provide a valid session URL for payments to work.