import { Inject, Injectable, } from '@angular/core'; import { KiteCheckoutInterface, } from './../../../models/index'; import { CurrentEnvironmentService, GeneralBrandService, } from './../../services/index'; @Injectable() export default class KiteCheckoutService { private _checkout: KiteCheckoutInterface; constructor( @Inject('window') private _window: Window, private _generalBrandService: GeneralBrandService, private _currentEnvironmentService: CurrentEnvironmentService, ) {} public initCheckout() { this._checkout = ( this._window as any ).KiteCheckout( this._currentEnvironmentService.isProduction() ? this._generalBrandService.getBrandSettings() .publishableKey : this._generalBrandService.getBrandSettings() .testPublishableKey, ); } public get checkout(): KiteCheckoutInterface { if (!this._checkout) { this.initCheckout(); } return this._checkout; } }