@justifi/webcomponents 3.3.5 → 4.0.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/CHANGELOG.md +40 -2
- package/changelog-template.hbs +3 -34
- package/dist/cjs/{Payment-5781460e.js → Payment-ac4dea02.js} +1 -1
- package/dist/cjs/index.esm-8df4906e.js +2092 -0
- package/dist/cjs/justifi-bank-account-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-billing-form_2.cjs.entry.js +14 -2104
- package/dist/cjs/justifi-business-address.cjs.entry.js +66 -0
- package/dist/cjs/justifi-card-form.cjs.entry.js +2 -2
- package/dist/cjs/justifi-payment-form.cjs.entry.js +4 -4
- package/dist/cjs/justifi-payment-method-form.cjs.entry.js +14 -14
- package/dist/cjs/justifi-payments-list.cjs.entry.js +9 -9
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/select-input_2.cjs.entry.js +2 -4
- package/dist/cjs/webcomponents.cjs.js +1 -1
- package/dist/collection/api/Api.js +3 -5
- package/dist/collection/api/Payment.js +1 -1
- package/dist/collection/api/mockData/MockPayments.js +24 -22
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/bank-account-form/bank-account-form.js +8 -4
- package/dist/collection/components/bank-account-form/bank-account-form.stories.js +13 -9
- package/dist/collection/components/bank-account-form/example.js +54 -0
- package/dist/collection/components/billing-form/billing-form-schema.js +1 -4
- package/dist/collection/components/billing-form/billing-form.js +7 -2
- package/dist/collection/components/billing-form/billing-form.stories.js +4 -4
- package/dist/collection/components/billing-form/example.js +26 -0
- package/dist/collection/components/billing-form/state-options.js +61 -61
- package/dist/collection/components/business-address/business-address-schema.js +13 -0
- package/dist/collection/components/business-address/business-address.css +2325 -0
- package/dist/collection/components/business-address/business-address.js +99 -0
- package/dist/collection/components/card-form/card-form.js +8 -4
- package/dist/collection/components/card-form/card-form.stories.js +11 -7
- package/dist/collection/components/card-form/example.js +59 -0
- package/dist/collection/components/payment-form/example.js +23 -0
- package/dist/collection/components/payment-form/payment-form.css +2 -0
- package/dist/collection/components/payment-form/payment-form.js +10 -5
- package/dist/collection/components/payment-form/payment-form.stories.js +15 -12
- package/dist/collection/components/payment-form/payment-method-selector.css +5 -0
- package/dist/collection/components/payment-form/payment-method-selector.js +2 -3
- package/dist/collection/components/payment-method-form/get-computed-theme.js +1 -1
- package/dist/collection/components/payment-method-form/message-event-types.js +1 -1
- package/dist/collection/components/payment-method-form/payment-method-form.js +11 -10
- package/dist/collection/components/payment-method-form/payment-method-responses.js +1 -0
- package/dist/collection/components/payments-list/payments-list.js +4 -4
- package/dist/collection/components/select-input/select-input.js +3 -4
- package/dist/collection/components/text-input/text-input.js +2 -3
- package/dist/collection/utils/utils.js +1 -5
- package/dist/components/Payment.js +1 -1
- package/dist/components/billing-form.js +4 -2093
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.js +1 -0
- package/dist/components/justifi-bank-account-form.js +2 -2
- package/dist/components/justifi-business-address.d.ts +11 -0
- package/dist/components/justifi-business-address.js +96 -0
- package/dist/components/justifi-card-form.js +2 -2
- package/dist/components/justifi-payment-form.js +3 -3
- package/dist/components/justifi-payments-list.js +8 -8
- package/dist/components/payment-method-form.js +14 -14
- package/dist/components/payment-method-selector.js +3 -4
- package/dist/components/select-input2.js +1 -2
- package/dist/components/state-options.js +2088 -0
- package/dist/components/text-input2.js +1 -2
- package/dist/esm/{Payment-3f7570a8.js → Payment-c86e1e84.js} +1 -1
- package/dist/esm/index.esm-c6a89005.js +2088 -0
- package/dist/esm/justifi-bank-account-form.entry.js +2 -2
- package/dist/esm/justifi-billing-form_2.entry.js +7 -2097
- package/dist/esm/justifi-business-address.entry.js +62 -0
- package/dist/esm/justifi-card-form.entry.js +2 -2
- package/dist/esm/justifi-payment-form.entry.js +4 -4
- package/dist/esm/justifi-payment-method-form.entry.js +14 -14
- package/dist/esm/justifi-payments-list.entry.js +9 -9
- package/dist/esm/loader.js +1 -1
- package/dist/esm/select-input_2.entry.js +2 -4
- package/dist/esm/webcomponents.js +1 -1
- package/dist/types/components/bank-account-form/bank-account-form.d.ts +7 -6
- package/dist/types/components/billing-form/billing-form.d.ts +5 -0
- package/dist/types/components/business-address/business-address-schema.d.ts +23 -0
- package/dist/types/components/business-address/business-address.d.ts +11 -0
- package/dist/types/components/card-form/card-form.d.ts +7 -6
- package/dist/types/components/payment-form/payment-form.d.ts +2 -3
- package/dist/types/components/payment-method-form/get-computed-theme.d.ts +1 -1
- package/dist/types/components/payment-method-form/payment-method-form.d.ts +2 -1
- package/dist/types/components/payment-method-form/payment-method-responses.d.ts +46 -0
- package/dist/types/components.d.ts +24 -8
- package/dist/webcomponents/p-039e3540.entry.js +1 -0
- package/dist/webcomponents/{p-64b19598.entry.js → p-11e5bef9.entry.js} +1 -1
- package/dist/webcomponents/p-20732337.js +1 -0
- package/dist/webcomponents/p-5b5e8351.entry.js +1 -0
- package/dist/webcomponents/{p-bf40b1ca.entry.js → p-7747c086.entry.js} +1 -1
- package/dist/webcomponents/{p-c3c51a2a.entry.js → p-b061da77.entry.js} +1 -1
- package/dist/webcomponents/webcomponents.css +1 -1
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +7 -4
- package/readme.md +7 -3
- package/dist/webcomponents/p-2530278e.entry.js +0 -1
- /package/dist/webcomponents/{p-21e020a8.js → p-1ca0646b.js} +0 -0
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import { Host, h } from '@stencil/core';
|
|
2
|
+
import StateOptions from '../billing-form/state-options';
|
|
3
|
+
import BusinessAddressFormSchema from './business-address-schema';
|
|
4
|
+
export class BusinessAddress {
|
|
5
|
+
constructor() {
|
|
6
|
+
this.businessAddress = {
|
|
7
|
+
line1: '',
|
|
8
|
+
line2: '',
|
|
9
|
+
city: '',
|
|
10
|
+
state: '',
|
|
11
|
+
postal_code: '',
|
|
12
|
+
country: ''
|
|
13
|
+
};
|
|
14
|
+
this.businessAddressErrors = {};
|
|
15
|
+
}
|
|
16
|
+
setFormValue(event) {
|
|
17
|
+
const data = event.detail;
|
|
18
|
+
const businessAddressClone = Object.assign({}, this.businessAddress);
|
|
19
|
+
if (data.name) {
|
|
20
|
+
businessAddressClone[data.name] = data.value;
|
|
21
|
+
this.businessAddress = businessAddressClone;
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
async submit() {
|
|
25
|
+
const newErrors = {};
|
|
26
|
+
let isValid = true;
|
|
27
|
+
try {
|
|
28
|
+
await BusinessAddressFormSchema.validate(this.businessAddress, { abortEarly: false });
|
|
29
|
+
}
|
|
30
|
+
catch (err) {
|
|
31
|
+
isValid = false;
|
|
32
|
+
err.inner.map((item) => {
|
|
33
|
+
newErrors[item.path] = item.message;
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
this.businessAddressErrors = newErrors;
|
|
37
|
+
return { isValid: isValid, values: this.businessAddress };
|
|
38
|
+
}
|
|
39
|
+
;
|
|
40
|
+
render() {
|
|
41
|
+
var _a, _b, _c, _d, _e, _f, _g, _h;
|
|
42
|
+
return (h(Host, { exportparts: "label,input,input-invalid" }, h("div", { class: "row gx-2 gy-2" }, h("div", { class: "col-12" }, h("text-input", { name: "line1", label: "Street Address", defaultValue: (_a = this.businessAddress) === null || _a === void 0 ? void 0 : _a.line1, error: (_b = this.businessAddressErrors) === null || _b === void 0 ? void 0 : _b.line1 })), h("div", { class: "col-12" }, h("text-input", { name: "line2", label: "Apartment, Suite, etc. (optional)", defaultValue: (_c = this.businessAddress) === null || _c === void 0 ? void 0 : _c.line2, error: (_d = this.businessAddressErrors) === null || _d === void 0 ? void 0 : _d.line2 })), h("div", { class: "col-12" }, h("text-input", { name: "city", label: "City", defaultValue: (_e = this.businessAddress) === null || _e === void 0 ? void 0 : _e.city, error: (_f = this.businessAddressErrors) === null || _f === void 0 ? void 0 : _f.city })), h("div", { class: "col-12" }, h("select-input", { name: "state", label: "State", options: StateOptions, defaultValue: this.businessAddress.state, error: this.businessAddressErrors.state })), h("div", { class: "col-12" }, h("text-input", { name: "postal_code", label: "Postal Code", defaultValue: (_g = this.businessAddress) === null || _g === void 0 ? void 0 : _g.postal_code, error: (_h = this.businessAddressErrors) === null || _h === void 0 ? void 0 : _h.postal_code })))));
|
|
43
|
+
}
|
|
44
|
+
static get is() { return "justifi-business-address"; }
|
|
45
|
+
static get encapsulation() { return "shadow"; }
|
|
46
|
+
static get originalStyleUrls() {
|
|
47
|
+
return {
|
|
48
|
+
"$": ["business-address.scss"]
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
static get styleUrls() {
|
|
52
|
+
return {
|
|
53
|
+
"$": ["business-address.css"]
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
static get states() {
|
|
57
|
+
return {
|
|
58
|
+
"businessAddress": {},
|
|
59
|
+
"businessAddressErrors": {}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
static get methods() {
|
|
63
|
+
return {
|
|
64
|
+
"submit": {
|
|
65
|
+
"complexType": {
|
|
66
|
+
"signature": "() => Promise<{ isValid: boolean; values: BusinessAddressFormFields; }>",
|
|
67
|
+
"parameters": [],
|
|
68
|
+
"references": {
|
|
69
|
+
"Promise": {
|
|
70
|
+
"location": "global"
|
|
71
|
+
},
|
|
72
|
+
"BusinessAddressFormFields": {
|
|
73
|
+
"location": "import",
|
|
74
|
+
"path": "./business-address-schema"
|
|
75
|
+
},
|
|
76
|
+
"ValidationError": {
|
|
77
|
+
"location": "import",
|
|
78
|
+
"path": "yup"
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
"return": "Promise<{ isValid: boolean; values: BusinessAddressFormFields; }>"
|
|
82
|
+
},
|
|
83
|
+
"docs": {
|
|
84
|
+
"text": "",
|
|
85
|
+
"tags": []
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}
|
|
90
|
+
static get listeners() {
|
|
91
|
+
return [{
|
|
92
|
+
"name": "fieldReceivedInput",
|
|
93
|
+
"method": "setFormValue",
|
|
94
|
+
"target": undefined,
|
|
95
|
+
"capture": false,
|
|
96
|
+
"passive": false
|
|
97
|
+
}];
|
|
98
|
+
}
|
|
99
|
+
}
|
|
@@ -17,7 +17,7 @@ export class CardForm {
|
|
|
17
17
|
}
|
|
18
18
|
/**
|
|
19
19
|
* Makes a tokenization request to the iframe
|
|
20
|
-
|
|
20
|
+
*/
|
|
21
21
|
async tokenize(...args) {
|
|
22
22
|
if (!this.childRef) {
|
|
23
23
|
throw new Error('Cannot call tokenize');
|
|
@@ -26,7 +26,7 @@ export class CardForm {
|
|
|
26
26
|
}
|
|
27
27
|
/**
|
|
28
28
|
* Runs a validation on the form and shows errors if any
|
|
29
|
-
|
|
29
|
+
*/
|
|
30
30
|
async validate() {
|
|
31
31
|
if (!this.childRef) {
|
|
32
32
|
throw new Error('Cannot call validate');
|
|
@@ -163,7 +163,7 @@ export class CardForm {
|
|
|
163
163
|
return {
|
|
164
164
|
"tokenize": {
|
|
165
165
|
"complexType": {
|
|
166
|
-
"signature": "(clientId: string, paymentMethodMetadata: any, account?: string) => Promise<
|
|
166
|
+
"signature": "(clientId: string, paymentMethodMetadata: any, account?: string) => Promise<CreatePaymentMethodResponse>",
|
|
167
167
|
"parameters": [{
|
|
168
168
|
"tags": [],
|
|
169
169
|
"text": ""
|
|
@@ -172,6 +172,10 @@ export class CardForm {
|
|
|
172
172
|
"Promise": {
|
|
173
173
|
"location": "global"
|
|
174
174
|
},
|
|
175
|
+
"CreatePaymentMethodResponse": {
|
|
176
|
+
"location": "import",
|
|
177
|
+
"path": "../payment-method-form/payment-method-responses"
|
|
178
|
+
},
|
|
175
179
|
"Parameters": {
|
|
176
180
|
"location": "global"
|
|
177
181
|
},
|
|
@@ -179,7 +183,7 @@ export class CardForm {
|
|
|
179
183
|
"location": "global"
|
|
180
184
|
}
|
|
181
185
|
},
|
|
182
|
-
"return": "Promise<
|
|
186
|
+
"return": "Promise<CreatePaymentMethodResponse>"
|
|
183
187
|
},
|
|
184
188
|
"docs": {
|
|
185
189
|
"text": "Makes a tokenization request to the iframe",
|
|
@@ -8,11 +8,11 @@ export default {
|
|
|
8
8
|
table: {
|
|
9
9
|
disable: isDev ? false : true,
|
|
10
10
|
category: 'props',
|
|
11
|
-
}
|
|
11
|
+
},
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
decorators: [
|
|
15
|
-
|
|
15
|
+
story => `
|
|
16
16
|
${story()}
|
|
17
17
|
<script>${addEvents()}</script>
|
|
18
18
|
`,
|
|
@@ -31,8 +31,12 @@ const handleReady = () => {
|
|
|
31
31
|
const cardForm = document.querySelector('justifi-card-form');
|
|
32
32
|
const validateBtn = document.querySelector('#validate-btn');
|
|
33
33
|
const tokenizeBtn = document.querySelector('#tokenize-btn');
|
|
34
|
-
validateBtn === null || validateBtn === void 0 ? void 0 : validateBtn.addEventListener('click', () => {
|
|
35
|
-
|
|
34
|
+
validateBtn === null || validateBtn === void 0 ? void 0 : validateBtn.addEventListener('click', () => {
|
|
35
|
+
handleValidateClick(cardForm);
|
|
36
|
+
});
|
|
37
|
+
tokenizeBtn === null || tokenizeBtn === void 0 ? void 0 : tokenizeBtn.addEventListener('click', () => {
|
|
38
|
+
handleTokenizeClick(cardForm, {});
|
|
39
|
+
});
|
|
36
40
|
};
|
|
37
41
|
const addEvents = () => {
|
|
38
42
|
addEventListener('cardFormReady', handleReady);
|
|
@@ -56,7 +60,7 @@ const FormButtons = `
|
|
|
56
60
|
</div>`;
|
|
57
61
|
const Template = (args) => {
|
|
58
62
|
const includeButtons = true;
|
|
59
|
-
return
|
|
63
|
+
return `
|
|
60
64
|
<div>
|
|
61
65
|
<style>
|
|
62
66
|
:root {
|
|
@@ -71,7 +75,7 @@ const Template = (args) => {
|
|
|
71
75
|
/>
|
|
72
76
|
</div>
|
|
73
77
|
${includeButtons ? FormButtons : ''}
|
|
74
|
-
|
|
78
|
+
`;
|
|
75
79
|
};
|
|
76
80
|
export const Basic = Template.bind({});
|
|
77
81
|
Basic.args = {
|
|
@@ -116,5 +120,5 @@ const styledVariables = `
|
|
|
116
120
|
`;
|
|
117
121
|
export const Styled = Template.bind({});
|
|
118
122
|
Styled.args = {
|
|
119
|
-
'css-variables': styledVariables
|
|
123
|
+
'css-variables': styledVariables,
|
|
120
124
|
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { head } from '../../../storybook-pages/example-parts';
|
|
2
|
+
|
|
3
|
+
export default `<!DOCTYPE html>
|
|
4
|
+
<html dir="ltr" lang="en">
|
|
5
|
+
|
|
6
|
+
${head('justifi-card-form')}
|
|
7
|
+
|
|
8
|
+
<body>
|
|
9
|
+
<justifi-card-form></justifi-card-form>
|
|
10
|
+
<button type="submit" id="card-submit-button">Tokenize</button>
|
|
11
|
+
<button type="submit" id="card-validate-button">Validate</button>
|
|
12
|
+
</body>
|
|
13
|
+
|
|
14
|
+
<script>
|
|
15
|
+
(function () {
|
|
16
|
+
// Card form component
|
|
17
|
+
var cardForm = document.querySelector('justifi-card-form');
|
|
18
|
+
var cardSubmitButton = document.querySelector('#card-submit-button');
|
|
19
|
+
var cardValidateButton = document.querySelector('#card-validate-button');
|
|
20
|
+
|
|
21
|
+
cardForm.addEventListener('cardFormReady', function () {
|
|
22
|
+
console.log('justifi-card-form ready');
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
cardSubmitButton.addEventListener('click', (event) => {
|
|
26
|
+
console.log('card form tokenize button clicked');
|
|
27
|
+
// All of this information would come from your form instead of being hard coded
|
|
28
|
+
// Card number, expiration and cvv are collected on our iframe
|
|
29
|
+
const paymentMethodData = {
|
|
30
|
+
name: 'John Doe',
|
|
31
|
+
address_line1: '123 Broadway', // optional
|
|
32
|
+
address_line2: '', // optional
|
|
33
|
+
address_city: 'Minneapolis', // optional
|
|
34
|
+
address_state: 'MN', // optional
|
|
35
|
+
address_postal_code: '55413',
|
|
36
|
+
address_country: 'US', // optional
|
|
37
|
+
metadata: { something: "somevalue" } // optional
|
|
38
|
+
};
|
|
39
|
+
// ACCOUNT_ID is optional, currently required for platforms
|
|
40
|
+
// ACCOUNT_ID is the seller account for which you are tokenizing
|
|
41
|
+
cardForm.tokenize('CLIENT_ID', paymentMethodData, 'ACCOUNT_ID')
|
|
42
|
+
.then((data) => {
|
|
43
|
+
// This is where you can submit the form and use the payment method token
|
|
44
|
+
// on your backend
|
|
45
|
+
console.log('justifi-card-form tokenized: ', data);
|
|
46
|
+
});
|
|
47
|
+
});
|
|
48
|
+
|
|
49
|
+
cardValidateButton.addEventListener('click', (event) => {
|
|
50
|
+
console.log('card validate button clicked');
|
|
51
|
+
cardForm.validate()
|
|
52
|
+
.then((data) => {
|
|
53
|
+
console.log('justifi-card-form validated. Is valid? ', data.isValid);
|
|
54
|
+
});
|
|
55
|
+
});
|
|
56
|
+
})();
|
|
57
|
+
</script>
|
|
58
|
+
|
|
59
|
+
</html>`;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { head } from '../../../storybook-pages/example-parts';
|
|
2
|
+
|
|
3
|
+
export default `<!DOCTYPE html>
|
|
4
|
+
<html dir="ltr" lang="en">
|
|
5
|
+
|
|
6
|
+
${head('justifi-payment-form')}
|
|
7
|
+
|
|
8
|
+
<body>
|
|
9
|
+
<justifi-payment-form bank-account="true" card="true"></justifi-payment-form>
|
|
10
|
+
</body>
|
|
11
|
+
|
|
12
|
+
<script>
|
|
13
|
+
(function () {
|
|
14
|
+
var paymentForm = document.querySelector('justifi-payment-form');
|
|
15
|
+
|
|
16
|
+
paymentForm.addEventListener('submitted', (data) => {
|
|
17
|
+
// here is where you would submit a payment with the token
|
|
18
|
+
console.log('data');
|
|
19
|
+
});
|
|
20
|
+
})();
|
|
21
|
+
</script>
|
|
22
|
+
|
|
23
|
+
</html>`;
|
|
@@ -1990,6 +1990,8 @@ justifi-payment-method-form {
|
|
|
1990
1990
|
padding: var(--jfi-submit-button-padding);
|
|
1991
1991
|
font-size: var(--jfi-submit-button-font-size);
|
|
1992
1992
|
border-radius: var(--jfi-submit-button-border-radius);
|
|
1993
|
+
width: var(--jfi-submit-button-width);
|
|
1994
|
+
box-shadow: var(--jfi-submit-button-box-shadow);
|
|
1993
1995
|
}
|
|
1994
1996
|
|
|
1995
1997
|
.jfi-submit-button:hover {
|
|
@@ -50,7 +50,7 @@ export class PaymentForm {
|
|
|
50
50
|
this.submitted.emit(tokenizeResponse);
|
|
51
51
|
}
|
|
52
52
|
render() {
|
|
53
|
-
return (h(Host, null, h("form", { class: "row gy-3" },
|
|
53
|
+
return (h(Host, null, h("form", { class: "row gy-3" }, this.allowedPaymentMethodTypes.length > 1 && (h("div", { class: "col-12" }, h("justifi-payment-method-selector", { paymentMethodTypes: this.allowedPaymentMethodTypes, selectedPaymentMethodType: this.selectedPaymentMethodType }))), h("div", { class: "col-12" }, h("justifi-payment-method-form", { "payment-method-form-type": this.selectedPaymentMethodType, "iframe-origin": this.iframeOrigin, ref: el => {
|
|
54
54
|
if (el) {
|
|
55
55
|
this.paymentMethodFormRef = el;
|
|
56
56
|
}
|
|
@@ -58,7 +58,7 @@ export class PaymentForm {
|
|
|
58
58
|
if (el) {
|
|
59
59
|
this.billingFormRef = el;
|
|
60
60
|
}
|
|
61
|
-
} })), h("div", { class: "col-12" }, h("button", { onClick:
|
|
61
|
+
} })), h("div", { class: "col-12" }, h("button", { onClick: event => this.submit(event), disabled: !this.submitButtonEnabled, type: "submit", class: "btn btn-primary jfi-submit-button" }, this.submitButtonText || 'Submit')))));
|
|
62
62
|
}
|
|
63
63
|
static get is() { return "justifi-payment-form"; }
|
|
64
64
|
static get encapsulation() { return "shadow"; }
|
|
@@ -214,9 +214,14 @@ export class PaymentForm {
|
|
|
214
214
|
"text": ""
|
|
215
215
|
},
|
|
216
216
|
"complexType": {
|
|
217
|
-
"original": "
|
|
218
|
-
"resolved": "
|
|
219
|
-
"references": {
|
|
217
|
+
"original": "CreatePaymentMethodResponse",
|
|
218
|
+
"resolved": "BankAccountCreateResponse | CardCreateResponse",
|
|
219
|
+
"references": {
|
|
220
|
+
"CreatePaymentMethodResponse": {
|
|
221
|
+
"location": "import",
|
|
222
|
+
"path": "../payment-method-form/payment-method-responses"
|
|
223
|
+
}
|
|
224
|
+
}
|
|
220
225
|
}
|
|
221
226
|
}];
|
|
222
227
|
}
|
|
@@ -8,13 +8,13 @@ export default {
|
|
|
8
8
|
table: {
|
|
9
9
|
disable: isDev ? false : true,
|
|
10
10
|
category: 'props',
|
|
11
|
-
}
|
|
11
|
+
},
|
|
12
12
|
},
|
|
13
13
|
},
|
|
14
14
|
};
|
|
15
15
|
const Template = (args) => {
|
|
16
16
|
// The <div> here should be replaced by a `display` property in the cardForm potentially
|
|
17
|
-
return
|
|
17
|
+
return `
|
|
18
18
|
<div>
|
|
19
19
|
<justifi-payment-form
|
|
20
20
|
card=${args.card}
|
|
@@ -43,28 +43,28 @@ const Template = (args) => {
|
|
|
43
43
|
});
|
|
44
44
|
})()
|
|
45
45
|
</script>
|
|
46
|
-
|
|
46
|
+
`;
|
|
47
47
|
};
|
|
48
48
|
export const Basic = Template.bind({});
|
|
49
49
|
Basic.args = {
|
|
50
50
|
'bank-account': true,
|
|
51
|
-
card: true,
|
|
52
|
-
email: '',
|
|
51
|
+
'card': true,
|
|
52
|
+
'email': '',
|
|
53
53
|
'client-id': '',
|
|
54
54
|
'account-id': '',
|
|
55
55
|
'submit-button-text': '',
|
|
56
|
-
'iframe-origin': ''
|
|
56
|
+
'iframe-origin': '',
|
|
57
57
|
};
|
|
58
58
|
export const Styled = Template.bind({});
|
|
59
59
|
Styled.args = {
|
|
60
60
|
'bank-account': true,
|
|
61
|
-
card: true,
|
|
62
|
-
email: '',
|
|
61
|
+
'card': true,
|
|
62
|
+
'email': '',
|
|
63
63
|
'client-id': '',
|
|
64
64
|
'account-id': '',
|
|
65
65
|
'submit-button-text': '',
|
|
66
66
|
'iframe-origin': '',
|
|
67
|
-
cssVariables:
|
|
67
|
+
'cssVariables': `
|
|
68
68
|
--jfi-primary-color: #212529;
|
|
69
69
|
|
|
70
70
|
--jfi-layout-padding: 0;
|
|
@@ -99,11 +99,11 @@ Styled.args = {
|
|
|
99
99
|
--jfi-error-message-font-size: .875rem;
|
|
100
100
|
|
|
101
101
|
--jfi-submit-button-color: white;
|
|
102
|
-
--jfi-submit-button-background-color:
|
|
102
|
+
--jfi-submit-button-background-color: #3F3F47;
|
|
103
103
|
--jfi-submit-button-border-color: var(--jfi-primary-color);
|
|
104
104
|
--jfi-submit-button-padding: 0.375rem 0.75rem;
|
|
105
105
|
--jfi-submit-button-font-size: 1rem;
|
|
106
|
-
--jfi-submit-button-border-radius:
|
|
106
|
+
--jfi-submit-button-border-radius: 1px;
|
|
107
107
|
--jfi-submit-button-color-hover: white;
|
|
108
108
|
--jfi-submit-button-background-color-hover: var(--jfi-primary-color);
|
|
109
109
|
--jfi-submit-button-border-color-hover: var(--jfi-primary-color);
|
|
@@ -113,6 +113,8 @@ Styled.args = {
|
|
|
113
113
|
--jfi-submit-button-color-active: white;
|
|
114
114
|
--jfi-submit-button-background-color-active: var(--jfi-primary-color);
|
|
115
115
|
--jfi-submit-button-border-color-active: var(--jfi-primary-color);
|
|
116
|
+
--jfi-submit-button-width: 100%;
|
|
117
|
+
--jfi-submit-button-box-shadow: rgba(0, 0, 0, 0.2) 0px 3px 1px -2px, rgba(0, 0, 0, 0.14) 0px 2px 2px 0px, rgba(0, 0, 0, 0.12) 0px 1px 5px 0px;
|
|
116
118
|
|
|
117
119
|
--jfi-radio-button-color: var(--jfi-primary-color);
|
|
118
120
|
--jfi-radio-button-background-color: transparent;
|
|
@@ -128,5 +130,6 @@ Styled.args = {
|
|
|
128
130
|
--jfi-radio-button-background-color-selected-hover: var(--jfi-primary-color);
|
|
129
131
|
--jfi-radio-button-border-color-selected-hover: var(--jfi-primary-color);
|
|
130
132
|
--jfi-radio-button-border-color-hover: var(--jfi-primary-color);
|
|
131
|
-
|
|
133
|
+
--jfi-radio-button-group-width: 100%;
|
|
134
|
+
`,
|
|
132
135
|
};
|
|
@@ -1360,4 +1360,9 @@ textarea.form-control-lg {
|
|
|
1360
1360
|
color: var(--jfi-radio-button-color-selected);
|
|
1361
1361
|
background-color: var(--jfi-radio-button-background-color-selected);
|
|
1362
1362
|
border-color: var(--jfi-radio-button-border-color-selected);
|
|
1363
|
+
}
|
|
1364
|
+
|
|
1365
|
+
.jfi-btn-radio-group {
|
|
1366
|
+
display: inline-flex;
|
|
1367
|
+
width: var(--jfi-radio-button-group-width);
|
|
1363
1368
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { Fragment, h } from '@stencil/core';
|
|
2
2
|
const PaymentMethodLabels = {
|
|
3
3
|
bankAccount: 'Bank Account',
|
|
4
|
-
card: 'Card'
|
|
4
|
+
card: 'Card',
|
|
5
5
|
};
|
|
6
6
|
export class PaymentMethodSelector {
|
|
7
7
|
constructor() {
|
|
@@ -12,9 +12,8 @@ export class PaymentMethodSelector {
|
|
|
12
12
|
this.paymentMethodSelected.emit(event.target.value);
|
|
13
13
|
}
|
|
14
14
|
render() {
|
|
15
|
-
return (h("div", { class: "btn-group", role: "group", "aria-label": "Radio toggle group for payment method" }, this.paymentMethodTypes.map((paymentMethodType) => h(Fragment, null, h("input", { id: paymentMethodType, type: "radio", name: "paymentMethodType", value: paymentMethodType, onChange: (event) => this.onChangeHandler(event), checked: this.selectedPaymentMethodType === paymentMethodType, class: "btn-check jfi-btn-radio" }), h("label", { htmlFor: paymentMethodType, class: "btn btn-outline-primary jfi-btn-radio-label" }, PaymentMethodLabels[paymentMethodType])))));
|
|
15
|
+
return (h("div", { class: "btn-group jfi-btn-radio-group", role: "group", "aria-label": "Radio toggle group for payment method" }, this.paymentMethodTypes.map((paymentMethodType) => (h(Fragment, null, h("input", { id: paymentMethodType, type: "radio", name: "paymentMethodType", value: paymentMethodType, onChange: (event) => this.onChangeHandler(event), checked: this.selectedPaymentMethodType === paymentMethodType, class: "btn-check jfi-btn-radio" }), h("label", { htmlFor: paymentMethodType, class: "btn btn-outline-primary jfi-btn-radio-label" }, PaymentMethodLabels[paymentMethodType]))))));
|
|
16
16
|
}
|
|
17
|
-
;
|
|
18
17
|
static get is() { return "justifi-payment-method-selector"; }
|
|
19
18
|
static get encapsulation() { return "shadow"; }
|
|
20
19
|
static get originalStyleUrls() {
|
|
@@ -41,7 +41,7 @@ const getComputedTheme = () => {
|
|
|
41
41
|
color: computedStyles.getPropertyValue('--jfi-error-message-color'),
|
|
42
42
|
margin: computedStyles.getPropertyValue('--jfi-error-message-margin'),
|
|
43
43
|
fontSize: computedStyles.getPropertyValue('--jfi-error-message-font-size'),
|
|
44
|
-
}
|
|
44
|
+
},
|
|
45
45
|
};
|
|
46
46
|
return computedTheme;
|
|
47
47
|
};
|
|
@@ -40,9 +40,8 @@ export class PaymentMethodForm {
|
|
|
40
40
|
var _a, _b;
|
|
41
41
|
(_b = (_a = this.iframeElement) === null || _a === void 0 ? void 0 : _a.contentWindow) === null || _b === void 0 ? void 0 : _b.postMessage(Object.assign({ eventType: eventType }, payload), '*');
|
|
42
42
|
}
|
|
43
|
-
;
|
|
44
43
|
async postMessageWithResponseListener(eventType, payload) {
|
|
45
|
-
return new Promise(
|
|
44
|
+
return new Promise(resolve => {
|
|
46
45
|
const responseListener = (event) => {
|
|
47
46
|
if (event.data.eventType !== eventType)
|
|
48
47
|
return;
|
|
@@ -63,18 +62,16 @@ export class PaymentMethodForm {
|
|
|
63
62
|
};
|
|
64
63
|
return this.postMessageWithResponseListener(eventType, payload);
|
|
65
64
|
}
|
|
66
|
-
;
|
|
67
65
|
async validate() {
|
|
68
66
|
return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
|
|
69
67
|
}
|
|
70
|
-
;
|
|
71
68
|
composeQueryParams(values) {
|
|
72
|
-
const queryParams = values.map(
|
|
69
|
+
const queryParams = values.map(value => {
|
|
73
70
|
if (value === values[0]) {
|
|
74
|
-
return value = `?${value}
|
|
71
|
+
return (value = `?${value}`);
|
|
75
72
|
}
|
|
76
73
|
else {
|
|
77
|
-
return value = `&${value}
|
|
74
|
+
return (value = `&${value}`);
|
|
78
75
|
}
|
|
79
76
|
});
|
|
80
77
|
return queryParams.join('');
|
|
@@ -93,7 +90,7 @@ export class PaymentMethodForm {
|
|
|
93
90
|
return iframeSrc.concat(this.composeQueryParams(paramsList));
|
|
94
91
|
}
|
|
95
92
|
render() {
|
|
96
|
-
return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref:
|
|
93
|
+
return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: el => (this.iframeElement = el), height: this.height })));
|
|
97
94
|
}
|
|
98
95
|
static get is() { return "justifi-payment-method-form"; }
|
|
99
96
|
static get originalStyleUrls() {
|
|
@@ -220,7 +217,7 @@ export class PaymentMethodForm {
|
|
|
220
217
|
return {
|
|
221
218
|
"tokenize": {
|
|
222
219
|
"complexType": {
|
|
223
|
-
"signature": "(clientId: string, paymentMethodMetadata: any, account?: string) => Promise<
|
|
220
|
+
"signature": "(clientId: string, paymentMethodMetadata: any, account?: string) => Promise<CreatePaymentMethodResponse>",
|
|
224
221
|
"parameters": [{
|
|
225
222
|
"tags": [],
|
|
226
223
|
"text": ""
|
|
@@ -234,9 +231,13 @@ export class PaymentMethodForm {
|
|
|
234
231
|
"references": {
|
|
235
232
|
"Promise": {
|
|
236
233
|
"location": "global"
|
|
234
|
+
},
|
|
235
|
+
"CreatePaymentMethodResponse": {
|
|
236
|
+
"location": "import",
|
|
237
|
+
"path": "./payment-method-responses"
|
|
237
238
|
}
|
|
238
239
|
},
|
|
239
|
-
"return": "Promise<
|
|
240
|
+
"return": "Promise<CreatePaymentMethodResponse>"
|
|
240
241
|
},
|
|
241
242
|
"docs": {
|
|
242
243
|
"text": "",
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -13,15 +13,15 @@ export class PaymentsList {
|
|
|
13
13
|
fetchData() {
|
|
14
14
|
const accountId = this.accountId;
|
|
15
15
|
const endpoint = `account/${accountId}/payments`;
|
|
16
|
-
Api(this.auth.token)
|
|
16
|
+
Api(this.auth.token)
|
|
17
|
+
.get(endpoint)
|
|
17
18
|
.then((response) => {
|
|
18
|
-
const data = response.data.map(
|
|
19
|
+
const data = response.data.map(dataItem => new Payment(dataItem));
|
|
19
20
|
this.payments = data;
|
|
20
21
|
});
|
|
21
22
|
}
|
|
22
|
-
;
|
|
23
23
|
render() {
|
|
24
|
-
return (h(Host, null, h("table", { class: "justifi-table" }, h("thead", null, h("tr", null, h("th", { scope: "col", title: "The date and time each payment was made" }, "Made on"), h("th", { scope: "col", title: "The dollar amount of each payment" }, "Amount"), h("th", { scope: "col" }, "Account"), h("th", { scope: "col" }, "Description"), h("th", { scope: "col" }, "Payment ID"), h("th", { scope: "col" }, "Cardholder"), h("th", { scope: "col" }, "Payment Method"), h("th", { scope: "col" }, "Status"))), h("tbody", null, this.payments.map(
|
|
24
|
+
return (h(Host, null, h("table", { class: "justifi-table" }, h("thead", null, h("tr", null, h("th", { scope: "col", title: "The date and time each payment was made" }, "Made on"), h("th", { scope: "col", title: "The dollar amount of each payment" }, "Amount"), h("th", { scope: "col" }, "Account"), h("th", { scope: "col" }, "Description"), h("th", { scope: "col" }, "Payment ID"), h("th", { scope: "col" }, "Cardholder"), h("th", { scope: "col" }, "Payment Method"), h("th", { scope: "col" }, "Status"))), h("tbody", null, this.payments.map(payment => {
|
|
25
25
|
var _a, _b, _c, _d;
|
|
26
26
|
h("tr", null, h("td", null, h("div", null, formatDate(payment.created_at)), h("div", null, formatTime(payment.created_at))), h("td", null, formatCurrency(payment.amount)), h("td", null, payment.account_id), h("td", null, payment.description), h("td", null, payment.id), h("td", null, (_b = (_a = payment.payment_method) === null || _a === void 0 ? void 0 : _a.card) === null || _b === void 0 ? void 0 : _b.name), h("td", null, (_d = (_c = payment.payment_method) === null || _c === void 0 ? void 0 : _c.card) === null || _d === void 0 ? void 0 : _d.acct_last_four), h("td", null, payment.status));
|
|
27
27
|
})))));
|
|
@@ -13,9 +13,8 @@ export class SelectInput {
|
|
|
13
13
|
const name = target.getAttribute('name');
|
|
14
14
|
this.fieldReceivedInput.emit({ name: name, value: target.value });
|
|
15
15
|
}
|
|
16
|
-
;
|
|
17
16
|
render() {
|
|
18
|
-
return (h(Host, { exportparts: "label,input,input-invalid" }, h("label", { part: "label", class: "form-label" }, this.label), h("select", { name: this.name, onInput:
|
|
17
|
+
return (h(Host, { exportparts: "label,input,input-invalid" }, h("label", { part: "label", class: "form-label" }, this.label), h("select", { name: this.name, onInput: event => this.onInput(event), part: `input ${this.error && 'input-invalid'}`, class: this.error ? 'form-select is-invalid' : 'form-select' }, this.options.map(option => (h("option", { value: option.value }, option.label)))), this.error && h("div", { class: "invalid-feedback" }, this.error)));
|
|
19
18
|
}
|
|
20
19
|
static get is() { return "select-input"; }
|
|
21
20
|
static get encapsulation() { return "shadow"; }
|
|
@@ -103,7 +102,7 @@ export class SelectInput {
|
|
|
103
102
|
"type": "unknown",
|
|
104
103
|
"mutable": false,
|
|
105
104
|
"complexType": {
|
|
106
|
-
"original": "{ label: string
|
|
105
|
+
"original": "{ label: string; value: string }[]",
|
|
107
106
|
"resolved": "{ label: string; value: string; }[]",
|
|
108
107
|
"references": {}
|
|
109
108
|
},
|
|
@@ -133,7 +132,7 @@ export class SelectInput {
|
|
|
133
132
|
"text": ""
|
|
134
133
|
},
|
|
135
134
|
"complexType": {
|
|
136
|
-
"original": "{ name: string
|
|
135
|
+
"original": "{ name: string; value: string }",
|
|
137
136
|
"resolved": "{ name: string; value: string; }",
|
|
138
137
|
"references": {}
|
|
139
138
|
}
|
|
@@ -12,9 +12,8 @@ export class TextInput {
|
|
|
12
12
|
const name = target.getAttribute('name');
|
|
13
13
|
this.fieldReceivedInput.emit({ name: name, value: target.value });
|
|
14
14
|
}
|
|
15
|
-
;
|
|
16
15
|
render() {
|
|
17
|
-
return (h(Host, { exportparts: "label,input,input-invalid" }, h("label", { part: "label", class: "form-label" }, this.label), h("input", { name: this.name, type: "text", onInput:
|
|
16
|
+
return (h(Host, { exportparts: "label,input,input-invalid" }, h("label", { part: "label", class: "form-label" }, this.label), h("input", { name: this.name, type: "text", onInput: event => this.onInput(event), value: this.internalValue || this.defaultValue, part: `input ${this.error && 'input-invalid'}`, class: this.error ? 'form-control is-invalid' : 'form-control' }), this.error && h("div", { class: "invalid-feedback" }, this.error)));
|
|
18
17
|
}
|
|
19
18
|
static get is() { return "text-input"; }
|
|
20
19
|
static get encapsulation() { return "shadow"; }
|
|
@@ -117,7 +116,7 @@ export class TextInput {
|
|
|
117
116
|
"text": ""
|
|
118
117
|
},
|
|
119
118
|
"complexType": {
|
|
120
|
-
"original": "{ name: string
|
|
119
|
+
"original": "{ name: string; value: string }",
|
|
121
120
|
"resolved": "{ name: string; value: string; }",
|
|
122
121
|
"references": {}
|
|
123
122
|
}
|
|
@@ -7,27 +7,23 @@ export function formatCurrency(amount, withSymbol = true) {
|
|
|
7
7
|
const formattedString = withSymbol ? '$0,0.00' : '0,0.00';
|
|
8
8
|
return Dinero({ amount: amount, currency: 'USD' }).toFormat(formattedString);
|
|
9
9
|
}
|
|
10
|
-
return
|
|
10
|
+
return amount < 0 ? `(${format(-amount)})` : format(amount);
|
|
11
11
|
}
|
|
12
|
-
;
|
|
13
12
|
export function formatDate(dateString) {
|
|
14
13
|
if (!dateString)
|
|
15
14
|
return '';
|
|
16
15
|
const date = new Date(dateString);
|
|
17
16
|
return format(date, 'MMM d, yyyy');
|
|
18
17
|
}
|
|
19
|
-
;
|
|
20
18
|
export function formatTime(dateString) {
|
|
21
19
|
if (!dateString)
|
|
22
20
|
return '';
|
|
23
21
|
const date = new Date(dateString);
|
|
24
22
|
return format(date, 'h:mmaaa');
|
|
25
23
|
}
|
|
26
|
-
;
|
|
27
24
|
export function formatTimeSeconds(dateString) {
|
|
28
25
|
if (!dateString)
|
|
29
26
|
return '';
|
|
30
27
|
const date = new Date(dateString);
|
|
31
28
|
return format(date, 'h:mm:ssaaa');
|
|
32
29
|
}
|
|
33
|
-
;
|
|
@@ -52,7 +52,7 @@ class Payment {
|
|
|
52
52
|
this.updated_at = payment.updated_at;
|
|
53
53
|
}
|
|
54
54
|
get disputedStatus() {
|
|
55
|
-
const lost = this.disputes.some(
|
|
55
|
+
const lost = this.disputes.some(dispute => dispute.status === PaymentDisputedStatuses.lost);
|
|
56
56
|
// if a dispute is 'won', we don't show a dispute status, just general status
|
|
57
57
|
if (!this.disputed) {
|
|
58
58
|
return null;
|