@justifi/webcomponents 0.0.10 → 0.0.12

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.
Files changed (44) hide show
  1. package/dist/cjs/{index-68222998.js → index-4f753ffd.js} +32 -1
  2. package/dist/cjs/index.cjs.js +0 -10
  3. package/dist/cjs/justifi-bank-account-form_4.cjs.entry.js +4352 -42
  4. package/dist/cjs/loader.cjs.js +4 -3
  5. package/dist/cjs/webcomponents.cjs.js +7 -3
  6. package/dist/collection/collection-manifest.json +4 -4
  7. package/dist/collection/components/bank-account-form/bank-account-form.js +43 -45
  8. package/dist/collection/components/card-form/card-form.js +66 -39
  9. package/dist/collection/components/payment-method-form/message-event-types.js +12 -0
  10. package/dist/collection/components/payment-method-form/payment-method-form.js +68 -73
  11. package/dist/collection/index.js +1 -3
  12. package/dist/components/index.d.ts +9 -0
  13. package/dist/components/index.js +4 -4
  14. package/dist/components/justifi-bank-account-form.js +17 -14
  15. package/dist/components/justifi-card-form.js +23 -11
  16. package/dist/components/justifi-payments-list.js +1 -1
  17. package/dist/components/payment-method-form.js +48 -39
  18. package/dist/esm/{index-e279d85e.js → index-3d88d85c.js} +32 -2
  19. package/dist/esm/index.js +1 -2
  20. package/dist/esm/justifi-bank-account-form_4.entry.js +4350 -40
  21. package/dist/esm/loader.js +4 -3
  22. package/dist/esm/polyfills/css-shim.js +1 -1
  23. package/dist/esm/webcomponents.js +4 -3
  24. package/dist/types/api/Api.d.ts +1 -1
  25. package/dist/types/api/Payment.d.ts +1 -1
  26. package/dist/types/components/bank-account-form/bank-account-form.d.ts +10 -5
  27. package/dist/types/components/card-form/card-form.d.ts +14 -3
  28. package/dist/types/components/payment-method-form/message-event-types.d.ts +12 -0
  29. package/dist/types/components/payment-method-form/payment-method-form.d.ts +5 -4
  30. package/dist/types/components.d.ts +13 -12
  31. package/dist/types/index.d.ts +1 -4
  32. package/dist/types/stencil-public-runtime.d.ts +48 -3
  33. package/dist/webcomponents/index.esm.js +0 -1
  34. package/dist/webcomponents/p-8ad58e9a.entry.js +1 -0
  35. package/dist/webcomponents/p-de108437.js +2 -0
  36. package/dist/webcomponents/webcomponents.esm.js +1 -1
  37. package/loader/index.d.ts +9 -0
  38. package/package.json +2 -3
  39. package/dist/cjs/payments-list-d2dfcef1.js +0 -4298
  40. package/dist/collection/components/card-form/card-form.css +0 -3
  41. package/dist/esm/payments-list-91eba70b.js +0 -4294
  42. package/dist/webcomponents/p-146348d6.js +0 -2
  43. package/dist/webcomponents/p-a688f9d3.entry.js +0 -1
  44. package/dist/webcomponents/p-c94a0f7f.js +0 -1
@@ -2,10 +2,10 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-68222998.js');
5
+ const index = require('./index-4f753ffd.js');
6
6
 
7
7
  /*
8
- Stencil Client Patch Esm v2.20.0 | MIT Licensed | https://stenciljs.com
8
+ Stencil Client Patch Esm v2.22.1 | MIT Licensed | https://stenciljs.com
9
9
  */
