diff --git a/index.html b/index.html
new file mode 100644
index 0000000..bf1dc70
--- /dev/null
+++ b/index.html
@@ -0,0 +1,92 @@
+
+
+
+
+
+
+ Document
+
+
+
+ Partner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/legal-component.html b/legal-component.html
new file mode 100644
index 0000000..f3da16a
--- /dev/null
+++ b/legal-component.html
@@ -0,0 +1,37 @@
+
+
+
+
+
+
+ Document
+
+
+
+
+ Partner
+
+
+
+
+
diff --git a/partner.html b/partner.html
new file mode 100644
index 0000000..58121e6
--- /dev/null
+++ b/partner.html
@@ -0,0 +1,112 @@
+
+
+
+
+
+
+ Document
+
+
+
+ Partner
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/src/core/event-name.enum.ts b/src/core/event-name.enum.ts
index 45ed4c4..17d36cb 100644
--- a/src/core/event-name.enum.ts
+++ b/src/core/event-name.enum.ts
@@ -28,4 +28,6 @@ export const enum EventName {
finishLoadComponent = 'finishLoadComponent',
getFormStatus = 'getFormStatus',
applePayError = 'applePayError',
+ openApplePayPage = 'openApplePayPage',
+ submitApplePayForm = 'submitApplePayForm',
}
diff --git a/src/core/guards/apple-pay/open-apple-pay-page.guard.spec.ts b/src/core/guards/apple-pay/open-apple-pay-page.guard.spec.ts
new file mode 100644
index 0000000..3dfd458
--- /dev/null
+++ b/src/core/guards/apple-pay/open-apple-pay-page.guard.spec.ts
@@ -0,0 +1,14 @@
+import 'reflect-metadata';
+import { EventName } from '../../event-name.enum';
+import { isOpenApplePayPageEventMessage } from './open-apple-pay-page.guard';
+
+describe('Event message type guard', () => {
+ it('Should return true', () => {
+ expect(
+ isOpenApplePayPageEventMessage({ name: EventName.openApplePayPage })
+ ).toBeTruthy();
+ });
+ it('Should return false', () => {
+ expect(isOpenApplePayPageEventMessage({})).toBeFalsy();
+ });
+});
diff --git a/src/core/guards/apple-pay/open-apple-pay-page.guard.ts b/src/core/guards/apple-pay/open-apple-pay-page.guard.ts
new file mode 100644
index 0000000..b62dc0c
--- /dev/null
+++ b/src/core/guards/apple-pay/open-apple-pay-page.guard.ts
@@ -0,0 +1,12 @@
+import { Message } from '../../message.interface';
+import { isEventMessage } from '../event-message.guard';
+import { EventName } from '../../event-name.enum';
+
+export const isOpenApplePayPageEventMessage = (
+ messageData: unknown
+): messageData is Message<{ redirectUrl: string } | null | undefined> => {
+ if (isEventMessage(messageData)) {
+ return messageData.name === EventName.openApplePayPage;
+ }
+ return false;
+};
diff --git a/src/features/headless-checkout/headless-checkout.spec.ts b/src/features/headless-checkout/headless-checkout.spec.ts
index 90a9fb7..31b67e1 100644
--- a/src/features/headless-checkout/headless-checkout.spec.ts
+++ b/src/features/headless-checkout/headless-checkout.spec.ts
@@ -8,6 +8,7 @@ import { LocalizeService } from '../../core/i18n/localize.service';
import { getFinanceDetailsHandler } from './post-messages-handlers/get-finance-details.handler';
import { FormStatus } from '../../core/status/form-status.enum';
import { noopStub } from '../../tests/stubs/noop.stub';
+import { headlessCheckoutAppUrl } from './environment';
const mockMessage: Message = {
name: EventName.initPayment,
@@ -19,7 +20,6 @@ const mockHandler: Handler = (): null => {
};
class MockIframeElement {
- public src = '';
public width = '';
public height = '';
public style = { border: '' };
@@ -46,6 +46,13 @@ describe('HeadlessCheckout', () => {
beforeEach(() => {
windowService = window;
+ spyOn(windowService, 'addEventListener').and.callFake(
+ (name: string, handlerWrapper: EventListenerOrEventListenerObject) => {
+ (handlerWrapper as (message: MessageEvent) => void)({
+ origin: headlessCheckoutAppUrl,
+ } as MessageEvent);
+ }
+ );
postMessagesClient = {
init: stub,
send: stub,
@@ -75,9 +82,8 @@ describe('HeadlessCheckout', () => {
const spy = spyOn(postMessagesClient, 'init');
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement,
+ () => new MockIframeElement() as unknown as HTMLIFrameElement
);
-
await headlessCheckout.init({ isWebview: false });
expect(spy).toHaveBeenCalled();
});
@@ -85,7 +91,7 @@ describe('HeadlessCheckout', () => {
it('Should init localization', () => {
const localizeSpy = spyOn(
localizeService,
- 'initDictionaries',
+ 'initDictionaries'
).and.resolveTo();
void headlessCheckout.init({ isWebview: false });
@@ -104,7 +110,7 @@ describe('HeadlessCheckout', () => {
headlessCheckout.events.onCoreEvent(
EventName.initPayment,
mockHandler,
- stub,
+ stub
);
expect(spy).toHaveBeenCalled();
});
@@ -113,7 +119,7 @@ describe('HeadlessCheckout', () => {
const spy = spyOn(postMessagesClient, 'listen');
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement,
+ () => new MockIframeElement() as unknown as HTMLIFrameElement
);
await headlessCheckout.init({ isWebview: false });
@@ -145,7 +151,7 @@ describe('HeadlessCheckout', () => {
await headlessCheckout.getFinanceDetails();
expect(spy).toHaveBeenCalledWith(
{ name: EventName.financeDetails },
- getFinanceDetailsHandler,
+ getFinanceDetailsHandler
);
});
@@ -166,7 +172,7 @@ describe('HeadlessCheckout', () => {
spyOn(windowService.customElements, 'get').and.returnValue(undefined);
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement,
+ () => new MockIframeElement() as unknown as HTMLIFrameElement
);
await headlessCheckout.init({ isWebview: false });
@@ -175,11 +181,11 @@ describe('HeadlessCheckout', () => {
it('Should web components not be redefined', async () => {
spyOn(windowService.customElements, 'get').and.returnValue(
- CustomElementMock,
+ CustomElementMock
);
spyOn(windowService.document.body, 'appendChild');
spyOn(windowService.document, 'createElement').and.callFake(
- () => new MockIframeElement() as unknown as HTMLIFrameElement,
+ () => new MockIframeElement() as unknown as HTMLIFrameElement
);
const spy = spyOn(window.customElements, 'define');
diff --git a/src/features/headless-checkout/headless-checkout.ts b/src/features/headless-checkout/headless-checkout.ts
index 60ebdc0..6be3e24 100644
--- a/src/features/headless-checkout/headless-checkout.ts
+++ b/src/features/headless-checkout/headless-checkout.ts
@@ -68,6 +68,7 @@ export class HeadlessCheckout {
* @returns {Form} form details
*/
init: async (configuration: FormConfiguration): Promise