@justifi/webcomponents 6.12.4 → 6.13.0-rc.1

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 (209) hide show
  1. package/dist/cjs/{Analytics-BERGweGK.js → Analytics-Be2I_aiS.js} +2 -2
  2. package/dist/cjs/{Plaid-BRSyOOuw.js → Plaid-Aw35bhCX.js} +2 -2
  3. package/dist/cjs/additional-questions-form-step_14.cjs.entry.js +5 -5
  4. package/dist/cjs/bank-account-form.cjs.entry.js +2 -2
  5. package/dist/cjs/{business.service-Z9OACEQL.js → business.service-CylI3Qrg.js} +1 -1
  6. package/dist/cjs/card-form.cjs.entry.js +2 -2
  7. package/dist/cjs/{check-pkg-version-ByKpJklZ.js → check-pkg-version-BLLLh6v-.js} +1 -1
  8. package/dist/cjs/checkout-actions-8-MUczKw.js +62 -0
  9. package/dist/cjs/{checkout.service-BZOyqXgW.js → checkout.service-BYpinbSR.js} +1 -1
  10. package/dist/cjs/dispute-notification_2.cjs.entry.js +6 -6
  11. package/dist/cjs/{event-types-AU1B76Vm.js → event-types-DptNnCEP.js} +1 -1
  12. package/dist/cjs/{get-business-aR-C83KX.js → get-business-D10Tmct1.js} +2 -2
  13. package/dist/cjs/{get-payment-details-dwhA02Zl.js → get-payment-details-BB5aa48u.js} +2 -2
  14. package/dist/cjs/{get-subaccounts-B1jmSa2d.js → get-subaccounts-CSD2nAqD.js} +2 -2
  15. package/dist/cjs/hidden-input_2.cjs.entry.js +1 -1
  16. package/dist/cjs/justifi-apple-pay_11.cjs.entry.js +10 -64
  17. package/dist/cjs/justifi-bank-account-billing-form-simple.cjs.entry.js +4 -4
  18. package/dist/cjs/justifi-bank-account-form.cjs.entry.js +4 -4
  19. package/dist/cjs/justifi-business-details.cjs.entry.js +7 -7
  20. package/dist/cjs/justifi-business-form.cjs.entry.js +7 -7
  21. package/dist/cjs/justifi-card-form.cjs.entry.js +4 -4
  22. package/dist/cjs/justifi-checkout-qr-code.cjs.entry.js +3141 -0
  23. package/dist/cjs/justifi-checkout.cjs.entry.js +4 -4
  24. package/dist/cjs/justifi-checkouts-list-filters.cjs.entry.js +1 -1
  25. package/dist/cjs/justifi-checkouts-list.cjs.entry.js +7 -7
  26. package/dist/cjs/justifi-dispute-management.cjs.entry.js +6 -6
  27. package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +5 -5
  28. package/dist/cjs/justifi-order-terminals.cjs.entry.js +8 -8
  29. package/dist/cjs/justifi-payment-details.cjs.entry.js +7 -7
  30. package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +7 -7
  31. package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +6 -6
  32. package/dist/cjs/justifi-payments-list.cjs.entry.js +6 -6
  33. package/dist/cjs/justifi-payout-details.cjs.entry.js +7 -7
  34. package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +6 -6
  35. package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +1 -1
  36. package/dist/cjs/justifi-payouts-list.cjs.entry.js +8 -8
  37. package/dist/cjs/justifi-qr-terminal.cjs.entry.js +208 -0
  38. package/dist/cjs/justifi-refund-payment.cjs.entry.js +7 -7
  39. package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +5 -5
  40. package/dist/cjs/justifi-terminal-orders-list-filters.cjs.entry.js +1 -1
  41. package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +5 -5
  42. package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +1 -1
  43. package/dist/cjs/justifi-terminals-list.cjs.entry.js +7 -7
  44. package/dist/cjs/loader.cjs.js +1 -1
  45. package/dist/cjs/{package-B6L3zyfG.js → package-gx36QXN1.js} +1 -1
  46. package/dist/cjs/{payment-provisioning-actions-BiSpysjW.js → payment-provisioning-actions-DimM0KGV.js} +2 -2
  47. package/dist/cjs/{payment.service-ByrgA_QZ.js → payment.service-fy5bXXmA.js} +1 -1
  48. package/dist/cjs/{payout.service-CnQm_BpU.js → payout.service-hp3PTXWI.js} +1 -1
  49. package/dist/cjs/{payouts-status-AuS3Mp0V.js → payouts-status-CF1YT_RL.js} +2 -2
  50. package/dist/cjs/{plaid.service-Dlb8EUR8.js → plaid.service-9PmS4X0g.js} +1 -1
  51. package/dist/cjs/{terminal.service-BdwHQ3Vv.js → terminal.service-D5D76Cnn.js} +1 -1
  52. package/dist/cjs/{utils-FVGp6se3.js → utils-Dcde8Zpt.js} +1 -1
  53. package/dist/cjs/webcomponents.cjs.js +1 -1
  54. package/dist/collection/collection-manifest.json +2 -0
  55. package/dist/collection/components/checkout-qr-code/justifi-checkout-qr-code.js +128 -0
  56. package/dist/collection/components/qr-terminal/justifi-qr-terminal.js +349 -0
  57. package/dist/docs.json +283 -1
  58. package/dist/esm/{Analytics-B1bQP71R.js → Analytics-DZWGizAK.js} +2 -2
  59. package/dist/esm/{Plaid-l6nNIjab.js → Plaid-fhlY0CIN.js} +1 -1
  60. package/dist/esm/additional-questions-form-step_14.entry.js +5 -5
  61. package/dist/esm/bank-account-form.entry.js +2 -2
  62. package/dist/esm/{business.service-C31wbMVs.js → business.service-Crs-0Mdy.js} +1 -1
  63. package/dist/esm/card-form.entry.js +2 -2
  64. package/dist/esm/{check-pkg-version-CNwUC4SV.js → check-pkg-version-CVyuA8aH.js} +1 -1
  65. package/dist/esm/checkout-actions-BMnp3uHK.js +59 -0
  66. package/dist/esm/{checkout.service-cVdOGDuI.js → checkout.service-BMAQVmHa.js} +1 -1
  67. package/dist/esm/dispute-notification_2.entry.js +6 -6
  68. package/dist/esm/{event-types-DalU_6SB.js → event-types-CVVB5p_Q.js} +1 -1
  69. package/dist/esm/{get-business-Gg6qn5on.js → get-business-B9ZS1tVq.js} +2 -2
  70. package/dist/esm/{get-payment-details-BiWgSJau.js → get-payment-details-CiR6FrkO.js} +2 -2
  71. package/dist/esm/{get-subaccounts-CkjZeR9U.js → get-subaccounts-VpDr7yN4.js} +2 -2
  72. package/dist/esm/hidden-input_2.entry.js +1 -1
  73. package/dist/esm/justifi-apple-pay_11.entry.js +8 -62
  74. package/dist/esm/justifi-bank-account-billing-form-simple.entry.js +4 -4
  75. package/dist/esm/justifi-bank-account-form.entry.js +4 -4
  76. package/dist/esm/justifi-business-details.entry.js +7 -7
  77. package/dist/esm/justifi-business-form.entry.js +7 -7
  78. package/dist/esm/justifi-card-form.entry.js +4 -4
  79. package/dist/esm/justifi-checkout-qr-code.entry.js +3139 -0
  80. package/dist/esm/justifi-checkout.entry.js +4 -4
  81. package/dist/esm/justifi-checkouts-list-filters.entry.js +1 -1
  82. package/dist/esm/justifi-checkouts-list.entry.js +7 -7
  83. package/dist/esm/justifi-dispute-management.entry.js +6 -6
  84. package/dist/esm/justifi-gross-payment-chart.entry.js +5 -5
  85. package/dist/esm/justifi-order-terminals.entry.js +8 -8
  86. package/dist/esm/justifi-payment-details.entry.js +7 -7
  87. package/dist/esm/justifi-payment-provisioning.entry.js +7 -7
  88. package/dist/esm/justifi-payment-transactions-list.entry.js +6 -6
  89. package/dist/esm/justifi-payments-list.entry.js +6 -6
  90. package/dist/esm/justifi-payout-details.entry.js +7 -7
  91. package/dist/esm/justifi-payout-transactions-list.entry.js +6 -6
  92. package/dist/esm/justifi-payouts-list-filters.entry.js +1 -1
  93. package/dist/esm/justifi-payouts-list.entry.js +8 -8
  94. package/dist/esm/justifi-qr-terminal.entry.js +206 -0
  95. package/dist/esm/justifi-refund-payment.entry.js +7 -7
  96. package/dist/esm/justifi-season-interruption-insurance.entry.js +5 -5
  97. package/dist/esm/justifi-terminal-orders-list-filters.entry.js +1 -1
  98. package/dist/esm/justifi-terminal-orders-list.entry.js +5 -5
  99. package/dist/esm/justifi-terminals-list-filters.entry.js +1 -1
  100. package/dist/esm/justifi-terminals-list.entry.js +7 -7
  101. package/dist/esm/loader.js +1 -1
  102. package/dist/esm/{package-OGt0dCJl.js → package-CZa-hHhJ.js} +1 -1
  103. package/dist/esm/{payment-provisioning-actions-cl5xIYnF.js → payment-provisioning-actions-CcDadiRe.js} +2 -2
  104. package/dist/esm/{payment.service-5_u-UzTY.js → payment.service-BiKQPL4M.js} +1 -1
  105. package/dist/esm/{payout.service-D2zS5y8N.js → payout.service-B9_cyUiU.js} +1 -1
  106. package/dist/esm/{payouts-status-DCjCGTaa.js → payouts-status-xOa5tT66.js} +2 -2
  107. package/dist/esm/{plaid.service-BiJ65YG8.js → plaid.service-bU3qIoKd.js} +1 -1
  108. package/dist/esm/{terminal.service-CIxDfM7V.js → terminal.service-BM6BvevW.js} +1 -1
  109. package/dist/esm/{utils-C1B2hVAB.js → utils-BogmBHgt.js} +1 -1
  110. package/dist/esm/webcomponents.js +1 -1
  111. package/dist/module/Plaid.js +1 -1
  112. package/dist/module/business-bank-account-form-step2.js +1 -1
  113. package/dist/module/checkout-actions.js +59 -0
  114. package/dist/module/get-payment-details.js +1 -1
  115. package/dist/module/justifi-checkout-qr-code.d.ts +11 -0
  116. package/dist/module/justifi-checkout-qr-code.js +6 -0
  117. package/dist/module/justifi-checkout-qr-code2.js +3154 -0
  118. package/dist/module/justifi-checkouts-list.js +1 -1
  119. package/dist/module/justifi-dispute-management.js +1 -1
  120. package/dist/module/justifi-modular-checkout2.js +2 -57
  121. package/dist/module/justifi-order-terminals.js +1 -1
  122. package/dist/module/justifi-payment-details.js +1 -1
  123. package/dist/module/justifi-payment-transactions-list.js +1 -1
  124. package/dist/module/justifi-payments-list.js +1 -1
  125. package/dist/module/justifi-payout-details.js +1 -1
  126. package/dist/module/justifi-payout-transactions-list.js +1 -1
  127. package/dist/module/justifi-payouts-list.js +1 -1
  128. package/dist/module/justifi-qr-terminal.d.ts +11 -0
  129. package/dist/module/justifi-qr-terminal.js +234 -0
  130. package/dist/module/justifi-refund-payment.js +1 -1
  131. package/dist/module/justifi-terminal-orders-list-filters.js +1 -1
  132. package/dist/module/justifi-terminal-orders-list.js +1 -1
  133. package/dist/module/justifi-terminals-list-filters.js +1 -1
  134. package/dist/module/justifi-terminals-list.js +1 -1
  135. package/dist/module/package.js +1 -1
  136. package/dist/types/api/Checkout.d.ts +1 -2
  137. package/dist/types/components/checkout-qr-code/justifi-checkout-qr-code.d.ts +18 -0
  138. package/dist/types/components/qr-terminal/justifi-qr-terminal.d.ts +42 -0
  139. package/dist/types/components.d.ts +92 -0
  140. package/dist/webcomponents/{p-ea0d7a98.entry.js → p-06e8df55.entry.js} +1 -1
  141. package/dist/webcomponents/{p-daaa2a99.entry.js → p-07f2f1bf.entry.js} +1 -1
  142. package/dist/webcomponents/p-0fb8fb8c.entry.js +1 -0
  143. package/dist/webcomponents/p-10087a53.entry.js +1 -0
  144. package/dist/webcomponents/{p-45c0fb53.entry.js → p-1d7b8c21.entry.js} +1 -1
  145. package/dist/webcomponents/{p-d24240a5.entry.js → p-21c89e22.entry.js} +1 -1
  146. package/dist/webcomponents/{p-d79c5ee4.entry.js → p-2ec7cd88.entry.js} +1 -1
  147. package/dist/webcomponents/p-2qotS5d_.js +1 -0
  148. package/dist/webcomponents/{p-69fdd137.entry.js → p-355a5c8d.entry.js} +1 -1
  149. package/dist/webcomponents/{p-8964f4ca.entry.js → p-37b95a11.entry.js} +1 -1
  150. package/dist/webcomponents/p-37fd1862.entry.js +1 -0
  151. package/dist/webcomponents/{p-c8f3656f.entry.js → p-392f0c1c.entry.js} +1 -1
  152. package/dist/webcomponents/{p-9d021e10.entry.js → p-44cf13ac.entry.js} +1 -1
  153. package/dist/webcomponents/{p-cde76bf8.entry.js → p-55fdab4e.entry.js} +1 -1
  154. package/dist/webcomponents/p-5ccb46ee.entry.js +1 -0
  155. package/dist/webcomponents/{p-8d173a7c.entry.js → p-5f8dfa8d.entry.js} +1 -1
  156. package/dist/webcomponents/{p-07236291.entry.js → p-70cd2808.entry.js} +1 -1
  157. package/dist/webcomponents/{p-3f5e9afb.entry.js → p-769d3d93.entry.js} +1 -1
  158. package/dist/webcomponents/{p-f30069ea.entry.js → p-79bd744e.entry.js} +1 -1
  159. package/dist/webcomponents/{p-49a4123c.entry.js → p-7a4cd292.entry.js} +1 -1
  160. package/dist/webcomponents/p-8d602e60.entry.js +1 -0
  161. package/dist/webcomponents/p-94f14640.entry.js +1 -0
  162. package/dist/webcomponents/p-98f399ec.entry.js +1 -0
  163. package/dist/webcomponents/{p-7119fddd.entry.js → p-9fca25fc.entry.js} +1 -1
  164. package/dist/webcomponents/{p-Ba8jdOkX.js → p-BGvaX-lJ.js} +1 -1
  165. package/dist/webcomponents/{p-NZS8uCtH.js → p-CSgcCWLS.js} +1 -1
  166. package/dist/webcomponents/p-CZa-hHhJ.js +1 -0
  167. package/dist/webcomponents/p-Cg_3KsGO.js +1 -0
  168. package/dist/webcomponents/p-CqPcl9v7.js +1 -0
  169. package/dist/webcomponents/p-CvgL8YaH.js +1 -0
  170. package/dist/webcomponents/{p-oTtn8xDw.js → p-D4E9P7df.js} +1 -1
  171. package/dist/webcomponents/{p-Dk26hk5T.js → p-DD-_8sbs.js} +1 -1
  172. package/dist/webcomponents/{p-mF5zKtkx.js → p-DHFQtPCq.js} +1 -1
  173. package/dist/webcomponents/p-DMqJWUK2.js +1 -0
  174. package/dist/webcomponents/{p-fE5A37L5.js → p-DZAMzLxa.js} +1 -1
  175. package/dist/webcomponents/{p-Cz_7BuGW.js → p-DbOUuBHs.js} +1 -1
  176. package/dist/webcomponents/{p-BxKbnILQ.js → p-Eb1f86_V.js} +1 -1
  177. package/dist/webcomponents/{p-av6jyzyC.js → p-XxG-t-Sl.js} +1 -1
  178. package/dist/webcomponents/{p-7ebed752.entry.js → p-aee2295b.entry.js} +1 -1
  179. package/dist/webcomponents/p-b20b8805.entry.js +1 -0
  180. package/dist/webcomponents/p-bb5de874.entry.js +1 -0
  181. package/dist/webcomponents/p-bd678d4a.entry.js +1 -0
  182. package/dist/webcomponents/{p-f3ff7e00.entry.js → p-c8ee1e4c.entry.js} +1 -1
  183. package/dist/webcomponents/p-ce1dde85.entry.js +1 -0
  184. package/dist/webcomponents/{p-8aa53ef2.entry.js → p-d620d4b4.entry.js} +1 -1
  185. package/dist/webcomponents/{p-ae91fc9b.entry.js → p-dcd600ca.entry.js} +1 -1
  186. package/dist/webcomponents/p-e6b9dfe1.entry.js +1 -0
  187. package/dist/webcomponents/p-eCeOsPHx.js +1 -0
  188. package/dist/webcomponents/{p-BJu1-9kE.js → p-eK8hZOMg.js} +1 -1
  189. package/dist/webcomponents/{p-a1dcdc8b.entry.js → p-ff5c5499.entry.js} +4 -4
  190. package/dist/webcomponents/{p-BXyADlAH.js → p-qju4tNG1.js} +1 -1
  191. package/dist/webcomponents/webcomponents.esm.js +1 -1
  192. package/package.json +16 -14
  193. package/LICENSE +0 -21
  194. package/dist/webcomponents/p-215c6b6b.entry.js +0 -1
  195. package/dist/webcomponents/p-31452258.entry.js +0 -1
  196. package/dist/webcomponents/p-35dd1fc0.entry.js +0 -1
  197. package/dist/webcomponents/p-4ec433f4.entry.js +0 -1
  198. package/dist/webcomponents/p-58b5e08e.entry.js +0 -1
  199. package/dist/webcomponents/p-5G1OMxZz.js +0 -1
  200. package/dist/webcomponents/p-6220a384.entry.js +0 -1
  201. package/dist/webcomponents/p-91aef5bf.entry.js +0 -1
  202. package/dist/webcomponents/p-APOabprT.js +0 -1
  203. package/dist/webcomponents/p-Aacb4jqT.js +0 -1
  204. package/dist/webcomponents/p-Cm9f5fyh.js +0 -1
  205. package/dist/webcomponents/p-OGt0dCJl.js +0 -1
  206. package/dist/webcomponents/p-b272a29d.entry.js +0 -1
  207. package/dist/webcomponents/p-c9fe4f33.entry.js +0 -1
  208. package/dist/webcomponents/p-ef85717f.entry.js +0 -1
  209. package/dist/webcomponents/p-nb_LhbJq.js +0 -1