10
10
  const patchEsm = () => {
11
11
  return index.promiseResolve();
@@ -14,8 +14,9 @@ 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-form_4.cjs",[[0,"justifi-bank-account-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormChange","changeHandler"],[0,"paymentMethodFormBlur","blurHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"]]],[0,"justifi-card-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]}],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[0,"justifi-payment-method-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]}]]]], options);
17
+ return index.bootstrapLazy([["justifi-bank-account-form_4.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"tokenize":[64],"validate":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
21
+ exports.setNonce = index.setNonce;
21
22
  exports.defineCustomElements = defineCustomElements;
@@ -1,9 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-68222998.js');
3
+ Object.defineProperty(exports, '__esModule', { value: true });
4
+
5
+ const index = require('./index-4f753ffd.js');
4
6
 
5
7
  /*
6
- Stencil Client Patch Browser v2.20.0 | MIT Licensed | https://stenciljs.com
8
+ Stencil Client Patch Browser v2.22.1 | MIT Licensed | https://stenciljs.com
7
9
  */
8
10
  const patchBrowser = () => {
9
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));
@@ -15,5 +17,7 @@ const patchBrowser = () => {
15
17
  };
16
18
 
17
19
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["justifi-bank-account-form_4.cjs",[[0,"justifi-bank-account-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormChange","changeHandler"],[0,"paymentMethodFormBlur","blurHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"]]],[0,"justifi-card-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]}],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[0,"justifi-payment-method-form",{"iframeOrigin":[1,"iframe-origin"],"tokenize":[64]}]]]], options);
20
+ return index.bootstrapLazy([["justifi-bank-account-form_4.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[0,"justifi-card-form",{"validationStrategy":[1,"validation-strategy"],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]],[1,"justifi-payments-list",{"accountId":[1,"account-id"],"auth":[16],"payments":[32]}],[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1,"payment-method-form-validation-strategy"],"tokenize":[64],"validate":[64]}]]]], options);
19
21
  });
22
+
23
+ exports.setNonce = index.setNonce;
@@ -2,13 +2,13 @@
2
2
  "entries": [
3
3
  "./components/bank-account-form/bank-account-form.js",
4
4
  "./components/card-form/card-form.js",
5
- "./components/payments-list/payments-list.js",
6
- "./components/payment-method-form/payment-method-form.js"
5
+ "./components/payment-method-form/payment-method-form.js",
6
+ "./components/payments-list/payments-list.js"
7
7
  ],
8
8
  "compiler": {
9
9
  "name": "@stencil/core",
10
- "version": "2.20.0",
11
- "typescriptVersion": "4.8.4"
10
+ "version": "2.22.1",
11
+ "typescriptVersion": "4.9.4"
12
12
  },
13
13
  "collections": [],
14
14
  "bundles": []
@@ -1,42 +1,45 @@
1
1
  import { h } from '@stencil/core';
2
2
  export class BankAccountForm {
3
3
  constructor() {
4
- this.iframeOrigin = undefined;
4
+ this.validationStrategy = undefined;
5
5
  }
6
6
  readyHandler(event) {
7
7
  this.bankAccountFormReady.emit(event);
8
8
  }
9
- changeHandler(event) {
10
- this.bankAccountFormChange.emit(event);
11
- }
12
- blurHandler(event) {
13
- this.bankAccountFormBlur.emit(event);
14
- }
15
9
  tokenizeHandler(event) {
16
10
  this.bankAccountFormTokenize.emit(event);
17
11
  }
12
+ validateHandler(event) {
13
+ this.bankAccountFormValidate.emit(event);
14
+ }
18
15
  async tokenize(...args) {
19
16
  if (!this.childRef) {
20
17
  throw new Error('Cannot call tokenize');
21
18
  }
22
19
  return this.childRef.tokenize(...args);
23
20
  }
21
+ async validate() {
22
+ if (!this.childRef) {
23
+ throw new Error('Cannot call validate');
24
+ }
25
+ return this.childRef.validate();
26
+ }
24
27
  render() {
25
28
  return (h("justifi-payment-method-form", { ref: el => {
26
29
  if (el) {
27
30
  this.childRef = el;
28
31
  }
29
- }, "iframe-origin": this.iframeOrigin || 'https://js.justifi.ai/bank-account', "payment-method-form-ready": this.bankAccountFormReady, "payment-method-form-change": this.bankAccountFormChange, "payment-method-form-blur": this.bankAccountFormBlur, "payment-method-form-tokenize": this.bankAccountFormTokenize }));
32
+ }, "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' }));
30
33
  }
31
34
  static get is() { return "justifi-bank-account-form"; }
32
35
  static get properties() {
33
36
  return {
34
- "iframeOrigin": {
37
+ "validationStrategy": {
35
38
  "type": "string",
36
39
  "mutable": false,
37
40
  "complexType": {
38
- "original": "string",
39
- "resolved": "string",
41
+ "original": "'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all'",
42
+ "resolved": "\"all\" | \"onBlur\" | \"onChange\" | \"onSubmit\" | \"onTouched\"",
40
43
  "references": {}
41
44
  },
42
45
  "required": false,
@@ -45,7 +48,7 @@ export class BankAccountForm {
45
48
  "tags": [],
46
49
  "text": ""
47
50
  },
48
- "attribute": "iframe-origin",
51
+ "attribute": "validation-strategy",
49
52
  "reflect": false
50
53
  }
51
54
  };
@@ -67,8 +70,8 @@ export class BankAccountForm {
67
70
  "references": {}
68
71
  }
69
72
  }, {
70
- "method": "bankAccountFormChange",
71
- "name": "bankAccountFormChange",
73
+ "method": "bankAccountFormTokenize",
74
+ "name": "bankAccountFormTokenize",
72
75
  "bubbles": true,
73
76
  "cancelable": true,
74
77
  "composed": true,
@@ -77,13 +80,13 @@ export class BankAccountForm {
77
80
  "text": ""
78
81
  },
79
82
  "complexType": {
80
- "original": "any",
81
- "resolved": "any",
83
+ "original": "{ data: any }",
84
+ "resolved": "{ data: any; }",
82
85
  "references": {}
83
86
  }
84
87
  }, {
85
- "method": "bankAccountFormBlur",
86
- "name": "bankAccountFormBlur",
88
+ "method": "bankAccountFormValidate",
89
+ "name": "bankAccountFormValidate",
87
90
  "bubbles": true,
88
91
  "cancelable": true,
89
92
  "composed": true,
@@ -92,23 +95,8 @@ export class BankAccountForm {
92
95
  "text": ""
93
96
  },
94
97
  "complexType": {
95
- "original": "any",
96
- "resolved": "any",
97
- "references": {}
98
- }
99
- }, {
100
- "method": "bankAccountFormTokenize",
101
- "name": "bankAccountFormTokenize",
102
- "bubbles": true,
103
- "cancelable": true,
104
- "composed": true,
105
- "docs": {
106
- "tags": [],
107
- "text": ""
108
- },
109
- "complexType": {
110
- "original": "{ data: any }",
111
- "resolved": "{ data: any; }",
98
+ "original": "{ data: { isValid: boolean } }",
99
+ "resolved": "{ data: { isValid: boolean; }; }",
112
100
  "references": {}
113
101
  }
114
102
  }];
@@ -139,6 +127,22 @@ export class BankAccountForm {
139
127
  "text": "",
140
128
  "tags": []
141
129
  }
130
+ },
131
+ "validate": {
132
+ "complexType": {
133
+ "signature": "() => Promise<any>",
134
+ "parameters": [],
135
+ "references": {
136
+ "Promise": {
137
+ "location": "global"
138
+ }
139
+ },
140
+ "return": "Promise<any>"
141
+ },
142
+ "docs": {
143
+ "text": "",
144
+ "tags": []
145
+ }
142
146
  }
143
147
  };
144
148
  }
@@ -150,20 +154,14 @@ export class BankAccountForm {
150
154
  "capture": false,
151
155
  "passive": false
152
156
  }, {
153
- "name": "paymentMethodFormChange",
154
- "method": "changeHandler",
155
- "target": undefined,
156
- "capture": false,
157
- "passive": false
158
- }, {
159
- "name": "paymentMethodFormBlur",
160
- "method": "blurHandler",
157
+ "name": "paymentMethodFormTokenize",
158
+ "method": "tokenizeHandler",
161
159
  "target": undefined,
162
160
  "capture": false,
163
161
  "passive": false
164
162
  }, {
165
- "name": "paymentMethodFormTokenize",
166
- "method": "tokenizeHandler",
163
+ "name": "paymentMethodFormValidate",
164
+ "method": "validateHandler",
167
165
  "target": undefined,
168
166
  "capture": false,
169
167
  "passive": false
@@ -1,7 +1,16 @@
1
1
  import { h } from '@stencil/core';
2
2
  export class CardForm {
3
3
  constructor() {
4
- this.iframeOrigin = undefined;
4
+ this.validationStrategy = undefined;
5
+ }
6
+ readyHandler(event) {
7
+ this.cardFormReady.emit(event);
8
+ }
9
+ tokenizeHandler(event) {
10
+ this.cardFormTokenize.emit(event);
11
+ }
12
+ validateHandler(event) {
13
+ this.cardFormValidate.emit(event);
5
14
  }
6
15
  async tokenize(...args) {
7
16
  if (!this.childRef) {
@@ -9,32 +18,28 @@ export class CardForm {
9
18
  }
10
19
  return this.childRef.tokenize(...args);
11
20
  }
21
+ async validate() {
22
+ if (!this.childRef) {
23
+ throw new Error('Cannot call validate');
24
+ }
25
+ return this.childRef.validate();
26
+ }
12
27
  render() {
13
28
  return (h("justifi-payment-method-form", { ref: el => {
14
29
  if (el) {
15
30
  this.childRef = el;
16
31
  }
17
- }, "iframe-origin": this.iframeOrigin || 'https://js.justifi.ai/card', "payment-method-form-ready": this.cardFormReady, "payment-method-form-change": this.cardFormChange, "payment-method-form-blur": this.cardFormBlur, "payment-method-form-tokenize": this.cardFormTokenize }));
32
+ }, "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' }));
18
33
  }
19
34
  static get is() { return "justifi-card-form"; }
20
- static get originalStyleUrls() {
21
- return {
22
- "$": ["card-form.css"]
23
- };
24
- }
25
- static get styleUrls() {
26
- return {
27
- "$": ["card-form.css"]
28
- };
29
- }
30
35
  static get properties() {
31
36
  return {
32
- "iframeOrigin": {
37
+ "validationStrategy": {
33
38
  "type": "string",
34
39
  "mutable": false,
35
40
  "complexType": {
36
- "original": "string",
37
- "resolved": "string",
41
+ "original": "'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all'",
42
+ "resolved": "\"all\" | \"onBlur\" | \"onChange\" | \"onSubmit\" | \"onTouched\"",
38
43
  "references": {}
39
44
  },
40
45
  "required": false,
@@ -43,7 +48,7 @@ export class CardForm {
43
48
  "tags": [],
44
49
  "text": ""
45
50
  },
46
- "attribute": "iframe-origin",
51
+ "attribute": "validation-strategy",
47
52
  "reflect": false
48
53
  }
49
54
  };
@@ -65,23 +70,8 @@ export class CardForm {
65
70
  "references": {}
66
71
  }
67
72
  }, {
68
- "method": "cardFormChange",
69
- "name": "cardFormChange",
70
- "bubbles": true,
71
- "cancelable": true,
72
- "composed": true,
73
- "docs": {
74
- "tags": [],
75
- "text": ""
76
- },
77
- "complexType": {
78
- "original": "any",
79
- "resolved": "any",
80
- "references": {}
81
- }
82
- }, {
83
- "method": "cardFormBlur",
84
- "name": "cardFormBlur",
73
+ "method": "cardFormTokenize",
74
+ "name": "cardFormTokenize",
85
75
  "bubbles": true,
86
76
  "cancelable": true,
87
77
  "composed": true,
@@ -90,13 +80,13 @@ export class CardForm {
90
80
  "text": ""
91
81
  },
92
82
  "complexType": {
93
- "original": "any",
94
- "resolved": "any",
83
+ "original": "{ data: any }",
84
+ "resolved": "{ data: any; }",
95
85
  "references": {}
96
86
  }
97
87
  }, {
98
- "method": "cardFormTokenize",
99
- "name": "cardFormTokenize",
88
+ "method": "cardFormValidate",
89
+ "name": "cardFormValidate",
100
90
  "bubbles": true,
101
91
  "cancelable": true,
102
92
  "composed": true,
@@ -105,8 +95,8 @@ export class CardForm {
105
95
  "text": ""
106
96
  },
107
97
  "complexType": {
108
- "original": "{ data: any }",
109
- "resolved": "{ data: any; }",
98
+ "original": "{ data: { isValid: boolean } }",
99
+ "resolved": "{ data: { isValid: boolean; }; }",
110
100
  "references": {}
111
101
  }
112
102
  }];
@@ -137,7 +127,44 @@ export class CardForm {
137
127
  "text": "",
138
128
  "tags": []
139
129
  }
130
+ },
131
+ "validate": {
132
+ "complexType": {
133
+ "signature": "() => Promise<any>",
134
+ "parameters": [],
135
+ "references": {
136
+ "Promise": {
137
+ "location": "global"
138
+ }
139
+ },
140
+ "return": "Promise<any>"
141
+ },
142
+ "docs": {
143
+ "text": "",
144
+ "tags": []
145
+ }
140
146
  }
141
147
  };
142
148
  }
149
+ static get listeners() {
150
+ return [{
151
+ "name": "paymentMethodFormReady",
152
+ "method": "readyHandler",
153
+ "target": undefined,
154
+ "capture": false,
155
+ "passive": false
156
+ }, {
157
+ "name": "paymentMethodFormTokenize",
158
+ "method": "tokenizeHandler",
159
+ "target": undefined,
160
+ "capture": false,
161
+ "passive": false
162
+ }, {
163
+ "name": "paymentMethodFormValidate",
164
+ "method": "validateHandler",
165
+ "target": undefined,
166
+ "capture": false,
167
+ "passive": false
168
+ }];
169
+ }
143
170
  }
