diff --git a/package.json b/package.json index f169cad..8538d95 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@xsolla/pay-station-sdk", - "version": "0.0.22", + "version": "0.0.23", "description": "Pay Station SDK", "main": "dist/main.js", "types": "dist/index.d.ts", diff --git a/src/features/headless-checkout/headless-checkout.ts b/src/features/headless-checkout/headless-checkout.ts index 1d56eb2..d402f3e 100644 --- a/src/features/headless-checkout/headless-checkout.ts +++ b/src/features/headless-checkout/headless-checkout.ts @@ -34,11 +34,11 @@ import { FormFieldsStatus } from '../../core/form/form-fields-status.interface'; import { getCombinedPaymentMethodsHandler } from './post-messages-handlers/get-combined-payment-methods.handler'; import { CombinedPaymentMethods } from '../../core/combined-payment-methods.interface'; import { ThemesLoader } from '../../core/customization/themes-loader'; -import { Themes } from '../../core/customization/themes.type'; import { Lang } from '../../core/i18n/lang.enum'; import { getCountryListHandler } from './post-messages-handlers/get-country-list.handler'; import { CountryResponse } from '../../core/country-response.interface'; import { FormLoader } from '../../core/form/form-loader'; +import { InitialOptions } from './initial-options.interface'; @singleton() export class HeadlessCheckout { @@ -165,12 +165,7 @@ export class HeadlessCheckout { private readonly formLoader: FormLoader, ) {} - public async init(environment: { - isWebview?: boolean; - sandbox?: boolean; - theme?: Themes; - language?: Lang; - }): Promise { + public async init(environment: InitialOptions): Promise { this.isWebView = environment.isWebview; this.isSandbox = environment.sandbox; this.theme = environment.theme; @@ -249,6 +244,20 @@ export class HeadlessCheckout { ) as Promise; } + public onUpdateFinanceDetails( + callbackFn: (financeDetails: FinanceDetails) => void, + ): void { + this.postMessagesClient.listen( + EventName.financeDetails, + getFinanceDetailsHandler, + (financeDetails) => { + if (financeDetails) { + callbackFn(financeDetails); + } + }, + ); + } + /** * Returns available payment methods except quick methods * @param country Country that quick methods should be loaded for. diff --git a/src/features/headless-checkout/initial-options.interface.ts b/src/features/headless-checkout/initial-options.interface.ts new file mode 100644 index 0000000..b5f7023 --- /dev/null +++ b/src/features/headless-checkout/initial-options.interface.ts @@ -0,0 +1,9 @@ +import { Themes } from '../../core/customization/themes.type'; +import { Lang } from '../../core/i18n/lang.enum'; + +export interface InitialOptions { + isWebview?: boolean; + sandbox?: boolean; + theme?: Themes; + language?: Lang; +} diff --git a/src/index.ts b/src/index.ts index 45a2f20..8428b2a 100644 --- a/src/index.ts +++ b/src/index.ts @@ -6,3 +6,5 @@ export * from './web-components'; export { Lang } from './core/i18n/lang.enum'; export { EventName } from './core/event-name.enum'; export { NextActionType } from './core/actions/next-action-type.enum'; +export { FinanceDetails } from './core/finance-details/finance-details.interface'; +export { InitialOptions } from './features/headless-checkout/initial-options.interface';