@justifi/webcomponents 4.8.0 → 4.8.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/{Business-540a6feb.js → Business-42d0c522.js} +15 -1
- package/dist/cjs/{SubAccount-b9487cbb.js → SubAccount-2a803b22.js} +1 -1
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +1 -1
- package/dist/cjs/justifi-additional-questions_5.cjs.entry.js +3 -3
- package/dist/cjs/justifi-bank-account-form.cjs.entry.js +2 -1
- package/dist/cjs/justifi-billing-form_2.cjs.entry.js +3 -1
- package/dist/cjs/justifi-business-details.cjs.entry.js +1 -1
- package/dist/cjs/justifi-business-form-stepped.cjs.entry.js +1 -1
- package/dist/cjs/justifi-business-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-card-form.cjs.entry.js +2 -1
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-balance-transactions.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-form.cjs.entry.js +9 -36
- package/dist/cjs/justifi-payment-method-form.cjs.entry.js +81 -64
- package/dist/cjs/justifi-proceeds-list.cjs.entry.js +1 -1
- package/dist/cjs/justifi-subaccount-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-subaccounts-list.cjs.entry.js +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/payment-details-core.cjs.entry.js +1 -1
- package/dist/cjs/payments-list-core.cjs.entry.js +1 -1
- package/dist/cjs/payout-details-core.cjs.entry.js +1 -1
- package/dist/cjs/payouts-list-core.cjs.entry.js +1 -1
- package/dist/cjs/subaccount-account-details_4.cjs.entry.js +1 -1
- package/dist/cjs/{utils-36bf8b3e.js → utils-29a8a91d.js} +33 -1
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/api/Business.js +15 -1
- package/dist/collection/components/bank-account-form/bank-account-form.js +4 -2
- package/dist/collection/components/bank-account-form/test/bank-account-form.spec.js +9 -0
- package/dist/collection/components/business-details/legal-address-details/legal-address-details.js +4 -4
- package/dist/collection/components/business-form/business-form.js +1 -1
- package/dist/collection/components/business-form/business-generic-info/business-generic-info.js +1 -1
- package/dist/collection/components/business-form/legal-address-form/legal-address-form.js +1 -1
- package/dist/collection/components/card-form/card-form.js +4 -2
- package/dist/collection/components/card-form/test/card-form.spec.js +9 -0
- package/dist/collection/components/payment-form/payment-form.js +12 -83
- package/dist/collection/components/payment-form/payment-method-selector.js +2 -23
- package/dist/collection/components/payment-form/test/payment-form.spec.js +5 -18
- package/dist/collection/components/payment-method-form/payment-method-form.js +62 -72
- package/dist/collection/components/payment-method-form/test/payment-method-form.e2e.js +1 -1
- package/dist/collection/components/payment-method-form/test/payment-method-form.spec.js +123 -41
- package/dist/collection/utils/frame-comunication-service.js +32 -0
- package/dist/collection/utils/utils.js +31 -0
- package/dist/docs.json +50 -113
- package/dist/esm/{Business-1f5e9f6b.js → Business-e9340f6b.js} +15 -1
- package/dist/esm/{SubAccount-bd59f646.js → SubAccount-46b4c2b1.js} +1 -1
- package/dist/esm/additional-questions-details_5.entry.js +1 -1
- package/dist/esm/justifi-additional-questions_5.entry.js +3 -3
- package/dist/esm/justifi-bank-account-form.entry.js +2 -1
- package/dist/esm/justifi-billing-form_2.entry.js +3 -1
- package/dist/esm/justifi-business-details.entry.js +1 -1
- package/dist/esm/justifi-business-form-stepped.entry.js +1 -1
- package/dist/esm/justifi-business-form.entry.js +2 -2
- package/dist/esm/justifi-business-list.entry.js +2 -2
- package/dist/esm/justifi-card-form.entry.js +2 -1
- package/dist/esm/justifi-gross-payment-chart.entry.js +1 -1
- package/dist/esm/justifi-payment-balance-transactions.entry.js +1 -1
- package/dist/esm/justifi-payment-form.entry.js +9 -36
- package/dist/esm/justifi-payment-method-form.entry.js +81 -64
- package/dist/esm/justifi-proceeds-list.entry.js +1 -1
- package/dist/esm/justifi-subaccount-details.entry.js +2 -2
- package/dist/esm/justifi-subaccounts-list.entry.js +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/payment-details-core.entry.js +1 -1
- package/dist/esm/payments-list-core.entry.js +1 -1
- package/dist/esm/payout-details-core.entry.js +1 -1
- package/dist/esm/payouts-list-core.entry.js +1 -1
- package/dist/esm/subaccount-account-details_4.entry.js +1 -1
- package/dist/esm/{utils-dd428dba.js → utils-76a93600.js} +32 -1
- package/dist/esm/webcomponents.js +1 -1
- package/dist/module/Business.js +15 -1
- package/dist/module/SubAccount.js +1 -1
- package/dist/module/business-generic-info.js +1 -1
- package/dist/module/justifi-bank-account-form.js +2 -1
- package/dist/module/justifi-business-form.js +1 -1
- package/dist/module/justifi-card-form.js +2 -1
- package/dist/module/justifi-gross-payment-chart.js +1 -1
- package/dist/module/justifi-payment-balance-transactions.js +1 -1
- package/dist/module/justifi-payment-form.js +11 -42
- package/dist/module/justifi-subaccount-details.js +1 -1
- package/dist/module/legal-address-form.js +1 -1
- package/dist/module/payment-details-core2.js +1 -1
- package/dist/module/payment-method-form.js +81 -64
- package/dist/module/payment-method-selector.js +3 -2
- package/dist/module/payments-list-core2.js +1 -1
- package/dist/module/payout-details-core2.js +1 -1
- package/dist/module/payouts-list-core2.js +1 -1
- package/dist/module/utils2.js +32 -1
- package/dist/types/api/Business.d.ts +16 -3
- package/dist/types/components/bank-account-form/bank-account-form.d.ts +1 -1
- package/dist/types/components/business-details/legal-address-details/legal-address-details.d.ts +2 -2
- package/dist/types/components/business-form/business-form-schema.d.ts +1 -1
- package/dist/types/components/business-form/legal-address-form/legal-address-form.d.ts +2 -1
- package/dist/types/components/card-form/card-form.d.ts +1 -1
- package/dist/types/components/payment-form/payment-form.d.ts +1 -5
- package/dist/types/components/payment-form/payment-method-selector.d.ts +1 -1
- package/dist/types/components/payment-method-form/payment-method-form.d.ts +12 -12
- package/dist/types/components.d.ts +12 -17
- package/dist/types/utils/frame-comunication-service.d.ts +13 -0
- package/dist/types/utils/utils.d.ts +2 -0
- package/dist/webcomponents/{p-d66a6057.entry.js → p-08833966.entry.js} +1 -1
- package/dist/webcomponents/p-0bc8b02e.entry.js +1 -0
- package/dist/webcomponents/{p-f0c535ed.js → p-22c1acd6.js} +1 -1
- package/dist/webcomponents/p-234bc840.entry.js +1 -0
- package/dist/webcomponents/{p-8a90b976.entry.js → p-40349ffc.entry.js} +1 -1
- package/dist/webcomponents/{p-1cb65d15.entry.js → p-4e56ddad.entry.js} +1 -1
- package/dist/webcomponents/{p-0b9146cd.entry.js → p-4ee44c76.entry.js} +1 -1
- package/dist/webcomponents/{p-57e592ac.entry.js → p-5422a24b.entry.js} +1 -1
- package/dist/webcomponents/{p-876c7257.entry.js → p-578e0a05.entry.js} +1 -1
- package/dist/webcomponents/{p-50730e69.js → p-5c0310ee.js} +1 -1
- package/dist/webcomponents/p-640d90dc.entry.js +1 -0
- package/dist/webcomponents/p-6478f3ca.js +1 -0
- package/dist/webcomponents/p-696396c7.entry.js +1 -0
- package/dist/webcomponents/p-7a1a06c0.entry.js +1 -0
- package/dist/webcomponents/{p-5e142186.entry.js → p-8516d602.entry.js} +1 -1
- package/dist/webcomponents/{p-c0f882ce.entry.js → p-894a7475.entry.js} +1 -1
- package/dist/webcomponents/{p-896a9ddb.entry.js → p-94ebfafb.entry.js} +1 -1
- package/dist/webcomponents/{p-d71ce1cd.entry.js → p-9e81808f.entry.js} +1 -1
- package/dist/webcomponents/{p-2e318b6a.entry.js → p-a432110c.entry.js} +1 -1
- package/dist/webcomponents/{p-7dd83492.entry.js → p-a9dc1e2e.entry.js} +1 -1
- package/dist/webcomponents/{p-1b6ff0d3.entry.js → p-b1881723.entry.js} +1 -1
- package/dist/webcomponents/{p-19c5ddf1.entry.js → p-bfd917b8.entry.js} +1 -1
- package/dist/webcomponents/p-c90fa055.entry.js +1 -0
- package/dist/webcomponents/{p-34de1c5d.entry.js → p-ebb91944.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +3 -3
- package/dist/webcomponents/p-36618b59.entry.js +0 -1
- package/dist/webcomponents/p-57aab065.entry.js +0 -1
- package/dist/webcomponents/p-5f8b9f64.entry.js +0 -1
- package/dist/webcomponents/p-731cb109.entry.js +0 -1
- package/dist/webcomponents/p-88027949.js +0 -1
- package/dist/webcomponents/p-f7a3fd12.entry.js +0 -1
- package/dist/webcomponents/p-f9183f12.entry.js +0 -1
- /package/dist/collection/{components/payment-method-form → utils}/get-computed-theme.js +0 -0
- /package/dist/collection/{components/payment-method-form → utils}/theme.js +0 -0
- /package/dist/types/{components/payment-method-form → utils}/get-computed-theme.d.ts +0 -0
- /package/dist/types/{components/payment-method-form → utils}/theme.d.ts +0 -0
|
@@ -2,11 +2,15 @@ import { config } from "../../../../config";
|
|
|
2
2
|
import { h } from "@stencil/core";
|
|
3
3
|
import { newSpecPage } from "@stencil/core/testing";
|
|
4
4
|
import { PaymentMethodForm } from "../payment-method-form";
|
|
5
|
+
import { PaymentMethodTypes } from "../../../api";
|
|
6
|
+
import { FrameCommunicationService } from "../../../utils/frame-comunication-service";
|
|
7
|
+
import { MessageEventType } from "../message-event-types";
|
|
8
|
+
import packageJson from "../../../../package.json";
|
|
5
9
|
describe('justifi-payment-method-form', () => {
|
|
6
10
|
it('renders an iframe', async () => {
|
|
7
11
|
const page = await newSpecPage({
|
|
8
12
|
components: [PaymentMethodForm],
|
|
9
|
-
template: () => h("justifi-payment-method-form", { paymentMethodFormType:
|
|
13
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.card, iframeOrigin: config.iframeOrigin })),
|
|
10
14
|
});
|
|
11
15
|
expect(page.root).toEqualHtml(`
|
|
12
16
|
<justifi-payment-method-form>
|
|
@@ -14,70 +18,148 @@ describe('justifi-payment-method-form', () => {
|
|
|
14
18
|
</justifi-payment-method-form>
|
|
15
19
|
`);
|
|
16
20
|
});
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
describe('Test Props', () => {
|
|
22
|
+
it('renders a card iframe when paymentMethodFormType is card', async () => {
|
|
23
|
+
const page = await newSpecPage({
|
|
24
|
+
components: [PaymentMethodForm],
|
|
25
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.card, iframeOrigin: config.iframeOrigin })),
|
|
26
|
+
});
|
|
27
|
+
expect(page.root).toEqualHtml(`
|
|
23
28
|
<justifi-payment-method-form>
|
|
24
29
|
<iframe id='justifi-payment-method-form-card' src='${config.iframeOrigin}/card'></iframe>
|
|
25
30
|
</justifi-payment-method-form>
|
|
26
31
|
`);
|
|
27
|
-
});
|
|
28
|
-
it('renders a bank iframe when paymentMethodFormType is bank', async () => {
|
|
29
|
-
const page = await newSpecPage({
|
|
30
|
-
components: [PaymentMethodForm],
|
|
31
|
-
template: () => h("justifi-payment-method-form", { paymentMethodFormType: 'bankAccount' }),
|
|
32
32
|
});
|
|
33
|
-
|
|
33
|
+
it('renders a bank iframe when paymentMethodFormType is bank', async () => {
|
|
34
|
+
const page = await newSpecPage({
|
|
35
|
+
components: [PaymentMethodForm],
|
|
36
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.bankAccount, iframeOrigin: config.iframeOrigin })),
|
|
37
|
+
});
|
|
38
|
+
expect(page.root).toEqualHtml(`
|
|
34
39
|
<justifi-payment-method-form>
|
|
35
40
|
<iframe id='justifi-payment-method-form-bankAccount' src='${config.iframeOrigin}/bankAccount'></iframe>
|
|
36
41
|
</justifi-payment-method-form>
|
|
37
42
|
`);
|
|
38
|
-
});
|
|
39
|
-
it('renders a card iframe with validationMode when paymentMethodFormType is card and paymentMethodFormValidationMode is set', async () => {
|
|
40
|
-
const page = await newSpecPage({
|
|
41
|
-
components: [PaymentMethodForm],
|
|
42
|
-
template: () => h("justifi-payment-method-form", { paymentMethodFormType: 'bankAccount', paymentMethodFormValidationMode: 'onChange' }),
|
|
43
43
|
});
|
|
44
|
-
|
|
44
|
+
it('renders a card iframe with validationMode when paymentMethodFormType is card and paymentMethodFormValidationMode is set', async () => {
|
|
45
|
+
const page = await newSpecPage({
|
|
46
|
+
components: [PaymentMethodForm],
|
|
47
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.bankAccount, paymentMethodFormValidationMode: 'onChange', iframeOrigin: config.iframeOrigin })),
|
|
48
|
+
});
|
|
49
|
+
expect(page.root).toEqualHtml(`
|
|
45
50
|
<justifi-payment-method-form>
|
|
46
51
|
<iframe id='justifi-payment-method-form-bankAccount' src='${config.iframeOrigin}/bankAccount?validationMode=onChange'></iframe>
|
|
47
52
|
</justifi-payment-method-form>
|
|
48
53
|
`);
|
|
49
|
-
});
|
|
50
|
-
it('renders a card iframe with validationMode when paymentMethodFormType is card and paymentMethodFormValidationMode is set', async () => {
|
|
51
|
-
const page = await newSpecPage({
|
|
52
|
-
components: [PaymentMethodForm],
|
|
53
|
-
template: () => h("justifi-payment-method-form", { paymentMethodFormType: 'bankAccount', paymentMethodFormValidationMode: 'onBlur' }),
|
|
54
54
|
});
|
|
55
|
-
|
|
55
|
+
it('renders a card iframe with validationMode when paymentMethodFormType is card and paymentMethodFormValidationMode is set', async () => {
|
|
56
|
+
const page = await newSpecPage({
|
|
57
|
+
components: [PaymentMethodForm],
|
|
58
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.bankAccount, paymentMethodFormValidationMode: 'onBlur', iframeOrigin: config.iframeOrigin })),
|
|
59
|
+
});
|
|
60
|
+
expect(page.root).toEqualHtml(`
|
|
56
61
|
<justifi-payment-method-form>
|
|
57
62
|
<iframe id='justifi-payment-method-form-bankAccount' src='${config.iframeOrigin}/bankAccount?validationMode=onBlur'></iframe>
|
|
58
63
|
</justifi-payment-method-form>
|
|
59
64
|
`);
|
|
60
|
-
});
|
|
61
|
-
it('renders a card iframe with iframeOrigin when paymentMethodFormType is card and iframeOrigin is set', async () => {
|
|
62
|
-
const page = await newSpecPage({
|
|
63
|
-
components: [PaymentMethodForm],
|
|
64
|
-
template: () => h("justifi-payment-method-form", { paymentMethodFormType: 'card', iframeOrigin: '${config.iframeOrigin}' }),
|
|
65
65
|
});
|
|
66
|
-
|
|
66
|
+
it('renders a card iframe with singleLine when paymentMethodFormType is card and singleLine is set', async () => {
|
|
67
|
+
const page = await newSpecPage({
|
|
68
|
+
components: [PaymentMethodForm],
|
|
69
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.card, singleLine: true, iframeOrigin: config.iframeOrigin })),
|
|
70
|
+
});
|
|
71
|
+
expect(page.root).toEqualHtml(`
|
|
67
72
|
<justifi-payment-method-form>
|
|
68
|
-
<iframe id='justifi-payment-method-form-card' src='${config.iframeOrigin}/card'></iframe>
|
|
73
|
+
<iframe id='justifi-payment-method-form-card' src='${config.iframeOrigin}/card?singleLine=true'></iframe>
|
|
69
74
|
</justifi-payment-method-form>
|
|
70
75
|
`);
|
|
76
|
+
});
|
|
71
77
|
});
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
78
|
+
// Frame comunication service
|
|
79
|
+
describe('Frame Communication Service', () => {
|
|
80
|
+
it('removes message listener on disconnected callback', async () => {
|
|
81
|
+
const removeSpy = jest.spyOn(FrameCommunicationService.prototype, 'removeMessageListener');
|
|
82
|
+
const page = await newSpecPage({
|
|
83
|
+
components: [PaymentMethodForm],
|
|
84
|
+
template: () => h("justifi-payment-method-form", { iframeOrigin: config.iframeOrigin }),
|
|
85
|
+
});
|
|
86
|
+
// Manually set up the frameService to ensure it's available for the disconnectedCallback
|
|
87
|
+
page.rootInstance.frameService = new FrameCommunicationService(page.rootInstance.iframeElement, config.iframeOrigin);
|
|
88
|
+
page.rootInstance.frameService.addMessageListener(jest.fn()); // Add a dummy listener
|
|
89
|
+
// Manually call disconnectedCallback to simulate the component being removed
|
|
90
|
+
await page.rootInstance.disconnectedCallback();
|
|
91
|
+
// Check if removeMessageListener was called upon disconnection
|
|
92
|
+
expect(removeSpy).toHaveBeenCalled();
|
|
93
|
+
// Cleanup the spy
|
|
94
|
+
removeSpy.mockRestore();
|
|
95
|
+
});
|
|
96
|
+
});
|
|
97
|
+
// Event emission tests
|
|
98
|
+
describe('Event Emissions', () => {
|
|
99
|
+
it('emits paymentMethodFormReady when iframe sends ready event', async () => {
|
|
100
|
+
const page = await newSpecPage({
|
|
101
|
+
components: [PaymentMethodForm],
|
|
102
|
+
template: () => (h("justifi-payment-method-form", { paymentMethodFormType: PaymentMethodTypes.card, iframeOrigin: config.iframeOrigin })),
|
|
103
|
+
});
|
|
104
|
+
await page.waitForChanges();
|
|
105
|
+
const eventSpy = jest.fn();
|
|
106
|
+
page.win.addEventListener('paymentMethodFormReady', eventSpy);
|
|
107
|
+
// Ensure paymentMethodFormType is set and is a valid key in MessageEventType
|
|
108
|
+
const formType = page.rootInstance.paymentMethodFormType;
|
|
109
|
+
const eventType = MessageEventType[formType] ? MessageEventType[formType].ready : null;
|
|
110
|
+
if (!eventType) {
|
|
111
|
+
throw new Error(`Invalid paymentMethodFormType: ${formType}`);
|
|
112
|
+
}
|
|
113
|
+
const simulatedEventData = { eventType, data: {} };
|
|
114
|
+
page.rootInstance.dispatchMessageEvent({ data: simulatedEventData });
|
|
115
|
+
await page.waitForChanges();
|
|
116
|
+
expect(eventSpy).toHaveBeenCalled();
|
|
117
|
+
});
|
|
118
|
+
});
|
|
119
|
+
describe('Methods', () => {
|
|
120
|
+
it('calls postMessageWithResponseListener with correct parameters on tokenize', async () => {
|
|
121
|
+
// Mock the iframe and its contentWindow.postMessage
|
|
122
|
+
const mockPostMessage = jest.fn();
|
|
123
|
+
global.window = Object.create(window);
|
|
124
|
+
const url = "https://example.com";
|
|
125
|
+
Object.defineProperty(window, 'location', {
|
|
126
|
+
value: {
|
|
127
|
+
href: url,
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const mockedIframe = {
|
|
131
|
+
contentWindow: {
|
|
132
|
+
postMessage: mockPostMessage,
|
|
133
|
+
}
|
|
134
|
+
};
|
|
135
|
+
const page = await newSpecPage({
|
|
136
|
+
components: [PaymentMethodForm],
|
|
137
|
+
template: () => h("justifi-payment-method-form", { iframeOrigin: url, paymentMethodFormType: PaymentMethodTypes.card }),
|
|
138
|
+
});
|
|
139
|
+
// Assign the mocked iframe to the component instance
|
|
140
|
+
page.rootInstance.iframeElement = mockedIframe;
|
|
141
|
+
// Replace the frameService with a mock that includes a mocked postMessageWithResponseListener
|
|
142
|
+
page.rootInstance.frameService = {
|
|
143
|
+
postMessage: jest.fn(),
|
|
144
|
+
postMessageWithResponseListener: jest.fn().mockResolvedValue({
|
|
145
|
+
// Mock the expected resolution value if your component expects any
|
|
146
|
+
}),
|
|
147
|
+
addMessageListener: jest.fn(),
|
|
148
|
+
removeMessageListener: jest.fn(),
|
|
149
|
+
};
|
|
150
|
+
const clientId = 'test-client-id';
|
|
151
|
+
const paymentMethodMetadata = { key: 'value' };
|
|
152
|
+
const account = 'test-account';
|
|
153
|
+
// Call the tokenize method
|
|
154
|
+
await page.rootInstance.tokenize(clientId, paymentMethodMetadata, account);
|
|
155
|
+
// Verify postMessageWithResponseListener was called with the expected parameters
|
|
156
|
+
expect(page.rootInstance.frameService.postMessageWithResponseListener)
|
|
157
|
+
.toHaveBeenCalledWith(MessageEventType.card.tokenize, expect.objectContaining({
|
|
158
|
+
clientId,
|
|
159
|
+
paymentMethodMetadata,
|
|
160
|
+
account,
|
|
161
|
+
componentVersion: packageJson.version,
|
|
162
|
+
}));
|
|
76
163
|
});
|
|
77
|
-
expect(page.root).toEqualHtml(`
|
|
78
|
-
<justifi-payment-method-form>
|
|
79
|
-
<iframe id='justifi-payment-method-form-card' src='${config.iframeOrigin}/card?singleLine=true'></iframe>
|
|
80
|
-
</justifi-payment-method-form>
|
|
81
|
-
`);
|
|
82
164
|
});
|
|
83
165
|
});
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This approach decouples the communication logic from PaymentMethodForm component,
|
|
3
|
+
* making it cleaner, more maintainable, and easier to test
|
|
4
|
+
*/
|
|
5
|
+
export class FrameCommunicationService {
|
|
6
|
+
constructor(iframe, iframeOrigin) {
|
|
7
|
+
this.iframe = iframe;
|
|
8
|
+
this.iframeOrigin = iframeOrigin;
|
|
9
|
+
}
|
|
10
|
+
postMessage(eventType, payload) {
|
|
11
|
+
const message = Object.assign({ eventType }, payload);
|
|
12
|
+
this.iframe.contentWindow.postMessage(message, this.iframeOrigin);
|
|
13
|
+
}
|
|
14
|
+
addMessageListener(callback) {
|
|
15
|
+
window.addEventListener('message', callback);
|
|
16
|
+
}
|
|
17
|
+
removeMessageListener(callback) {
|
|
18
|
+
window.removeEventListener('message', callback);
|
|
19
|
+
}
|
|
20
|
+
postMessageWithResponseListener(eventType, payload) {
|
|
21
|
+
return new Promise((resolve) => {
|
|
22
|
+
const responseListener = (event) => {
|
|
23
|
+
if (event.data.eventType !== eventType)
|
|
24
|
+
return;
|
|
25
|
+
window.removeEventListener('message', responseListener);
|
|
26
|
+
resolve(event.data.data);
|
|
27
|
+
};
|
|
28
|
+
window.addEventListener('message', responseListener);
|
|
29
|
+
this.postMessage(eventType, payload);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -150,3 +150,34 @@ export function snakeCaseToHumanReadable(snakeCaseStr) {
|
|
|
150
150
|
.map(word => word.charAt(0).toUpperCase() + word.slice(1))
|
|
151
151
|
.join(' ');
|
|
152
152
|
}
|
|
153
|
+
export function composeQueryParams(values) {
|
|
154
|
+
const queryParams = values.map((value) => {
|
|
155
|
+
if (value === values[0]) {
|
|
156
|
+
return (value = `?${value}`);
|
|
157
|
+
}
|
|
158
|
+
else {
|
|
159
|
+
return (value = `&${value}`);
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return queryParams.join('');
|
|
163
|
+
}
|
|
164
|
+
export async function loadFontsOnParent() {
|
|
165
|
+
const parent = document.body;
|
|
166
|
+
const fontsToLoad = extractComputedFontsToLoad();
|
|
167
|
+
if (!parent || !fontsToLoad) {
|
|
168
|
+
return null;
|
|
169
|
+
}
|
|
170
|
+
// Construct the font URL
|
|
171
|
+
const fontHref = `https://fonts.googleapis.com/css2?family=${fontsToLoad}&display=swap`;
|
|
172
|
+
// Check if a link element with the same href already exists
|
|
173
|
+
const existingFontLink = Array.from(document.querySelectorAll('link')).find((link) => link.href === fontHref);
|
|
174
|
+
// If the font link already exists, there's no need to append a new one
|
|
175
|
+
if (existingFontLink) {
|
|
176
|
+
return;
|
|
177
|
+
}
|
|
178
|
+
// This approach is needed to load the font in a parent of the component
|
|
179
|
+
const fonts = document.createElement('link');
|
|
180
|
+
fonts.rel = 'stylesheet';
|
|
181
|
+
fonts.href = fontHref;
|
|
182
|
+
parent.append(fonts);
|
|
183
|
+
}
|
package/dist/docs.json
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
{
|
|
2
|
-
"timestamp": "2024-
|
|
2
|
+
"timestamp": "2024-03-07T18:05:31",
|
|
3
3
|
"compiler": {
|
|
4
4
|
"name": "@stencil/core",
|
|
5
5
|
"version": "4.10.0",
|
|
@@ -1447,6 +1447,7 @@
|
|
|
1447
1447
|
"reflectToAttr": false,
|
|
1448
1448
|
"docs": "URL for the rendered iFrame. End-users need not use this.",
|
|
1449
1449
|
"docsTags": [],
|
|
1450
|
+
"default": "config.iframeOrigin",
|
|
1450
1451
|
"values": [
|
|
1451
1452
|
{
|
|
1452
1453
|
"type": "string"
|
|
@@ -2826,6 +2827,7 @@
|
|
|
2826
2827
|
"reflectToAttr": false,
|
|
2827
2828
|
"docs": "URL for the rendered iFrame. End-users need not use this.",
|
|
2828
2829
|
"docsTags": [],
|
|
2830
|
+
"default": "config.iframeOrigin",
|
|
2829
2831
|
"values": [
|
|
2830
2832
|
{
|
|
2831
2833
|
"type": "string"
|
|
@@ -3613,6 +3615,7 @@
|
|
|
3613
3615
|
"reflectToAttr": false,
|
|
3614
3616
|
"docs": "",
|
|
3615
3617
|
"docsTags": [],
|
|
3618
|
+
"default": "true",
|
|
3616
3619
|
"values": [
|
|
3617
3620
|
{
|
|
3618
3621
|
"type": "boolean"
|
|
@@ -3663,27 +3666,6 @@
|
|
|
3663
3666
|
"optional": true,
|
|
3664
3667
|
"required": false
|
|
3665
3668
|
},
|
|
3666
|
-
{
|
|
3667
|
-
"name": "iframeOrigin",
|
|
3668
|
-
"type": "string",
|
|
3669
|
-
"complexType": {
|
|
3670
|
-
"original": "string",
|
|
3671
|
-
"resolved": "string",
|
|
3672
|
-
"references": {}
|
|
3673
|
-
},
|
|
3674
|
-
"mutable": false,
|
|
3675
|
-
"attr": "iframe-origin",
|
|
3676
|
-
"reflectToAttr": false,
|
|
3677
|
-
"docs": "",
|
|
3678
|
-
"docsTags": [],
|
|
3679
|
-
"values": [
|
|
3680
|
-
{
|
|
3681
|
-
"type": "string"
|
|
3682
|
-
}
|
|
3683
|
-
],
|
|
3684
|
-
"optional": true,
|
|
3685
|
-
"required": false
|
|
3686
|
-
},
|
|
3687
3669
|
{
|
|
3688
3670
|
"name": "submitButtonText",
|
|
3689
3671
|
"type": "string",
|
|
@@ -3767,28 +3749,6 @@
|
|
|
3767
3749
|
],
|
|
3768
3750
|
"docs": "",
|
|
3769
3751
|
"docsTags": []
|
|
3770
|
-
},
|
|
3771
|
-
{
|
|
3772
|
-
"name": "loadFontsOnParent",
|
|
3773
|
-
"returns": {
|
|
3774
|
-
"type": "Promise<any>",
|
|
3775
|
-
"docs": ""
|
|
3776
|
-
},
|
|
3777
|
-
"complexType": {
|
|
3778
|
-
"signature": "() => Promise<any>",
|
|
3779
|
-
"parameters": [],
|
|
3780
|
-
"references": {
|
|
3781
|
-
"Promise": {
|
|
3782
|
-
"location": "global",
|
|
3783
|
-
"id": "global::Promise"
|
|
3784
|
-
}
|
|
3785
|
-
},
|
|
3786
|
-
"return": "Promise<any>"
|
|
3787
|
-
},
|
|
3788
|
-
"signature": "loadFontsOnParent() => Promise<any>",
|
|
3789
|
-
"parameters": [],
|
|
3790
|
-
"docs": "",
|
|
3791
|
-
"docsTags": []
|
|
3792
3752
|
}
|
|
3793
3753
|
],
|
|
3794
3754
|
"events": [
|
|
@@ -3813,13 +3773,7 @@
|
|
|
3813
3773
|
"docsTags": []
|
|
3814
3774
|
}
|
|
3815
3775
|
],
|
|
3816
|
-
"listeners": [
|
|
3817
|
-
{
|
|
3818
|
-
"event": "paymentMethodSelected",
|
|
3819
|
-
"capture": false,
|
|
3820
|
-
"passive": false
|
|
3821
|
-
}
|
|
3822
|
-
],
|
|
3776
|
+
"listeners": [],
|
|
3823
3777
|
"styles": [],
|
|
3824
3778
|
"slots": [],
|
|
3825
3779
|
"parts": [],
|
|
@@ -3868,16 +3822,22 @@
|
|
|
3868
3822
|
"type": "string"
|
|
3869
3823
|
}
|
|
3870
3824
|
],
|
|
3871
|
-
"optional":
|
|
3825
|
+
"optional": false,
|
|
3872
3826
|
"required": false
|
|
3873
3827
|
},
|
|
3874
3828
|
{
|
|
3875
3829
|
"name": "paymentMethodFormType",
|
|
3876
|
-
"type": "
|
|
3830
|
+
"type": "PaymentMethodTypes.bankAccount | PaymentMethodTypes.card",
|
|
3877
3831
|
"complexType": {
|
|
3878
|
-
"original": "
|
|
3879
|
-
"resolved": "
|
|
3880
|
-
"references": {
|
|
3832
|
+
"original": "PaymentMethodTypes",
|
|
3833
|
+
"resolved": "PaymentMethodTypes.bankAccount | PaymentMethodTypes.card",
|
|
3834
|
+
"references": {
|
|
3835
|
+
"PaymentMethodTypes": {
|
|
3836
|
+
"location": "import",
|
|
3837
|
+
"path": "../../api",
|
|
3838
|
+
"id": "src/api/index.ts::PaymentMethodTypes"
|
|
3839
|
+
}
|
|
3840
|
+
}
|
|
3881
3841
|
},
|
|
3882
3842
|
"mutable": false,
|
|
3883
3843
|
"attr": "payment-method-form-type",
|
|
@@ -3886,12 +3846,10 @@
|
|
|
3886
3846
|
"docsTags": [],
|
|
3887
3847
|
"values": [
|
|
3888
3848
|
{
|
|
3889
|
-
"
|
|
3890
|
-
"type": "string"
|
|
3849
|
+
"type": "PaymentMethodTypes.bankAccount"
|
|
3891
3850
|
},
|
|
3892
3851
|
{
|
|
3893
|
-
"
|
|
3894
|
-
"type": "string"
|
|
3852
|
+
"type": "PaymentMethodTypes.card"
|
|
3895
3853
|
}
|
|
3896
3854
|
],
|
|
3897
3855
|
"optional": false,
|
|
@@ -3961,11 +3919,11 @@
|
|
|
3961
3919
|
{
|
|
3962
3920
|
"name": "resize",
|
|
3963
3921
|
"returns": {
|
|
3964
|
-
"type": "Promise<
|
|
3922
|
+
"type": "Promise<void>",
|
|
3965
3923
|
"docs": ""
|
|
3966
3924
|
},
|
|
3967
3925
|
"complexType": {
|
|
3968
|
-
"signature": "() => Promise<
|
|
3926
|
+
"signature": "() => Promise<void>",
|
|
3969
3927
|
"parameters": [],
|
|
3970
3928
|
"references": {
|
|
3971
3929
|
"Promise": {
|
|
@@ -3973,9 +3931,9 @@
|
|
|
3973
3931
|
"id": "global::Promise"
|
|
3974
3932
|
}
|
|
3975
3933
|
},
|
|
3976
|
-
"return": "Promise<
|
|
3934
|
+
"return": "Promise<void>"
|
|
3977
3935
|
},
|
|
3978
|
-
"signature": "resize() => Promise<
|
|
3936
|
+
"signature": "resize() => Promise<void>",
|
|
3979
3937
|
"parameters": [],
|
|
3980
3938
|
"docs": "",
|
|
3981
3939
|
"docsTags": []
|
|
@@ -4065,11 +4023,11 @@
|
|
|
4065
4023
|
"events": [
|
|
4066
4024
|
{
|
|
4067
4025
|
"event": "paymentMethodFormReady",
|
|
4068
|
-
"detail": "
|
|
4026
|
+
"detail": "void",
|
|
4069
4027
|
"bubbles": true,
|
|
4070
4028
|
"complexType": {
|
|
4071
|
-
"original": "
|
|
4072
|
-
"resolved": "
|
|
4029
|
+
"original": "void",
|
|
4030
|
+
"resolved": "void",
|
|
4073
4031
|
"references": {}
|
|
4074
4032
|
},
|
|
4075
4033
|
"cancelable": true,
|
|
@@ -4079,12 +4037,18 @@
|
|
|
4079
4037
|
},
|
|
4080
4038
|
{
|
|
4081
4039
|
"event": "paymentMethodFormTokenized",
|
|
4082
|
-
"detail": "
|
|
4040
|
+
"detail": "BankAccountCreateResponse | CardCreateResponse | PaymentMethodErrorResponse",
|
|
4083
4041
|
"bubbles": true,
|
|
4084
4042
|
"complexType": {
|
|
4085
|
-
"original": "
|
|
4086
|
-
"resolved": "
|
|
4087
|
-
"references": {
|
|
4043
|
+
"original": "CreatePaymentMethodResponse",
|
|
4044
|
+
"resolved": "BankAccountCreateResponse | CardCreateResponse | PaymentMethodErrorResponse",
|
|
4045
|
+
"references": {
|
|
4046
|
+
"CreatePaymentMethodResponse": {
|
|
4047
|
+
"location": "import",
|
|
4048
|
+
"path": "./payment-method-responses",
|
|
4049
|
+
"id": "src/components/payment-method-form/payment-method-responses.ts::CreatePaymentMethodResponse"
|
|
4050
|
+
}
|
|
4051
|
+
}
|
|
4088
4052
|
},
|
|
4089
4053
|
"cancelable": true,
|
|
4090
4054
|
"composed": true,
|
|
@@ -4137,33 +4101,6 @@
|
|
|
4137
4101
|
"docsTags": [],
|
|
4138
4102
|
"usage": {},
|
|
4139
4103
|
"props": [
|
|
4140
|
-
{
|
|
4141
|
-
"name": "paymentMethodTypes",
|
|
4142
|
-
"type": "PaymentMethodTypes[]",
|
|
4143
|
-
"complexType": {
|
|
4144
|
-
"original": "PaymentMethodTypes[]",
|
|
4145
|
-
"resolved": "PaymentMethodTypes[]",
|
|
4146
|
-
"references": {
|
|
4147
|
-
"PaymentMethodTypes": {
|
|
4148
|
-
"location": "import",
|
|
4149
|
-
"path": "../../api",
|
|
4150
|
-
"id": "src/api/index.ts::PaymentMethodTypes"
|
|
4151
|
-
}
|
|
4152
|
-
}
|
|
4153
|
-
},
|
|
4154
|
-
"mutable": false,
|
|
4155
|
-
"reflectToAttr": false,
|
|
4156
|
-
"docs": "",
|
|
4157
|
-
"docsTags": [],
|
|
4158
|
-
"default": "[]",
|
|
4159
|
-
"values": [
|
|
4160
|
-
{
|
|
4161
|
-
"type": "PaymentMethodTypes[]"
|
|
4162
|
-
}
|
|
4163
|
-
],
|
|
4164
|
-
"optional": false,
|
|
4165
|
-
"required": false
|
|
4166
|
-
},
|
|
4167
4104
|
{
|
|
4168
4105
|
"name": "selectedPaymentMethodType",
|
|
4169
4106
|
"type": "PaymentMethodTypes.bankAccount | PaymentMethodTypes.card",
|
|
@@ -5404,15 +5341,15 @@
|
|
|
5404
5341
|
"props": [
|
|
5405
5342
|
{
|
|
5406
5343
|
"name": "legalAddress",
|
|
5407
|
-
"type": "
|
|
5344
|
+
"type": "IAddress",
|
|
5408
5345
|
"complexType": {
|
|
5409
|
-
"original": "
|
|
5410
|
-
"resolved": "
|
|
5346
|
+
"original": "IAddress",
|
|
5347
|
+
"resolved": "IAddress",
|
|
5411
5348
|
"references": {
|
|
5412
|
-
"
|
|
5349
|
+
"IAddress": {
|
|
5413
5350
|
"location": "import",
|
|
5414
5351
|
"path": "../../../api/Business",
|
|
5415
|
-
"id": "src/api/Business.ts::
|
|
5352
|
+
"id": "src/api/Business.ts::IAddress"
|
|
5416
5353
|
}
|
|
5417
5354
|
}
|
|
5418
5355
|
},
|
|
@@ -5422,7 +5359,7 @@
|
|
|
5422
5359
|
"docsTags": [],
|
|
5423
5360
|
"values": [
|
|
5424
5361
|
{
|
|
5425
|
-
"type": "
|
|
5362
|
+
"type": "IAddress"
|
|
5426
5363
|
}
|
|
5427
5364
|
],
|
|
5428
5365
|
"optional": false,
|
|
@@ -6576,6 +6513,11 @@
|
|
|
6576
6513
|
"docstring": "",
|
|
6577
6514
|
"path": "src/components/payment-method-form/payment-method-responses.ts"
|
|
6578
6515
|
},
|
|
6516
|
+
"src/api/index.ts::PaymentMethodTypes": {
|
|
6517
|
+
"declaration": "any",
|
|
6518
|
+
"docstring": "",
|
|
6519
|
+
"path": "src/api/index.ts"
|
|
6520
|
+
},
|
|
6579
6521
|
"src/components/billing-form/billing-form-schema.ts::BillingFormFields": {
|
|
6580
6522
|
"declaration": "export interface BillingFormFields {\n name: string;\n address_line1: string;\n address_line2?: string;\n address_city: string;\n address_state: string;\n address_postal_code: string;\n}",
|
|
6581
6523
|
"docstring": "",
|
|
@@ -6592,17 +6534,17 @@
|
|
|
6592
6534
|
"path": "src/api/Business.ts"
|
|
6593
6535
|
},
|
|
6594
6536
|
"src/api/Business.ts::IBusiness": {
|
|
6595
|
-
"declaration": "export interface IBusiness {\n additional_questions: AdditionalQuestions | {};\n business_structure: BusinessStructure;\n business_type: BusinessType;\n bank_accounts: BankAccount[];\n created_at: string;\n documents: Document[];\n doing_business_as: string;\n email: string;\n id: string;\n industry: string;\n legal_address:
|
|
6537
|
+
"declaration": "export interface IBusiness {\n additional_questions: AdditionalQuestions | {};\n business_structure: BusinessStructure;\n business_type: BusinessType;\n bank_accounts: BankAccount[];\n created_at: string;\n documents: Document[];\n doing_business_as: string;\n email: string;\n id: string;\n industry: string;\n legal_address: IAddress | {};\n legal_name: string;\n metadata: any;\n owners: Identity[];\n phone: string;\n platform_account_id: string;\n product_categories: ProductCategories;\n representative: Identity | {};\n tax_id: string;\n updated_at: string;\n website_url: string;\n}",
|
|
6596
6538
|
"docstring": "",
|
|
6597
6539
|
"path": "src/api/Business.ts"
|
|
6598
6540
|
},
|
|
6599
|
-
"src/api/Business.ts::
|
|
6600
|
-
"declaration": "export interface
|
|
6541
|
+
"src/api/Business.ts::IAddress": {
|
|
6542
|
+
"declaration": "export interface IAddress {\n id?: string;\n platform_account_id?: string;\n line1?: string;\n line2?: string;\n postal_code?: string;\n city?: string;\n state?: string;\n country?: string;\n created_at?: string;\n updated_at?: string;\n}",
|
|
6601
6543
|
"docstring": "",
|
|
6602
6544
|
"path": "src/api/Business.ts"
|
|
6603
6545
|
},
|
|
6604
6546
|
"src/api/Business.ts::Identity": {
|
|
6605
|
-
"declaration": "export interface Identity {\n address?:
|
|
6547
|
+
"declaration": "export interface Identity {\n address?: IAddress;\n created_at?: string;\n dob_day?: string;\n dob_month?: string;\n dob_year?: string;\n documents?: Document[];\n email?: string;\n id?: string;\n is_owner?: boolean;\n metadata?: any;\n name?: string;\n phone?: string;\n platform_account_id?: string;\n ssn_last4?: string;\n title?: string;\n updated_at?: string;\n}",
|
|
6606
6548
|
"docstring": "",
|
|
6607
6549
|
"path": "src/api/Business.ts"
|
|
6608
6550
|
},
|
|
@@ -6611,11 +6553,6 @@
|
|
|
6611
6553
|
"docstring": "",
|
|
6612
6554
|
"path": "src/components/form/form.ts"
|
|
6613
6555
|
},
|
|
6614
|
-
"src/api/index.ts::PaymentMethodTypes": {
|
|
6615
|
-
"declaration": "any",
|
|
6616
|
-
"docstring": "",
|
|
6617
|
-
"path": "src/api/index.ts"
|
|
6618
|
-
},
|
|
6619
6556
|
"src/api/index.ts::Payment": {
|
|
6620
6557
|
"declaration": "any",
|
|
6621
6558
|
"docstring": "",
|
|
@@ -21,6 +21,20 @@ var BusinessType;
|
|
|
21
21
|
BusinessType["non_profit"] = "non_profit";
|
|
22
22
|
BusinessType["government_entity"] = "government_entity";
|
|
23
23
|
})(BusinessType || (BusinessType = {}));
|
|
24
|
+
class Address {
|
|
25
|
+
constructor(address) {
|
|
26
|
+
this.id = address.id;
|
|
27
|
+
this.platform_account_id = address.platform_account_id;
|
|
28
|
+
this.line1 = address.line1;
|
|
29
|
+
this.line2 = address.line2;
|
|
30
|
+
this.postal_code = address.postal_code;
|
|
31
|
+
this.city = address.city;
|
|
32
|
+
this.state = address.state;
|
|
33
|
+
this.country = address.country || 'USA';
|
|
34
|
+
this.created_at = address.created_at;
|
|
35
|
+
this.updated_at = address.updated_at;
|
|
36
|
+
}
|
|
37
|
+
}
|
|
24
38
|
class CoreBusinessInfo {
|
|
25
39
|
constructor(coreBusinessInfo) {
|
|
26
40
|
this.business_structure = coreBusinessInfo.business_structure;
|
|
@@ -54,7 +68,7 @@ class Business {
|
|
|
54
68
|
this.website_url = business.website_url;
|
|
55
69
|
this.product_categories = business.product_categories;
|
|
56
70
|
// Form sections
|
|
57
|
-
this.legal_address = business.legal_address || {
|
|
71
|
+
this.legal_address = Object.assign({}, new Address(business.legal_address || {}));
|
|
58
72
|
this.representative = business.representative || {};
|
|
59
73
|
this.additional_questions = business.additional_questions || {};
|
|
60
74
|
this.owners = business.owners;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as formatPercentage, a as formatCurrency, f as formatDate, c as formatTime } from './utils-
|
|
1
|
+
import { d as formatPercentage, a as formatCurrency, f as formatDate, c as formatTime } from './utils-76a93600.js';
|
|
2
2
|
|
|
3
3
|
var TagTypes;
|
|
4
4
|
(function (TagTypes) {
|