Partner Integration Guide
Embed BBK Bank's mortgage application widget on your website with a few lines of code. Customers can apply for mortgages without leaving your platform.
Quick Start #
Integrate the BBK mortgage widget in three steps. No build tools, no dependencies.
Add the SDK script
Include the BBK SDK in your HTML. This single file contains everything needed.
Initialize with your API key
Call BBK.init() with your public API key. Use pk_test_ keys for sandbox and pk_live_ for production.
Open the widget
Call BBK.open() when a customer clicks your "Apply for Mortgage" button. Pass property details to pre-fill the form.
Installation #
CDN (Recommended)
NPM (TypeScript Projects)
Self-Hosted
Download bbk-embed.min.js and serve it from your own infrastructure. Ensure you update to the latest version when BBK releases SDK updates.
Configuration #
Pass a configuration object to BBK.init(). Only apiKey is required -- everything else has sensible defaults.
| Option | Type | Default | Description |
|---|---|---|---|
apiKey Required |
string | -- | Your public API key. Must start with pk_. |
partnerId |
string | null |
Your partner ID (provided by BBK during onboarding). |
environment |
string | 'sandbox' |
'sandbox', 'production', or 'local'. |
container |
string | null |
CSS selector for inline mode. Omit for modal overlay. |
modal |
boolean | true |
Open as modal overlay. Set false with container for inline. |
language |
string | 'en' |
'en' (English) or 'ar' (Arabic with RTL). |
currency |
string | 'BHD' |
ISO 4217 currency code. |
debug |
boolean | false |
Enable console logging. Disable in production. |
loadTimeout |
number | 15000 |
iFrame load timeout in milliseconds. |
theme |
object | BBK defaults | Theme customization. See Theming section. |
property |
object | null |
Pre-fill property: { name, price, location, type, bedrooms, area }. |
customer |
object | null |
Pre-fill customer: { name, email, phone }. |
Full Configuration Example
Methods #
| Method | Returns | Description |
|---|---|---|
BBK.init(config) |
BBK | Initialize the SDK. Must be called before any other method. Returns the BBK instance for chaining. |
BBK.open([property]) |
void | Open the modal. Optionally pass property data to override the init config. |
BBK.close() |
void | Close the modal with a fade-out animation. Safe to call multiple times. |
BBK.updateProperty(prop) |
void | Update property details while the widget is open. |
BBK.updateCustomer(cust) |
void | Update customer pre-fill data while the widget is open. |
BBK.destroy() |
void | Completely destroy the SDK instance. Removes all DOM elements and event listeners. |
BBK.isInitialized() |
boolean | Returns true if init() has been called. |
BBK.isOpen() |
boolean | Returns true if the modal is currently open. |
BBK.version |
string | The SDK version string (e.g., '1.0.0'). |
BBK.open() with property override
Event Callbacks #
Register callbacks in the init() config to respond to widget events.
| Event | Payload | Description |
|---|---|---|
onReady |
none | Widget has fully loaded and is ready for user interaction. |
onCalculated |
result |
Customer completed the mortgage calculator step. |
onApplicationSubmitted |
result |
Customer submitted the mortgage application. |
onApproved |
result |
Application received pre-approval. |
onRejected |
result |
Application was rejected. Generic reason for compliance. |
onError |
error |
Widget encountered an error. See error codes table below. |
onClose |
none | Modal was closed (by user or programmatically). |
onCalculated Payload
onApplicationSubmitted Payload
Error Codes
| Code | Description | Suggested Action |
|---|---|---|
LOAD_TIMEOUT | Widget did not load within timeout | Check network, retry |
LOAD_ERROR | iFrame failed to load entirely | Check CSP, ad blockers |
VALIDATION_ERROR | Form validation failure | User corrects input |
API_ERROR | BBK backend returned an error | Retry or contact support |
SESSION_EXPIRED | Customer session timed out (15 min) | Re-open widget |
RATE_LIMITED | Too many requests from this session | Wait and retry |
MAINTENANCE | BBK systems under maintenance | Show maintenance message |
Theming #
Customize the widget to match your brand using the theme configuration object.
| Property | Type | Default | Description |
|---|---|---|---|
primaryColor |
string | '#1e3c72' |
Header, buttons, progress indicators, section titles. |
accentColor |
string | '#2a5298' |
Secondary buttons, hover states, input focus borders, badges. |
borderRadius |
string | '12px' |
Card and input border radius. |
fontFamily |
string | 'Inter, sans-serif' |
Font override for the widget. |
primaryColor and accentColor should meet WCAG 2.1 AA contrast ratio (4.5:1) against white text. The BBK default colors are already compliant.Rendering Modes #
Modal Mode (Default)
The widget opens as a centered overlay with a dark backdrop. Recommended for property listing pages where multiple properties each have a "Finance" button.
- Dark backdrop (
rgba(0,0,0,0.75)) - Centered card with max-width 740px
- Close on backdrop click, Escape key, or close button
- Body scroll locked while open
- Focus trapped within the modal for accessibility
Inline Mode
The widget renders directly inside a container element. Useful for dedicated mortgage pages where the calculator is a primary feature.
Code Examples #
Basic Integration
Minimal setup for a property listing page with multiple properties.
Modal with Button Trigger
Initialize once, open the modal with different properties each time.
React Component Wrapper
Programmatic with Analytics
Security #
API Keys
| Key Type | Format | Use |
|---|---|---|
| Public key | pk_live_* or pk_test_* |
Client-side SDK (safe to expose in HTML) |
| Secret key | sk_live_* or sk_test_* |
Server-side API calls only (webhooks, status queries) |
sk_* key. Secret keys must never appear in HTML source, JavaScript bundles, or browser developer tools.iFrame Sandbox
The widget runs inside a sandboxed iFrame with restricted permissions:
This prevents the widget from accessing the partner page's DOM, cookies, or localStorage. It cannot navigate the parent page or submit forms to arbitrary URLs.
postMessage Origin Validation
All communication between the SDK and widget uses postMessage with strict origin validation. The SDK only accepts messages from configured BBK environment domains:
- Sandbox:
https://sandbox-embed.bbk.com - Production:
https://embed.bbk.com
Messages from any other origin are silently dropped.
Content Security Policy
If your site uses CSP, add the following directives:
Data Handling
- Customer PII is transmitted directly to BBK servers via the iFrame. It never passes through the partner's domain.
- The SDK does not store any data in localStorage, sessionStorage, or cookies.
- Document uploads go directly to BBK's secure S3 storage via pre-signed URLs.
- The widget is PCI DSS compliant -- no sensitive financial data passes through the partner's domain.
Browser Support #
The SDK uses ES5 syntax for maximum compatibility. No transpilation or polyfills required.
FAQ #
BBK.init() once when your app mounts, and BBK.open() whenever you need the widget. Call BBK.destroy() when the component unmounts to clean up event listeners and DOM elements.BBK.open(property). Each call can use different property details without re-initializing the SDK.onError with code SESSION_EXPIRED. The customer can re-open the widget to start fresh. No data is lost on your side -- only the in-progress form within the widget resets.language: 'ar' in the config. The widget automatically switches to RTL layout with Arabic text, including all form labels, buttons, and result displays.customer config to reduce friction, and you can pre-fill property data to skip the property selection step.sdk.bbk.com which is not typically blocked by ad blockers. If a customer's ad blocker interferes, the onError callback fires with LOAD_ERROR. We recommend showing a fallback link to BBK's direct application page in this case.