import { Inject, Injectable, } from '@angular/core'; import { BrandSettingsInterface, } from './../../../models/index'; import { CurrentEnvironmentService, } from './../../services/index'; import { KiteCheckout, KiteCheckoutSdk, } from '@kite-tech/checkout-sdk'; @Injectable() export class KiteCheckoutService { private _checkout: KiteCheckoutSdk; constructor( @Inject('brandSettings') private _brandSettings: BrandSettingsInterface, private _currentEnvironmentService: CurrentEnvironmentService, ) {} public initCheckout() { const isProduction = this._currentEnvironmentService.isProduction(); this._checkout = KiteCheckout( isProduction ? this._brandSettings.publishableKey : this._brandSettings.testPublishableKey, isProduction, ); } public get checkout() { if (!this._checkout) { this.initCheckout(); } return this._checkout; } }