@justifi/webcomponents 0.2.2 → 0.4.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.
Files changed (81) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/cjs/Payment-5781460e.js +71 -0
  3. package/dist/cjs/{index-ca2cd154.js → index-4f2a13d2.js} +13 -389
  4. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +3 -2
  5. package/dist/cjs/{justifi-billing-form.cjs.entry.js → justifi-billing-form_2.cjs.entry.js} +33 -2
  6. package/dist/cjs/justifi-card-form.cjs.entry.js +3 -2
  7. package/dist/cjs/justifi-payment-form.cjs.entry.js +46 -3
  8. package/dist/cjs/justifi-payment-method-form.cjs.entry.js +28 -17
  9. package/dist/cjs/justifi-payments-list.cjs.entry.js +3 -70
  10. package/dist/cjs/loader.cjs.js +2 -2
  11. package/dist/cjs/select-input_2.cjs.entry.js +2 -4
  12. package/dist/cjs/webcomponents.cjs.js +2 -2
  13. package/dist/collection/api/Payment.js +1 -1
  14. package/dist/collection/collection-manifest.json +1 -0
  15. package/dist/collection/components/bank-account-form/bank-account-form.js +21 -3
  16. package/dist/collection/components/billing-form/billing-form.js +73 -1
  17. package/dist/collection/components/billing-form/billing-form.stories.js +14 -0
  18. package/dist/collection/components/card-form/card-form.js +21 -3
  19. package/dist/collection/components/card-form/card-form.stories.js +35 -28
  20. package/dist/collection/components/payment-form/payment-form.js +145 -7
  21. package/dist/collection/components/payment-form/payment-form.stories.js +82 -0
  22. package/dist/collection/components/payment-form/payment-method-selector.js +86 -0
  23. package/dist/collection/components/payment-form/tokenize.js +1 -0
  24. package/dist/collection/components/payment-method-form/payment-method-form.js +22 -2
  25. package/dist/collection/components/select-input/select-input.js +1 -3
  26. package/dist/components/Payment.js +69 -0
  27. package/dist/components/billing-form.js +2188 -0
  28. package/dist/components/index.d.ts +1 -0
  29. package/dist/components/index.js +1 -0
  30. package/dist/components/justifi-bank-account-form.js +5 -3
  31. package/dist/components/justifi-billing-form.js +1 -2175
  32. package/dist/components/justifi-card-form.js +5 -3
  33. package/dist/components/justifi-payment-form.js +85 -6
  34. package/dist/components/justifi-payment-method-selector.d.ts +11 -0
  35. package/dist/components/justifi-payment-method-selector.js +6 -0
  36. package/dist/components/justifi-payments-list.js +1 -68
  37. package/dist/components/payment-method-form.js +29 -17
  38. package/dist/components/payment-method-selector.js +42 -0
  39. package/dist/components/select-input2.js +1 -3
  40. package/dist/esm/Payment-3f7570a8.js +69 -0
  41. package/dist/esm/{index-05706eb5.js → index-3ce5521c.js} +13 -389
  42. package/dist/esm/justifi-bank-account-form.entry.js +3 -2
  43. package/dist/esm/{justifi-billing-form.entry.js → justifi-billing-form_2.entry.js} +33 -3
  44. package/dist/esm/justifi-card-form.entry.js +3 -2
  45. package/dist/esm/justifi-payment-form.entry.js +46 -3
  46. package/dist/esm/justifi-payment-method-form.entry.js +28 -17
  47. package/dist/esm/justifi-payments-list.entry.js +2 -69
  48. package/dist/esm/loader.js +2 -2
  49. package/dist/esm/select-input_2.entry.js +2 -4
  50. package/dist/esm/webcomponents.js +2 -2
  51. package/dist/types/api/Payment.d.ts +1 -1
  52. package/dist/types/components/bank-account-form/bank-account-form.d.ts +1 -0
  53. package/dist/types/components/billing-form/billing-form-schema.d.ts +7 -0
  54. package/dist/types/components/billing-form/billing-form.d.ts +5 -8
  55. package/dist/types/components/billing-form/billing-form.stories.d.ts +7 -0
  56. package/dist/types/components/card-form/card-form.d.ts +1 -0
  57. package/dist/types/components/card-form/card-form.stories.d.ts +1 -0
  58. package/dist/types/components/payment-form/payment-form.d.ts +17 -1
  59. package/dist/types/components/payment-form/payment-form.stories.d.ts +44 -0
  60. package/dist/types/components/payment-form/payment-method-selector.d.ts +10 -0
  61. package/dist/types/components/payment-form/tokenize.d.ts +5 -0
  62. package/dist/types/components/payment-method-form/payment-method-form.d.ts +1 -0
  63. package/dist/types/components.d.ts +42 -2
  64. package/dist/webcomponents/p-21e020a8.js +1 -0
  65. package/dist/webcomponents/p-2e5be95e.entry.js +1 -0
  66. package/dist/webcomponents/p-6633de1b.entry.js +1 -0
  67. package/dist/webcomponents/p-68e47ee5.entry.js +1 -0
  68. package/dist/webcomponents/p-6a9c764f.entry.js +1 -0
  69. package/dist/webcomponents/p-6c3a226e.entry.js +1 -0
  70. package/dist/webcomponents/{p-3809130a.entry.js → p-763a2b4f.entry.js} +1 -1
  71. package/dist/webcomponents/p-92ca574f.entry.js +1 -0
  72. package/dist/webcomponents/p-9f34a2c1.js +2 -0
  73. package/dist/webcomponents/webcomponents.esm.js +1 -1
  74. package/package.json +23 -15
  75. package/dist/webcomponents/p-4009b629.entry.js +0 -1
  76. package/dist/webcomponents/p-787671b9.entry.js +0 -1
  77. package/dist/webcomponents/p-87654bf4.entry.js +0 -1
  78. package/dist/webcomponents/p-8ee06fd1.js +0 -2
  79. package/dist/webcomponents/p-94ef2d0e.entry.js +0 -1
  80. package/dist/webcomponents/p-c07191dc.entry.js +0 -1
  81. package/dist/webcomponents/p-e5b0f047.entry.js +0 -1
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
6
 
