For demo, please visit https://checkout.kontempo.io/demo/sdk
Add the code snippet below to your website page, generally before the closing </head>
tag.
This code snippet is used to load Kontempo Checkout SDK for using its functions in your website.
<!-- Kontempo Checkout SDK - Installation Code Snippet -->
<script>
(function (w, d, s, o, f, u, js, fjs) {
w[o] = w[o] || function () { (w[o].q = w[o].q || []).push(arguments) };
js = d.createElement(s), fjs = d.getElementsByTagName(s)[0];
u = u || ''; w[o].u = u;
js.src = (u || '') + '/sdk/' + f + '.js'; js.async = 1;
fjs.parentNode.insertBefore(js, fjs);
}(window, document, 'script', 'Kontempo', 'v1', 'https://checkout.kontempo.io'));
</script>
In order to start a checkout session, you need to prepare Checkout Options object.
The Checkout Options need the following data specified:
merchantAccount
(required): merchant accountorder
(required): order data
referenceId
(required): external order idtotalAmount
(required): order total amountsummary
(optional): order summary, to give buyer more details about your ordervar MERCHANT_ACCOUNT = 'mer_xxxxxxxxxx.xxxx'; // required
var ORDER_ID = 'order id'; // required
var ORDER_TOTAL = 123.45; // required
var ORDER_SUMMARY = 'order summary'; // optional
var checkoutOptions = {
merchantAccount: MERCHANT_ACCOUNT,
order: {
referenceId: ORDER_ID,
totalAmount: ORDER_TOTAL,
summary: ORDER_SUMMARY,
},
}
Hosted Checkout is Komtempo built-in checkout app, located at https://checkout.kontempo.io.
Using this mode, the SDK will open https://checkout.kontempo.io in a new tab with the data from specified Checkout Options. Buyer then perform their checkout directly on Kontempo Hosted Checkout app.
To start a Hosted Checkout session, use the following code snippet.
Kontempo('sdk_v1.ready', function (sdk) {
sdk.initHostedCheckout(checkoutOptions);
});
If you want to place the Checkout UI directly in your website inside a modal / popup, you can use Modal Checkout mode.
To start a Modal Checkout session, use the following code snippet.
Kontempo('sdk_v1.ready', function (sdk) {
// start modal checkout session
var instance = sdk.initModalCheckout(checkoutOptions, {
onCancel: function () {
instance.destroy(); // destroy the instance
}
});
});
You can customize Modal Checkout UI further by using following config options.
const overlayOptions = {
// specify CSS z-index property of the modal
zIndex: 1,
// specify custom color of modal backdrop
backdropColor: 'rgba(0, 0, 0, 0.5)',
}
Kontempo('sdk_v1.ready', function (sdk) {
var instance = sdk.initModalCheckout(checkoutOptions, {
// optional - modal overlay options
overlay: overlayOptions,
// optional - callback when checkout canceled
onCancel: function () {
alert('Checkout Canceled!');
},
// optional - callback when checkout successfully completed
onComplete: function (data) {
console.log('Checkout Data:', data);
console.log('Order ID:', data.orderId);
alert('Checkout Completed!');
},
// optional - callback when error occurred
onError: function (data) {
console.log('Checkout Error Code:', data.code);
alert('Checkout Error!');
},
});
});
If you want to place the Checkout UI directly in your website in specific area / element, you can use Inline Checkout mode.
To start an Inline Checkout session, use the following code snippet.
// get the container element from your page
const containerElement = document.getElementById('checkout_ui_container_element');
Kontempo('sdk_v1.ready', function (sdk) {
// start inline checkout session
var instance = sdk.initInlineCheckout(checkoutOptions, {
element: containerElement,
onCancel: function () {
// destroy the instance - only unbind events
instance.destroy();
// destroy the instance - also remove the checkout UI
instance.destroy({ removeIframe: true });
// destroy the instance - also remove the container element
instance.destroy({ removeIframe: true, removeElement: true });
}
});
});
You can customize Inline Checkout UI further by using following config options.
const configOptions = {
// specify default language to display in case the SKD failed to detect language from browser settings
// supported value: 'es' (for Spanish) | 'en' (for English)
defaultLanguage: 'es',
// force specific language to display
// supported value: 'es' (for Spanish) | 'en' (for English)
language: 'es',
// whether to show header or not
// supported values: true (show header) | false (hide header)
showHeader: true,
// whether to show language menu or not
// supported values: true (show language menu) | false (hide language menu)
showLanguageMenu: true,
}
Kontempo('sdk_v1.ready', function (sdk) {
var instance = sdk.initInlineCheckout(checkoutOptions, {
element: containerElement,
// optional - additional config options
config: configOptions,
// optional - callback when checkout canceled
onCancel: function () {
alert('Checkout Canceled!');
},
// optional - callback when checkout successfully completed
onComplete: function (data) {
console.log('Checkout Data:', data);
console.log('Order ID:', data.orderId);
alert('Checkout Completed!');
},
// optional - callback when error occurred
onError: function (data) {
console.log('Checkout Error Code:', data.code);
alert('Checkout Error!');
},
});
});
onComplete(data)
data.orderId
: Kontempo’s Internal Order ID.data.orderData.referenceId
: External Order IDdata.orderData.totalAmount
: Order Total Amountdata.orderData.summary
: Order Summary (if provided)onError(data)
data.code
:
data.login_type
:
phone_number
or email
.login.send_verification_code_error
, login.resend_verification_code_error
, login.verification_code_incorrect
, login.verify_verification_code_error
.login.phone_number_invalid
: triggered on login, when buyer submitted a phone number with invalid format.login.phone_number_not_found
: triggered on login, when buyer submitted a phone number that is not found in Kontempo system.login.email_invalid
: triggered on login, when buyer submitted an email with invalid format.login.email_not_found
: triggered on login, when buyer submitted an email that is not found in Kontempo system.login.user_disabled
: triggered on login, when the user is currently disabled.login.send_verification_code_error
: triggered on login, when error occurred during sending verification code to the phone number or the email.login.resend_verification_code_error
: triggered on login, when error occurred during re-sending verification code to the phone number or the email (when buyer selected re-send verification code option).login.verification_code_incorrect
: triggered on login, when buyer submitted an incorrect verification code.login.verify_verification_code_error
: triggered on login, when error occurred during verifying the verification code submitted by buyer.order_confirmation.error
: triggered when error occurred during order confirmation.Copyright © Kontempo.io