UNPKG

@tamara-solution/checkout

Version:

Script will be embedded in merchant's site to checkout. The merchant's don't need to redirect to tamara's site.

35 lines (28 loc) 856 B
import { isObject, isFunction } from '@/helpers/type' import isBrowser from '@/helpers/is-browser' import CheckoutFrame from '@/helpers/frame-v1' let instance = null function initInstance() { const checkoutFrame = new CheckoutFrame() if (isObject(window.tamaraCKOConfig)) { const namespace = window.tamaraCKOConfig.namespace || 'TamaraCheckoutFrame' window[namespace] = checkoutFrame window[namespace].init(window.tamaraCKOConfig) if (isFunction(window.tamaraCKOConfig.init)) { window.tamaraCKOConfig.init() } } else { window['TamaraCheckoutFrame'] = checkoutFrame } } if (isBrowser()) { if (document.body !== null) { initInstance() } else { // Trigger init instance after onload window.addEventListener('DOMContentLoaded', function () { initInstance() }) } } export default instance