7
7
  const BankAccountForm = class {
8
8
  constructor(hostRef) {
@@ -12,6 +12,7 @@ const BankAccountForm = class {
12
12
  this.bankAccountFormValidate = index.createEvent(this, "bankAccountFormValidate", 7);
13
13
  this.validationStrategy = undefined;
14
14
  this.styleOverrides = undefined;
15
+ this.iframeOrigin = undefined;
15
16
  this.internalStyleOverrides = undefined;
16
17
  }
17
18
  readyHandler(event) {
@@ -49,7 +50,7 @@ const BankAccountForm = class {
49
50
  if (el) {
50
51
  this.childRef = el;
51
52
  }
52
- }, "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 }));
53
+ }, "iframe-origin": this.iframeOrigin, "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 }));
53
54
  }
54
55
  static get watchers() { return {
55
56
  "styleOverrides": ["parseStyleOverrides"]
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
6
 
7
7
  /**
8
8
  * Based on Kendo UI Core expression code <https://github.com/telerik/kendo-ui-core#license-information>
@@ -2109,6 +2109,8 @@ const billingFormCss = ":host{display:block}label{display:block}input{margin-bot
2109
2109
  const BillingForm = class {
2110
2110
  constructor(hostRef) {
2111
2111
  index.registerInstance(this, hostRef);
2112
+ this.legendBlock = (index.h("legend", null, this.legend));
2113
+ this.legend = undefined;
2112
2114
  this.billingFields = {
2113
2115
  address_line1: '',
2114
2116
  address_line2: '',
@@ -2126,6 +2128,9 @@ const BillingForm = class {
2126
2128
  this.billingFields = billingFieldsClone;
2127
2129
  }
2128
2130
  }
2131
+ async fill(fields) {
2132
+ this.billingFields = Object.assign({}, fields);
2133
+ }
2129
2134
  async validate() {
2130
2135
  const newErrors = {};
2131
2136
  let isValid = true;
@@ -2141,10 +2146,36 @@ const BillingForm = class {
2141
2146
  this.billingFieldsErrors = newErrors;
2142
2147
  return { isValid: isValid };
2143
2148
  }
2149
+ async getValues() {
2150
+ return this.billingFields;
2151
+ }
2144
2152
  render() {
2145
- return (index.h(index.Host, null, index.h("fieldset", null, index.h("text-input", { name: "address_line1", label: "Street Address", defaultValue: this.billingFields.address_line1, error: this.billingFieldsErrors.address_line1 }), index.h("text-input", { name: "address_line2", label: "Apartment, Suite, etc. (optional)", defaultValue: this.billingFields.address_line2, error: this.billingFieldsErrors.address_line2 }), index.h("text-input", { name: "address_city", label: "City", defaultValue: this.billingFields.address_city, error: this.billingFieldsErrors.address_city }), index.h("select-input", { name: "address_state", label: "State", options: StateOptions, defaultValue: this.billingFields.address_state, error: this.billingFieldsErrors.address_state }), index.h("text-input", { name: "address_postal_code", label: "ZIP", defaultValue: this.billingFields.address_postal_code, error: this.billingFieldsErrors.address_postal_code }))));
2153
+ return (index.h(index.Host, null, index.h("fieldset", null, this.legend && this.legendBlock, index.h("text-input", { name: "address_line1", label: "Street Address", defaultValue: this.billingFields.address_line1, error: this.billingFieldsErrors.address_line1 }), index.h("text-input", { name: "address_line2", label: "Apartment, Suite, etc. (optional)", defaultValue: this.billingFields.address_line2, error: this.billingFieldsErrors.address_line2 }), index.h("text-input", { name: "address_city", label: "City", defaultValue: this.billingFields.address_city, error: this.billingFieldsErrors.address_city }), index.h("select-input", { name: "address_state", label: "State", options: StateOptions, defaultValue: this.billingFields.address_state, error: this.billingFieldsErrors.address_state }), index.h("text-input", { name: "address_postal_code", label: "ZIP", defaultValue: this.billingFields.address_postal_code, error: this.billingFieldsErrors.address_postal_code }))));
2146
2154
  }
2147
2155
  };
2148
2156
  BillingForm.style = billingFormCss;
2149
2157
 
2158
+ const PaymentMethodLabels = {
2159
+ bankAccount: 'Bank Account',
2160
+ card: 'Card'
2161
+ };
2162
+ const PaymentMethodSelector = class {
2163
+ constructor(hostRef) {
2164
+ index.registerInstance(this, hostRef);
2165
+ this.paymentMethodSelected = index.createEvent(this, "paymentMethodSelected", 7);
2166
+ this.paymentMethodTypes = [];
2167
+ this.selectedPaymentMethodType = undefined;
2168
+ }
2169
+ onChangeHandler(event) {
2170
+ this.paymentMethodSelected.emit(event.target.value);
2171
+ }
2172
+ render() {
2173
+ return (index.h("div", null, this.paymentMethodTypes.map((paymentMethodType) => {
2174
+ return (index.h("div", null, index.h("input", { id: paymentMethodType, type: "radio", name: "paymentMethodType", value: paymentMethodType, onChange: (event) => this.onChangeHandler(event), checked: this.selectedPaymentMethodType === paymentMethodType }), index.h("label", { htmlFor: paymentMethodType }, PaymentMethodLabels[paymentMethodType])));
2175
+ })));
2176
+ }
2177
+ ;
2178
+ };
2179
+
2150
2180
  exports.justifi_billing_form = BillingForm;
2181
+ exports.justifi_payment_method_selector = PaymentMethodSelector;
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
6
 
7
7
  const CardForm = class {
8
8
  constructor(hostRef) {
@@ -12,6 +12,7 @@ const CardForm = class {
12
12
  this.cardFormValidate = index.createEvent(this, "cardFormValidate", 7);
13
13
  this.validationStrategy = undefined;
14
14
  this.styleOverrides = undefined;
15
+ this.iframeOrigin = undefined;
15
16
  this.internalStyleOverrides = undefined;
16
17
  }
17
18
  readyHandler(event) {
@@ -49,7 +50,7 @@ const CardForm = class {
49
50
  if (el) {
50
51
  this.childRef = el;
51
52
  }
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
+ }, "iframe-origin": this.iframeOrigin, "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
  }
54
55
  static get watchers() { return {
55
56
  "styleOverrides": ["parseStyleOverrides"]
@@ -2,15 +2,58 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
+ const Payment = require('./Payment-5781460e.js');
6
7
 
7
8
  const PaymentForm = class {
8
9
  constructor(hostRef) {
9
10
  index.registerInstance(this, hostRef);
10
- this.validationStrategy = undefined;
11
+ this.bankAccount = undefined;
12
+ this.card = undefined;
13
+ this.iframeOrigin = undefined;
14
+ this.selectedPaymentMethodType = undefined;
15
+ this.allowedPaymentMethodTypes = [];
16
+ }
17
+ connectedCallback() {
18
+ if (this.card) {
19
+ this.allowedPaymentMethodTypes.push(Payment.PaymentMethodTypes.card);
20
+ }
21
+ if (this.bankAccount) {
22
+ this.allowedPaymentMethodTypes.push(Payment.PaymentMethodTypes.bankAccount);
23
+ }
24
+ if (!this.allowedPaymentMethodTypes.length) {
25
+ this.allowedPaymentMethodTypes.push(Payment.PaymentMethodTypes.card);
26
+ }
27
+ this.selectedPaymentMethodType = this.allowedPaymentMethodTypes[0];
28
+ }
29
+ paymentMethodSelectedHandler(event) {
30
+ const paymentMethodType = event.detail;
31
+ this.selectedPaymentMethodType = paymentMethodType;
32
+ }
33
+ async fillBillingForm(fields) {
34
+ this.billingFormRef.fill(fields);
35
+ }
36
+ async submit(args) {
37
+ if (!this.paymentMethodFormRef || !this.billingFormRef)
38
+ return;
39
+ const billingFormValidation = await this.billingFormRef.validate();
40
+ const paymentMethodFormValidation = await this.paymentMethodFormRef.validate();
41
+ if (!billingFormValidation.isValid || !paymentMethodFormValidation.isValid)
42
+ return;
43
+ const billingFormFieldValues = await this.billingFormRef.getValues();
44
+ const paymentMethodData = Object.assign(Object.assign({}, args.paymentMethodData), billingFormFieldValues);
45
+ return this.paymentMethodFormRef.tokenize(args.clientId, paymentMethodData, args.accountId);
11
46
  }
12
47
  render() {
13
- return (index.h(index.Host, null, index.h("form", null, index.h("slot", null))));
48
+ return (index.h(index.Host, null, index.h("form", null, (this.allowedPaymentMethodTypes.length > 1) && (index.h("justifi-payment-method-selector", { paymentMethodTypes: this.allowedPaymentMethodTypes, selectedPaymentMethodType: this.selectedPaymentMethodType })), index.h("justifi-payment-method-form", { "payment-method-form-type": this.selectedPaymentMethodType, "iframe-origin": this.iframeOrigin, ref: el => {
49
+ if (el) {
50
+ this.paymentMethodFormRef = el;
51
+ }
52
+ } }), index.h("justifi-billing-form", { legend: "Billing Info", ref: el => {
53
+ if (el) {
54
+ this.billingFormRef = el;
55
+ }
56
+ } }))));
14
57
  }
15
58
  };
16
59
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
6
 
7
7
  const MessageEventType = {
8
8
  card: {
@@ -22,7 +22,7 @@ const MessageEventType = {
22
22
  };
23
23
 
24
24
  const name = "@justifi/webcomponents";
25
- const version = "0.2.2";
25
+ const version = "0.4.0";
26
26
  const description = "JustiFi Web Components";
27
27
  const main = "dist/index.cjs.js";
28
28
  const module$1 = "dist/index.js";
@@ -47,11 +47,11 @@ const scripts = {
47
47
  build: "stencil build --docs",
48
48
  start: "concurrently -c \"bgBlue.bold,bgMagenta.bold,bgGreen.bold\" \"yarn run start-stencil\" \"yarn run storybook\"",
49
49
  "start-stencil": "stencil build --watch --serve --no-open",
50
- test: "stencil test --spec --e2e",
51
- "test:watch": "stencil test --spec --e2e --watchAll",
50
+ test: "stencil test --spec",
51
+ "test:watch": "stencil test --spec --watchAll",
52
52
  generate: "stencil generate",
53
- storybook: "start-storybook -p 6006",
54
- "build-storybook": "build-storybook"
53
+ storybook: "storybook dev -p 6006 --quiet",
54
+ "build-storybook": "storybook build"
55
55
  };
56
56
  const dependencies = {
57
57
  "@stencil/core": "^2.13.0",
@@ -62,22 +62,30 @@ const dependencies = {
62
62
  yup: "^1.0.0"
63
63
  };
64
64
  const devDependencies = {
65
+ "@babel/preset-env": "^7.21.4",
66
+ "@babel/preset-typescript": "^7.21.4",
65
67
  "@pxtrn/storybook-addon-docs-stencil": "^6.4.1",
66
- "@storybook/addon-actions": "^6.5.16",
67
- "@storybook/addon-essentials": "^6.5.16",
68
- "@storybook/addon-interactions": "^6.5.16",
69
- "@storybook/addon-links": "^6.5.16",
70
- "@storybook/builder-webpack4": "^6.5.16",
71
- "@storybook/html": "^6.5.16",
72
- "@storybook/manager-webpack4": "^6.5.16",
73
- "@storybook/testing-library": "^0.0.13",
74
- "@types/jest": "^27.0.3",
68
+ "@storybook/addon-actions": "^7.0.4",
69
+ "@storybook/addon-essentials": "^7.0.4",
70
+ "@storybook/addon-interactions": "^7.0.4",
71
+ "@storybook/addon-links": "^7.0.4",
72
+ "@storybook/html": "^7.0.4",
73
+ "@storybook/html-webpack5": "^7.0.4",
74
+ "@storybook/jest": "^0.1.0",
75
+ "@storybook/testing-library": "^0.1.0",
76
+ "@types/jest": "27.0.3",
77
+ "@types/node": "^18.15.11",
78
+ "@types/react": "^18.0.37",
79
+ "@types/react-dom": "^18.0.11",
75
80
  "auto-changelog": "^2.4.0",
76
81
  concurrently: "^7.6.0",
77
82
  jest: "^27.4.5",
78
83
  "jest-cli": "^27.4.5",
79
84
  puppeteer: "^10.0.0",
80
- "release-it": "^15.6.0"
85
+ react: "^18.2.0",
86
+ "react-dom": "^18.2.0",
87
+ "release-it": "^15.6.0",
88
+ storybook: "^7.0.4"
81
89
  };
82
90
  const license = "MIT";
83
91
  const packageJson = {
@@ -110,6 +118,7 @@ const PaymentMethodForm = class {
110
118
  this.paymentMethodFormType = undefined;
111
119
  this.paymentMethodFormValidationStrategy = undefined;
112
120
  this.paymentMethodStyleOverrides = undefined;
121
+ this.iframeOrigin = undefined;
113
122
  this.height = 55;
114
123
  }
115
124
  connectedCallback() {
@@ -171,7 +180,9 @@ const PaymentMethodForm = class {
171
180
  }
172
181
  ;
173
182
  getIframeSrc() {
174
- let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
183
+ const productionIframeOrigin = 'https://js.justifi.ai/v2';
184
+ const iframeOrigin = this.iframeOrigin || productionIframeOrigin;
185
+ let iframeSrc = `${iframeOrigin}/${this.paymentMethodFormType}`;
175
186
  if (this.paymentMethodFormValidationStrategy) {
176
187
  iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
177
188
  }
@@ -2,7 +2,8 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
+ const Payment = require('./Payment-5781460e.js');
6
7
 
7
8
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
8
9
  // require the crypto API and do not support built-in fallback to lower quality random number
@@ -110,74 +111,6 @@ function handleError(requestUrl) {
110
111
  console.error(`Error fetching from ${requestUrl}`);
111
112
  }
112
113
 
113
- var CaptureStrategy;
114
- (function (CaptureStrategy) {
115
- CaptureStrategy["automatic"] = "automatic";
116
- CaptureStrategy["manual"] = "manual";
117
- })(CaptureStrategy || (CaptureStrategy = {}));
118
- var PaymentMethodTypes;
119
- (function (PaymentMethodTypes) {
120
- PaymentMethodTypes["card"] = "card";
121
- PaymentMethodTypes["bankAccount"] = "bank_account";
122
- })(PaymentMethodTypes || (PaymentMethodTypes = {}));
123
- var PaymentStatuses;
124
- (function (PaymentStatuses) {
125
- PaymentStatuses["pending"] = "pending";
126
- PaymentStatuses["authorized"] = "authorized";
127
- PaymentStatuses["succeeded"] = "succeeded";
128
- PaymentStatuses["failed"] = "failed";
129
- PaymentStatuses["disputed"] = "disputed";
130
- PaymentStatuses["fully_refunded"] = "fully_refunded";
131
- PaymentStatuses["partially_refunded"] = "partially_refunded";
132
- })(PaymentStatuses || (PaymentStatuses = {}));
133
- var PaymentDisputedStatuses;
134
- (function (PaymentDisputedStatuses) {
135
- // if a dispute is 'won', we don't show a dispute status, just general status
136
- PaymentDisputedStatuses["lost"] = "lost";
137
- PaymentDisputedStatuses["open"] = "open";
138
- })(PaymentDisputedStatuses || (PaymentDisputedStatuses = {}));
139
- class Payment {
140
- constructor(payment) {
141
- this.id = payment.id;
142
- this.account_id = payment.account_id;
143
- this.amount = payment.amount;
144
- this.amount_disputed = payment.amount_disputed;
145
- this.amount_refundable = payment.amount_refundable;
146
- this.amount_refunded = payment.amount_refunded;
147
- this.balance = payment.balance;
148
- this.captured = payment.captured;
149
- this.capture_strategy = payment.capture_strategy;
150
- this.currency = payment.currency;
151
- this.description = payment.description;
152
- this.disputed = payment.disputed;
153
- this.disputes = payment.disputes;
154
- this.error_code = payment.error_code;
155
- this.error_description = payment.error_description;
156
- this.fee_amount = payment.fee_amount;
157
- this.is_test = payment.is_test;
158
- this.metadata = payment.metadata;
159
- this.payment_method = payment.payment_method;
160
- this.payment_intent_id = payment.payment_intent_id;
161
- this.refunded = payment.refunded;
162
- this.status = payment.status;
163
- this.created_at = payment.created_at;
164
- this.updated_at = payment.updated_at;
165
- }
166
- get disputedStatus() {
167
- const lost = this.disputes.some((dispute) => dispute.status === PaymentDisputedStatuses.lost);
168
- // if a dispute is 'won', we don't show a dispute status, just general status
169
- if (!this.disputed) {
170
- return null;
171
- }
172
- else if (lost) {
173
- return PaymentDisputedStatuses.lost;
174
- }
175
- else {
176
- return PaymentDisputedStatuses.open;
177
- }
178
- }
179
- }
180
-
181
114
  function toInteger(dirtyNumber) {
182
115
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
183
116
  return NaN;
@@ -4214,7 +4147,7 @@ const PaymentsList = class {
4214
4147
  const endpoint = `account/${accountId}/payments`;
4215
4148
  Api(this.auth.token).get(endpoint)
4216
4149
  .then((response) => {
4217
- const data = response.data.map((dataItem) => new Payment(dataItem));
4150
+ const data = response.data.map((dataItem) => new Payment.Payment(dataItem));
4218
4151
  this.payments = data;
4219
4152
  });
4220
4153
  }
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
6
 
7
7
  /*
8
8
  Stencil Client Patch Esm v2.20.0 | MIT Licensed | https://stenciljs.com
@@ -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-billing-form.cjs",[[1,"justifi-billing-form",{"billingFields":[32],"billingFieldsErrors":[32],"validate":[64]},[[0,"fieldReceivedInput","setFormValue"]]]]],["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-payment-form.cjs",[[4,"justifi-payment-form",{"validationStrategy":[1,"validation-strategy"]}]]],["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]}]]],["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]}]]]], options);
17
+ return index.bootstrapLazy([["justifi-payment-form.cjs",[[0,"justifi-payment-form",{"bankAccount":[4,"bank-account"],"card":[4],"iframeOrigin":[1,"iframe-origin"],"selectedPaymentMethodType":[32],"allowedPaymentMethodTypes":[32],"fillBillingForm":[64],"submit":[64]},[[0,"paymentMethodSelected","paymentMethodSelectedHandler"]]]]],["justifi-bank-account-form.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1025,"validation-strategy"],"styleOverrides":[1025,"style-overrides"],"iframeOrigin":[1025,"iframe-origin"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]]]],["justifi-card-form.cjs",[[0,"justifi-card-form",{"validationStrategy":[1025,"validation-strategy"],"styleOverrides":[1025,"style-overrides"],"iframeOrigin":[1025,"iframe-origin"],"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]}]]],["justifi-billing-form_2.cjs",[[1,"justifi-billing-form",{"legend":[1],"billingFields":[32],"billingFieldsErrors":[32],"fill":[64],"validate":[64],"getValues":[64]},[[0,"fieldReceivedInput","setFormValue"]]],[0,"justifi-payment-method-selector",{"paymentMethodTypes":[16],"selectedPaymentMethodType":[1,"selected-payment-method-type"]}]]],["justifi-payment-method-form.cjs",[[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1025,"payment-method-form-validation-strategy"],"paymentMethodStyleOverrides":[16],"iframeOrigin":[1,"iframe-origin"],"height":[32],"tokenize":[64],"validate":[64]}]]]], options);
18
18
  });
19
19
  };
20
20
 
@@ -2,7 +2,7 @@
2
2
 
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
- const index = require('./index-ca2cd154.js');
5
+ const index = require('./index-4f2a13d2.js');
6
6
 
7
7
  const selectInputCss = ":host{display:block}label{display:block}";
8
8
 
@@ -24,9 +24,7 @@ const SelectInput = class {
24
24
  }
25
25
  ;
26
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)));
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) => index.h("option", { value: option.value }, option.label))), this.error && index.h("div", { style: { color: 'red' } }, this.error)));
30
28
  }
31
29
  };
32
30
  SelectInput.style = selectInputCss;
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const index = require('./index-ca2cd154.js');
3
+ const index = require('./index-4f2a13d2.js');
4
4
 
5
5
  /*
6
6
  Stencil Client Patch Browser v2.20.0 | MIT Licensed | https://stenciljs.com
@@ -15,5 +15,5 @@ const patchBrowser = () => {
15
15
  };
16
16
 
17
17
  patchBrowser().then(options => {
18
- return index.bootstrapLazy([["justifi-billing-form.cjs",[[1,"justifi-billing-form",{"billingFields":[32],"billingFieldsErrors":[32],"validate":[64]},[[0,"fieldReceivedInput","setFormValue"]]]]],["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-payment-form.cjs",[[4,"justifi-payment-form",{"validationStrategy":[1,"validation-strategy"]}]]],["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]}]]],["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]}]]]], options);
18
+ return index.bootstrapLazy([["justifi-payment-form.cjs",[[0,"justifi-payment-form",{"bankAccount":[4,"bank-account"],"card":[4],"iframeOrigin":[1,"iframe-origin"],"selectedPaymentMethodType":[32],"allowedPaymentMethodTypes":[32],"fillBillingForm":[64],"submit":[64]},[[0,"paymentMethodSelected","paymentMethodSelectedHandler"]]]]],["justifi-bank-account-form.cjs",[[0,"justifi-bank-account-form",{"validationStrategy":[1025,"validation-strategy"],"styleOverrides":[1025,"style-overrides"],"iframeOrigin":[1025,"iframe-origin"],"internalStyleOverrides":[32],"tokenize":[64],"validate":[64]},[[0,"paymentMethodFormReady","readyHandler"],[0,"paymentMethodFormTokenize","tokenizeHandler"],[0,"paymentMethodFormValidate","validateHandler"]]]]],["justifi-card-form.cjs",[[0,"justifi-card-form",{"validationStrategy":[1025,"validation-strategy"],"styleOverrides":[1025,"style-overrides"],"iframeOrigin":[1025,"iframe-origin"],"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]}]]],["justifi-billing-form_2.cjs",[[1,"justifi-billing-form",{"legend":[1],"billingFields":[32],"billingFieldsErrors":[32],"fill":[64],"validate":[64],"getValues":[64]},[[0,"fieldReceivedInput","setFormValue"]]],[0,"justifi-payment-method-selector",{"paymentMethodTypes":[16],"selectedPaymentMethodType":[1,"selected-payment-method-type"]}]]],["justifi-payment-method-form.cjs",[[0,"justifi-payment-method-form",{"paymentMethodFormType":[1,"payment-method-form-type"],"paymentMethodFormValidationStrategy":[1025,"payment-method-form-validation-strategy"],"paymentMethodStyleOverrides":[16],"iframeOrigin":[1,"iframe-origin"],"height":[32],"tokenize":[64],"validate":[64]}]]]], options);
19
19
  });
@@ -6,7 +6,7 @@ export var CaptureStrategy;
6
6
  export var PaymentMethodTypes;
7
7
  (function (PaymentMethodTypes) {
8
8
  PaymentMethodTypes["card"] = "card";
9
- PaymentMethodTypes["bankAccount"] = "bank_account";
9
+ PaymentMethodTypes["bankAccount"] = "bankAccount";
10
10
  })(PaymentMethodTypes || (PaymentMethodTypes = {}));
11
11
  export var PaymentStatuses;
12
12
  (function (PaymentStatuses) {
@@ -4,6 +4,7 @@
4
4
  "./components/billing-form/billing-form.js",
5
5
  "./components/card-form/card-form.js",
6
6
  "./components/payment-form/payment-form.js",
7
+ "./components/payment-form/payment-method-selector.js",
7
8
  "./components/payment-method-form/payment-method-form.js",
8
9
  "./components/payments-list/payments-list.js",
9
10
  "./components/select-input/select-input.js",
@@ -3,6 +3,7 @@ export class BankAccountForm {
3
3
  constructor() {
4
4
  this.validationStrategy = undefined;
5
5
  this.styleOverrides = undefined;
6
+ this.iframeOrigin = undefined;
6
7
  this.internalStyleOverrides = undefined;
7
8
  }
8
9
  readyHandler(event) {
@@ -40,14 +41,14 @@ export class BankAccountForm {
40
41
  if (el) {
41
42
  this.childRef = el;
42
43
  }
43
- }, "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 }));
44
+ }, "iframe-origin": this.iframeOrigin, "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 }));
44
45
  }
45
46
  static get is() { return "justifi-bank-account-form"; }
46
47
  static get properties() {
47
48
  return {
48
49
  "validationStrategy": {
49
50
  "type": "string",
50
- "mutable": false,
51
+ "mutable": true,
51
52
  "complexType": {
52
53
  "original": "'onChange' | 'onBlur' | 'onSubmit' | 'onTouched' | 'all'",
53
54
  "resolved": "\"all\" | \"onBlur\" | \"onChange\" | \"onSubmit\" | \"onTouched\"",
@@ -64,7 +65,7 @@ export class BankAccountForm {
64
65
  },
65
66
  "styleOverrides": {
66
67
  "type": "string",
67
- "mutable": false,
68
+ "mutable": true,
68
69
  "complexType": {
69
70
  "original": "string",
70
71
  "resolved": "string",
@@ -78,6 +79,23 @@ export class BankAccountForm {
78
79
  },
79
80
  "attribute": "style-overrides",
80
81
  "reflect": false
82
+ },
83
+ "iframeOrigin": {
84
+ "type": "string",
85
+ "mutable": true,
86
+ "complexType": {
87
+ "original": "string",
88
+ "resolved": "string",
89
+ "references": {}
90
+ },
91
+ "required": false,
92
+ "optional": true,
93
+ "docs": {
94
+ "tags": [],
95
+ "text": ""
96
+ },
97
+ "attribute": "iframe-origin",
98
+ "reflect": false
81
99
  }
82
100
  };
83
101
  }
@@ -3,6 +3,8 @@ import BillingFormSchema from './billing-form-schema';
3
3
  import StateOptions from './state-options';
4
4
  export class BillingForm {
5
5
  constructor() {
6
+ this.legendBlock = (h("legend", null, this.legend));
7
+ this.legend = undefined;
6
8
  this.billingFields = {
7
9
  address_line1: '',
8
10
  address_line2: '',
@@ -20,6 +22,9 @@ export class BillingForm {
20
22
  this.billingFields = billingFieldsClone;
21
23
  }
22
24
  }
25
+ async fill(fields) {
26
+ this.billingFields = Object.assign({}, fields);
27
+ }
23
28
  async validate() {
24
29
  const newErrors = {};
25
30
  let isValid = true;
@@ -35,8 +40,11 @@ export class BillingForm {
35
40
  this.billingFieldsErrors = newErrors;
36
41
  return { isValid: isValid };
37
42
  }
43
+ async getValues() {
44
+ return this.billingFields;
45
+ }
38
46
  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 }))));
47
+ return (h(Host, null, h("fieldset", null, this.legend && this.legendBlock, 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
48
  }
41
49
  static get is() { return "justifi-billing-form"; }
42
50
  static get encapsulation() { return "shadow"; }
@@ -50,6 +58,27 @@ export class BillingForm {
50
58
  "$": ["billing-form.css"]
51
59
  };
52
60
  }
61
+ static get properties() {
62
+ return {
63
+ "legend": {
64
+ "type": "string",
65
+ "mutable": false,
66
+ "complexType": {
67
+ "original": "string",
68
+ "resolved": "string",
69
+ "references": {}
70
+ },
71
+ "required": false,
72
+ "optional": true,
73
+ "docs": {
74
+ "tags": [],
75
+ "text": ""
76
+ },
77
+ "attribute": "legend",
78
+ "reflect": false
79
+ }
80
+ };
81
+ }
53
82
  static get states() {
54
83
  return {
55
84
  "billingFields": {},
@@ -58,6 +87,29 @@ export class BillingForm {
58
87
  }
59
88
  static get methods() {
60
89
  return {
90
+ "fill": {
91
+ "complexType": {
92
+ "signature": "(fields: BillingFormFields) => Promise<void>",
93
+ "parameters": [{
94
+ "tags": [],
95
+ "text": ""
96
+ }],
97
+ "references": {
98
+ "Promise": {
99
+ "location": "global"
100
+ },
101
+ "BillingFormFields": {
102
+ "location": "import",
103
+ "path": "./billing-form-schema"
104
+ }
105
+ },
106
+ "return": "Promise<void>"
107
+ },
108
+ "docs": {
109
+ "text": "",
110
+ "tags": []
111
+ }
112
+ },
61
113
  "validate": {
62
114
  "complexType": {
63
115
  "signature": "() => Promise<{ isValid: boolean; }>",
@@ -77,6 +129,26 @@ export class BillingForm {
77
129
  "text": "",
78
130
  "tags": []
79
131
  }
132
+ },
133
+ "getValues": {
134
+ "complexType": {
135
+ "signature": "() => Promise<BillingFormFields>",
136
+ "parameters": [],
137
+ "references": {
138
+ "Promise": {
139
+ "location": "global"
140
+ },
141
+ "BillingFormFields": {
142
+ "location": "import",
143
+ "path": "./billing-form-schema"
144
+ }
145
+ },
146
+ "return": "Promise<BillingFormFields>"
147
+ },
148
+ "docs": {
149
+ "text": "",
150
+ "tags": []
151
+ }
80
152
  }
81
153
  };
82
154
  }
@@ -0,0 +1,14 @@
1
+ export default {
2
+ title: 'Components/BillingForm',
3
+ component: 'justifi-billing-form',
4
+ parameters: {},
5
+ };
6
+ const Template = ({ styleOverrides }) => {
7
+ const parsedStyleOverrides = styleOverrides ? JSON.stringify(styleOverrides) : null;
8
+ return (`
9
+ <div>
10
+ <justifi-billing-form data-testid="billing-form-iframe" style-overrides='${parsedStyleOverrides || ''}' />
11
+ </div>
12
+ `);
13
+ };
14
+ export const Basic = Template.bind({});