@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
@@ -10,6 +10,7 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
10
10
  this.cardFormValidate = createEvent(this, "cardFormValidate", 7);
11
11
  this.validationStrategy = undefined;
12
12
  this.styleOverrides = undefined;
13
+ this.iframeOrigin = undefined;
13
14
  this.internalStyleOverrides = undefined;
14
15
  }
15
16
  readyHandler(event) {
@@ -47,14 +48,15 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
47
48
  if (el) {
48
49
  this.childRef = el;
49
50
  }
50
- }, "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 }));
51
+ }, "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 }));
51
52
  }
52
53
  static get watchers() { return {
53
54
  "styleOverrides": ["parseStyleOverrides"]
54
55
  }; }
55
56
  }, [0, "justifi-card-form", {
56
- "validationStrategy": [1, "validation-strategy"],
57
- "styleOverrides": [1, "style-overrides"],
57
+ "validationStrategy": [1025, "validation-strategy"],
58
+ "styleOverrides": [1025, "style-overrides"],
59
+ "iframeOrigin": [1025, "iframe-origin"],
58
60
  "internalStyleOverrides": [32],
59
61
  "tokenize": [64],
60
62
  "validate": [64]
@@ -1,28 +1,107 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
+ import { P as PaymentMethodTypes } from './Payment.js';
3
+ import { d as defineCustomElement$6 } from './billing-form.js';
4
+ import { d as defineCustomElement$5 } from './payment-method-form.js';
5
+ import { d as defineCustomElement$4 } from './payment-method-selector.js';
6
+ import { d as defineCustomElement$3 } from './select-input2.js';
7
+ import { d as defineCustomElement$2 } from './text-input2.js';
2
8
 
3
9
  const PaymentForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
4
10
  constructor() {
5
11
  super();
6
12
  this.__registerHost();
7
- this.validationStrategy = undefined;
13
+ this.bankAccount = undefined;
14
+ this.card = undefined;
15
+ this.iframeOrigin = undefined;
16
+ this.selectedPaymentMethodType = undefined;
17
+ this.allowedPaymentMethodTypes = [];
18
+ }
19
+ connectedCallback() {
20
+ if (this.card) {
21
+ this.allowedPaymentMethodTypes.push(PaymentMethodTypes.card);
22
+ }
23
+ if (this.bankAccount) {
24
+ this.allowedPaymentMethodTypes.push(PaymentMethodTypes.bankAccount);
25
+ }
26
+ if (!this.allowedPaymentMethodTypes.length) {
27
+ this.allowedPaymentMethodTypes.push(PaymentMethodTypes.card);
28
+ }
29
+ this.selectedPaymentMethodType = this.allowedPaymentMethodTypes[0];
30
+ }
31
+ paymentMethodSelectedHandler(event) {
32
+ const paymentMethodType = event.detail;
33
+ this.selectedPaymentMethodType = paymentMethodType;
34
+ }
35
+ async fillBillingForm(fields) {
36
+ this.billingFormRef.fill(fields);
37
+ }
38
+ async submit(args) {
39
+ if (!this.paymentMethodFormRef || !this.billingFormRef)
40
+ return;
41
+ const billingFormValidation = await this.billingFormRef.validate();
42
+ const paymentMethodFormValidation = await this.paymentMethodFormRef.validate();
43
+ if (!billingFormValidation.isValid || !paymentMethodFormValidation.isValid)
44
+ return;
45
+ const billingFormFieldValues = await this.billingFormRef.getValues();
46
+ const paymentMethodData = Object.assign(Object.assign({}, args.paymentMethodData), billingFormFieldValues);
47
+ return this.paymentMethodFormRef.tokenize(args.clientId, paymentMethodData, args.accountId);
8
48
  }
9
49
  render() {
10
- return (h(Host, null, h("form", null, h("slot", null))));
50
+ return (h(Host, null, h("form", null, (this.allowedPaymentMethodTypes.length > 1) && (h("justifi-payment-method-selector", { paymentMethodTypes: this.allowedPaymentMethodTypes, selectedPaymentMethodType: this.selectedPaymentMethodType })), h("justifi-payment-method-form", { "payment-method-form-type": this.selectedPaymentMethodType, "iframe-origin": this.iframeOrigin, ref: el => {
51
+ if (el) {
52
+ this.paymentMethodFormRef = el;
53
+ }
54
+ } }), h("justifi-billing-form", { legend: "Billing Info", ref: el => {
55
+ if (el) {
56
+ this.billingFormRef = el;
57
+ }
58
+ } }))));
11
59
  }
12
- }, [4, "justifi-payment-form", {
13
- "validationStrategy": [1, "validation-strategy"]
14
- }]);
60
+ }, [0, "justifi-payment-form", {
61
+ "bankAccount": [4, "bank-account"],
62
+ "card": [4],
63
+ "iframeOrigin": [1, "iframe-origin"],
64
+ "selectedPaymentMethodType": [32],
65
+ "allowedPaymentMethodTypes": [32],
66
+ "fillBillingForm": [64],
67
+ "submit": [64]
68
+ }, [[0, "paymentMethodSelected", "paymentMethodSelectedHandler"]]]);
15
69
  function defineCustomElement$1() {
16
70
  if (typeof customElements === "undefined") {
17
71
  return;
18
72
  }
19
- const components = ["justifi-payment-form"];
73
+ const components = ["justifi-payment-form", "justifi-billing-form", "justifi-payment-method-form", "justifi-payment-method-selector", "select-input", "text-input"];
20
74
  components.forEach(tagName => { switch (tagName) {
21
75
  case "justifi-payment-form":
22
76
  if (!customElements.get(tagName)) {
23
77
  customElements.define(tagName, PaymentForm);
24
78
  }
25
79
  break;
80
+ case "justifi-billing-form":
81
+ if (!customElements.get(tagName)) {
82
+ defineCustomElement$6();
83
+ }
84
+ break;
85
+ case "justifi-payment-method-form":
86
+ if (!customElements.get(tagName)) {
87
+ defineCustomElement$5();
88
+ }
89
+ break;
90
+ case "justifi-payment-method-selector":
91
+ if (!customElements.get(tagName)) {
92
+ defineCustomElement$4();
93
+ }
94
+ break;
95
+ case "select-input":
96
+ if (!customElements.get(tagName)) {
97
+ defineCustomElement$3();
98
+ }
99
+ break;
100
+ case "text-input":
101
+ if (!customElements.get(tagName)) {
102
+ defineCustomElement$2();
103
+ }
104
+ break;
26
105
  } });
27
106
  }
