SDK Integration
Supported currencies: AUD & USD.
The JavaScript SDK allows you to securely accept card payments in your checkout flow with a few lines of code. This guide covers setup, initialization, payment creation, callback handling.
๐ง Environmentsโ
| Environment | Script URL |
|---|---|
| Sandbox | https://cdn.lightningpay.me/media/getkollo-sdk/1.1.0/sandbox/getkollo.js |
| Production | https://cdn.lightningpay.me/media/getkollo-sdk/1.1.0/prod/getkollo.js |
๐ View Demo Website
โ Integration Stepsโ
Step 1: Register Your App ID & Domainโ
- Contact the Hello Clever team to register your domain and receive your
app_id.
Step 2: Include SDK Script in Checkout Pageโ
<script
src="https://cdn.lightningpay.me/media/getkollo-sdk/1.1.0/sandbox/getkollo.js"
async
></script>
Step 3: Add Mount Element in HTMLโ
<div class="get-kollo"></div>
This is where the payment iframe will be injected. It must exist before calling createPayment().
Step 4: Initialize SDK and Create Paymentโ
async function createGetKollo() {
const getKolloSDK = new GetKollo({
app_id: "your-app-id",
});
const init = await getKolloSDK.initialize();
if (!init?.success) return alert(init?.error);
const order = {
external_id: "order-001",
customer_name: "John Doe",
customer_email: "john_doe@gmail.com",
amount: 1000,
currency: "USD",
return_url: "https://yourdomain.com/success",
payment_type: "regular"
};
const options = {
mountElement: ".get-kollo",
styleProps: {
frame: {
width: "100%",
height: "100%"
}
}
};
const resp = await getKolloSDK.createPayment(order, options);
if (!resp?.success) return alert(resp?.error);
window.getkolloCardCallback = (message) => {
if (message?.status !== "succeeded") {
alert(message?.error);
}
};
}
๐งพ SDK Configuration Referenceโ
GetKollo({ app_id })โ
app_id: Your unique application identifier (required)
const getKolloSDK = new GetKollo({
app_id: [YOUR_APP_ID],
});
const init = await getKolloSDK.initialize();
createPayment(order, options)โ
๐งพ order (required)โ
| Field | Type | Required | Description |
|---|---|---|---|
external_id | string | โ | Unique identifier for the order |
customer_name | string | โ | Name of the customer |
customer_email | string | โ | Email of the customer |
amount | number | โ | Transaction amount in cents |
currency | string | โ | "USD" or "AUD" |
return_url | string | โ | URL to redirect after success/failure |
payment_type | enum | โ | The type of payment. One of regular | unscheduled. Default: regular. |
โ๏ธ options (required)โ
| Field | Type | Required | Description |
|---|---|---|---|
mountElement | string | โ | CSS selector for mounting the iframe |
styleProps.frame.width | string | โ | Width of iframe (default: 500px) |
styleProps.frame.height | string | โ | Height of iframe (default: 500px) |
paymentButton | enum | โ | Default: 'iframe'. - 'iframe': use default payment button inside the iframe. - 'external': allows you to use your own custom button outside the iframe. In this case, you must trigger the payment by calling getKolloSDK.onSubmit() function when the button is clicked. |
events | object | โ | Event handlers: - onReady(): Triggered when the payment form is fully loaded and ready for user input. - onLoading(boolean): Used to manage the loading state of your external button. |
const order = {
external_id: [EXTERNAL_ID],
customer_name: [CUSTOMER_NAME],
customer_email: [CUSTOMER_EMAIL],
amount: [ORDER_AMOUNT],
currency: [CURRENCY], // USD or AUD
return_url: [RETURN_URL], // optional redirect URL
payment_type: "regular", // optional: "regular" | "unscheduled"
};
const options = {
mountElement: ".get-kollo", // Element classname or ID
styleProps: {
frame: {
width: "100%",
height: "100%",
},
},
paymentButton: "iframe",
// Event handlers
events: {
// Triggered when the payment form is fully loaded and ready for user input.
onReady: () => {
console.log("โ
Event: Payframe is ready.");
},
// paymentButton: 'external' - Used to manage the loading state of your external button.
onLoading: (isLoading: boolean) => {
console.log(`๐ Event: Payframe loading state: ${isLoading}`);
},
}
};
const resp = await getKolloSDK.createPayment(order, options);
onSubmit(payload)โ
Use this to handle form submission when paymentButton is set to external.
๐งพ payload (required)โ
| Field | Type | Required | Description |
|---|---|---|---|
country | string | โ | Two-letter country code (ISO 3166-1 alpha-2). |
postalCode | string | โ | Required if the country is US, GB, or CA. |
Example 1 โ With required postalCode (US, GB, CA)โ
const payload = {
country: "GB",
postalCode: "SW1A 1AA" // Required for US, GB, CA
}
getKolloSDK.onSubmit(payload)
Example 2 โ Without postalCode (other countries)โ
const payload = { country: "VN" } // postalCode not required
getKolloSDK.onSubmit(payload)
Listener Payment statusโ
After the payment is submitted, or if the card form fails to render, the SDK will trigger:
window.getkolloCardCallback = (response) => {
if (response?.status !== "succeeded") {
// If the card form fails to render in 7s, the SDK provides an error code.
if (response?.error?.code === 'card_init_timeout') {
// Handle rendering timeout.
} else {
alert(response?.error?.message);
}
}
};
Response Fields
| Field | Description |
|---|---|
status | "succeeded" or "failed" |
error | An error object (message, code). Ex: The "card_init_timeout" code indicates the card form failed to render. |
order | Order object as provided in the SDK call |
type | "callback" |