📝 Changelog
v3.44.0
Feature: Added buttonType prop for structured styling and buttonBorder option
v3.43.0
Feature: Added installation guide and url's to documentation
v3.42.0
Feature: Added comprehensive documentation with live demos and enhanced styling
v3.41.1-hotfix
Fix: Restored backwards compatibility for numeric values in sizing properties
v3.41.0
Feature: Implemented enhanced sizing system with support for multiple CSS units
📦 Installation
To use the KonekButtonV1 component in your project, include the SDK script in your HTML page's
<head> section:
Environment URLs:
Non-Production:
<script defer type="module" src="https://sdk.fit1.konek.dev/konek-sdk/konek-sdk.esm.js"></script>
Production:
<script defer type="module" src="https://sdk.konek.ca/konek-sdk/konek-sdk.esm.js"></script>
Complete HTML Example:
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1.0" /> <title>My Konek Integration</title> <!-- Include Konek SDK (choose appropriate environment) --> <script defer type="module" src="https://sdk.konek.ca/konek-sdk/konek-sdk.esm.js"></script> </head> <body> <!-- Use the component anywhere in your page --> <konek-button-v1></konek-button-v1> </body> </html>
🚀 Live Demo
📋 Properties
| Property | Type | Default | Description |
|---|---|---|---|
locales |
string |
'en-CA' |
Language locale ('en-CA' or 'fr-CA') |
button-type |
'black-yellow' | 'yellow-black' | 'black-white' | 'white-black' |
'black-yellow' |
Button styling theme (background and logo color) |
button-border |
boolean |
false |
Adds a solid 1px border (#0F1019) to the button |
height |
string |
'48px' |
Height of the button |
width |
string |
'100%' |
Width of the button |
border-radius |
string |
'5px' |
Border radius of the button |
color DEPRECATED |
string |
'black' |
Background color of the button (use button-type instead) |
text-color DEPRECATED |
'black-magenta' | 'white-white' | 'white-magenta' | null |
null |
Explicit logo color override (use button-type instead) |
show-cart |
boolean |
false |
When true, displays the cart in the Konek checkout |
show-embedded |
boolean |
false |
When true, and localstorage passkeyEnabled is true then displays the embedded checkout |
🎯 Enhanced Unit Handling
Smart CSS Unit Processing
The component now intelligently handles CSS units with the improved addPxIfNeeded() method:
- Numeric values: Automatically adds 'px' (e.g., "48" → "48px")
- Decimal values: Supports decimals (e.g., "48.5" → "48.5px")
- Existing units: Preserves existing units (e.g., "2em", "100%", "1.5rem")
Examples:
<konek-button-v1 height="48"></konek-button-v1> <konek-button-v1 height="48px"></konek-button-v1> <konek-button-v1 height="3em"></konek-button-v1> <konek-button-v1 width="100%"></konek-button-v1> <konek-button-v1 height="2.5rem"></konek-button-v1>
🎨 Button Type System
The component uses a structured buttonType system for consistent styling:
Button Types:
'black-yellow' (default)
'yellow-black'
'black-white'
'white-black'
With Border Option:
button-border="true"
⚡ Events
As a merchant integration, these are the events you should listen to on
<konek-button-v1>: click, konekSuccess,
konekError, and shippingOptions.
Merchant Guidance
- On click: create consent and call
setConsentData()with your backend response. - On konekSuccess: if payload is
konekCompleted, create order/checkout and redirect. - On konekError: show user feedback and offer retry when appropriate.
- On shippingOptions: respond using
updateShippingOption()orupdateShippingConsent().
Event Reference
| Event | Payload | Description & Purpose |
|---|---|---|
click |
Native click event detail from the web component click emitter. | The user initiates the checkout journey by clicking the Konek button, indicating intent to start the purchase flow. |
konekSuccess |
"konekLoaded" |
Konek checkout has loaded successfully, allowing the user to continue with checkout. |
"konekCompleted" |
Authorization was successful and the user was able to finish the checkout process and completed their purchase. | |
konekError |
"konekError" |
An issue occurred during checkout that prevented the user from continuing with the flow (service or network issue). Show an error message and allow the customer to retry. |
"konekLoadError" |
The checkout experience failed to load, or Konek did not receive consent details from the Merchant. | |
"konekClosed" |
The user exited the checkout experience before completing the purchase, leaving the flow unfinished. | |
"konekCancelled" |
The user had to cancel the checkout flow as they could not continue with the purchase (authorization failed). Return the user to the cart and provide an option to restart the flow. | |
"popupBlocked" |
The checkout pop‑up was blocked by the browser or was closed before it could fully open, preventing checkout from starting. | |
shippingOptions |
{ type: "requestOptions", request_id, postal_code, is_rural_postal_code?, correlation_id, locales }
|
Konek is requesting available shipping options for the customer's address.
Respond with a list of ShippingOption objects via updateShippingOption(),
passing the same request_id.
|
{ type: "selectedOption", request_id, shipping_option_id }
|
Customer has selected a shipping option in the Konek checkout.
Confirm the selection via updateShippingConsent(), passing the same
request_id.
|
🌍 Locale Validation
The component validates the locales property and automatically defaults to 'en-CA'
if an invalid locale is provided.
Supported locales:
'en-CA'(English - Canada)'fr-CA'(French - Canada)
Invalid locales trigger an error log and reset to the default.
💻 Advanced Usage Examples
Basic Usage:
<!-- Basic usage --> <konek-button-v1></konek-button-v1> <!-- With custom properties --> <konek-button-v1 locales="fr-CA" button-type="white-black" button-border="true" height="60px" width="200px" border-radius="8px" text-color="black-magenta"> </konek-button-v1> <!-- With cart enabled --> <konek-button-v1 show-cart="true" color="black" height="48px"> </konek-button-v1>
Payment Flow Breakdown:
🔄 Complete Payment Process
- Click: Generate consent → Open Konek overlay → Start payment flow
- Success: Payment completed → Create checkout → Redirect to order page
- Error: Handle payment failures → Display error details
- shippingOptions: Handle shipping options updates → Display updated options
Event Handling Implementation:
const konekButton = document.querySelector('konek-button-v1') as KonekButtonElement;
// Handle button click - start payment flow
konekButton.addEventListener('click', async () => {
if (!konekButton.client) {
console.error('Konek client not available');
return;
}
try {
// Generate consent and show overlay
const consent = // Create the Consent Data Object
konekButton.client.addOverlay(); // Add the overlay
// Submit consent to API
const consentResponse = await fetch.post(`MARCHANT_BACKEND`, consent);
konekButton.client.setConsentData(consentResponse.data); // Set consent data in the client
} catch (error) {
konekButton.client.setConsentError({
error: 'createConsentFailed',
details: error,
});
console.error('Consent error:', error);
}
});
// Handle successful payment
konekButton.addEventListener('konekSuccess', async (event: Event) => {
const customEvent = event as CustomEvent<string>;
if (customEvent.detail === 'konekCompleted') {
try {
// Create checkout and redirect
const checkoutData = {
consentId: konekButton.client.consentId,
correlationId: konekButton.client.correlationId,
};
const checkoutResponse = await axios.post(`MARCHANT_BACKEND`, checkoutData);
window.location.href = `/orders/${checkoutResponse.data.orderId}`; // Redirect to order page
} catch (error) {
console.error('Checkout creation failed:', error);
}
}
});
// Handle payment errors
konekButton.addEventListener('konekError', (event: Event) => {
const customEvent = event as CustomEvent<KonekErrorEventDetail>;
console.error('Konek error:', customEvent.detail);
if (konekButton.client) {
konekButton.client.setConsentError({
error: customEvent.detail?.error || 'konekErrorEvent',
details: customEvent.detail,
});
}
});
konekv1.addEventListener('shippingOptions', event => {
if(event.detail.type === "selectedOption") {
// Update the Shipping Consent with the selected shipping option.
// If just passing request_id with no data or error, it will be considered as consent update successful.
const updateShippingConsentResponseSuccess = {
request_id: event.detail.request_id,
}
// If just passing request_id with with error, it will be considered as consent update failed.
const updateShippingConsentResponseFailure = {
request_id: event.detail.request_id,
error: {
code: "Timeout",
message:"The merchant failed to respond with the selected shipping option in time.",
retry: true
}
}
konekv1.client.updateShippingConsent(updateShippingConsentResponseSuccess);
} else if(event.detail.type === "requestOptions") {
// Generate shipping options to be presented to the user.
// Response object when shipping options are successfully generated and returned to the user.
const shippingOptionsResponse = {
request_id: event.detail.request_id,
data: [
{
shipping_option_id: crypto.randomUUID(),
name: "Standard Delivery",
description: "3–5 business days",
shipping_cost: 0,
category: "Delivery"
},
{
shipping_option_id: crypto.randomUUID(),
name: "Express Delivery",
description: "1–2 business days",
shipping_cost: 5,
category: "Delivery"
}
]
}
// Response object when there is an error generating or returning shipping options to the user.
const shippingOptionsResponse = {
request_id: event.detail.request_id,
error: {
code: "Timeout",
message:"The merchant failed to respond with shipping options in time."
retry: true
}
}
konekv1.client.updateShippingOption(shippingOptionsResponse);
}
})
🔧 Browser Compatibility
Built with Stencil, this component works in all modern browsers and can be used with any framework or vanilla JavaScript.