Skip to content

Commit

Permalink
Merge pull request #65 from xsolla/PAYMENTS-17871
Browse files Browse the repository at this point in the history
feat(PAYMENTS-17871) fix: remove isMobile from initial params
  • Loading branch information
ekireevxs authored Mar 14, 2024
2 parents e729e31 + 089703d commit ffeb389
Showing 1 changed file with 16 additions and 19 deletions.
35 changes: 16 additions & 19 deletions src/features/headless-checkout/headless-checkout.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class HeadlessCheckout {
onCoreEvent: <T>(
eventName: EventName,
handler: Handler<T>,
callback: (value?: T) => void
callback: (value?: T) => void,
): (() => void) => {
return this.postMessagesClient.listen(eventName, handler, callback);
},
Expand Down Expand Up @@ -85,7 +85,7 @@ export class HeadlessCheckout {
}
this.formSpy.formWasInit = true;
this.formStatus = FormStatus.active;
})
}),
) as Promise<Form>;
},

Expand All @@ -97,12 +97,12 @@ export class HeadlessCheckout {
if (nextAction) {
callbackFn(nextAction);
}
}
},
);
},

onFieldsStatusChange: (
callbackFn: (fieldsStatus: FormFieldsStatus) => void
callbackFn: (fieldsStatus: FormFieldsStatus) => void,
): void => {
this.postMessagesClient.listen<FormFieldsStatus>(
EventName.formFieldsStatusChanged,
Expand All @@ -111,7 +111,7 @@ export class HeadlessCheckout {
if (fieldsStatus) {
callbackFn(fieldsStatus);
}
}
},
);
},

Expand All @@ -129,14 +129,14 @@ export class HeadlessCheckout {
this.formStatus = FormStatus.active;
},
};

public get formConfiguration(): FormConfiguration | undefined {
return this._formConfiguration;
}

private formStatus: FormStatus = FormStatus.undefined;
private isWebView?: boolean;
private isSandbox?: boolean;
private isMobile!: boolean;
private coreIframe!: HTMLIFrameElement;
private errorsSubscription?: () => void;
private readonly headlessAppUrl = headlessCheckoutAppUrl;
Expand All @@ -147,17 +147,15 @@ export class HeadlessCheckout {
private readonly postMessagesClient: PostMessagesClient,
private readonly localizeService: LocalizeService,
private readonly headlessCheckoutSpy: HeadlessCheckoutSpy,
private readonly formSpy: FormSpy
private readonly formSpy: FormSpy,
) {}

public async init(environment: {
isWebview?: boolean;
sandbox?: boolean;
isMobile?: boolean;
}): Promise<void> {
this.isWebView = environment.isWebview;
this.isSandbox = environment.sandbox;
this.isMobile = !!environment.isMobile;

await this.localizeService.initDictionaries();

Expand All @@ -171,7 +169,7 @@ export class HeadlessCheckout {
getErrorHandler,
(error) => {
throw new Error(error);
}
},
);
}

Expand All @@ -192,15 +190,14 @@ export class HeadlessCheckout {
token,
isWebView: this.isWebView,
sandbox: this.isSandbox,
isMobile: this.isMobile,
},
},
};

return this.postMessagesClient.send<void>(msg, (message) =>
setTokenHandler(message, () => {
this.headlessCheckoutSpy.appWasInit = true;
})
}),
);
}

Expand All @@ -210,7 +207,7 @@ export class HeadlessCheckout {
name: EventName.setSecureComponentStyles,
data: styles,
},
setSecureComponentStylesHandler
setSecureComponentStylesHandler,
);
}

Expand All @@ -225,7 +222,7 @@ export class HeadlessCheckout {

return this.postMessagesClient.send<FinanceDetails | null>(
msg,
getFinanceDetailsHandler
getFinanceDetailsHandler,
) as Promise<FinanceDetails | null>;
}

Expand All @@ -249,7 +246,7 @@ export class HeadlessCheckout {

return this.postMessagesClient.send<PaymentMethod[]>(
msg,
getRegularMethodsHandler
getRegularMethodsHandler,
) as Promise<PaymentMethod[]>;
}

Expand All @@ -269,7 +266,7 @@ export class HeadlessCheckout {

return this.postMessagesClient.send<PaymentMethod[]>(
msg,
getQuickMethodsHandler
getQuickMethodsHandler,
) as Promise<PaymentMethod[]>;
}

Expand All @@ -280,7 +277,7 @@ export class HeadlessCheckout {

return this.postMessagesClient.send<SavedMethod[]>(
msg,
getSavedMethodsHandler
getSavedMethodsHandler,
) as Promise<SavedMethod[]>;
}

Expand All @@ -291,7 +288,7 @@ export class HeadlessCheckout {

return this.postMessagesClient.send<UserBalance>(
msg,
getUserBalanceHandler
getUserBalanceHandler,
) as Promise<UserBalance>;
}

Expand All @@ -304,7 +301,7 @@ export class HeadlessCheckout {
};

return this.postMessagesClient.send<Status>(msg, (message) =>
getPaymentStatusHandler(message)
getPaymentStatusHandler(message),
) as Promise<Status>;
}

Expand Down

0 comments on commit ffeb389

Please sign in to comment.