@@ -48,6 +48,7 @@
48
48
  "components/checkout/save-new-payment-method/justifi-save-new-payment-method.js",
49
49
  "components/checkout/save-new-payment-method/save-new-payment-method.js",
50
50
  "ui-components/form/form-control-checkbox.js",
51
+ "components/checkout-qr-code/justifi-checkout-qr-code.js",
51
52
  "components/checkouts-list/checkouts-list-filters.js",
52
53
  "components/checkouts-list/justifi-checkouts-list.js",
53
54
  "components/filters/table-filters-menu.js",
@@ -90,6 +91,7 @@
90
91
  "components/payouts-list/justifi-payouts-list-filters.js",
91
92
  "components/payouts-list/justifi-payouts-list.js",
92
93
  "ui-components/form/form-control-date.js",
94
+ "components/qr-terminal/justifi-qr-terminal.js",
93
95
  "components/refund-payment/justifi-refund-payment.js",
94
96
  "components/terminal-orders-list/justifi-terminal-orders-list-filters.js",
95
97
  "components/terminal-orders-list/justifi-terminal-orders-list.js",
@@ -0,0 +1,128 @@
1
+ import { h } from "@stencil/core";
2
+ import QRCode from "qrcode";
3
+ import { ComponentErrorCodes, ComponentErrorSeverity } from "../../api/ComponentError";
4
+ import JustifiAnalytics from "../../api/Analytics";
5
+ import { checkPkgVersion } from "../../utils/check-pkg-version";
6
+ export class JustifiCheckoutQrCode {
7
+ constructor() {
8
+ this.size = 256;
9
+ }
10
+ componentWillLoad() {
11
+ checkPkgVersion();
12
+ this.analytics = new JustifiAnalytics(this);
13
+ }
14
+ componentDidLoad() {
15
+ this.renderQrCode();
16
+ }
17
+ disconnectedCallback() {
18
+ var _a;
19
+ (_a = this.analytics) === null || _a === void 0 ? void 0 : _a.cleanup();
20
+ }
21
+ propChanged() {
22
+ this.renderQrCode();
23
+ }
24
+ get checkoutUrl() {
25
+ return `https://components.justifi.ai/hosted-checkout/${this.checkoutId}`;
26
+ }
27
+ async renderQrCode() {
28
+ if (!this.checkoutId) {
29
+ this.errorEvent.emit({
30
+ message: 'checkoutId is required',
31
+ errorCode: ComponentErrorCodes.MISSING_PROPS,
32
+ severity: ComponentErrorSeverity.ERROR,
33
+ });
34
+ return;
35
+ }
36
+ if (!this.qrContainerEl)
37
+ return;
38
+ const svg = await QRCode.toString(this.checkoutUrl, {
39
+ type: 'svg',
40
+ width: this.size,
41
+ errorCorrectionLevel: 'M',
42
+ });
43
+ this.qrContainerEl.innerHTML = svg;
44
+ }
45
+ render() {
46
+ if (!this.checkoutId)
47
+ return null;
48
+ return (h("div", { ref: (el) => (this.qrContainerEl = el) }));
49
+ }
50
+ static get is() { return "justifi-checkout-qr-code"; }
51
+ static get properties() {
52
+ return {
53
+ "checkoutId": {
54
+ "type": "string",
55
+ "mutable": false,
56
+ "complexType": {
57
+ "original": "string",
58
+ "resolved": "string",
59
+ "references": {}
60
+ },
61
+ "required": true,
62
+ "optional": false,
63
+ "docs": {
64
+ "tags": [],
65
+ "text": ""
66
+ },
67
+ "getter": false,
68
+ "setter": false,
69
+ "reflect": false,
70
+ "attribute": "checkout-id"
71
+ },
72
+ "size": {
73
+ "type": "number",
74
+ "mutable": false,
75
+ "complexType": {
76
+ "original": "number",
77
+ "resolved": "number",
78
+ "references": {}
79
+ },
80
+ "required": false,
81
+ "optional": false,
82
+ "docs": {
83
+ "tags": [],
84
+ "text": ""
85
+ },
86
+ "getter": false,
87
+ "setter": false,
88
+ "reflect": false,
89
+ "attribute": "size",
90
+ "defaultValue": "256"
91
+ }
92
+ };
93
+ }
94
+ static get events() {
95
+ return [{
96
+ "method": "errorEvent",
97
+ "name": "error-event",
98
+ "bubbles": true,
99
+ "cancelable": true,
100
+ "composed": true,
101
+ "docs": {
102
+ "tags": [],
103
+ "text": ""
104
+ },
105
+ "complexType": {
106
+ "original": "ComponentErrorEvent",
107
+ "resolved": "ComponentErrorEvent",
108
+ "references": {
109
+ "ComponentErrorEvent": {
110
+ "location": "import",
111
+ "path": "../../api/ComponentEvents",
112
+ "id": "src/api/ComponentEvents.ts::ComponentErrorEvent"
113
+ }
114
+ }
115
+ }
116
+ }];
117
+ }
118
+ static get elementRef() { return "el"; }
119
+ static get watchers() {
120
+ return [{
121
+ "propName": "checkoutId",
122
+ "methodName": "propChanged"
123
+ }, {
124
+ "propName": "size",
125
+ "methodName": "propChanged"
126
+ }];
127
+ }
128
+ }
@@ -0,0 +1,349 @@
1
+ import { h } from "@stencil/core";
2
+ import { makeGetCheckout } from "../../actions/checkout/checkout-actions";
3
+ import { CheckoutService } from "../../api/services/checkout.service";
4
+ import { CompletionStatuses, ICheckoutStatus } from "../../api/Checkout";
5
+ import { ComponentErrorCodes, ComponentErrorMessages, ComponentErrorSeverity } from "../../api/ComponentError";
6
+ import JustifiAnalytics from "../../api/Analytics";
7
+ import { checkPkgVersion } from "../../utils/check-pkg-version";
8
+ export class JustifiQrTerminal {
9
+ constructor() {
10
+ this.pollIntervalMs = 3000;
11
+ this.pollTimeoutMs = 600000;
12
+ this.terminalState = 'loading';
13
+ this.paymentStatus = '';
14
+ this.errorMessage = '';
15
+ this.pollIntervalHandle = null;
16
+ this.pollTimeoutHandle = null;
17
+ this.failedDismissHandle = null;
18
+ this.seenCompletionCreatedAts = new Set();
19
+ this.inFlight = false;
20
+ }
21
+ componentWillLoad() {
22
+ checkPkgVersion();
23
+ this.analytics = new JustifiAnalytics(this);
24
+ this.initialize();
25
+ }
26
+ disconnectedCallback() {
27
+ var _a;
28
+ this.stopAll();
29
+ (_a = this.analytics) === null || _a === void 0 ? void 0 : _a.cleanup();
30
+ }
31
+ propChanged() {
32
+ this.stopAll();
33
+ this.initialize();
34
+ }
35
+ suppressInnerErrors(event) {
36
+ // Suppress error-event bubbling from inner justifi-checkout-qr-code
37
+ event.stopPropagation();
38
+ }
39
+ get effectivePollInterval() {
40
+ return Math.max(1000, this.pollIntervalMs);
41
+ }
42
+ initialize() {
43
+ if (!this.authToken || !this.checkoutId) {
44
+ this.errorEvent.emit({
45
+ message: 'authToken and checkoutId are required',
46
+ errorCode: ComponentErrorCodes.MISSING_PROPS,
47
+ severity: ComponentErrorSeverity.ERROR,
48
+ });
49
+ return;
50
+ }
51
+ this.terminalState = 'loading';
52
+ this.getCheckout = makeGetCheckout({
53
+ authToken: this.authToken,
54
+ checkoutId: this.checkoutId,
55
+ service: new CheckoutService(),
56
+ });
57
+ this.getCheckout({
58
+ onSuccess: ({ checkout }) => this.handleInitialLoad(checkout),
59
+ onError: ({ error, code, severity }) => {
60
+ this.terminalState = 'error';
61
+ this.errorMessage = error;
62
+ this.errorEvent.emit({ message: error, errorCode: code, severity });
63
+ },
64
+ });
65
+ }
66
+ handleInitialLoad(checkout) {
67
+ var _a;
68
+ switch (checkout.status) {
69
+ case ICheckoutStatus.expired:
70
+ this.terminalState = 'expired';
71
+ this.checkoutExpired.emit({ checkoutId: this.checkoutId });
72
+ this.errorEvent.emit({
73
+ message: ComponentErrorMessages.CHECKOUT_EXPIRED,
74
+ errorCode: ComponentErrorCodes.CHECKOUT_EXPIRED,
75
+ severity: ComponentErrorSeverity.ERROR,
76
+ });
77
+ break;
78
+ case ICheckoutStatus.completed:
79
+ this.terminalState = 'completed';
80
+ this.paymentStatus = this.resolvePaymentStatus(checkout);
81
+ this.checkoutCompleted.emit({ checkoutId: this.checkoutId, paymentStatus: this.paymentStatus });
82
+ break;
83
+ default:
84
+ ((_a = checkout.completions) !== null && _a !== void 0 ? _a : []).forEach((c) => this.seenCompletionCreatedAts.add(c.created_at));
85
+ this.terminalState = 'ready';
86
+ this.startPolling();
87
+ break;
88
+ }
89
+ }
90
+ startPolling() {
91
+ this.pollTimeoutHandle = setTimeout(() => {
92
+ this.stopAll();
93
+ this.terminalState = 'error';
94
+ this.errorMessage = 'Checkout polling timed out';
95
+ this.errorEvent.emit({
96
+ message: 'Checkout polling timed out',
97
+ errorCode: ComponentErrorCodes.FETCH_ERROR,
98
+ severity: ComponentErrorSeverity.ERROR,
99
+ });
100
+ }, this.pollTimeoutMs);
101
+ this.pollIntervalHandle = setInterval(() => this.tick(), this.effectivePollInterval);
102
+ }
103
+ tick() {
104
+ if (this.inFlight)
105
+ return;
106
+ this.inFlight = true;
107
+ this.getCheckout({
108
+ onSuccess: ({ checkout }) => {
109
+ this.inFlight = false;
110
+ this.handlePollResult(checkout);
111
+ },
112
+ onError: ({ error, code, severity }) => {
113
+ this.inFlight = false;
114
+ this.stopAll();
115
+ this.terminalState = 'error';
116
+ this.errorMessage = error;
117
+ this.errorEvent.emit({ message: error, errorCode: code, severity });
118
+ },
119
+ });
120
+ }
121
+ handlePollResult(checkout) {
122
+ var _a;
123
+ const completions = (_a = checkout.completions) !== null && _a !== void 0 ? _a : [];
124
+ const newFailures = completions.filter((c) => !this.seenCompletionCreatedAts.has(c.created_at) && c.payment_status === 'failed');
125
+ newFailures.forEach((c) => this.seenCompletionCreatedAts.add(c.created_at));
126
+ if (newFailures.length > 0) {
127
+ this.terminalState = 'payment-failed';
128
+ if (this.failedDismissHandle)
129
+ clearTimeout(this.failedDismissHandle);
130
+ this.failedDismissHandle = setTimeout(() => {
131
+ if (this.terminalState === 'payment-failed')
132
+ this.terminalState = 'ready';
133
+ }, 3000);
134
+ }
135
+ if (checkout.status === ICheckoutStatus.completed) {
136
+ this.stopAll();
137
+ this.terminalState = 'completed';
138
+ this.paymentStatus = this.resolvePaymentStatus(checkout);
139
+ this.checkoutCompleted.emit({ checkoutId: this.checkoutId, paymentStatus: this.paymentStatus });
140
+ return;
141
+ }
142
+ if (checkout.status === ICheckoutStatus.expired) {
143
+ this.stopAll();
144
+ this.terminalState = 'expired';
145
+ this.checkoutExpired.emit({ checkoutId: this.checkoutId });
146
+ this.errorEvent.emit({
147
+ message: ComponentErrorMessages.CHECKOUT_EXPIRED,
148
+ errorCode: ComponentErrorCodes.CHECKOUT_EXPIRED,
149
+ severity: ComponentErrorSeverity.ERROR,
150
+ });
151
+ }
152
+ }
153
+ resolvePaymentStatus(checkout) {
154
+ var _a, _b;
155
+ const completions = (_a = checkout.completions) !== null && _a !== void 0 ? _a : [];
156
+ const sorted = [...completions].sort((a, b) => new Date(b.updated_at).getTime() - new Date(a.updated_at).getTime());
157
+ const latestStatus = (_b = sorted[0]) === null || _b === void 0 ? void 0 : _b.payment_status;
158
+ if (latestStatus === CompletionStatuses.succeeded)
159
+ return 'succeeded';
160
+ if (latestStatus == null) {
161
+ return checkout.successful_payment_id ? 'succeeded' : 'pending';
162
+ }
163
+ return 'pending';
164
+ }
165
+ stopAll() {
166
+ if (this.pollIntervalHandle) {
167
+ clearInterval(this.pollIntervalHandle);
168
+ this.pollIntervalHandle = null;
169
+ }
170
+ if (this.pollTimeoutHandle) {
171
+ clearTimeout(this.pollTimeoutHandle);
172
+ this.pollTimeoutHandle = null;
173
+ }
174
+ if (this.failedDismissHandle) {
175
+ clearTimeout(this.failedDismissHandle);
176
+ this.failedDismissHandle = null;
177
+ }
178
+ this.inFlight = false;
179
+ }
180
+ render() {
181
+ if (!this.authToken || !this.checkoutId)
182
+ return null;
183
+ return (h("div", null, this.terminalState === 'loading' && null, (this.terminalState === 'ready' || this.terminalState === 'payment-failed') && (h("div", null, h("justifi-checkout-qr-code", { checkoutId: this.checkoutId }), this.terminalState === 'payment-failed' && (h("p", null, "Payment failed. Please try again.")), this.terminalState === 'ready' && (h("p", null, "Scan to pay")))), this.terminalState === 'completed' && (h("div", null, this.paymentStatus === 'succeeded'
184
+ ? h("p", null, "Payment received")
185
+ : h("p", null, "Payment pending"))), this.terminalState === 'expired' && (h("p", null, "Checkout expired. Please create a new checkout.")), this.terminalState === 'error' && (h("p", null, this.errorMessage))));
186
+ }
187
+ static get is() { return "justifi-qr-terminal"; }
188
+ static get properties() {
189
+ return {
190
+ "authToken": {
191
+ "type": "string",
192
+ "mutable": false,
193
+ "complexType": {
194
+ "original": "string",
195
+ "resolved": "string",
196
+ "references": {}
197
+ },
198
+ "required": true,
199
+ "optional": false,
200
+ "docs": {
201
+ "tags": [],
202
+ "text": ""
203
+ },
204
+ "getter": false,
205
+ "setter": false,
206
+ "reflect": false,
207
+ "attribute": "auth-token"
208
+ },
209
+ "checkoutId": {
210
+ "type": "string",
211
+ "mutable": false,
212
+ "complexType": {
213
+ "original": "string",
214
+ "resolved": "string",
215
+ "references": {}
216
+ },
217
+ "required": true,
218
+ "optional": false,
219
+ "docs": {
220
+ "tags": [],
221
+ "text": ""
222
+ },
223
+ "getter": false,
224
+ "setter": false,
225
+ "reflect": false,
226
+ "attribute": "checkout-id"
227
+ },
228
+ "pollIntervalMs": {
229
+ "type": "number",
230
+ "mutable": false,
231
+ "complexType": {
232
+ "original": "number",
233
+ "resolved": "number",
234
+ "references": {}
235
+ },
236
+ "required": false,
237
+ "optional": false,
238
+ "docs": {
239
+ "tags": [],
240
+ "text": ""
241
+ },
242
+ "getter": false,
243
+ "setter": false,
244
+ "reflect": false,
245
+ "attribute": "poll-interval-ms",
246
+ "defaultValue": "3000"
247
+ },
248
+ "pollTimeoutMs": {
249
+ "type": "number",
250
+ "mutable": false,
251
+ "complexType": {
252
+ "original": "number",
253
+ "resolved": "number",
254
+ "references": {}
255
+ },
256
+ "required": false,
257
+ "optional": false,
258
+ "docs": {
259
+ "tags": [],
260
+ "text": ""
261
+ },
262
+ "getter": false,
263
+ "setter": false,
264
+ "reflect": false,
265
+ "attribute": "poll-timeout-ms",
266
+ "defaultValue": "600000"
267
+ }
268
+ };
269
+ }
270
+ static get states() {
271
+ return {
272
+ "terminalState": {},
273
+ "paymentStatus": {},
274
+ "errorMessage": {}
275
+ };
276
+ }
277
+ static get events() {
278
+ return [{
279
+ "method": "checkoutCompleted",
280
+ "name": "checkout-completed",
281
+ "bubbles": true,
282
+ "cancelable": true,
283
+ "composed": true,
284
+ "docs": {
285
+ "tags": [],
286
+ "text": ""
287
+ },
288
+ "complexType": {
289
+ "original": "{ checkoutId: string; paymentStatus: string }",
290
+ "resolved": "{ checkoutId: string; paymentStatus: string; }",
291
+ "references": {}
292
+ }
293
+ }, {
294
+ "method": "checkoutExpired",
295
+ "name": "checkout-expired",
296
+ "bubbles": true,
297
+ "cancelable": true,
298
+ "composed": true,
299
+ "docs": {
300
+ "tags": [],
301
+ "text": ""
302
+ },
303
+ "complexType": {
304
+ "original": "{ checkoutId: string }",
305
+ "resolved": "{ checkoutId: string; }",
306
+ "references": {}
307
+ }
308
+ }, {
309
+ "method": "errorEvent",
310
+ "name": "error-event",
311
+ "bubbles": true,
312
+ "cancelable": true,
313
+ "composed": true,
314
+ "docs": {
315
+ "tags": [],
316
+ "text": ""
317
+ },
318
+ "complexType": {
319
+ "original": "ComponentErrorEvent",
320
+ "resolved": "ComponentErrorEvent",
321
+ "references": {
322
+ "ComponentErrorEvent": {
323
+ "location": "import",
324
+ "path": "../../api/ComponentEvents",
325
+ "id": "src/api/ComponentEvents.ts::ComponentErrorEvent"
326
+ }
327
+ }
328
+ }
329
+ }];
330
+ }
331
+ static get watchers() {
332
+ return [{
333
+ "propName": "authToken",
334
+ "methodName": "propChanged"
335
+ }, {
336
+ "propName": "checkoutId",
337
+ "methodName": "propChanged"
338
+ }];
339
+ }
340
+ static get listeners() {
341
+ return [{
342
+ "name": "error-event",
343
+ "method": "suppressInnerErrors",
344
+ "target": undefined,
345
+ "capture": false,
346
+ "passive": false
347
+ }];
348
+ }
349
+ }