Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(PAYMENTS-17871) fix: remove isMobile from initial params #65

Merged
merged 1 commit into from
Mar 14, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading