@justifi/webcomponents 4.19.3-rc-1 → 4.19.3-rc-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/{Analytics-84cccd4a.js → Analytics-adc90fc6.js} +1 -1
- package/dist/cjs/justifi-bank-account-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-business-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-card-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-checkout-core.cjs.entry.js +2 -1
- package/dist/cjs/justifi-checkout.cjs.entry.js +2 -2
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +2 -2
- package/dist/cjs/justifi-new-payment-method_4.cjs.entry.js +4 -1
- package/dist/cjs/justifi-payment-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-method-form.cjs.entry.js +1 -1
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payments-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payout-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +2 -2
- package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +2 -2
- package/dist/cjs/{package-d2e04416.js → package-22d30c5d.js} +1 -1
- package/dist/collection/components/checkout/checkout-core.js +2 -1
- package/dist/collection/components/checkout/new-payment-method.js +4 -1
- package/dist/docs.json +1 -1
- package/dist/esm/{Analytics-a742f6d2.js → Analytics-a8eb7344.js} +1 -1
- package/dist/esm/justifi-bank-account-form.entry.js +2 -2
- package/dist/esm/justifi-business-details.entry.js +2 -2
- package/dist/esm/justifi-business-form.entry.js +2 -2
- package/dist/esm/justifi-card-form.entry.js +2 -2
- package/dist/esm/justifi-checkout-core.entry.js +2 -1
- package/dist/esm/justifi-checkout.entry.js +2 -2
- package/dist/esm/justifi-gross-payment-chart.entry.js +2 -2
- package/dist/esm/justifi-new-payment-method_4.entry.js +4 -1
- package/dist/esm/justifi-payment-details.entry.js +2 -2
- package/dist/esm/justifi-payment-form.entry.js +2 -2
- package/dist/esm/justifi-payment-method-form.entry.js +1 -1
- package/dist/esm/justifi-payment-provisioning.entry.js +2 -2
- package/dist/esm/justifi-payments-list.entry.js +2 -2
- package/dist/esm/justifi-payout-details.entry.js +2 -2
- package/dist/esm/justifi-payouts-list.entry.js +2 -2
- package/dist/esm/justifi-season-interruption-insurance.entry.js +2 -2
- package/dist/esm/{package-a70c900f.js → package-ccb774a9.js} +1 -1
- package/dist/module/checkout-core.js +2 -1
- package/dist/module/new-payment-method.js +4 -1
- package/dist/module/package.js +1 -1
- package/dist/types/components/checkout/new-payment-method.d.ts +1 -0
- package/dist/webcomponents/index.esm.js +1 -0
- package/dist/webcomponents/p-01a404ca.entry.js +44 -0
- package/dist/webcomponents/p-03d35880.entry.js +130 -0
- package/dist/webcomponents/p-06ff0429.entry.js +65 -0
- package/dist/webcomponents/p-08b0fb31.js +41 -1
- package/dist/webcomponents/p-0e1bc91e.js +28 -1
- package/dist/webcomponents/p-10875f3d.entry.js +97 -0
- package/dist/webcomponents/p-14c91ffd.js +20 -1
- package/dist/webcomponents/p-157acba8.entry.js +98 -0
- package/dist/webcomponents/p-15eafa87.js +77 -0
- package/dist/webcomponents/p-18fa0479.entry.js +131 -0
- package/dist/webcomponents/p-1a5120f4.entry.js +145 -0
- package/dist/webcomponents/p-1ad5995e.js +3599 -1
- package/dist/webcomponents/p-1ff8810b.js +29 -1
- package/dist/webcomponents/p-2338affa.js +213 -1
- package/dist/webcomponents/p-24dc023a.entry.js +791 -0
- package/dist/webcomponents/p-25d8cd65.entry.js +102 -0
- package/dist/webcomponents/p-27d87fe2.entry.js +133 -0
- package/dist/webcomponents/p-29c0b182.js +114 -1
- package/dist/webcomponents/p-2b6c9c4f.js +7 -1
- package/dist/webcomponents/p-2e8f4937.js +79 -0
- package/dist/webcomponents/p-2eab3c90.js +3052 -1
- package/dist/webcomponents/p-3395e896.entry.js +74 -0
- package/dist/webcomponents/p-3fd13ca3.js +52 -1
- package/dist/webcomponents/p-47d79529.js +18 -1
- package/dist/webcomponents/p-525db3e8.js +22 -1
- package/dist/webcomponents/p-53ecc8b9.entry.js +261 -0
- package/dist/webcomponents/p-5482d030.entry.js +21 -0
- package/dist/webcomponents/p-56f6ce4c.js +10 -1
- package/dist/webcomponents/p-576826b1.entry.js +43 -0
- package/dist/webcomponents/p-5968ff8a.js +178 -1
- package/dist/webcomponents/p-5f835b89.entry.js +606 -0
- package/dist/webcomponents/p-6078a370.js +244 -1
- package/dist/webcomponents/p-6124b1b3.entry.js +80 -0
- package/dist/webcomponents/p-70a2aa74.entry.js +76 -0
- package/dist/webcomponents/p-7582b554.entry.js +18 -0
- package/dist/webcomponents/p-75fd6367.entry.js +149 -0
- package/dist/webcomponents/p-79646550.entry.js +61 -0
- package/dist/webcomponents/p-7d85af5c.js +16 -1
- package/dist/webcomponents/p-800d31fe.entry.js +162 -0
- package/dist/webcomponents/p-8115b2f4.js +28 -1
- package/dist/webcomponents/p-83125497.js +4027 -1
- package/dist/webcomponents/p-85fc69e5.js +90 -1
- package/dist/webcomponents/p-89887332.js +301 -1
- package/dist/webcomponents/p-8df7bde8.js +27 -1
- package/dist/webcomponents/p-8eb774df.entry.js +54 -0
- package/dist/webcomponents/p-9c9c7dac.js +24 -1
- package/dist/webcomponents/p-9e17630d.entry.js +1684 -0
- package/dist/webcomponents/p-9f94bbb6.entry.js +118 -0
- package/dist/webcomponents/p-a4e8573e.entry.js +94 -0
- package/dist/webcomponents/p-a5a225d9.entry.js +125 -0
- package/dist/webcomponents/p-a5fb51dc.entry.js +131 -0
- package/dist/webcomponents/p-ab4816e1.entry.js +117 -0
- package/dist/webcomponents/p-ac086069.entry.js +58 -0
- package/dist/webcomponents/p-af244664.js +126 -1
- package/dist/webcomponents/p-b4b8b531.js +44 -1
- package/dist/webcomponents/p-b82c146f.entry.js +111 -0
- package/dist/webcomponents/p-ba4bae6f.js +12 -1
- package/dist/webcomponents/p-ba5fae28.js +90 -1
- package/dist/webcomponents/p-bd66f9d2.entry.js +101 -0
- package/dist/webcomponents/p-cc39384f.entry.js +99 -0
- package/dist/webcomponents/p-d17aee2b.entry.js +26 -0
- package/dist/webcomponents/p-d89bad72.js +39 -1
- package/dist/webcomponents/p-dad3e069.entry.js +298 -0
- package/dist/webcomponents/p-dce846bf.js +27 -1
- package/dist/webcomponents/p-df21aaad.js +120 -1
- package/dist/webcomponents/p-e1255160.js +3 -1
- package/dist/webcomponents/p-e1e7525b.entry.js +73 -0
- package/dist/webcomponents/p-e333620e.js +34 -1
- package/dist/webcomponents/p-e356f280.entry.js +29 -0
- package/dist/webcomponents/p-e3fab0e2.js +43 -1
- package/dist/webcomponents/p-e9a5cb95.entry.js +94 -0
- package/dist/webcomponents/p-ec854a3e.entry.js +11053 -0
- package/dist/webcomponents/p-edc37d1f.entry.js +75 -0
- package/dist/webcomponents/p-f02b75dc.entry.js +96 -0
- package/dist/webcomponents/p-fad19d75.js +1638 -2
- package/dist/webcomponents/webcomponents.css +362 -4
- package/dist/webcomponents/webcomponents.esm.js +20 -1
- package/package.json +1 -1
- package/dist/webcomponents/p-07109641.entry.js +0 -1
- package/dist/webcomponents/p-080fedb5.entry.js +0 -1
- package/dist/webcomponents/p-0e3e3544.entry.js +0 -1
- package/dist/webcomponents/p-0f7b9555.entry.js +0 -1
- package/dist/webcomponents/p-1295970b.entry.js +0 -1
- package/dist/webcomponents/p-15b9b267.entry.js +0 -1
- package/dist/webcomponents/p-17e4246f.entry.js +0 -1
- package/dist/webcomponents/p-1a43e355.entry.js +0 -19
- package/dist/webcomponents/p-232278e0.entry.js +0 -1
- package/dist/webcomponents/p-30a493cd.entry.js +0 -1
- package/dist/webcomponents/p-32211b2f.entry.js +0 -1
- package/dist/webcomponents/p-3352353a.entry.js +0 -1
- package/dist/webcomponents/p-462dc522.entry.js +0 -1
- package/dist/webcomponents/p-487b72a8.entry.js +0 -1
- package/dist/webcomponents/p-4abc17f0.entry.js +0 -1
- package/dist/webcomponents/p-52021fa1.entry.js +0 -1
- package/dist/webcomponents/p-53e64f15.entry.js +0 -1
- package/dist/webcomponents/p-62b32c4c.entry.js +0 -1
- package/dist/webcomponents/p-701e03a8.entry.js +0 -1
- package/dist/webcomponents/p-79cfbcfa.entry.js +0 -1
- package/dist/webcomponents/p-8e263202.js +0 -1
- package/dist/webcomponents/p-8e541a32.entry.js +0 -1
- package/dist/webcomponents/p-99899e7e.entry.js +0 -1
- package/dist/webcomponents/p-9993e959.entry.js +0 -1
- package/dist/webcomponents/p-b29f5084.entry.js +0 -1
- package/dist/webcomponents/p-bbed6107.entry.js +0 -1
- package/dist/webcomponents/p-be39c802.entry.js +0 -1
- package/dist/webcomponents/p-c9f8f7ec.entry.js +0 -1
- package/dist/webcomponents/p-cc97f21b.entry.js +0 -1
- package/dist/webcomponents/p-cd37a87e.entry.js +0 -1
- package/dist/webcomponents/p-d4c94340.entry.js +0 -1
- package/dist/webcomponents/p-d5c9e036.entry.js +0 -1
- package/dist/webcomponents/p-d6a998e4.js +0 -1
- package/dist/webcomponents/p-d8355f91.entry.js +0 -1
- package/dist/webcomponents/p-e2c88817.entry.js +0 -1
- package/dist/webcomponents/p-e31f0f3e.entry.js +0 -1
- package/dist/webcomponents/p-ea3598f3.entry.js +0 -1
- package/dist/webcomponents/p-eca70b1d.entry.js +0 -1
- package/dist/webcomponents/p-f0866375.entry.js +0 -1
- package/dist/webcomponents/p-f117d1d1.entry.js +0 -1
- package/dist/webcomponents/p-fb58feb5.entry.js +0 -1
- package/dist/webcomponents/p-fe33151d.entry.js +0 -1
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import { p as packageJson } from './p-2e8f4937.js';
|
|
2
|
+
import { A as Api } from './p-29c0b182.js';
|
|
3
|
+
|
|
4
|
+
class AnalyticsService {
|
|
5
|
+
async record(body) {
|
|
6
|
+
const endpoint = 'analytics';
|
|
7
|
+
return Api({ apiOrigin: "" }).post(endpoint, JSON.stringify(body));
|
|
8
|
+
}
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* @class JustifiAnalytics
|
|
13
|
+
* @description A class to track analytics for a component
|
|
14
|
+
* @param { component } ComponentInterface - The component to track
|
|
15
|
+
*
|
|
16
|
+
*/
|
|
17
|
+
class JustifiAnalytics {
|
|
18
|
+
constructor(component) {
|
|
19
|
+
this.handleCustomEvent = async (data) => {
|
|
20
|
+
// Track the event
|
|
21
|
+
await this.service.record(data);
|
|
22
|
+
};
|
|
23
|
+
this.service = new AnalyticsService();
|
|
24
|
+
this.componentInstance = component;
|
|
25
|
+
this.setUpBasicData();
|
|
26
|
+
this.setupLifecycleTracking();
|
|
27
|
+
this.trackCustomEvents();
|
|
28
|
+
}
|
|
29
|
+
get resourceId() {
|
|
30
|
+
return (this.componentInstance.accountId ||
|
|
31
|
+
this.componentInstance.businessId ||
|
|
32
|
+
this.componentInstance.paymentId ||
|
|
33
|
+
this.componentInstance.payoutId ||
|
|
34
|
+
this.componentInstance.checkoutId);
|
|
35
|
+
}
|
|
36
|
+
setUpBasicData() {
|
|
37
|
+
this.basicData = {
|
|
38
|
+
component_name: this.componentInstance.tagName,
|
|
39
|
+
component_version: packageJson.version,
|
|
40
|
+
client_user_agent: navigator.userAgent,
|
|
41
|
+
// navigator.platform is deprecated, use navigator.userAgent instead
|
|
42
|
+
client_platform: navigator.userAgent,
|
|
43
|
+
client_origin: window.location.origin,
|
|
44
|
+
resource_id: this.resourceId,
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
trackCustomEvents() {
|
|
48
|
+
this.eventEmitters = ['submitted', 'error-event'];
|
|
49
|
+
// for each event, add an event listener
|
|
50
|
+
this.eventEmitters.forEach((eventName) => {
|
|
51
|
+
// if this.componentInstance.addEventListener is a function add the event listener
|
|
52
|
+
if (typeof this.componentInstance.addEventListener === 'function') {
|
|
53
|
+
this.componentInstance.addEventListener(eventName, (event) => this.handleCustomEvent({
|
|
54
|
+
event_type: eventName,
|
|
55
|
+
data: Object.assign(Object.assign({}, this.basicData), { error: event.detail }),
|
|
56
|
+
}));
|
|
57
|
+
}
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
setupLifecycleTracking() {
|
|
61
|
+
const originalComponentDidLoad = this.componentInstance.componentDidLoad;
|
|
62
|
+
this.componentInstance.componentDidLoad = () => {
|
|
63
|
+
this.service.record({ event_type: 'init', data: this.basicData });
|
|
64
|
+
if (originalComponentDidLoad) {
|
|
65
|
+
return originalComponentDidLoad.apply(this.componentInstance);
|
|
66
|
+
}
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
cleanup() {
|
|
70
|
+
// Remove event listeners
|
|
71
|
+
this.eventEmitters.forEach((event) => {
|
|
72
|
+
this.componentInstance.removeEventListener(event, this.handleCustomEvent);
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export { JustifiAnalytics as J };
|
|
@@ -0,0 +1,131 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './p-fad19d75.js';
|
|
2
|
+
import { A as Api } from './p-29c0b182.js';
|
|
3
|
+
import './p-56f6ce4c.js';
|
|
4
|
+
import './p-df21aaad.js';
|
|
5
|
+
import './p-e3fab0e2.js';
|
|
6
|
+
import { g as getErrorMessage, a as getErrorCode } from './p-8115b2f4.js';
|
|
7
|
+
import { C as ComponentErrorSeverity, a as ComponentErrorCodes } from './p-14c91ffd.js';
|
|
8
|
+
import { J as JustifiAnalytics } from './p-15eafa87.js';
|
|
9
|
+
import './p-2e8f4937.js';
|
|
10
|
+
|
|
11
|
+
class InsuranceService {
|
|
12
|
+
async fetchQuote(authToken, payload) {
|
|
13
|
+
const endpoint = 'insurance/quotes';
|
|
14
|
+
return Api({ authToken, apiOrigin: "" }).post(endpoint, JSON.stringify(payload));
|
|
15
|
+
}
|
|
16
|
+
async toggleCoverage(authToken, quoteId, payload) {
|
|
17
|
+
const endpoint = `insurance/quotes/${quoteId}/toggle`;
|
|
18
|
+
return Api({ authToken, apiOrigin: "" }).post(endpoint, JSON.stringify(payload));
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const makeGetQuote = ({ authToken, service }) => async ({ payload, onSuccess, onError }) => {
|
|
23
|
+
var _a;
|
|
24
|
+
try {
|
|
25
|
+
const response = await service.fetchQuote(authToken, payload);
|
|
26
|
+
if (!response.error) {
|
|
27
|
+
const quote = response.data;
|
|
28
|
+
onSuccess({ quote });
|
|
29
|
+
}
|
|
30
|
+
else {
|
|
31
|
+
const responseError = getErrorMessage(response.error);
|
|
32
|
+
const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
|
|
33
|
+
return onError({
|
|
34
|
+
error: responseError,
|
|
35
|
+
code,
|
|
36
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
catch (error) {
|
|
41
|
+
const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
|
|
42
|
+
return onError({
|
|
43
|
+
error: error.message || error,
|
|
44
|
+
code,
|
|
45
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
46
|
+
});
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
const makeToggleCoverage = ({ authToken, service }) => async ({ quoteId, payload, onSuccess, onError }) => {
|
|
50
|
+
var _a;
|
|
51
|
+
try {
|
|
52
|
+
const response = await service.toggleCoverage(authToken, quoteId, payload);
|
|
53
|
+
if (!response.error) {
|
|
54
|
+
const quote = response.data;
|
|
55
|
+
onSuccess({ quote });
|
|
56
|
+
}
|
|
57
|
+
else {
|
|
58
|
+
const responseError = getErrorMessage(response.error);
|
|
59
|
+
const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
|
|
60
|
+
return onError({
|
|
61
|
+
error: responseError,
|
|
62
|
+
code,
|
|
63
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
catch (error) {
|
|
68
|
+
const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
|
|
69
|
+
return onError({
|
|
70
|
+
error: error.message || error,
|
|
71
|
+
code,
|
|
72
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const SeasonInterruptionInsurance = class {
|
|
78
|
+
constructor(hostRef) {
|
|
79
|
+
registerInstance(this, hostRef);
|
|
80
|
+
this.errorEvent = createEvent(this, "error-event", 7);
|
|
81
|
+
this.authToken = undefined;
|
|
82
|
+
this.checkoutId = undefined;
|
|
83
|
+
this.primaryIdentityFirstName = undefined;
|
|
84
|
+
this.primaryIdentityLastName = undefined;
|
|
85
|
+
this.primaryIdentityState = undefined;
|
|
86
|
+
this.primaryIdentityPostalCode = undefined;
|
|
87
|
+
this.primaryIdentityCountry = undefined;
|
|
88
|
+
this.primaryIdentityEmailAddress = undefined;
|
|
89
|
+
this.policyAttributesInsurableAmount = undefined;
|
|
90
|
+
this.policyAttributesStartDate = undefined;
|
|
91
|
+
this.policyAttributesEndDate = undefined;
|
|
92
|
+
this.coveredIdentityFirstName = undefined;
|
|
93
|
+
this.coveredIdentityLastName = undefined;
|
|
94
|
+
this.getQuote = undefined;
|
|
95
|
+
this.toggleCoverage = undefined;
|
|
96
|
+
this.quote = undefined;
|
|
97
|
+
}
|
|
98
|
+
async validate() {
|
|
99
|
+
return this.seasonInterruptionCoreRef.validate();
|
|
100
|
+
}
|
|
101
|
+
componentWillLoad() {
|
|
102
|
+
this.analytics = new JustifiAnalytics(this);
|
|
103
|
+
this.initializeServiceMethods();
|
|
104
|
+
}
|
|
105
|
+
disconnectedCallback() {
|
|
106
|
+
this.analytics.cleanup();
|
|
107
|
+
}
|
|
108
|
+
initializeServiceMethods() {
|
|
109
|
+
if (!this.authToken) {
|
|
110
|
+
this.errorEvent.emit({
|
|
111
|
+
errorCode: ComponentErrorCodes.MISSING_PROPS,
|
|
112
|
+
message: 'Missing authToken',
|
|
113
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
114
|
+
});
|
|
115
|
+
return;
|
|
116
|
+
}
|
|
117
|
+
this.getQuote = makeGetQuote({
|
|
118
|
+
authToken: this.authToken,
|
|
119
|
+
service: new InsuranceService(),
|
|
120
|
+
});
|
|
121
|
+
this.toggleCoverage = makeToggleCoverage({
|
|
122
|
+
authToken: this.authToken,
|
|
123
|
+
service: new InsuranceService(),
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
render() {
|
|
127
|
+
return (h("justifi-season-interruption-insurance-core", { key: '256d45d39c5d297abb7f955229b0e0e9fbc9504a', ref: (el) => (this.seasonInterruptionCoreRef = el), "checkout-id": this.checkoutId, getQuote: this.getQuote, toggleCoverage: this.toggleCoverage, "primary-identity-first-name": this.primaryIdentityFirstName, "primary-identity-last-name": this.primaryIdentityLastName, "primary-identity-state": this.primaryIdentityState, "primary-identity-postal-code": this.primaryIdentityPostalCode, "primary-identity-country": this.primaryIdentityCountry, "primary-identity-email-address": this.primaryIdentityEmailAddress, "policy-attributes-insurable-amount": this.policyAttributesInsurableAmount, "policy-attributes-start-date": this.policyAttributesStartDate, "policy-attributes-end-date": this.policyAttributesEndDate, "covered-identity-first-name": this.coveredIdentityFirstName, "covered-identity-last-name": this.coveredIdentityLastName }));
|
|
128
|
+
}
|
|
129
|
+
};
|
|
130
|
+
|
|
131
|
+
export { SeasonInterruptionInsurance as justifi_season_interruption_insurance };
|
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
import { r as registerInstance, c as createEvent, h } from './p-fad19d75.js';
|
|
2
|
+
import { C as ComponentErrorSeverity, a as ComponentErrorCodes } from './p-14c91ffd.js';
|
|
3
|
+
import { g as getErrorMessage, a as getErrorCode } from './p-8115b2f4.js';
|
|
4
|
+
import { A as Api } from './p-29c0b182.js';
|
|
5
|
+
import './p-56f6ce4c.js';
|
|
6
|
+
import './p-df21aaad.js';
|
|
7
|
+
import './p-e3fab0e2.js';
|
|
8
|
+
import { J as JustifiAnalytics } from './p-15eafa87.js';
|
|
9
|
+
import './p-2e8f4937.js';
|
|
10
|
+
|
|
11
|
+
const makeGetCheckout = ({ authToken, checkoutId, service }) => async ({ onSuccess, onError }) => {
|
|
12
|
+
var _a;
|
|
13
|
+
try {
|
|
14
|
+
const response = await service.fetchCheckout(authToken, checkoutId);
|
|
15
|
+
if (!response.error) {
|
|
16
|
+
const checkout = response.data;
|
|
17
|
+
onSuccess({ checkout });
|
|
18
|
+
}
|
|
19
|
+
else {
|
|
20
|
+
const responseError = getErrorMessage(response.error);
|
|
21
|
+
const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
|
|
22
|
+
return onError({
|
|
23
|
+
error: responseError,
|
|
24
|
+
code,
|
|
25
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
catch (error) {
|
|
30
|
+
const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
|
|
31
|
+
return onError({
|
|
32
|
+
error: error.message || error,
|
|
33
|
+
code,
|
|
34
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
};
|
|
38
|
+
const makeCheckoutComplete = ({ authToken, checkoutId, service }) => async ({ payment, onSuccess, onError }) => {
|
|
39
|
+
var _a;
|
|
40
|
+
try {
|
|
41
|
+
const response = await service.complete(authToken, checkoutId, payment);
|
|
42
|
+
if (!response.error) {
|
|
43
|
+
onSuccess(response);
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
const responseError = getErrorMessage(response.error);
|
|
47
|
+
const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
|
|
48
|
+
return onError({
|
|
49
|
+
error: responseError,
|
|
50
|
+
code,
|
|
51
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
catch (error) {
|
|
56
|
+
const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
|
|
57
|
+
return onError({
|
|
58
|
+
error: error.message || error,
|
|
59
|
+
code,
|
|
60
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
class CheckoutService {
|
|
66
|
+
async fetchCheckout(authToken, checkoutId) {
|
|
67
|
+
const endpoint = `checkouts/${checkoutId}`;
|
|
68
|
+
return Api({ authToken, apiOrigin: "" }).get(endpoint);
|
|
69
|
+
}
|
|
70
|
+
async complete(authToken, checkoutId, payment) {
|
|
71
|
+
const endpoint = `checkouts/${checkoutId}/complete`;
|
|
72
|
+
const payload = {
|
|
73
|
+
payment_mode: payment.payment_mode,
|
|
74
|
+
};
|
|
75
|
+
if (payment.payment_token) {
|
|
76
|
+
payload.payment_token = payment.payment_token;
|
|
77
|
+
}
|
|
78
|
+
return Api({ authToken, apiOrigin: "" }).post(endpoint, JSON.stringify(payload));
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
const Checkout = class {
|
|
83
|
+
constructor(hostRef) {
|
|
84
|
+
registerInstance(this, hostRef);
|
|
85
|
+
this.errorEvent = createEvent(this, "error-event", 7);
|
|
86
|
+
this.loadedEvent = createEvent(this, "loaded", 7);
|
|
87
|
+
this.iframeOrigin = undefined;
|
|
88
|
+
this.authToken = undefined;
|
|
89
|
+
this.checkoutId = undefined;
|
|
90
|
+
this.disableCreditCard = undefined;
|
|
91
|
+
this.disableBankAccount = undefined;
|
|
92
|
+
this.disableBnpl = undefined;
|
|
93
|
+
this.disablePaymentMethodGroup = undefined;
|
|
94
|
+
this.getCheckout = undefined;
|
|
95
|
+
this.complete = undefined;
|
|
96
|
+
this.errorMessage = '';
|
|
97
|
+
}
|
|
98
|
+
componentWillLoad() {
|
|
99
|
+
this.analytics = new JustifiAnalytics(this);
|
|
100
|
+
this.initializeGetCheckout();
|
|
101
|
+
}
|
|
102
|
+
disconnectedCallback() {
|
|
103
|
+
this.analytics.cleanup();
|
|
104
|
+
}
|
|
105
|
+
initializeGetCheckout() {
|
|
106
|
+
if (this.authToken && this.checkoutId) {
|
|
107
|
+
this.getCheckout = makeGetCheckout({
|
|
108
|
+
authToken: this.authToken,
|
|
109
|
+
checkoutId: this.checkoutId,
|
|
110
|
+
service: new CheckoutService()
|
|
111
|
+
});
|
|
112
|
+
this.complete = makeCheckoutComplete({
|
|
113
|
+
authToken: this.authToken,
|
|
114
|
+
checkoutId: this.checkoutId,
|
|
115
|
+
service: new CheckoutService()
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
else {
|
|
119
|
+
this.errorEvent.emit({
|
|
120
|
+
message: 'auth-token and checkout-id are required',
|
|
121
|
+
errorCode: ComponentErrorCodes.MISSING_PROPS,
|
|
122
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
123
|
+
});
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
propChanged() {
|
|
127
|
+
this.initializeGetCheckout();
|
|
128
|
+
}
|
|
129
|
+
async fillBillingForm(fields) {
|
|
130
|
+
this.checkoutCoreRef.fillBillingForm(fields);
|
|
131
|
+
}
|
|
132
|
+
render() {
|
|
133
|
+
return (h("justifi-checkout-core", { key: 'd2f6bfed1be767edcf4ba21cddc503ff5efbec1a', getCheckout: this.getCheckout, authToken: this.authToken, complete: this.complete, disableCreditCard: this.disableCreditCard, disableBankAccount: this.disableBankAccount, disableBnpl: this.disableBnpl, disablePaymentMethodGroup: this.disablePaymentMethodGroup, ref: el => {
|
|
134
|
+
if (el) {
|
|
135
|
+
this.checkoutCoreRef = el;
|
|
136
|
+
}
|
|
137
|
+
} }, h("div", { key: '45ac1bea74ca8ef7999211b51fe7791225d61f00', slot: "insurance" }, h("slot", { key: '13e051844cc7cb4aed98076ccd64954b2dd68228', name: "insurance" }))));
|
|
138
|
+
}
|
|
139
|
+
static get watchers() { return {
|
|
140
|
+
"authToken": ["propChanged"],
|
|
141
|
+
"checkoutId": ["propChanged"]
|
|
142
|
+
}; }
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
export { Checkout as justifi_checkout };
|