@justifi/webcomponents 0.2.1 → 0.3.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) 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} +30 -1
  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 +22 -16
  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 +1 -1
  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 +19 -1
  16. package/dist/collection/components/billing-form/billing-form.js +49 -0
  17. package/dist/collection/components/card-form/card-form.js +19 -1
  18. package/dist/collection/components/card-form/card-form.stories.js +35 -28
  19. package/dist/collection/components/payment-form/payment-form.js +145 -7
  20. package/dist/collection/components/payment-form/payment-form.stories.js +82 -0
  21. package/dist/collection/components/payment-form/payment-method-selector.js +86 -0
  22. package/dist/collection/components/payment-form/tokenize.js +1 -0
  23. package/dist/collection/components/payment-method-form/payment-method-form.js +21 -1
  24. package/dist/components/Payment.js +69 -0
  25. package/dist/components/billing-form.js +2185 -0
  26. package/dist/components/index.d.ts +1 -0
  27. package/dist/components/index.js +1 -0
  28. package/dist/components/justifi-bank-account-form.js +3 -1
  29. package/dist/components/justifi-billing-form.js +1 -2175
  30. package/dist/components/justifi-card-form.js +3 -1
  31. package/dist/components/justifi-payment-form.js +85 -6
  32. package/dist/components/justifi-payment-method-selector.d.ts +11 -0
  33. package/dist/components/justifi-payment-method-selector.js +6 -0
  34. package/dist/components/justifi-payments-list.js +1 -68
  35. package/dist/components/payment-method-form.js +22 -15
  36. package/dist/components/payment-method-selector.js +42 -0
  37. package/dist/esm/Payment-3f7570a8.js +69 -0
  38. package/dist/esm/{index-05706eb5.js → index-3ce5521c.js} +13 -389
  39. package/dist/esm/justifi-bank-account-form.entry.js +3 -2
  40. package/dist/esm/{justifi-billing-form.entry.js → justifi-billing-form_2.entry.js} +30 -2
  41. package/dist/esm/justifi-card-form.entry.js +3 -2
  42. package/dist/esm/justifi-payment-form.entry.js +46 -3
  43. package/dist/esm/justifi-payment-method-form.entry.js +22 -16
  44. package/dist/esm/justifi-payments-list.entry.js +2 -69
  45. package/dist/esm/loader.js +2 -2
  46. package/dist/esm/select-input_2.entry.js +1 -1
  47. package/dist/esm/webcomponents.js +2 -2
  48. package/dist/types/api/Payment.d.ts +1 -1
  49. package/dist/types/components/bank-account-form/bank-account-form.d.ts +1 -0
  50. package/dist/types/components/billing-form/billing-form-schema.d.ts +7 -0
  51. package/dist/types/components/billing-form/billing-form.d.ts +3 -8
  52. package/dist/types/components/card-form/card-form.d.ts +1 -0
  53. package/dist/types/components/card-form/card-form.stories.d.ts +1 -0
  54. package/dist/types/components/payment-form/payment-form.d.ts +17 -1
  55. package/dist/types/components/payment-form/payment-form.stories.d.ts +44 -0
  56. package/dist/types/components/payment-form/payment-method-selector.d.ts +10 -0
  57. package/dist/types/components/payment-form/tokenize.d.ts +5 -0
  58. package/dist/types/components/payment-method-form/payment-method-form.d.ts +1 -0
  59. package/dist/types/components.d.ts +40 -2
  60. package/dist/webcomponents/p-19a76621.entry.js +1 -0
  61. package/dist/webcomponents/p-21e020a8.js +1 -0
  62. package/dist/webcomponents/p-250118e4.entry.js +1 -0
  63. package/dist/webcomponents/p-3536328b.entry.js +1 -0
  64. package/dist/webcomponents/p-6633de1b.entry.js +1 -0
  65. package/dist/webcomponents/p-68e47ee5.entry.js +1 -0
  66. package/dist/webcomponents/p-6c3a226e.entry.js +1 -0
  67. package/dist/webcomponents/{p-3809130a.entry.js → p-763a2b4f.entry.js} +1 -1
  68. package/dist/webcomponents/p-9f34a2c1.js +2 -0
  69. package/dist/webcomponents/webcomponents.esm.js +1 -1
  70. package/package.json +18 -14
  71. package/readme.md +1 -1
  72. package/dist/webcomponents/p-67be9585.entry.js +0 -1
  73. package/dist/webcomponents/p-787671b9.entry.js +0 -1
  74. package/dist/webcomponents/p-87654bf4.entry.js +0 -1
  75. package/dist/webcomponents/p-8ee06fd1.js +0 -2
  76. package/dist/webcomponents/p-94ef2d0e.entry.js +0 -1
  77. package/dist/webcomponents/p-c07191dc.entry.js +0 -1
  78. 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,7 +48,7 @@ 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"]
