@justifi/webcomponents 0.0.14 → 0.2.0
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/CHANGELOG.md +40 -0
- package/changelog-template.hbs +41 -0
- package/dist/cjs/{index-e1b45289.js → index-3947d225.js} +65 -1
- package/dist/cjs/justifi-bank-account-form.cjs.entry.js +59 -0
- package/dist/cjs/justifi-billing-form.cjs.entry.js +2150 -0
- package/dist/cjs/justifi-card-form.cjs.entry.js +59 -0
- package/dist/cjs/justifi-payment-method-form.cjs.entry.js +109 -0
- package/dist/cjs/{justifi-bank-account-form_4.cjs.entry.js → justifi-payments-list.cjs.entry.js} +1 -206
- package/dist/cjs/loader.cjs.js +3 -3
- package/dist/cjs/select-input_2.cjs.entry.js +59 -0
- package/dist/cjs/webcomponents.cjs.js +3 -3
- package/dist/collection/collection-manifest.json +5 -2
- package/dist/collection/components/bank-account-form/bank-account-form.js +5 -3
- package/dist/collection/components/billing-form/billing-form-schema.js +14 -0
- package/dist/collection/components/billing-form/billing-form.css +11 -0
- package/dist/collection/components/billing-form/billing-form.js +92 -0
- package/dist/collection/components/billing-form/state-options.js +243 -0
- package/dist/collection/components/card-form/card-form.js +5 -3
- package/dist/collection/components/payment-method-form/payment-method-form.js +4 -4
- package/dist/collection/components/select-input/select-input.css +7 -0
- package/dist/collection/components/select-input/select-input.js +144 -0
- package/dist/collection/components/text-input/text-input.css +7 -0
- package/dist/collection/components/text-input/text-input.js +126 -0
- package/dist/components/index.d.ts +3 -0
- package/dist/components/index.js +3 -0
- package/dist/components/justifi-bank-account-form.js +4 -2
- package/dist/components/justifi-billing-form.d.ts +11 -0
- package/dist/components/justifi-billing-form.js +2180 -0
- package/dist/components/justifi-card-form.js +4 -2
- package/dist/components/payment-method-form.js +2 -2
- package/dist/components/select-input.d.ts +11 -0
- package/dist/components/select-input.js +6 -0
- package/dist/components/select-input2.js +52 -0
- package/dist/components/text-input.d.ts +11 -0
- package/dist/components/text-input.js +6 -0
- package/dist/components/text-input2.js +48 -0
- package/dist/esm/{index-c1f569bd.js → index-0bcf33c4.js} +65 -1
- package/dist/esm/justifi-bank-account-form.entry.js +55 -0
- package/dist/esm/justifi-billing-form.entry.js +2146 -0
- package/dist/esm/justifi-card-form.entry.js +55 -0
- package/dist/esm/justifi-payment-method-form.entry.js +105 -0
- package/dist/esm/{justifi-bank-account-form_4.entry.js → justifi-payments-list.entry.js} +2 -204
- package/dist/esm/loader.js +4 -4
- package/dist/esm/select-input_2.entry.js +54 -0
- package/dist/esm/webcomponents.js +4 -4
- package/dist/types/components/billing-form/billing-form-schema.d.ts +15 -0
- package/dist/types/components/billing-form/billing-form.d.ts +17 -0
- package/dist/types/components/billing-form/state-options.d.ts +5 -0
- package/dist/types/components/payment-method-form/payment-method-form.d.ts +2 -2
- package/dist/types/components/payment-method-form/theme.d.ts +3 -1
- package/dist/types/components/select-input/select-input.d.ts +18 -0
- package/dist/types/components/text-input/text-input.d.ts +14 -0
- package/dist/types/components.d.ts +74 -5
- package/dist/webcomponents/p-0cddfd4f.entry.js +1 -0
- package/dist/webcomponents/p-17badb93.entry.js +1 -0
- package/dist/webcomponents/p-7fd07095.entry.js +1 -0
- package/dist/webcomponents/p-864e32fd.entry.js +1 -0
- package/dist/webcomponents/p-cecf0fe8.entry.js +1 -0
- package/dist/webcomponents/p-d3dc4e0a.entry.js +1 -0
- package/dist/webcomponents/p-e82c9746.js +2 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +8 -3
- package/readme.md +11 -72
- package/LICENSE +0 -21
- package/dist/webcomponents/p-1de39730.js +0 -2
- package/dist/webcomponents/p-d6caba00.entry.js +0 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-3947d225.js');
|
|
6
|
+
|
|
7
|
+
const CardForm = class {
|
|
8
|
+
constructor(hostRef) {
|
|
9
|
+
index.registerInstance(this, hostRef);
|
|
10
|
+
this.cardFormReady = index.createEvent(this, "cardFormReady", 7);
|
|
11
|
+
this.cardFormTokenize = index.createEvent(this, "cardFormTokenize", 7);
|
|
12
|
+
this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
|
|
13
|
+
this.validationStrategy = undefined;
|
|
14
|
+
this.styleOverrides = undefined;
|
|
15
|
+
this.internalStyleOverrides = undefined;
|
|
16
|
+
}
|
|
17
|
+
readyHandler(event) {
|
|
18
|
+
this.cardFormReady.emit(event);
|
|
19
|
+
}
|
|
20
|
+
tokenizeHandler(event) {
|
|
21
|
+
this.cardFormTokenize.emit(event);
|
|
22
|
+
}
|
|
23
|
+
validateHandler(event) {
|
|
24
|
+
this.cardFormValidate.emit(event);
|
|
25
|
+
}
|
|
26
|
+
componentWillLoad() {
|
|
27
|
+
this.parseStyleOverrides();
|
|
28
|
+
}
|
|
29
|
+
parseStyleOverrides() {
|
|
30
|
+
if (this.styleOverrides) {
|
|
31
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
32
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
async tokenize(...args) {
|
|
36
|
+
if (!this.childRef) {
|
|
37
|
+
throw new Error('Cannot call tokenize');
|
|
38
|
+
}
|
|
39
|
+
return this.childRef.tokenize(...args);
|
|
40
|
+
}
|
|
41
|
+
async validate() {
|
|
42
|
+
if (!this.childRef) {
|
|
43
|
+
throw new Error('Cannot call validate');
|
|
44
|
+
}
|
|
45
|
+
return this.childRef.validate();
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
49
|
+
if (el) {
|
|
50
|
+
this.childRef = el;
|
|
51
|
+
}
|
|
52
|
+
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
53
|
+
}
|
|
54
|
+
static get watchers() { return {
|
|
55
|
+
"styleOverrides": ["parseStyleOverrides"]
|
|
56
|
+
}; }
|
|
57
|
+
};
|
|
58
|
+
|
|
59
|
+
exports.justifi_card_form = CardForm;
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-3947d225.js');
|
|
6
|
+
|
|
7
|
+
const MessageEventType = {
|
|
8
|
+
card: {
|
|
9
|
+
ready: 'justifi.card.ready',
|
|
10
|
+
tokenize: 'justifi.card.tokenize',
|
|
11
|
+
validate: 'justifi.card.validate',
|
|
12
|
+
resize: 'justifi.card.resize',
|
|
13
|
+
styleOverrides: 'justifi.card.styleOverrides',
|
|
14
|
+
},
|
|
15
|
+
bankAccount: {
|
|
16
|
+
ready: 'justifi.bankAccount.ready',
|
|
17
|
+
tokenize: 'justifi.bankAccount.tokenize',
|
|
18
|
+
validate: 'justifi.bankAccount.validate',
|
|
19
|
+
resize: 'justifi.bankAccount.resize',
|
|
20
|
+
styleOverrides: 'justifi.bankAccount.styleOverrides',
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const paymentMethodFormCss = ":host{display:block}justifi-payment-method-form iframe{border:none;width:100%}";
|
|
25
|
+
|
|
26
|
+
const PaymentMethodForm = class {
|
|
27
|
+
constructor(hostRef) {
|
|
28
|
+
index.registerInstance(this, hostRef);
|
|
29
|
+
this.paymentMethodFormReady = index.createEvent(this, "paymentMethodFormReady", 7);
|
|
30
|
+
this.paymentMethodFormTokenize = index.createEvent(this, "paymentMethodFormTokenize", 7);
|
|
31
|
+
this.paymentMethodFormType = undefined;
|
|
32
|
+
this.paymentMethodFormValidationStrategy = undefined;
|
|
33
|
+
this.paymentMethodStyleOverrides = undefined;
|
|
34
|
+
this.height = 55;
|
|
35
|
+
}
|
|
36
|
+
connectedCallback() {
|
|
37
|
+
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
38
|
+
}
|
|
39
|
+
disconnectedCallback() {
|
|
40
|
+
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
41
|
+
}
|
|
42
|
+
componentShouldUpdate() {
|
|
43
|
+
this.sendStyleOverrides();
|
|
44
|
+
}
|
|
45
|
+
sendStyleOverrides() {
|
|
46
|
+
if (this.paymentMethodStyleOverrides) {
|
|
47
|
+
this.postMessage(MessageEventType[this.paymentMethodFormType].styleOverrides, { styleOverrides: this.paymentMethodStyleOverrides });
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
dispatchMessageEvent(messageEvent) {
|
|
51
|
+
const messagePayload = messageEvent.data;
|
|
52
|
+
const messageType = messagePayload.eventType;
|
|
53
|
+
const messageData = messagePayload.data;
|
|
54
|
+
if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
|
|
55
|
+
this.paymentMethodFormReady.emit(messageData);
|
|
56
|
+
}
|
|
57
|
+
if (messageType === MessageEventType[this.paymentMethodFormType].resize) {
|
|
58
|
+
this.height = messageData.height;
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
postMessage(eventType, payload) {
|
|
62
|
+
if (this.iframeElement) {
|
|
63
|
+
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
;
|
|
67
|
+
async postMessageWithResponseListener(eventType, payload) {
|
|
68
|
+
return new Promise((resolve) => {
|
|
69
|
+
const responseListener = (event) => {
|
|
70
|
+
if (event.data.eventType !== eventType)
|
|
71
|
+
return;
|
|
72
|
+
window.removeEventListener('message', responseListener);
|
|
73
|
+
resolve(event.data.data);
|
|
74
|
+
};
|
|
75
|
+
window.addEventListener('message', responseListener);
|
|
76
|
+
this.postMessage(eventType, payload);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
async tokenize(clientId, paymentMethodMetadata, account) {
|
|
80
|
+
const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
|
|
81
|
+
const payload = {
|
|
82
|
+
clientId: clientId,
|
|
83
|
+
paymentMethodMetadata: paymentMethodMetadata,
|
|
84
|
+
account: account
|
|
85
|
+
};
|
|
86
|
+
return this.postMessageWithResponseListener(eventType, payload);
|
|
87
|
+
}
|
|
88
|
+
;
|
|
89
|
+
async validate() {
|
|
90
|
+
return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
|
|
91
|
+
}
|
|
92
|
+
;
|
|
93
|
+
getIframeSrc() {
|
|
94
|
+
let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
|
|
95
|
+
if (this.paymentMethodFormValidationStrategy) {
|
|
96
|
+
iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
|
|
97
|
+
}
|
|
98
|
+
return iframeSrc;
|
|
99
|
+
}
|
|
100
|
+
render() {
|
|
101
|
+
return (index.h(index.Host, null, index.h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
|
|
102
|
+
}
|
|
103
|
+
static get watchers() { return {
|
|
104
|
+
"paymentMethodStyleOverrides": ["sendStyleOverrides"]
|
|
105
|
+
}; }
|
|
106
|
+
};
|
|
107
|
+
PaymentMethodForm.style = paymentMethodFormCss;
|
|
108
|
+
|
|
109
|
+
exports.justifi_payment_method_form = PaymentMethodForm;
|
package/dist/cjs/{justifi-bank-account-form_4.cjs.entry.js → justifi-payments-list.cjs.entry.js}
RENAMED
|
@@ -2,209 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
6
|
-
|
|
7
|
-
const BankAccountForm = class {
|
|
8
|
-
constructor(hostRef) {
|
|
9
|
-
index.registerInstance(this, hostRef);
|
|
10
|
-
this.bankAccountFormReady = index.createEvent(this, "bankAccountFormReady", 7);
|
|
11
|
-
this.bankAccountFormTokenize = index.createEvent(this, "bankAccountFormTokenize", 7);
|
|
12
|
-
this.bankAccountFormValidate = index.createEvent(this, "bankAccountFormValidate", 7);
|
|
13
|
-
this.validationStrategy = undefined;
|
|
14
|
-
this.styleOverrides = undefined;
|
|
15
|
-
this.internalStyleOverrides = undefined;
|
|
16
|
-
}
|
|
17
|
-
readyHandler(event) {
|
|
18
|
-
this.bankAccountFormReady.emit(event);
|
|
19
|
-
}
|
|
20
|
-
tokenizeHandler(event) {
|
|
21
|
-
this.bankAccountFormTokenize.emit(event);
|
|
22
|
-
}
|
|
23
|
-
validateHandler(event) {
|
|
24
|
-
this.bankAccountFormValidate.emit(event);
|
|
25
|
-
}
|
|
26
|
-
componentWillLoad() {
|
|
27
|
-
this.parseStyleOverrides();
|
|
28
|
-
}
|
|
29
|
-
parseStyleOverrides() {
|
|
30
|
-
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
31
|
-
this.internalStyleOverrides = parsedStyleOverrides;
|
|
32
|
-
}
|
|
33
|
-
async tokenize(...args) {
|
|
34
|
-
if (!this.childRef) {
|
|
35
|
-
throw new Error('Cannot call tokenize');
|
|
36
|
-
}
|
|
37
|
-
return this.childRef.tokenize(...args);
|
|
38
|
-
}
|
|
39
|
-
async validate() {
|
|
40
|
-
if (!this.childRef) {
|
|
41
|
-
throw new Error('Cannot call validate');
|
|
42
|
-
}
|
|
43
|
-
return this.childRef.validate();
|
|
44
|
-
}
|
|
45
|
-
render() {
|
|
46
|
-
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
47
|
-
if (el) {
|
|
48
|
-
this.childRef = el;
|
|
49
|
-
}
|
|
50
|
-
}, "payment-method-form-type": "bankAccount", "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-tokenize": this.bankAccountFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
51
|
-
}
|
|
52
|
-
static get watchers() { return {
|
|
53
|
-
"styleOverrides": ["parseStyleOverrides"]
|
|
54
|
-
}; }
|
|
55
|
-
};
|
|
56
|
-
|
|
57
|
-
const CardForm = class {
|
|
58
|
-
constructor(hostRef) {
|
|
59
|
-
index.registerInstance(this, hostRef);
|
|
60
|
-
this.cardFormReady = index.createEvent(this, "cardFormReady", 7);
|
|
61
|
-
this.cardFormTokenize = index.createEvent(this, "cardFormTokenize", 7);
|
|
62
|
-
this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
|
|
63
|
-
this.validationStrategy = undefined;
|
|
64
|
-
this.styleOverrides = undefined;
|
|
65
|
-
this.internalStyleOverrides = undefined;
|
|
66
|
-
}
|
|
67
|
-
readyHandler(event) {
|
|
68
|
-
this.cardFormReady.emit(event);
|
|
69
|
-
}
|
|
70
|
-
tokenizeHandler(event) {
|
|
71
|
-
this.cardFormTokenize.emit(event);
|
|
72
|
-
}
|
|
73
|
-
validateHandler(event) {
|
|
74
|
-
this.cardFormValidate.emit(event);
|
|
75
|
-
}
|
|
76
|
-
componentWillLoad() {
|
|
77
|
-
this.parseStyleOverrides();
|
|
78
|
-
}
|
|
79
|
-
parseStyleOverrides() {
|
|
80
|
-
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
81
|
-
this.internalStyleOverrides = parsedStyleOverrides;
|
|
82
|
-
}
|
|
83
|
-
async tokenize(...args) {
|
|
84
|
-
if (!this.childRef) {
|
|
85
|
-
throw new Error('Cannot call tokenize');
|
|
86
|
-
}
|
|
87
|
-
return this.childRef.tokenize(...args);
|
|
88
|
-
}
|
|
89
|
-
async validate() {
|
|
90
|
-
if (!this.childRef) {
|
|
91
|
-
throw new Error('Cannot call validate');
|
|
92
|
-
}
|
|
93
|
-
return this.childRef.validate();
|
|
94
|
-
}
|
|
95
|
-
render() {
|
|
96
|
-
return (index.h("justifi-payment-method-form", { ref: el => {
|
|
97
|
-
if (el) {
|
|
98
|
-
this.childRef = el;
|
|
99
|
-
}
|
|
100
|
-
}, "payment-method-form-type": "card", "payment-method-form-ready": this.cardFormReady, "payment-method-form-tokenize": this.cardFormTokenize, "payment-method-form-validation-strategy": this.validationStrategy || 'onSubmit', paymentMethodStyleOverrides: this.internalStyleOverrides }));
|
|
101
|
-
}
|
|
102
|
-
static get watchers() { return {
|
|
103
|
-
"styleOverrides": ["parseStyleOverrides"]
|
|
104
|
-
}; }
|
|
105
|
-
};
|
|
106
|
-
|
|
107
|
-
const MessageEventType = {
|
|
108
|
-
card: {
|
|
109
|
-
ready: 'justifi.card.ready',
|
|
110
|
-
tokenize: 'justifi.card.tokenize',
|
|
111
|
-
validate: 'justifi.card.validate',
|
|
112
|
-
resize: 'justifi.card.resize',
|
|
113
|
-
styleOverrides: 'justifi.card.styleOverrides',
|
|
114
|
-
},
|
|
115
|
-
bankAccount: {
|
|
116
|
-
ready: 'justifi.bankAccount.ready',
|
|
117
|
-
tokenize: 'justifi.bankAccount.tokenize',
|
|
118
|
-
validate: 'justifi.bankAccount.validate',
|
|
119
|
-
resize: 'justifi.bankAccount.resize',
|
|
120
|
-
styleOverrides: 'justifi.bankAccount.styleOverrides',
|
|
121
|
-
}
|
|
122
|
-
};
|
|
123
|
-
|
|
124
|
-
const paymentMethodFormCss = ":host{display:block}justifi-payment-method-form iframe{border:none;width:100%}";
|
|
125
|
-
|
|
126
|
-
const PaymentMethodForm = class {
|
|
127
|
-
constructor(hostRef) {
|
|
128
|
-
index.registerInstance(this, hostRef);
|
|
129
|
-
this.paymentMethodFormReady = index.createEvent(this, "paymentMethodFormReady", 7);
|
|
130
|
-
this.paymentMethodFormTokenize = index.createEvent(this, "paymentMethodFormTokenize", 7);
|
|
131
|
-
this.paymentMethodFormType = undefined;
|
|
132
|
-
this.paymentMethodFormValidationStrategy = undefined;
|
|
133
|
-
this.paymentMethodStyleOverrides = undefined;
|
|
134
|
-
this.height = 55;
|
|
135
|
-
}
|
|
136
|
-
connectedCallback() {
|
|
137
|
-
window.addEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
138
|
-
}
|
|
139
|
-
disconnectedCallback() {
|
|
140
|
-
window.removeEventListener('message', this.dispatchMessageEvent.bind(this));
|
|
141
|
-
}
|
|
142
|
-
componentShouldUpdate() {
|
|
143
|
-
this.sendStyleOverrides();
|
|
144
|
-
}
|
|
145
|
-
sendStyleOverrides() {
|
|
146
|
-
if (this.paymentMethodStyleOverrides) {
|
|
147
|
-
this.postMessage(MessageEventType[this.paymentMethodFormType].styleOverrides, { styleOverrides: this.paymentMethodStyleOverrides });
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
dispatchMessageEvent(messageEvent) {
|
|
151
|
-
const messagePayload = messageEvent.data;
|
|
152
|
-
const messageType = messagePayload.eventType;
|
|
153
|
-
const messageData = messagePayload.data;
|
|
154
|
-
if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
|
|
155
|
-
this.paymentMethodFormReady.emit(messageData);
|
|
156
|
-
}
|
|
157
|
-
if (messageType === MessageEventType[this.paymentMethodFormType].resize) {
|
|
158
|
-
this.height = messageData.height;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
postMessage(eventType, payload) {
|
|
162
|
-
if (this.iframeElement) {
|
|
163
|
-
this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
;
|
|
167
|
-
async postMessageWithResponseListener(eventType, payload) {
|
|
168
|
-
return new Promise((resolve) => {
|
|
169
|
-
const responseListener = (event) => {
|
|
170
|
-
if (event.data.eventType !== eventType)
|
|
171
|
-
return;
|
|
172
|
-
window.removeEventListener('message', responseListener);
|
|
173
|
-
resolve(event.data.data);
|
|
174
|
-
};
|
|
175
|
-
window.addEventListener('message', responseListener);
|
|
176
|
-
this.postMessage(eventType, payload);
|
|
177
|
-
});
|
|
178
|
-
}
|
|
179
|
-
async tokenize(clientKey, paymentMethodMetadata, account) {
|
|
180
|
-
const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
|
|
181
|
-
const payload = {
|
|
182
|
-
clientKey: clientKey,
|
|
183
|
-
paymentMethodMetadata: paymentMethodMetadata,
|
|
184
|
-
account: account
|
|
185
|
-
};
|
|
186
|
-
return this.postMessageWithResponseListener(eventType, payload);
|
|
187
|
-
}
|
|
188
|
-
;
|
|
189
|
-
async validate() {
|
|
190
|
-
return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
|
|
191
|
-
}
|
|
192
|
-
;
|
|
193
|
-
getIframeSrc() {
|
|
194
|
-
let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
|
|
195
|
-
if (this.paymentMethodFormValidationStrategy) {
|
|
196
|
-
iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
|
|
197
|
-
}
|
|
198
|
-
return iframeSrc;
|
|
199
|
-
}
|
|
200
|
-
render() {
|
|
201
|
-
return (index.h(index.Host, null, index.h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el, height: this.height })));
|
|
202
|
-
}
|
|
203
|
-
static get watchers() { return {
|
|
204
|
-
"paymentMethodStyleOverrides": ["sendStyleOverrides"]
|
|
205
|
-
}; }
|
|
206
|
-
};
|
|
207
|
-
PaymentMethodForm.style = paymentMethodFormCss;
|
|
5
|
+
const index = require('./index-3947d225.js');
|
|
208
6
|
|
|
209
7
|
// Unique ID creation requires a high quality random # generator. In the browser we therefore
|
|
210
8
|
// require the crypto API and do not support built-in fallback to lower quality random number
|
|
@@ -4434,7 +4232,4 @@ const PaymentsList = class {
|
|
|
4434
4232
|
};
|
|
4435
4233
|
PaymentsList.style = paymentsListCss;
|
|
4436
4234
|
|
|
4437
|
-
exports.justifi_bank_account_form = BankAccountForm;
|
|
4438
|
-
exports.justifi_card_form = CardForm;
|
|
4439
|
-
exports.justifi_payment_method_form = PaymentMethodForm;
|
|
4440
4235
|
exports.justifi_payments_list = PaymentsList;
|
package/dist/cjs/loader.cjs.js
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-3947d225.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
Stencil Client Patch Esm v2.22.
|
|
8
|
+
Stencil Client Patch Esm v2.22.3 | MIT Licensed | https://stenciljs.com
|
|
9
9
|
*/
|
|
10
10
|
const patchEsm = () => {
|
|
11
11
|
return index.promiseResolve();
|
|
@@ -14,7 +14,7 @@ const patchEsm = () => {
|
|
|
14
14
|
const defineCustomElements = (win, options) => {
|
|
15
15
|
if (typeof window === 'undefined') return Promise.resolve();
|
|
16
16
|
return patchEsm().then(() => {
|
|
17
|
-
return index.bootstrapLazy([["justifi-bank-account-
|
|
17
|
+
return index.bootstrapLazy([["justifi-billing-form.cjs",[[1,"justifi-billing-form",{"billingFields":[32],"billingFieldsErrors":[32],"validate":[64]},[[0,"fieldReceivedInput","setFormValue"]]]]],["justifi-payment-method-form.cjs",[[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"paymentMethodStyleOverrides":[16],"height":[32],"tokenize":[64],"validate":[64]}]]],["justifi-bank-account-form.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]]]],["justifi-card-form.cjs",[[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]]]],["justifi-payments-list.cjs",[[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]],["select-input_2.cjs",[[1,"select-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"options":[16],"internalValue":[32]}],[1,"text-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"internalValue":[32]}]]]], options);
|
|
18
18
|
});
|
|
19
19
|
};
|
|
20
20
|
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
|
+
|
|
5
|
+
const index = require('./index-3947d225.js');
|
|
6
|
+
|
|
7
|
+
const selectInputCss = ":host{display:block}label{display:block}";
|
|
8
|
+
|
|
9
|
+
const SelectInput = class {
|
|
10
|
+
constructor(hostRef) {
|
|
11
|
+
index.registerInstance(this, hostRef);
|
|
12
|
+
this.fieldReceivedInput = index.createEvent(this, "fieldReceivedInput", 7);
|
|
13
|
+
this.name = undefined;
|
|
14
|
+
this.label = undefined;
|
|
15
|
+
this.defaultValue = undefined;
|
|
16
|
+
this.error = undefined;
|
|
17
|
+
this.options = undefined;
|
|
18
|
+
this.internalValue = '';
|
|
19
|
+
}
|
|
20
|
+
onInput(event) {
|
|
21
|
+
const target = event.target;
|
|
22
|
+
const name = target.getAttribute('name');
|
|
23
|
+
this.fieldReceivedInput.emit({ name: name, value: target.value });
|
|
24
|
+
}
|
|
25
|
+
;
|
|
26
|
+
render() {
|
|
27
|
+
return (index.h(index.Host, null, index.h("label", null, this.label), index.h("select", { name: this.name, onInput: (event) => this.onInput(event) }, this.options.map((option) => {
|
|
28
|
+
return (index.h("option", { value: option.value }, option.label));
|
|
29
|
+
})), this.error && index.h("div", { style: { color: 'red' } }, this.error)));
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
SelectInput.style = selectInputCss;
|
|
33
|
+
|
|
34
|
+
const textInputCss = ":host{display:block}label{display:block}";
|
|
35
|
+
|
|
36
|
+
const TextInput = class {
|
|
37
|
+
constructor(hostRef) {
|
|
38
|
+
index.registerInstance(this, hostRef);
|
|
39
|
+
this.fieldReceivedInput = index.createEvent(this, "fieldReceivedInput", 7);
|
|
40
|
+
this.name = undefined;
|
|
41
|
+
this.label = undefined;
|
|
42
|
+
this.defaultValue = undefined;
|
|
43
|
+
this.error = undefined;
|
|
44
|
+
this.internalValue = '';
|
|
45
|
+
}
|
|
46
|
+
onInput(event) {
|
|
47
|
+
const target = event.target;
|
|
48
|
+
const name = target.getAttribute('name');
|
|
49
|
+
this.fieldReceivedInput.emit({ name: name, value: target.value });
|
|
50
|
+
}
|
|
51
|
+
;
|
|
52
|
+
render() {
|
|
53
|
+
return (index.h(index.Host, null, index.h("label", null, this.label), index.h("input", { name: this.name, type: "text", onInput: (event) => this.onInput(event), value: this.internalValue || this.defaultValue }), this.error && index.h("div", { style: { color: 'red' } }, this.error)));
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
TextInput.style = textInputCss;
|
|
57
|
+
|
|
58
|
+
exports.select_input = SelectInput;
|
|
59
|
+
exports.text_input = TextInput;
|
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
-
const index = require('./index-
|
|
5
|
+
const index = require('./index-3947d225.js');
|
|
6
6
|
|
|
7
7
|
/*
|
|
8
|
-
Stencil Client Patch Browser v2.22.
|
|
8
|
+
Stencil Client Patch Browser v2.22.3 | MIT Licensed | https://stenciljs.com
|
|
9
9
|
*/
|
|
10
10
|
const patchBrowser = () => {
|
|
11
11
|
const importMeta = (typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('webcomponents.cjs.js', document.baseURI).href));
|
|
@@ -17,7 +17,7 @@ const patchBrowser = () => {
|
|
|
17
17
|
};
|
|
18
18
|
|
|
19
19
|
patchBrowser().then(options => {
|
|
20
|
-
return index.bootstrapLazy([["justifi-bank-account-
|
|
20
|
+
return index.bootstrapLazy([["justifi-billing-form.cjs",[[1,"justifi-billing-form",{"billingFields":[32],"billingFieldsErrors":[32],"validate":[64]},[[0,"fieldReceivedInput","setFormValue"]]]]],["justifi-payment-method-form.cjs",[[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"paymentMethodStyleOverrides":[16],"height":[32],"tokenize":[64],"validate":[64]}]]],["justifi-bank-account-form.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]]]],["justifi-card-form.cjs",[[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"styleOverrides":[1,"style-overrides"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]]]],["justifi-payments-list.cjs",[[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}]]],["select-input_2.cjs",[[1,"select-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"options":[16],"internalValue":[32]}],[1,"text-input",{"name":[1],"label":[1],"defaultValue":[1,"default-value"],"error":[1],"internalValue":[32]}]]]], options);
|
|
21
21
|
});
|
|
22
22
|
|
|
23
23
|
exports.setNonce = index.setNonce;
|
|
@@ -1,13 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"entries": [
|
|
3
3
|
"./components/bank-account-form/bank-account-form.js",
|
|
4
|
+
"./components/billing-form/billing-form.js",
|
|
4
5
|
"./components/card-form/card-form.js",
|
|
5
6
|
"./components/payment-method-form/payment-method-form.js",
|
|
6
|
-
"./components/payments-list/payments-list.js"
|
|
7
|
+
"./components/payments-list/payments-list.js",
|
|
8
|
+
"./components/select-input/select-input.js",
|
|
9
|
+
"./components/text-input/text-input.js"
|
|
7
10
|
],
|
|
8
11
|
"compiler": {
|
|
9
12
|
"name": "@stencil/core",
|
|
10
|
-
"version": "2.22.
|
|
13
|
+
"version": "2.22.3",
|
|
11
14
|
"typescriptVersion": "4.9.4"
|
|
12
15
|
},
|
|
13
16
|
"collections": [],
|
|
@@ -18,8 +18,10 @@ export class BankAccountForm {
|
|
|
18
18
|
this.parseStyleOverrides();
|
|
19
19
|
}
|
|
20
20
|
parseStyleOverrides() {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
if (this.styleOverrides) {
|
|
22
|
+
const parsedStyleOverrides = JSON.parse(this.styleOverrides);
|
|
23
|
+
this.internalStyleOverrides = parsedStyleOverrides;
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
async tokenize(...args) {
|
|
25
27
|
if (!this.childRef) {
|
|
@@ -136,7 +138,7 @@ export class BankAccountForm {
|
|
|
136
138
|
return {
|
|
137
139
|
"tokenize": {
|
|
138
140
|
"complexType": {
|
|
139
|
-
"signature": "(
|
|
141
|
+
"signature": "(clientId: string, paymentMethodMetadata: any, account?: string) => Promise<any>",
|
|
140
142
|
"parameters": [{
|
|
141
143
|
"tags": [],
|
|
142
144
|
"text": ""
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { object, string } from 'yup';
|
|
2
|
+
export const RegExZip = /^\d{5}/;
|
|
3
|
+
const BillingFormSchema = object({
|
|
4
|
+
// name: string().required('Enter name'),
|
|
5
|
+
address_line1: string().required('Enter street address'),
|
|
6
|
+
address_line2: string(),
|
|
7
|
+
address_city: string().required('Enter city'),
|
|
8
|
+
address_state: string().required('Choose state'),
|
|
9
|
+
address_postal_code: string()
|
|
10
|
+
.required('Enter ZIP')
|
|
11
|
+
.matches(RegExZip, 'Enter a valid ZIP')
|
|
12
|
+
.min(5, 'Enter a valid ZIP')
|
|
13
|
+
});
|
|
14
|
+
export default BillingFormSchema;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { Host, h } from '@stencil/core';
|
|
2
|
+
import BillingFormSchema from './billing-form-schema';
|
|
3
|
+
import StateOptions from './state-options';
|
|
4
|
+
export class BillingForm {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.billingFields = {
|
|
7
|
+
address_line1: '',
|
|
8
|
+
address_line2: '',
|
|
9
|
+
address_city: '',
|
|
10
|
+
address_state: '',
|
|
11
|
+
address_postal_code: ''
|
|
12
|
+
};
|
|
13
|
+
this.billingFieldsErrors = {};
|
|
14
|
+
}
|
|
15
|
+
setFormValue(event) {
|
|
16
|
+
const data = event.detail;
|
|
17
|
+
const billingFieldsClone = Object.assign({}, this.billingFields);
|
|
18
|
+
if (data.name) {
|
|
19
|
+
billingFieldsClone[data.name] = data.value;
|
|
20
|
+
this.billingFields = billingFieldsClone;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
async validate() {
|
|
24
|
+
const newErrors = {};
|
|
25
|
+
let isValid = true;
|
|
26
|
+
try {
|
|
27
|
+
await BillingFormSchema.validate(this.billingFields, { abortEarly: false });
|
|
28
|
+
}
|
|
29
|
+
catch (err) {
|
|
30
|
+
isValid = false;
|
|
31
|
+
err.inner.map((item) => {
|
|
32
|
+
newErrors[item.path] = item.message;
|
|
33
|
+
});
|
|
34
|
+
}
|
|
35
|
+
this.billingFieldsErrors = newErrors;
|
|
36
|
+
return { isValid: isValid };
|
|
37
|
+
}
|
|
38
|
+
render() {
|
|
39
|
+
return (h(Host, null, h("fieldset", null, h("text-input", { name: "address_line1", label: "Street Address", defaultValue: this.billingFields.address_line1, error: this.billingFieldsErrors.address_line1 }), h("text-input", { name: "address_line2", label: "Apartment, Suite, etc. (optional)", defaultValue: this.billingFields.address_line2, error: this.billingFieldsErrors.address_line2 }), h("text-input", { name: "address_city", label: "City", defaultValue: this.billingFields.address_city, error: this.billingFieldsErrors.address_city }), h("select-input", { name: "address_state", label: "State", options: StateOptions, defaultValue: this.billingFields.address_state, error: this.billingFieldsErrors.address_state }), h("text-input", { name: "address_postal_code", label: "ZIP", defaultValue: this.billingFields.address_postal_code, error: this.billingFieldsErrors.address_postal_code }))));
|
|
40
|
+
}
|
|
41
|
+
static get is() { return "justifi-billing-form"; }
|
|
42
|
+
static get encapsulation() { return "shadow"; }
|
|
43
|
+
static get originalStyleUrls() {
|
|
44
|
+
return {
|
|
45
|
+
"$": ["billing-form.css"]
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
static get styleUrls() {
|
|
49
|
+
return {
|
|
50
|
+
"$": ["billing-form.css"]
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
static get states() {
|
|
54
|
+
return {
|
|
55
|
+
"billingFields": {},
|
|
56
|
+
"billingFieldsErrors": {}
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
static get methods() {
|
|
60
|
+
return {
|
|
61
|
+
"validate": {
|
|
62
|
+
"complexType": {
|
|
63
|
+
"signature": "() => Promise<{ isValid: boolean; }>",
|
|
64
|
+
"parameters": [],
|
|
65
|
+
"references": {
|
|
66
|
+
"Promise": {
|
|
67
|
+
"location": "global"
|
|
68
|
+
},
|
|
69
|
+
"ValidationError": {
|
|
70
|
+
"location": "import",
|
|
71
|
+
"path": "yup"
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"return": "Promise<{ isValid: boolean; }>"
|
|
75
|
+
},
|
|
76
|
+
"docs": {
|
|
77
|
+
"text": "",
|
|
78
|
+
"tags": []
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
static get listeners() {
|
|
84
|
+
return [{
|
|
85
|
+
"name": "fieldReceivedInput",
|
|
86
|
+
"method": "setFormValue",
|
|
87
|
+
"target": undefined,
|
|
88
|
+
"capture": false,
|
|
89
|
+
"passive": false
|
|
90
|
+
}];
|
|
91
|
+
}
|
|
92
|
+
}
|