Skip to main content
Version: 3.0.0 (current)

Initializing the SDK

Load the SDK

The SDK script tag is sent together with the <iframe> snippet from Create session, so in the usual cases you don't need to do anything in order for the SDK to be initialized. This will for example ensure that the height of the iframe gets automatically adjusted as the content changes.

Load the SDK manually

If you have logic that needs to be executed immediately, you can add the SDK manually. For example, if you are using the payment module without supplying it with enough data, it will be rendered in a "locked state". By ensuring that the SDK is loaded, you can unlock the module on load, in those cases where your payment alternatives doesn't require that many data points to complete a purchase.

<script async>
function setupBriqpayExample() {
// Wait for Briqpay to have finished setting up two-way communication with the iframes
window._briqpay.v3.onReady(function () {
// Example, unlock a module immediately if all user data fulfills your criteria
const hasFullUserDataAndShipping = true // Replace with your function call to validate user data
if (hasFullUserDataAndShipping) {
window._briqpay.v3.unlockModule('payment')
}
})
}

// Get the script tag element handler, ensure it matches with the id attribute in the first script tag
const existingElement = document.getElementById('briqpay-sdk')

// If SDK is not found, inject it
if (!existingElement) {
const element = document.createElement('script')
element.setAttribute('src', 'https://api.briqpay.com/briq.min.js')
element.setAttribute('id', 'briqpay-sdk')
element.async = true
document.head.appendChild(element)
element.onload = setupBriqpayExample
} else {
setupBriqpayExample()
}
</script>