@@ -0,0 +1,12 @@
1
+ export const MessageEventType = {
2
+ card: {
3
+ ready: 'justifi.card.ready',
4
+ tokenize: 'justifi.card.tokenize',
5
+ validate: 'justifi.card.validate',
6
+ },
7
+ bankAccount: {
8
+ ready: 'justifi.bank_account.ready',
9
+ tokenize: 'justifi.bank_account.tokenize',
10
+ validate: 'justifi.bank_account.validate',
11
+ }
12
+ };
@@ -1,14 +1,9 @@
1
1
  import { Host, h } from '@stencil/core';
2
- var DispatchedEventTypes;
3
- (function (DispatchedEventTypes) {
4
- DispatchedEventTypes["blur"] = "blur";
5
- DispatchedEventTypes["change"] = "change";
6
- DispatchedEventTypes["ready"] = "ready";
7
- DispatchedEventTypes["tokenize"] = "tokenize";
8
- })(DispatchedEventTypes || (DispatchedEventTypes = {}));
2
+ import { MessageEventType } from './message-event-types';
9
3
  export class PaymentMethodForm {
10
4
  constructor() {
11
- this.iframeOrigin = undefined;
5
+ this.paymentMethodFormType = undefined;
6
+ this.paymentMethodFormValidationStrategy = undefined;
12
7
  }
13
8
  connectedCallback() {
14
9
  window.addEventListener('message', this.dispatchMessageEvent.bind(this));
@@ -20,45 +15,45 @@ export class PaymentMethodForm {
20
15
  const messagePayload = messageEvent.data;
21
16
  const messageType = messagePayload.eventType;
22
17
  const messageData = messagePayload.data;
23
- switch (messageType) {
24
- case DispatchedEventTypes.ready:
25
- this.paymentMethodFormReady.emit(messageData);
26
- break;
27
- case DispatchedEventTypes.change:
28
- this.paymentMethodFormChange.emit(messageData);
29
- break;
30
- case DispatchedEventTypes.blur:
31
- this.paymentMethodFormBlur.emit(messageData);
32
- break;
33
- default:
34
- break;
18
+ if (messageType === MessageEventType[this.paymentMethodFormType].ready) {
19
+ this.paymentMethodFormReady.emit(messageData);
35
20
  }
36
21
  }
37
- triggerTokenization(clientKey, paymentMethodMetadata, account) {
38
- if (this.iframeElement && this.iframeElement.contentWindow) {
39
- this.iframeElement.contentWindow.postMessage({
40
- eventType: DispatchedEventTypes.tokenize,
41
- clientKey: clientKey,
42
- paymentMethodMetadata: paymentMethodMetadata,
43
- account: account
44
- }, '*');
45
- }
46
- }
47
- async tokenize(clientKey, paymentMethodMetadata, account) {
22
+ async postMessageWithResponseListener(eventType, payload) {
48
23
  return new Promise((resolve) => {
49
- const tokenizeEventListener = (event) => {
50
- if (event.data.eventType !== DispatchedEventTypes.tokenize)
24
+ const responseListener = (event) => {
25
+ if (event.data.eventType !== eventType)
51
26
  return;
52
- window.removeEventListener('message', tokenizeEventListener);
27
+ window.removeEventListener('message', responseListener);
53
28
  resolve(event.data.data);
54
29
  };
55
- window.addEventListener('message', tokenizeEventListener);
56
- this.triggerTokenization(clientKey, paymentMethodMetadata, account);
30
+ window.addEventListener('message', responseListener);
31
+ this.iframeElement.contentWindow.postMessage(Object.assign({ eventType: eventType }, payload), '*');
57
32
  });
58
33
  }
34
+ async tokenize(clientKey, paymentMethodMetadata, account) {
35
+ const eventType = MessageEventType[this.paymentMethodFormType].tokenize;
36
+ const payload = {
37
+ clientKey: clientKey,
38
+ paymentMethodMetadata: paymentMethodMetadata,
39
+ account: account
40
+ };
41
+ return this.postMessageWithResponseListener(eventType, payload);
42
+ }
43
+ ;
44
+ async validate() {
45
+ return this.postMessageWithResponseListener(MessageEventType[this.paymentMethodFormType].validate);
46
+ }
59
47
  ;
48
+ getIframeSrc() {
49
+ let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
50
+ if (this.paymentMethodFormValidationStrategy) {
51
+ iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
52
+ }
53
+ return iframeSrc;
54
+ }
60
55
  render() {
61
- return (h(Host, null, h("iframe", { id: "justifi-payment-method-form", src: this.iframeOrigin, ref: (el) => this.iframeElement = el })));
56
+ return (h(Host, null, h("iframe", { id: `justifi-payment-method-form-${this.paymentMethodFormType}`, src: this.getIframeSrc(), ref: (el) => this.iframeElement = el })));
62
57
  }
63
58
  static get is() { return "justifi-payment-method-form"; }
64
59
  static get originalStyleUrls() {
@@ -73,12 +68,29 @@ export class PaymentMethodForm {
73
68
  }
74
69
  static get properties() {
75
70
  return {
76
- "iframeOrigin": {
71
+ "paymentMethodFormType": {
72
+ "type": "string",
73
+ "mutable": false,
74
+ "complexType": {
75
+ "original": "'card' | 'bankAccount'",
76
+ "resolved": "\"bankAccount\" | \"card\"",
77
+ "references": {}
78
+ },
79
+ "required": false,
80
+ "optional": false,
81
+ "docs": {
82
+ "tags": [],
83
+ "text": ""
84
+ },
85
+ "attribute": "payment-method-form-type",
86
+ "reflect": false
87
+ },
88
+ "paymentMethodFormValidationStrategy": {
77
89
  "type": "string",
78
90
  "mutable": false,
79
91
  "complexType": {
80
- "original": "string",
81
- "resolved": "string",
92
+ "original": "'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all'",
93
+ "resolved": "\"all\" | \"onBlur\" | \"onChange\" | \"onSubmit\" | \"onTouched\"",
82
94
  "references": {}
83
95
  },
84
96
  "required": false,
@@ -87,7 +99,7 @@ export class PaymentMethodForm {
87
99
  "tags": [],
88
100
  "text": ""
89
101
  },
90
- "attribute": "iframe-origin",
102
+ "attribute": "payment-method-form-validation-strategy",
91
103
  "reflect": false
92
104
  }
93
105
  };
@@ -108,36 +120,6 @@ export class PaymentMethodForm {
108
120
  "resolved": "any",
109
121
  "references": {}
110
122
  }
111
- }, {
112
- "method": "paymentMethodFormChange",
113
- "name": "paymentMethodFormChange",
114
- "bubbles": true,
115
- "cancelable": true,
116
- "composed": true,
117
- "docs": {
118
- "tags": [],
119
- "text": ""
120
- },
121
- "complexType": {
122
- "original": "any",
123
- "resolved": "any",
124
- "references": {}
125
- }
126
- }, {
127
- "method": "paymentMethodFormBlur",
128
- "name": "paymentMethodFormBlur",
129
- "bubbles": true,
130
- "cancelable": true,
131
- "composed": true,
132
- "docs": {
133
- "tags": [],
134
- "text": ""
135
- },
136
- "complexType": {
137
- "original": "any",
138
- "resolved": "any",
139
- "references": {}
140
- }
141
123
  }, {
142
124
  "method": "paymentMethodFormTokenize",
143
125
  "name": "paymentMethodFormTokenize",
@@ -173,8 +155,21 @@ export class PaymentMethodForm {
173
155
  "references": {
174
156
  "Promise": {
175
157
  "location": "global"
176
- },
177
- "MessageEvent": {
158
+ }
159
+ },
160
+ "return": "Promise<any>"
161
+ },
162
+ "docs": {
163
+ "text": "",
164
+ "tags": []
165
+ }
166
+ },
167
+ "validate": {
168
+ "complexType": {
169
+ "signature": "() => Promise<any>",
170
+ "parameters": [],
171
+ "references": {
172
+ "Promise": {
178
173
  "location": "global"
179
174
  }
180
175
  },
@@ -1,3 +1 @@
1
- export { BankAccountForm } from './components/bank-account-form/bank-account-form';
2
- export { CardForm } from './components/card-form/card-form';
3
- export { PaymentsList } from './components/payments-list/payments-list';
1
+ export * from './components';
@@ -16,6 +16,15 @@ export { PaymentsList as JustifiPaymentsList } from '../types/components/payment
16
16
  */
17
17
  export declare const setAssetPath: (path: string) => void;
18
18
 
19
+ /**
20
+ * Used to specify a nonce value that corresponds with an application's CSP.
21
+ * When set, the nonce will be added to all dynamically created script and style tags at runtime.
22
+ * Alternatively, the nonce value can be set on a meta tag in the DOM head
23
+ * (<meta name="csp-nonce" content="{ nonce value here }" />) which
24
+ * will result in the same behavior.
25
+ */
26
+ export declare const setNonce: (nonce: string) => void
27
+
19
28
  export interface SetPlatformOptions {
20
29
  raf?: (c: FrameRequestCallback) => number;
21
30
  ael?: (el: EventTarget, eventName: string, listener: EventListenerOrEventListenerObject, options: boolean | AddEventListenerOptions) => void;
@@ -1,5 +1,5 @@
1
- export { setAssetPath, setPlatformOptions } from '@stencil/core/internal/client';
2
- export { B as BankAccountForm, JustifiBankAccountForm, defineCustomElement as defineCustomElementJustifiBankAccountForm } from './justifi-bank-account-form.js';
3
- export { C as CardForm, JustifiCardForm, defineCustomElement as defineCustomElementJustifiCardForm } from './justifi-card-form.js';
4
- export { JustifiPaymentsList, P as PaymentsList, defineCustomElement as defineCustomElementJustifiPaymentsList } from './justifi-payments-list.js';
1
+ export { setAssetPath, setNonce, setPlatformOptions } from '@stencil/core/internal/client';
2
+ export { JustifiBankAccountForm, defineCustomElement as defineCustomElementJustifiBankAccountForm } from './justifi-bank-account-form.js';
3
+ export { JustifiCardForm, defineCustomElement as defineCustomElementJustifiCardForm } from './justifi-card-form.js';
5
4
  export { JustifiPaymentMethodForm, defineCustomElement as defineCustomElementJustifiPaymentMethodForm } from './justifi-payment-method-form.js';
5
+ export { JustifiPaymentsList, defineCustomElement as defineCustomElementJustifiPaymentsList } from './justifi-payments-list.js';