28
107
 
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface JustifiPaymentMethodSelector extends Components.JustifiPaymentMethodSelector, HTMLElement {}
4
+ export const JustifiPaymentMethodSelector: {
5
+ prototype: JustifiPaymentMethodSelector;
6
+ new (): JustifiPaymentMethodSelector;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { P as PaymentMethodSelector, d as defineCustomElement$1 } from './payment-method-selector.js';
2
+
3
+ const JustifiPaymentMethodSelector = PaymentMethodSelector;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { JustifiPaymentMethodSelector, defineCustomElement };
@@ -1,4 +1,5 @@
1
1
  import { proxyCustomElement, HTMLElement, h, Host } from '@stencil/core/internal/client';
2
+ import { a as Payment } from './Payment.js';
2
3
 
3
4
  // Unique ID creation requires a high quality random # generator. In the browser we therefore
4
5
  // require the crypto API and do not support built-in fallback to lower quality random number
@@ -106,74 +107,6 @@ function handleError(requestUrl) {
106
107
  console.error(`Error fetching from ${requestUrl}`);
107
108
  }
108
109
 
109
- var CaptureStrategy;
110
- (function (CaptureStrategy) {
111
- CaptureStrategy["automatic"] = "automatic";
112
- CaptureStrategy["manual"] = "manual";
113
- })(CaptureStrategy || (CaptureStrategy = {}));
114
- var PaymentMethodTypes;
115
- (function (PaymentMethodTypes) {
116
- PaymentMethodTypes["card"] = "card";
117
- PaymentMethodTypes["bankAccount"] = "bank_account";
118
- })(PaymentMethodTypes || (PaymentMethodTypes = {}));
119
- var PaymentStatuses;
120
- (function (PaymentStatuses) {
121
- PaymentStatuses["pending"] = "pending";
122
- PaymentStatuses["authorized"] = "authorized";
123
- PaymentStatuses["succeeded"] = "succeeded";
124
- PaymentStatuses["failed"] = "failed";
125
- PaymentStatuses["disputed"] = "disputed";
126
- PaymentStatuses["fully_refunded"] = "fully_refunded";
127
- PaymentStatuses["partially_refunded"] = "partially_refunded";
128
- })(PaymentStatuses || (PaymentStatuses = {}));
129
- var PaymentDisputedStatuses;
130
- (function (PaymentDisputedStatuses) {
131
- // if a dispute is 'won', we don't show a dispute status, just general status
132
- PaymentDisputedStatuses["lost"] = "lost";
133
- PaymentDisputedStatuses["open"] = "open";
134
- })(PaymentDisputedStatuses || (PaymentDisputedStatuses = {}));
135
- class Payment {
136
- constructor(payment) {
137
- this.id = payment.id;
138
- this.account_id = payment.account_id;
139
- this.amount = payment.amount;
140
- this.amount_disputed = payment.amount_disputed;
141
- this.amount_refundable = payment.amount_refundable;
142
- this.amount_refunded = payment.amount_refunded;
143
- this.balance = payment.balance;
144
- this.captured = payment.captured;
145
- this.capture_strategy = payment.capture_strategy;
146
- this.currency = payment.currency;
147
- this.description = payment.description;
148
- this.disputed = payment.disputed;
149
- this.disputes = payment.disputes;
150
- this.error_code = payment.error_code;
151
- this.error_description = payment.error_description;
152
- this.fee_amount = payment.fee_amount;
153
- this.is_test = payment.is_test;
154
- this.metadata = payment.metadata;
155
- this.payment_method = payment.payment_method;
156
- this.payment_intent_id = payment.payment_intent_id;
157
- this.refunded = payment.refunded;
158
- this.status = payment.status;
159
- this.created_at = payment.created_at;
160
- this.updated_at = payment.updated_at;
161
- }
162
- get disputedStatus() {
163
- const lost = this.disputes.some((dispute) => dispute.status === PaymentDisputedStatuses.lost);
164
- // if a dispute is 'won', we don't show a dispute status, just general status
165
- if (!this.disputed) {
166
- return null;
167
- }
168
- else if (lost) {
169
- return PaymentDisputedStatuses.lost;
170
- }
171
- else {
172
- return PaymentDisputedStatuses.open;
173
- }
174
- }
175
- }
176
-
177
110
  function toInteger(dirtyNumber) {
178
111
  if (dirtyNumber === null || dirtyNumber === true || dirtyNumber === false) {
179
112
  return NaN;
@@ -18,7 +18,7 @@ const MessageEventType = {
18
18
  };
19
19
 
20
20
  const name = "@justifi/webcomponents";
21
- const version = "0.2.2";
21
+ const version = "0.4.0";
22
22
  const description = "JustiFi Web Components";
23
23
  const main = "dist/index.cjs.js";
24
24
  const module = "dist/index.js";
@@ -43,11 +43,11 @@ const scripts = {
43
43
  build: "stencil build --docs",
44
44
  start: "concurrently -c \"bgBlue.bold,bgMagenta.bold,bgGreen.bold\" \"yarn run start-stencil\" \"yarn run storybook\"",
45
45
  "start-stencil": "stencil build --watch --serve --no-open",
46
- test: "stencil test --spec --e2e",
47
- "test:watch": "stencil test --spec --e2e --watchAll",
46
+ test: "stencil test --spec",
47
+ "test:watch": "stencil test --spec --watchAll",
48
48
  generate: "stencil generate",
49
- storybook: "start-storybook -p 6006",
50
- "build-storybook": "build-storybook"
49
+ storybook: "storybook dev -p 6006 --quiet",
50
+ "build-storybook": "storybook build"
51
51
  };
52
52
  const dependencies = {
53
53
  "@stencil/core": "^2.13.0",
@@ -58,22 +58,30 @@ const dependencies = {
58
58
  yup: "^1.0.0"
59
59
  };
60
60
  const devDependencies = {
61
+ "@babel/preset-env": "^7.21.4",
62
+ "@babel/preset-typescript": "^7.21.4",
61
63
  "@pxtrn/storybook-addon-docs-stencil": "^6.4.1",
62
- "@storybook/addon-actions": "^6.5.16",
63
- "@storybook/addon-essentials": "^6.5.16",
64
- "@storybook/addon-interactions": "^6.5.16",
65
- "@storybook/addon-links": "^6.5.16",
66
- "@storybook/builder-webpack4": "^6.5.16",
67
- "@storybook/html": "^6.5.16",
68
- "@storybook/manager-webpack4": "^6.5.16",
69
- "@storybook/testing-library": "^0.0.13",
70
- "@types/jest": "^27.0.3",
64
+ "@storybook/addon-actions": "^7.0.4",
65
+ "@storybook/addon-essentials": "^7.0.4",
66
+ "@storybook/addon-interactions": "^7.0.4",
67
+ "@storybook/addon-links": "^7.0.4",
68
+ "@storybook/html": "^7.0.4",
69
+ "@storybook/html-webpack5": "^7.0.4",
70
+ "@storybook/jest": "^0.1.0",
71
+ "@storybook/testing-library": "^0.1.0",
72
+ "@types/jest": "27.0.3",
73
+ "@types/node": "^18.15.11",
74
+ "@types/react": "^18.0.37",
75
+ "@types/react-dom": "^18.0.11",
71
76
  "auto-changelog": "^2.4.0",
72
77
  concurrently: "^7.6.0",
73
78
  jest: "^27.4.5",
74
79
  "jest-cli": "^27.4.5",
75
80
  puppeteer: "^10.0.0",
76
- "release-it": "^15.6.0"
81
+ react: "^18.2.0",
82
+ "react-dom": "^18.2.0",
83
+ "release-it": "^15.6.0",
84
+ storybook: "^7.0.4"
77
85
  };
78
86
  const license = "MIT";
79
87
  const packageJson = {
@@ -107,6 +115,7 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
107
115
  this.paymentMethodFormType = undefined;
108
116
  this.paymentMethodFormValidationStrategy = undefined;
109
117
  this.paymentMethodStyleOverrides = undefined;
118
+ this.iframeOrigin = undefined;
110
119
  this.height = 55;
111
120
  }
112
121
  connectedCallback() {
@@ -168,7 +177,9 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
168
177
  }
169
178
  ;
170
179
  getIframeSrc() {
171
- let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
180
+ const productionIframeOrigin = 'https://js.justifi.ai/v2';
181
+ const iframeOrigin = this.iframeOrigin || productionIframeOrigin;
182
+ let iframeSrc = `${iframeOrigin}/${this.paymentMethodFormType}`;
172
183
  if (this.paymentMethodFormValidationStrategy) {
173
184
  iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
174
185
  }
@@ -183,8 +194,9 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
183
194
  static get style() { return paymentMethodFormCss; }
184
195
  }, [0, "justifi-payment-method-form", {
185
196
  "paymentMethodFormType": [1, "payment-method-form-type"],
186
- "paymentMethodFormValidationStrategy": [1, "payment-method-form-validation-strategy"],
197
+ "paymentMethodFormValidationStrategy": [1025, "payment-method-form-validation-strategy"],
187
198
  "paymentMethodStyleOverrides": [16],
199
+ "iframeOrigin": [1, "iframe-origin"],
188
200
  "height": [32],
189
201
  "tokenize": [64],
190
202
  "validate": [64]
@@ -0,0 +1,42 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+
3
+ const PaymentMethodLabels = {
4
+ bankAccount: 'Bank Account',
5
+ card: 'Card'
6
+ };
7
+ const PaymentMethodSelector = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
8
+ constructor() {
9
+ super();
10
+ this.__registerHost();
11
+ this.paymentMethodSelected = createEvent(this, "paymentMethodSelected", 7);
12
+ this.paymentMethodTypes = [];
13
+ this.selectedPaymentMethodType = undefined;
14
+ }
15
+ onChangeHandler(event) {
16
+ this.paymentMethodSelected.emit(event.target.value);
17
+ }
18
+ render() {
19
+ return (h("div", null, this.paymentMethodTypes.map((paymentMethodType) => {
20
+ return (h("div", null, h("input", { id: paymentMethodType, type: "radio", name: "paymentMethodType", value: paymentMethodType, onChange: (event) => this.onChangeHandler(event), checked: this.selectedPaymentMethodType === paymentMethodType }), h("label", { htmlFor: paymentMethodType }, PaymentMethodLabels[paymentMethodType])));
21
+ })));
22
+ }
23
+ ;
24
+ }, [0, "justifi-payment-method-selector", {
25
+ "paymentMethodTypes": [16],
26
+ "selectedPaymentMethodType": [1, "selected-payment-method-type"]
27
+ }]);
28
+ function defineCustomElement() {
29
+ if (typeof customElements === "undefined") {
30
+ return;
31
+ }
32
+ const components = ["justifi-payment-method-selector"];
33
+ components.forEach(tagName => { switch (tagName) {
34
+ case "justifi-payment-method-selector":
35
+ if (!customElements.get(tagName)) {
36
+ customElements.define(tagName, PaymentMethodSelector);
37
+ }
38
+ break;
39
+ } });
40
+ }
41
+
42
+ export { PaymentMethodSelector as P, defineCustomElement as d };
@@ -22,9 +22,7 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
22
22
  }
23
23
  ;
24
24
  render() {
25
- return (h(Host, null, h("label", null, this.label), h("select", { name: this.name, onInput: (event) => this.onInput(event) }, this.options.map((option) => {
26
- return (h("option", { value: option.value }, option.label));
27
- })), this.error && h("div", { style: { color: 'red' } }, this.error)));
25
+ return (h(Host, null, h("label", null, this.label), h("select", { name: this.name, onInput: (event) => this.onInput(event) }, this.options.map((option) => h("option", { value: option.value }, option.label))), this.error && h("div", { style: { color: 'red' } }, this.error)));
28
26
  }
29
27
  static get style() { return selectInputCss; }
30
28
  }, [1, "select-input", {
@@ -0,0 +1,69 @@
1
+ var CaptureStrategy;
2
+ (function (CaptureStrategy) {
3
+ CaptureStrategy["automatic"] = "automatic";
4
+ CaptureStrategy["manual"] = "manual";
5
+ })(CaptureStrategy || (CaptureStrategy = {}));
6
+ var PaymentMethodTypes;
7
+ (function (PaymentMethodTypes) {
8
+ PaymentMethodTypes["card"] = "card";
9
+ PaymentMethodTypes["bankAccount"] = "bankAccount";
10
+ })(PaymentMethodTypes || (PaymentMethodTypes = {}));
11
+ var PaymentStatuses;
12
+ (function (PaymentStatuses) {
13
+ PaymentStatuses["pending"] = "pending";
14
+ PaymentStatuses["authorized"] = "authorized";
15
+ PaymentStatuses["succeeded"] = "succeeded";
16
+ PaymentStatuses["failed"] = "failed";
17
+ PaymentStatuses["disputed"] = "disputed";
18
+ PaymentStatuses["fully_refunded"] = "fully_refunded";
19
+ PaymentStatuses["partially_refunded"] = "partially_refunded";
20
+ })(PaymentStatuses || (PaymentStatuses = {}));
21
+ var PaymentDisputedStatuses;
22
+ (function (PaymentDisputedStatuses) {
23
+ // if a dispute is 'won', we don't show a dispute status, just general status
24
+ PaymentDisputedStatuses["lost"] = "lost";
25
+ PaymentDisputedStatuses["open"] = "open";
26
+ })(PaymentDisputedStatuses || (PaymentDisputedStatuses = {}));
27
+ class Payment {
28
+ constructor(payment) {
29
+ this.id = payment.id;
30
+ this.account_id = payment.account_id;
31
+ this.amount = payment.amount;
32
+ this.amount_disputed = payment.amount_disputed;
33
+ this.amount_refundable = payment.amount_refundable;
34
+ this.amount_refunded = payment.amount_refunded;
35
+ this.balance = payment.balance;
36
+ this.captured = payment.captured;
37
+ this.capture_strategy = payment.capture_strategy;
38
+ this.currency = payment.currency;
39
+ this.description = payment.description;
40
+ this.disputed = payment.disputed;
41
+ this.disputes = payment.disputes;
42
+ this.error_code = payment.error_code;
43
+ this.error_description = payment.error_description;
44
+ this.fee_amount = payment.fee_amount;
45
+ this.is_test = payment.is_test;
46
+ this.metadata = payment.metadata;
47
+ this.payment_method = payment.payment_method;
48
+ this.payment_intent_id = payment.payment_intent_id;
49
+ this.refunded = payment.refunded;
50
+ this.status = payment.status;
51
+ this.created_at = payment.created_at;
52
+ this.updated_at = payment.updated_at;
53
+ }
54
+ get disputedStatus() {
55
+ const lost = this.disputes.some((dispute) => dispute.status === PaymentDisputedStatuses.lost);
56
+ // if a dispute is 'won', we don't show a dispute status, just general status
57
+ if (!this.disputed) {
58
+ return null;
59
+ }
60
+ else if (lost) {
61
+ return PaymentDisputedStatuses.lost;
62
+ }
63
+ else {
64
+ return PaymentDisputedStatuses.open;
65
+ }
66
+ }
67
+ }
68
+
69
+ export { PaymentMethodTypes as P, Payment as a };