@@ -55,6 +56,7 @@ const CardForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
55
56
  }, [0, "justifi-card-form", {
56
57
  "validationStrategy": [1, "validation-strategy"],
57
58
  "styleOverrides": [1, "style-overrides"],
59
+ "iframeOrigin": [1, "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", { 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.1";
21
+ const version = "0.3.2";
22
22
  const description = "JustiFi Web Components";
23
23
  const main = "dist/index.cjs.js";
24
24
  const module = "dist/index.js";
@@ -26,7 +26,6 @@ const es2015 = "dist/esm/index.mjs";
26
26
  const es2017 = "dist/esm/index.mjs";
27
27
  const types = "dist/types/index.d.ts";
28
28
  const collection = "dist/collection/collection-manifest.json";
29
- const unpkg = "dist/stencil-webcomponents/stencil-webcomponents.esm.js";
30
29
  const repository = {
31
30
  type: "git",
32
31
  url: "git+https://github.com/justifi-tech/web-component-library.git"
@@ -47,8 +46,8 @@ const scripts = {
47
46
  test: "stencil test --spec --e2e",
48
47
  "test:watch": "stencil test --spec --e2e --watchAll",
49
48
  generate: "stencil generate",
50
- storybook: "start-storybook -p 6006",
51
- "build-storybook": "build-storybook"
49
+ storybook: "storybook dev -p 6006 --quiet",
50
+ "build-storybook": "storybook build"
52
51
  };
53
52
  const dependencies = {
54
53
  "@stencil/core": "^2.13.0",
@@ -59,22 +58,27 @@ const dependencies = {
59
58
  yup: "^1.0.0"
60
59
  };
61
60
  const devDependencies = {
61
+ "@babel/preset-env": "^7.21.4",
62
+ "@babel/preset-typescript": "^7.21.4",
62
63
  "@pxtrn/storybook-addon-docs-stencil": "^6.4.1",
63
- "@storybook/addon-actions": "^6.5.16",
64
- "@storybook/addon-essentials": "^6.5.16",
65
- "@storybook/addon-interactions": "^6.5.16",
66
- "@storybook/addon-links": "^6.5.16",
67
- "@storybook/builder-webpack4": "^6.5.16",
68
- "@storybook/html": "^6.5.16",
69
- "@storybook/manager-webpack4": "^6.5.16",
70
- "@storybook/testing-library": "^0.0.13",
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",
71
72
  "@types/jest": "^27.0.3",
72
73
  "auto-changelog": "^2.4.0",
73
74
  concurrently: "^7.6.0",
74
75
  jest: "^27.4.5",
75
76
  "jest-cli": "^27.4.5",
76
77
  puppeteer: "^10.0.0",
77
- "release-it": "^15.6.0"
78
+ react: "^18.2.0",
79
+ "react-dom": "^18.2.0",
80
+ "release-it": "^15.6.0",
81
+ storybook: "^7.0.4"
78
82
  };
79
83
  const license = "MIT";
80
84
  const packageJson = {
@@ -88,7 +92,6 @@ const packageJson = {
88
92
  types: types,
89
93
  collection: collection,
90
94
  "collection:main": "dist/collection/index.js",
91
- unpkg: unpkg,
92
95
  repository: repository,
93
96
  publishConfig: publishConfig,
94
97
  files: files,
@@ -109,6 +112,7 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
109
112
  this.paymentMethodFormType = undefined;
110
113
  this.paymentMethodFormValidationStrategy = undefined;
111
114
  this.paymentMethodStyleOverrides = undefined;
115
+ this.iframeOrigin = undefined;
112
116
  this.height = 55;
113
117
  }
114
118
  connectedCallback() {
@@ -170,7 +174,9 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
170
174
  }
171
175
  ;
172
176
  getIframeSrc() {
173
- let iframeSrc = `https://js.justifi.ai/v2/${this.paymentMethodFormType}`;
177
+ const productionIframeOrigin = 'https://js.justifi.ai/v2';
178
+ const iframeOrigin = this.iframeOrigin || productionIframeOrigin;
179
+ let iframeSrc = `${iframeOrigin}/${this.paymentMethodFormType}`;
174
180
  if (this.paymentMethodFormValidationStrategy) {
175
181
  iframeSrc += `?validationStrategy=${this.paymentMethodFormValidationStrategy}`;
176
182
  }
@@ -187,6 +193,7 @@ const PaymentMethodForm = /*@__PURE__*/ proxyCustomElement(class extends HTMLEle
187
193
  "paymentMethodFormType": [1, "payment-method-form-type"],
188
194
  "paymentMethodFormValidationStrategy": [1, "payment-method-form-validation-strategy"],
189
195
  "paymentMethodStyleOverrides": [16],
196
+ "iframeOrigin": [1, "iframe-origin"],
190
197
  "height": [32],
191
198
  "tokenize": [64],
192
199
  "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 };
@@ -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 };