@justifi/webcomponents 6.0.0-rc.1 → 6.0.0-rc.10
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.
- package/dist/cjs/{Api-CPuq_15r.js → Api-DyimBzKT.js} +2 -2
- package/dist/cjs/{Refund-CqWNG8sx.js → Refund-BefKONu4.js} +6 -3
- package/dist/cjs/additional-questions-details_5.cjs.entry.js +3 -3
- package/dist/cjs/{badge-CMmPvqtE.js → badge-CcJ9H85-.js} +1 -1
- package/dist/cjs/bank-account-document-form-inputs_4.cjs.entry.js +7 -7
- package/dist/cjs/bank-account-form.cjs.entry.js +9 -6
- package/dist/cjs/business-details-core.cjs.entry.js +4 -4
- package/dist/cjs/{business.service-C3BdUPlm.js → business.service-BB6zl4Gc.js} +2 -2
- package/dist/cjs/{button-CfVQSysQ.js → button-DsHDMHaa.js} +1 -1
- package/dist/cjs/card-form.cjs.entry.js +9 -6
- package/dist/cjs/{check-pkg-version-D_lazhBQ.js → check-pkg-version-DiQ-d5Nl.js} +9 -3
- package/dist/cjs/{checkout.service-B0ZmvWwI.js → checkout.service-B-R80p4f.js} +2 -2
- package/dist/cjs/checkout.store-BGvYPPz0.js +88 -0
- package/dist/cjs/checkouts-list-core.cjs.entry.js +10 -10
- package/dist/cjs/{payments-list-params-state-BNbT1fuJ.js → checkouts-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{checkouts-table-UN5gPpQ_.js → checkouts-table-DjMdEiEW.js} +3 -3
- package/dist/cjs/{config-state-5xZf-jax.js → config-state-BBOZIS8x.js} +1 -1
- package/dist/cjs/custom-popper_2.cjs.entry.js +1 -1
- package/dist/cjs/{dispute.service-DsPEAcDn.js → dispute.service-B5tITFAh.js} +2 -2
- package/dist/cjs/form-alert_5.cjs.entry.js +1 -1
- package/dist/cjs/form-control-checkbox.cjs.entry.js +3 -3
- package/dist/cjs/form-control-date.cjs.entry.js +2 -2
- package/dist/cjs/{form-control-error-text-HM0zQerh.js → form-control-error-text-B-P5UDhm.js} +1 -1
- package/dist/cjs/form-control-file-v2_2.cjs.entry.js +2 -2
- package/dist/cjs/{form-control-help-text-5KIUw1IP.js → form-control-help-text-JoZjhb9m.js} +1 -1
- package/dist/cjs/form-control-help-text.cjs.entry.js +1 -1
- package/dist/cjs/form-control-monetary-provisioning.cjs.entry.js +3 -3
- package/dist/cjs/form-control-monetary.cjs.entry.js +4 -4
- package/dist/cjs/form-control-number-masked_2.cjs.entry.js +2 -2
- package/dist/cjs/form-control-number.cjs.entry.js +3 -3
- package/dist/cjs/form-control-radio.cjs.entry.js +3 -3
- package/dist/cjs/form-control-select_2.cjs.entry.js +2 -2
- package/dist/cjs/{get-payment-details-DtCXaIMx.js → get-payment-details-BfgRmNL4.js} +2 -2
- package/dist/cjs/{get-subaccounts-CwCH5rC8.js → get-subaccounts-Bnfv2tEN.js} +3 -3
- package/dist/cjs/gross-payment-chart-core.cjs.entry.js +4 -4
- package/dist/cjs/{header-1-DD41iNlG.js → header-1-DRA3f4Jh.js} +1 -1
- package/dist/cjs/{header-3-D9Wa0IfT.js → header-3-sOdOpfx3.js} +1 -1
- package/dist/cjs/hidden-input_2.cjs.entry.js +4 -4
- package/dist/cjs/{index-Yd9aLenr.js → index-B32W0A3m.js} +1 -1
- package/dist/cjs/{index-dm_GlYlb.js → index-C9hBD-32.js} +2 -2
- package/dist/cjs/index-D-dD-aC2.js +30 -0
- package/dist/cjs/index.cjs.js +8 -0
- package/dist/cjs/{insurance-state-Cyva9u6S.js → insurance-state-d2thhXUX.js} +2 -2
- package/dist/cjs/justifi-additional-questions-form-step-core_6.cjs.entry.js +7 -7
- package/dist/cjs/justifi-additional-questions-form-step_9.cjs.entry.js +8 -8
- package/dist/cjs/justifi-additional-statement_8.cjs.entry.js +1 -1
- package/dist/cjs/justifi-apple-pay.cjs.entry.js +782 -0
- package/dist/cjs/justifi-bank-account-billing-form-simple_9.cjs.entry.js +16 -15
- package/dist/cjs/justifi-business-details.cjs.entry.js +10 -10
- package/dist/cjs/justifi-business-form.cjs.entry.js +13 -13
- package/dist/cjs/justifi-business-representative-form-inputs.cjs.entry.js +1 -1
- package/dist/cjs/justifi-checkout-summary_7.cjs.entry.js +1421 -0
- package/dist/cjs/justifi-checkout.cjs.entry.js +26 -48
- package/dist/cjs/justifi-checkouts-list-filters.cjs.entry.js +7 -7
- package/dist/cjs/justifi-checkouts-list.cjs.entry.js +13 -13
- package/dist/cjs/justifi-config-provider.cjs.entry.js +3 -3
- package/dist/cjs/justifi-details.cjs.entry.js +2 -2
- package/dist/cjs/justifi-dispute-management-core.cjs.entry.js +1 -1
- package/dist/cjs/justifi-dispute-management.cjs.entry.js +9 -9
- package/dist/cjs/justifi-dispute-notification_3.cjs.entry.js +12 -12
- package/dist/cjs/justifi-gross-payment-chart.cjs.entry.js +9 -9
- package/dist/cjs/justifi-order-terminals.cjs.entry.js +12 -12
- package/dist/cjs/justifi-owner-form_3.cjs.entry.js +8 -8
- package/dist/cjs/justifi-payment-details.cjs.entry.js +11 -11
- package/dist/cjs/justifi-payment-provisioning-core.cjs.entry.js +3 -3
- package/dist/cjs/justifi-payment-provisioning.cjs.entry.js +9 -9
- package/dist/cjs/justifi-payment-transactions-list.cjs.entry.js +12 -12
- package/dist/cjs/justifi-payments-list-filters.cjs.entry.js +5 -5
- package/dist/cjs/justifi-payments-list.cjs.entry.js +13 -13
- package/dist/cjs/justifi-payout-details.cjs.entry.js +10 -10
- package/dist/cjs/justifi-payout-transactions-list.cjs.entry.js +12 -12
- package/dist/cjs/justifi-payouts-list-filters.cjs.entry.js +5 -5
- package/dist/cjs/justifi-payouts-list.cjs.entry.js +14 -14
- package/dist/cjs/justifi-refund-payment.cjs.entry.js +13 -13
- package/dist/cjs/justifi-saved-payment-method.cjs.entry.js +1 -1
- package/dist/cjs/justifi-season-interruption-insurance.cjs.entry.js +17 -12
- package/dist/cjs/justifi-skeleton.cjs.entry.js +3 -3
- package/dist/cjs/justifi-terminal-orders-list-filters.cjs.entry.js +7 -7
- package/dist/cjs/justifi-terminal-orders-list.cjs.entry.js +11 -11
- package/dist/cjs/justifi-terminals-list-filters.cjs.entry.js +7 -7
- package/dist/cjs/justifi-terminals-list.cjs.entry.js +13 -13
- package/dist/cjs/loader.cjs.js +2 -2
- package/dist/cjs/{package-Cp_7Ls2E.js → package-Be2aoTf8.js} +1 -1
- package/dist/cjs/pagination-menu.cjs.entry.js +1 -1
- package/dist/cjs/payment-details-core.cjs.entry.js +7 -7
- package/dist/cjs/payment-method-option.cjs.entry.js +2 -2
- package/dist/cjs/{payment.service-1H0VC3LV.js → payment.service-aR96UW5e.js} +2 -2
- package/dist/cjs/payments-list-core.cjs.entry.js +11 -11
- package/dist/cjs/{payouts-list-params-state-BNbT1fuJ.js → payments-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{payments-status-PB63klt3.js → payments-status-DXRh_ekP.js} +2 -2
- package/dist/cjs/{payments-table-quF0NnsS.js → payments-table-BE8u0-i0.js} +3 -3
- package/dist/cjs/payout-details-core.cjs.entry.js +8 -8
- package/dist/cjs/{payout.service-CIZFU-hV.js → payout.service-6Cl_yXXQ.js} +2 -2
- package/dist/cjs/payouts-list-core.cjs.entry.js +11 -11
- package/dist/cjs/{checkouts-list-params-state-BNbT1fuJ.js → payouts-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{payouts-status-Bk1JFzbP.js → payouts-status-DxTQZv3i.js} +2 -2
- package/dist/cjs/{payouts-table-D_CCTR_k.js → payouts-table-BbydhJUr.js} +3 -3
- package/dist/cjs/{skeleton-x-GSs3xk.js → skeleton-C7DQRD6r.js} +1 -1
- package/dist/cjs/{spinner-Kb1BFvnL.js → spinner-jmeA44Ee.js} +1 -1
- package/dist/cjs/{styled-host-CqQYxX-w.js → styled-host-BfVJlAsJ.js} +1 -1
- package/dist/cjs/{table-BJVUhh3s.js → table-Ccdrt0v_.js} +2 -2
- package/dist/cjs/table-filters-menu.cjs.entry.js +2 -2
- package/dist/cjs/terminal-orders-list-core.cjs.entry.js +10 -10
- package/dist/cjs/{terminal-orders-list-params-state-BNbT1fuJ.js → terminal-orders-list-params-state-Cewmin_p.js} +1 -1
- package/dist/cjs/{terminal-orders-table-0O5jtzYj.js → terminal-orders-table-B4HjERrK.js} +5 -5
- package/dist/cjs/terminal-quantity-selector.cjs.entry.js +1 -1
- package/dist/cjs/{terminal.service-DUlyMTrX.js → terminal.service-D1FAYZzd.js} +2 -2
- package/dist/cjs/terminals-list-core.cjs.entry.js +10 -10
- package/dist/cjs/terminals-list-params-state-Cewmin_p.js +22 -0
- package/dist/cjs/{terminals-table-C2BNRUS5.js → terminals-table-C79Xc4FI.js} +3 -3
- package/dist/cjs/{utils-Df-pajL7.js → utils-Bzyj4qWe.js} +1 -1
- package/dist/cjs/{utils-BaGF9XIe.js → utils-ChCUZgUy.js} +6 -0
- package/dist/cjs/webcomponents.cjs.js +3 -3
- package/dist/collection/api/ApplePay.js +119 -0
- package/dist/collection/api/Payment.js +5 -2
- package/dist/collection/api/services/apple-pay.service.js +293 -0
- package/dist/collection/api/services/plaid.service.js +20 -0
- package/dist/collection/assets/plaid-icon.svg +1 -0
- package/dist/collection/collection-manifest.json +3 -1
- package/dist/collection/components/checkout/bank-account-form/bank-account-form.js +6 -3
- package/dist/collection/components/checkout/card-form/card-form.js +6 -3
- package/dist/collection/components/checkout/checkout.js +17 -39
- package/dist/collection/components/checkout/save-new-payment-method.js +1 -1
- package/dist/collection/components/insurance/season-interruption/season-interruption-insurance.js +4 -0
- package/dist/collection/components/modular-checkout/ModularCheckout.js +28 -0
- package/dist/collection/components/modular-checkout/modular-checkout.js +228 -125
- package/dist/collection/components/modular-checkout/sub-components/apple-pay-skeleton.js +10 -0
- package/dist/collection/components/modular-checkout/sub-components/apple-pay.js +509 -0
- package/dist/collection/components/modular-checkout/sub-components/plaid-payment-method.js +885 -0
- package/dist/collection/components/modular-checkout/sub-components/plaid-payment-method.test.js +124 -0
- package/dist/collection/components/modular-checkout/sub-components/saved-payment-methods.js +7 -5
- package/dist/collection/components/modular-checkout/sub-components/sezzle-payment-method.js +25 -8
- package/dist/collection/components/tokenize-payment-method/tokenize-payment-method.js +63 -34
- package/dist/collection/index.js +1 -0
- package/dist/collection/store/checkout.store.js +46 -2
- package/dist/collection/ui-components/apple-pay-button.js +146 -0
- package/dist/collection/ui-components/form/form-control-radio.js +5 -5
- package/dist/collection/ui-components/shadow-dom-components/justifi-radio-list-item.js +4 -4
- package/dist/collection/utils/check-pkg-version.js +6 -0
- package/dist/collection/utils/utils.js +5 -0
- package/dist/docs.json +1037 -212
- package/dist/esm/{Api-N_veT2p6.js → Api-DAWuvzbl.js} +2 -2
- package/dist/esm/{Refund-Di6J0oN2.js → Refund-CVh70dXA.js} +7 -4
- package/dist/esm/additional-questions-details_5.entry.js +4 -4
- package/dist/esm/{badge-D_mzXSCQ.js → badge-DSYSJcRy.js} +2 -2
- package/dist/esm/bank-account-document-form-inputs_4.entry.js +8 -8
- package/dist/esm/bank-account-form.entry.js +10 -7
- package/dist/esm/business-details-core.entry.js +5 -5
- package/dist/esm/{business.service-Bdvhdc_d.js → business.service-cQrH5BqF.js} +2 -2
- package/dist/esm/{button-CeR8qVS3.js → button-CpllL0At.js} +2 -2
- package/dist/esm/card-form.entry.js +10 -7
- package/dist/esm/{check-pkg-version-Bb69ihTN.js → check-pkg-version-CAnDiqiu.js} +9 -3
- package/dist/esm/{checkout.service-XgGFa7H8.js → checkout.service-Bbgi1I6V.js} +2 -2
- package/dist/esm/checkout.store-CCdFOPCK.js +83 -0
- package/dist/esm/checkouts-list-core.entry.js +11 -11
- package/dist/esm/{checkouts-list-params-state-SMXQIZTt.js → checkouts-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{checkouts-table-CFZYoYjn.js → checkouts-table-Ddf2I-Ul.js} +4 -4
- package/dist/esm/{config-state-BrllxiM0.js → config-state-DZeVYerv.js} +1 -1
- package/dist/esm/custom-popper_2.entry.js +2 -2
- package/dist/esm/{dispute.service-CKPcmwhH.js → dispute.service-CrZsNDW8.js} +2 -2
- package/dist/esm/form-alert_5.entry.js +2 -2
- package/dist/esm/form-control-checkbox.entry.js +4 -4
- package/dist/esm/form-control-date.entry.js +3 -3
- package/dist/esm/{form-control-error-text-D3ZwkOv-.js → form-control-error-text-R7U07nTg.js} +2 -2
- package/dist/esm/form-control-file-v2_2.entry.js +3 -3
- package/dist/esm/{form-control-help-text-C39ZW65w.js → form-control-help-text-CRLH-2f7.js} +2 -2
- package/dist/esm/form-control-help-text.entry.js +1 -1
- package/dist/esm/form-control-monetary-provisioning.entry.js +4 -4
- package/dist/esm/form-control-monetary.entry.js +5 -5
- package/dist/esm/form-control-number-masked_2.entry.js +3 -3
- package/dist/esm/form-control-number.entry.js +4 -4
- package/dist/esm/form-control-radio.entry.js +4 -4
- package/dist/esm/form-control-select_2.entry.js +3 -3
- package/dist/esm/{get-payment-details-Dt-dr16k.js → get-payment-details-0VzpMNY9.js} +2 -2
- package/dist/esm/{get-subaccounts-BsoVLANw.js → get-subaccounts-9UMbyFiT.js} +3 -3
- package/dist/esm/gross-payment-chart-core.entry.js +5 -5
- package/dist/esm/{header-1-E-hEi3wF.js → header-1-3M9If0gM.js} +2 -2
- package/dist/esm/{header-3-Dm7M85kz.js → header-3-CWa41YWq.js} +2 -2
- package/dist/esm/hidden-input_2.entry.js +5 -5
- package/dist/esm/{index-B9me4yN2.js → index-B_KxSZIF.js} +1 -1
- package/dist/esm/{index-kpoIU4v_.js → index-Bn7inNWG.js} +2 -2
- package/dist/esm/index-CbL73B6U.js +30 -0
- package/dist/esm/index.js +1 -1
- package/dist/esm/{insurance-state-CB4l8sOv.js → insurance-state-CTalqbNa.js} +3 -3
- package/dist/esm/justifi-additional-questions-form-step-core_6.entry.js +8 -8
- package/dist/esm/justifi-additional-questions-form-step_9.entry.js +9 -9
- package/dist/esm/justifi-additional-statement_8.entry.js +2 -2
- package/dist/esm/justifi-apple-pay.entry.js +780 -0
- package/dist/esm/justifi-bank-account-billing-form-simple_9.entry.js +17 -16
- package/dist/esm/justifi-business-details.entry.js +11 -11
- package/dist/esm/justifi-business-form.entry.js +14 -14
- package/dist/esm/justifi-business-representative-form-inputs.entry.js +2 -2
- package/dist/esm/justifi-checkout-summary_7.entry.js +1413 -0
- package/dist/esm/justifi-checkout.entry.js +26 -48
- package/dist/esm/justifi-checkouts-list-filters.entry.js +8 -8
- package/dist/esm/justifi-checkouts-list.entry.js +14 -14
- package/dist/esm/justifi-config-provider.entry.js +3 -3
- package/dist/esm/justifi-details.entry.js +3 -3
- package/dist/esm/justifi-dispute-management-core.entry.js +1 -1
- package/dist/esm/justifi-dispute-management.entry.js +9 -9
- package/dist/esm/justifi-dispute-notification_3.entry.js +13 -13
- package/dist/esm/justifi-gross-payment-chart.entry.js +10 -10
- package/dist/esm/justifi-order-terminals.entry.js +13 -13
- package/dist/esm/justifi-owner-form_3.entry.js +9 -9
- package/dist/esm/justifi-payment-details.entry.js +12 -12
- package/dist/esm/justifi-payment-provisioning-core.entry.js +4 -4
- package/dist/esm/justifi-payment-provisioning.entry.js +9 -9
- package/dist/esm/justifi-payment-transactions-list.entry.js +13 -13
- package/dist/esm/justifi-payments-list-filters.entry.js +6 -6
- package/dist/esm/justifi-payments-list.entry.js +14 -14
- package/dist/esm/justifi-payout-details.entry.js +11 -11
- package/dist/esm/justifi-payout-transactions-list.entry.js +13 -13
- package/dist/esm/justifi-payouts-list-filters.entry.js +6 -6
- package/dist/esm/justifi-payouts-list.entry.js +15 -15
- package/dist/esm/justifi-refund-payment.entry.js +14 -14
- package/dist/esm/justifi-saved-payment-method.entry.js +2 -2
- package/dist/esm/justifi-season-interruption-insurance.entry.js +18 -13
- package/dist/esm/justifi-skeleton.entry.js +4 -4
- package/dist/esm/justifi-terminal-orders-list-filters.entry.js +8 -8
- package/dist/esm/justifi-terminal-orders-list.entry.js +12 -12
- package/dist/esm/justifi-terminals-list-filters.entry.js +8 -8
- package/dist/esm/justifi-terminals-list.entry.js +14 -14
- package/dist/esm/loader.js +3 -3
- package/dist/esm/{package-O3LY2Da6.js → package-CnWtPu8L.js} +1 -1
- package/dist/esm/pagination-menu.entry.js +2 -2
- package/dist/esm/{parts-CfF8KKwx.js → parts-RvUQ__Pq.js} +1 -1
- package/dist/esm/payment-details-core.entry.js +8 -8
- package/dist/esm/payment-method-option.entry.js +3 -3
- package/dist/esm/{payment.service-BWO84KlP.js → payment.service-TxyxCg0E.js} +2 -2
- package/dist/esm/payments-list-core.entry.js +12 -12
- package/dist/esm/{payments-list-params-state-SMXQIZTt.js → payments-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{payments-status-XoZrlbiZ.js → payments-status-5orNU2Rd.js} +2 -2
- package/dist/esm/{payments-table-Dh4P9mTb.js → payments-table-gkJV5GNK.js} +4 -4
- package/dist/esm/payout-details-core.entry.js +9 -9
- package/dist/esm/{payout.service-Cld6TS5W.js → payout.service-BOwZ4wWh.js} +2 -2
- package/dist/esm/payouts-list-core.entry.js +12 -12
- package/dist/esm/{payouts-list-params-state-SMXQIZTt.js → payouts-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{payouts-status-Qm2jZG1-.js → payouts-status-CZPwa2AE.js} +2 -2
- package/dist/esm/{payouts-table-DMVAZp-r.js → payouts-table-0PtktGRd.js} +4 -4
- package/dist/esm/{skeleton-DrHwsgs_.js → skeleton-qMb0_Cjy.js} +2 -2
- package/dist/esm/{spinner-XBq6mVJW.js → spinner-DUzyWLhj.js} +2 -2
- package/dist/esm/{styled-host-B_XBaM7z.js → styled-host-CTAGIN84.js} +1 -1
- package/dist/esm/{table-qqt2Ew5y.js → table-Br3n9Xu-.js} +3 -3
- package/dist/esm/table-filters-menu.entry.js +3 -3
- package/dist/esm/terminal-orders-list-core.entry.js +11 -11
- package/dist/esm/{terminal-orders-list-params-state-SMXQIZTt.js → terminal-orders-list-params-state-D8tzsGR_.js} +1 -1
- package/dist/esm/{terminal-orders-table-BN4Co4T8.js → terminal-orders-table-DTBSIMlJ.js} +6 -6
- package/dist/esm/terminal-quantity-selector.entry.js +2 -2
- package/dist/esm/{terminal.service-DmYCUQcA.js → terminal.service-E6dZlM43.js} +2 -2
- package/dist/esm/terminals-list-core.entry.js +11 -11
- package/dist/esm/terminals-list-params-state-D8tzsGR_.js +16 -0
- package/dist/esm/{terminals-table-C8LczeG_.js → terminals-table-TGUKTi7I.js} +4 -4
- package/dist/esm/{utils-lb8p1Exq.js → utils-BscIVFn8.js} +6 -1
- package/dist/esm/{utils-kWaZhFAd.js → utils-Dg6gMUTv.js} +2 -2
- package/dist/esm/webcomponents.js +4 -4
- package/dist/module/Analytics.js +6 -0
- package/dist/module/ModularCheckout.js +30 -0
- package/dist/module/Refund.js +5 -2
- package/dist/module/bank-account-form.js +5 -2
- package/dist/module/card-form.js +5 -2
- package/dist/module/checkout.store.js +47 -2
- package/dist/module/form-control-radio2.js +3 -3
- package/dist/module/gross-payment-chart-core2.js +1 -1
- package/dist/module/index.js +1 -0
- package/dist/module/justifi-apple-pay.d.ts +11 -0
- package/dist/module/justifi-apple-pay.js +811 -0
- package/dist/module/justifi-checkout.js +63 -75
- package/dist/module/justifi-order-terminals.js +1 -1
- package/dist/module/justifi-plaid-payment-method.d.ts +11 -0
- package/dist/module/justifi-plaid-payment-method.js +6 -0
- package/dist/module/justifi-radio-list-item2.js +2 -2
- package/dist/module/justifi-season-interruption-insurance.js +5 -1
- package/dist/module/modular-checkout.js +179 -101
- package/dist/module/package.js +1 -1
- package/dist/module/plaid-payment-method.js +687 -0
- package/dist/module/save-new-payment-method.js +1 -1
- package/dist/module/saved-payment-methods.js +7 -5
- package/dist/module/sezzle-payment-method.js +14 -22
- package/dist/module/terminals-list-core2.js +1 -1
- package/dist/module/tokenize-payment-method.js +44 -34
- package/dist/module/utils2.js +6 -1
- package/dist/types/api/ApplePay.d.ts +196 -0
- package/dist/types/api/Checkout.d.ts +9 -14
- package/dist/types/api/Payment.d.ts +4 -3
- package/dist/types/api/services/apple-pay.service.d.ts +55 -0
- package/dist/types/api/services/plaid.service.d.ts +12 -0
- package/dist/types/components/checkout/bank-account-form/bank-account-form.d.ts +1 -0
- package/dist/types/components/checkout/card-form/card-form.d.ts +1 -0
- package/dist/types/components/checkout/checkout.d.ts +6 -7
- package/dist/types/components/modular-checkout/ModularCheckout.d.ts +31 -0
- package/dist/types/components/modular-checkout/modular-checkout.d.ts +13 -4
- package/dist/types/components/modular-checkout/sub-components/apple-pay-skeleton.d.ts +6 -0
- package/dist/types/components/modular-checkout/sub-components/apple-pay.d.ts +39 -0
- package/dist/types/components/modular-checkout/sub-components/plaid-payment-method.d.ts +80 -0
- package/dist/types/components/modular-checkout/sub-components/plaid-payment-method.test.d.ts +1 -0
- package/dist/types/components/modular-checkout/sub-components/saved-payment-methods.d.ts +1 -1
- package/dist/types/components/modular-checkout/sub-components/sezzle-payment-method.d.ts +1 -1
- package/dist/types/components/tokenize-payment-method/tokenize-payment-method.d.ts +7 -6
- package/dist/types/components.d.ts +172 -11
- package/dist/types/index.d.ts +2 -0
- package/dist/types/store/checkout.store.d.ts +14 -3
- package/dist/types/ui-components/apple-pay-button.d.ts +17 -0
- package/dist/types/ui-components/form/form-control-radio.d.ts +1 -1
- package/dist/types/ui-components/shadow-dom-components/justifi-radio-list-item.d.ts +1 -1
- package/dist/types/utils/utils.d.ts +1 -0
- package/dist/webcomponents/index.esm.js +1 -0
- package/dist/webcomponents/p-0803d130.entry.js +1 -0
- package/dist/webcomponents/{p-Dvxpy_P1.js → p-0Om7jLBs.js} +1 -1
- package/dist/webcomponents/{p-0932f6a9.entry.js → p-117b7f47.entry.js} +1 -1
- package/dist/webcomponents/p-17093105.entry.js +1 -0
- package/dist/webcomponents/{p-f01953ea.entry.js → p-1a08b47f.entry.js} +1 -1
- package/dist/webcomponents/p-1bcb3852.entry.js +1 -0
- package/dist/webcomponents/{p-ae4297dd.entry.js → p-1eb2b847.entry.js} +1 -1
- package/dist/webcomponents/{p-dd257e60.entry.js → p-2f7aa249.entry.js} +1 -1
- package/dist/webcomponents/{p-28c7bef7.entry.js → p-2fa34c82.entry.js} +4 -4
- package/dist/webcomponents/{p-08ea8974.entry.js → p-33311d41.entry.js} +1 -1
- package/dist/webcomponents/p-336c31b3.entry.js +1 -0
- package/dist/webcomponents/{p-22be0859.entry.js → p-3f33c940.entry.js} +1 -1
- package/dist/webcomponents/{p-f3a757b2.entry.js → p-442f86e8.entry.js} +1 -1
- package/dist/webcomponents/{p-a8205044.entry.js → p-44450a94.entry.js} +1 -1
- package/dist/webcomponents/{p-cebe360b.entry.js → p-464e7a8e.entry.js} +1 -1
- package/dist/webcomponents/{p-ba8ae31f.entry.js → p-50392803.entry.js} +1 -1
- package/dist/webcomponents/p-52cbd667.entry.js +1 -0
- package/dist/webcomponents/{p-ded22005.entry.js → p-54ca3070.entry.js} +1 -1
- package/dist/webcomponents/{p-77515be6.entry.js → p-5ad0f438.entry.js} +1 -1
- package/dist/webcomponents/{p-6e18d13f.entry.js → p-613421d4.entry.js} +1 -1
- package/dist/webcomponents/{p-9b75aced.entry.js → p-62d12566.entry.js} +1 -1
- package/dist/webcomponents/p-65ed60bf.entry.js +1 -0
- package/dist/webcomponents/p-6cf30a24.entry.js +1 -0
- package/dist/webcomponents/{p-48bccf3b.entry.js → p-70f51444.entry.js} +1 -1
- package/dist/webcomponents/{p-a4172773.entry.js → p-729dbd8f.entry.js} +1 -1
- package/dist/webcomponents/p-77948b46.entry.js +1 -0
- package/dist/webcomponents/{p-1d53f0b8.entry.js → p-7bcfaff4.entry.js} +1 -1
- package/dist/webcomponents/{p-b0bfa20f.entry.js → p-7cf87637.entry.js} +1 -1
- package/dist/webcomponents/{p-dfd7c212.entry.js → p-7dd74e6f.entry.js} +1 -1
- package/dist/webcomponents/{p-I8XpD1TX.js → p-7s1gsXM5.js} +1 -1
- package/dist/webcomponents/{p-3d85d046.entry.js → p-80331983.entry.js} +1 -1
- package/dist/webcomponents/{p-d0e24727.entry.js → p-85f20746.entry.js} +1 -1
- package/dist/webcomponents/{p-79055216.entry.js → p-8687e5d6.entry.js} +1 -1
- package/dist/webcomponents/p-89ecd650.entry.js +1 -0
- package/dist/webcomponents/p-8a6718b6.entry.js +1 -0
- package/dist/webcomponents/p-8d6b81ba.entry.js +1 -0
- package/dist/webcomponents/{p-a7d5e434.entry.js → p-8d743490.entry.js} +1 -1
- package/dist/webcomponents/{p-8f0339de.entry.js → p-8f7396b1.entry.js} +1 -1
- package/dist/webcomponents/{p-15777cfe.entry.js → p-8ff839a4.entry.js} +1 -1
- package/dist/webcomponents/{p-57143978.entry.js → p-95cbb655.entry.js} +1 -1
- package/dist/webcomponents/{p-ae5a3c2a.entry.js → p-98cffba9.entry.js} +1 -1
- package/dist/webcomponents/{p-4ba144ac.entry.js → p-9a2c044f.entry.js} +1 -1
- package/dist/webcomponents/{p-904a95e5.entry.js → p-9be67b19.entry.js} +1 -1
- package/dist/webcomponents/{p-df199396.entry.js → p-9e8021a1.entry.js} +1 -1
- package/dist/webcomponents/{p-131d799c.entry.js → p-9fc0ea58.entry.js} +1 -1
- package/dist/webcomponents/p-9fc567d8.entry.js +1 -0
- package/dist/webcomponents/{p-424f491c.entry.js → p-9fcff84c.entry.js} +1 -1
- package/dist/webcomponents/p-B71k50jz.js +1 -0
- package/dist/webcomponents/p-BF4U0yVj.js +1 -0
- package/dist/webcomponents/{p-zdIeCUeh.js → p-BHf9IqGw.js} +1 -1
- package/dist/webcomponents/p-BQ2TIFoY.js +1 -0
- package/dist/webcomponents/p-BSt6p1oq.js +1 -0
- package/dist/webcomponents/p-BY1mRAvj.js +1 -0
- package/dist/webcomponents/{p-YND5pTuF.js → p-Bb-6bNcq.js} +1 -1
- package/dist/webcomponents/p-BbZwa5UI.js +1 -0
- package/dist/webcomponents/p-BdKWuCys.js +1 -0
- package/dist/webcomponents/p-BfM6X7lF.js +1 -0
- package/dist/webcomponents/{p-BbYVgLcf.js → p-BjVfIXWC.js} +1 -1
- package/dist/webcomponents/{p-kpoIU4v_.js → p-Bn7inNWG.js} +1 -1
- package/dist/webcomponents/{p-BisQ61nK.js → p-BsGE9UDv.js} +1 -1
- package/dist/webcomponents/{p-BeszVz87.js → p-C5id7s_l.js} +1 -1
- package/dist/webcomponents/{p-CsNubTqD.js → p-CAJnQLZF.js} +1 -1
- package/dist/webcomponents/{p-Bz164TKZ.js → p-CB0mCq1M.js} +1 -1
- package/dist/webcomponents/p-CaAVuW6B.js +1 -0
- package/dist/webcomponents/p-Cb0FhuyU.js +1 -0
- package/dist/webcomponents/p-CbL73B6U.js +1 -0
- package/dist/webcomponents/p-CnWtPu8L.js +1 -0
- package/dist/webcomponents/p-CpaS1Lex.js +1 -0
- package/dist/webcomponents/p-DD0Mvpeu.js +1 -0
- package/dist/webcomponents/p-DDUmOl3v.js +1 -0
- package/dist/webcomponents/p-DIDloHpm.js +1 -0
- package/dist/webcomponents/p-DIjoBk44.js +1 -0
- package/dist/webcomponents/{p-UD2JhYS2.js → p-DK2sRMlx.js} +1 -1
- package/dist/webcomponents/{p-DO3INvI2.js → p-DNo0OPOP.js} +1 -1
- package/dist/webcomponents/{p-BTkXk7ol.js → p-DRXvcLy9.js} +1 -1
- package/dist/webcomponents/{p-BNz6wy4f.js → p-DZYcH7jA.js} +1 -1
- package/dist/webcomponents/p-Da3idOSV.js +1 -0
- package/dist/webcomponents/p-Dgflaz6J.js +1 -0
- package/dist/webcomponents/{p-9y5MOK55.js → p-DhGNCW2f.js} +1 -1
- package/dist/webcomponents/p-DsZZxRXY.js +1 -0
- package/dist/webcomponents/{p-CRFzwZW6.js → p-DxqCFDtF.js} +1 -1
- package/dist/webcomponents/p-ED_TzwCp.js +1 -0
- package/dist/webcomponents/p-JyHlIFWl.js +1 -0
- package/dist/webcomponents/{p-CfF8KKwx.js → p-RvUQ__Pq.js} +1 -1
- package/dist/webcomponents/{p-DWUnL_zj.js → p-Wh1V0gvF.js} +1 -1
- package/dist/webcomponents/{p-c3a2c619.entry.js → p-a55f07af.entry.js} +1 -1
- package/dist/webcomponents/{p-40ba49e4.entry.js → p-aa6194ef.entry.js} +1 -1
- package/dist/webcomponents/{p-d77908ca.entry.js → p-ab6a5dc9.entry.js} +1 -1
- package/dist/webcomponents/{p-463ae23a.entry.js → p-abbf14b5.entry.js} +1 -1
- package/dist/webcomponents/{p-283cd78b.entry.js → p-af9c4174.entry.js} +1 -1
- package/dist/webcomponents/{p-f47095cd.entry.js → p-b7d2f2eb.entry.js} +1 -1
- package/dist/webcomponents/p-bbc4b4cb.entry.js +1 -0
- package/dist/webcomponents/{p-36d72e2d.entry.js → p-c599e526.entry.js} +1 -1
- package/dist/webcomponents/{p-5e10aa65.entry.js → p-d46dbb83.entry.js} +1 -1
- package/dist/webcomponents/{p-6849bf8e.entry.js → p-d62cd269.entry.js} +1 -1
- package/dist/webcomponents/{p-ff3377e7.entry.js → p-d9dd7d24.entry.js} +1 -1
- package/dist/webcomponents/p-dd7352da.entry.js +1 -0
- package/dist/webcomponents/{p-7c51805a.entry.js → p-e8a67dc7.entry.js} +1 -1
- package/dist/webcomponents/p-eP3fmhta.js +1 -0
- package/dist/webcomponents/p-eb2d9e5b.entry.js +1 -0
- package/dist/webcomponents/{p-1f8cd44e.entry.js → p-eddaca4e.entry.js} +1 -1
- package/dist/webcomponents/{p-9106fd74.entry.js → p-ef32fe0e.entry.js} +1 -1
- package/dist/webcomponents/{p-c5b48e8d.entry.js → p-f1cba43c.entry.js} +1 -1
- package/dist/webcomponents/{p-e830a580.entry.js → p-f1f0b405.entry.js} +1 -1
- package/dist/webcomponents/p-f499a8de.entry.js +1 -0
- package/dist/webcomponents/{p-828a61b9.entry.js → p-f4d0cdf0.entry.js} +1 -1
- package/dist/webcomponents/{p-818f51fd.entry.js → p-f680e617.entry.js} +1 -1
- package/dist/webcomponents/{p-bea4309d.entry.js → p-f7c4222f.entry.js} +1 -1
- package/dist/webcomponents/p-fa1884b4.entry.js +1 -0
- package/dist/webcomponents/p-sw5RO19U.js +1 -0
- package/dist/webcomponents/p-z-5r0gWn.js +1 -0
- package/dist/webcomponents/webcomponents.esm.js +1 -1
- package/package.json +2 -2
- package/dist/cjs/checkout.store-CV_fuGQw.js +0 -39
- package/dist/cjs/justifi-checkout-summary_6.cjs.entry.js +0 -698
- package/dist/cjs/terminals-list-params-state-BNbT1fuJ.js +0 -22
- package/dist/esm/checkout.store-B60siz2l.js +0 -36
- package/dist/esm/justifi-checkout-summary_6.entry.js +0 -691
- package/dist/esm/terminals-list-params-state-SMXQIZTt.js +0 -16
- package/dist/webcomponents/p-09e768fe.entry.js +0 -1
- package/dist/webcomponents/p-0dcc83ac.entry.js +0 -1
- package/dist/webcomponents/p-1bdce018.entry.js +0 -1
- package/dist/webcomponents/p-2f31a4e5.entry.js +0 -1
- package/dist/webcomponents/p-3a4ca4df.entry.js +0 -1
- package/dist/webcomponents/p-466f33d7.entry.js +0 -1
- package/dist/webcomponents/p-57802e57.entry.js +0 -1
- package/dist/webcomponents/p-5rVtZ2GJ.js +0 -1
- package/dist/webcomponents/p-7322c86e.entry.js +0 -1
- package/dist/webcomponents/p-7WIgS5RM.js +0 -1
- package/dist/webcomponents/p-89e27079.entry.js +0 -1
- package/dist/webcomponents/p-BC8YDY7M.js +0 -1
- package/dist/webcomponents/p-BVD7g3cE.js +0 -1
- package/dist/webcomponents/p-Bb6FBEPP.js +0 -1
- package/dist/webcomponents/p-Bpcb3SsP.js +0 -1
- package/dist/webcomponents/p-Bt388eye.js +0 -1
- package/dist/webcomponents/p-BySyDTv5.js +0 -1
- package/dist/webcomponents/p-C1fMfnu0.js +0 -1
- package/dist/webcomponents/p-CCME-fyU.js +0 -1
- package/dist/webcomponents/p-CLwzqWk2.js +0 -1
- package/dist/webcomponents/p-CVQyw7ao.js +0 -1
- package/dist/webcomponents/p-C_CXv7AN.js +0 -1
- package/dist/webcomponents/p-CwZKT93w.js +0 -1
- package/dist/webcomponents/p-D599ZMGU.js +0 -1
- package/dist/webcomponents/p-DD74a16D.js +0 -1
- package/dist/webcomponents/p-DaDsBt65.js +0 -1
- package/dist/webcomponents/p-JgbsbAhz.js +0 -1
- package/dist/webcomponents/p-O3LY2Da6.js +0 -1
- package/dist/webcomponents/p-WEguiGt1.js +0 -1
- package/dist/webcomponents/p-be06d86a.entry.js +0 -1
- package/dist/webcomponents/p-dd689b5e.entry.js +0 -1
- package/dist/webcomponents/p-dd6d6ddb.entry.js +0 -1
- package/dist/webcomponents/p-e859ece8.entry.js +0 -1
- package/dist/webcomponents/p-eaea7cc1.entry.js +0 -1
- package/dist/webcomponents/p-fa33df9f.entry.js +0 -1
- package/dist/webcomponents/p-ff869ded.entry.js +0 -1
- package/dist/webcomponents/p-pska2q1M.js +0 -1
- package/dist/webcomponents/p-qMrd7_Gp.js +0 -1
- package/dist/webcomponents/p-vRhNRfmB.js +0 -1
- package/dist/webcomponents/p-zrUQD0Wr.js +0 -1
|
@@ -0,0 +1,1413 @@
|
|
|
1
|
+
import { r as registerInstance, h, c as createEvent, H as Host, g as getElement } from './index-Bn7inNWG.js';
|
|
2
|
+
import { z as text, r as radioListItem } from './parts-RvUQ__Pq.js';
|
|
3
|
+
import { f as formatCurrency } from './utils-BscIVFn8.js';
|
|
4
|
+
import { c as checkoutStore, a as onAnyChange, g as getAvailablePaymentMethodTypes, o as onChange } from './checkout.store-CCdFOPCK.js';
|
|
5
|
+
import { S as StyledHost } from './styled-host-CTAGIN84.js';
|
|
6
|
+
import './event-types-CZfYo5-1.js';
|
|
7
|
+
import { H as Header1 } from './header-1-3M9If0gM.js';
|
|
8
|
+
import { H as Header2, b as insuranceValuesOn, h as hasInsuranceValueChanged, i as insuranceValues } from './insurance-state-CTalqbNa.js';
|
|
9
|
+
import { H as Header3 } from './header-3-CWa41YWq.js';
|
|
10
|
+
import { J as JustifiAnalytics, c as checkPkgVersion } from './check-pkg-version-CAnDiqiu.js';
|
|
11
|
+
import './config-state-DZeVYerv.js';
|
|
12
|
+
import './dinero-HXpYMWUU.js';
|
|
13
|
+
import { C as ComponentErrorSeverity, a as ComponentErrorCodes, b as ComponentErrorMessages } from './ComponentError-Cjcsf8ku.js';
|
|
14
|
+
import { P as PaymentMethodTypes, I as ICheckoutStatus } from './Refund-CVh70dXA.js';
|
|
15
|
+
import './Pagination-CLHwhyvu.js';
|
|
16
|
+
import './Business-BCoP0TAV.js';
|
|
17
|
+
import './Dispute-BH0Xfn-F.js';
|
|
18
|
+
import { g as getErrorCode, a as getErrorMessage } from './utils-BeQLScSm.js';
|
|
19
|
+
import { C as CheckoutService } from './checkout.service-Bbgi1I6V.js';
|
|
20
|
+
import { a as PAYMENT_MODE, b as PAYMENT_METHOD_TYPES, P as PAYMENT_METHODS } from './index-CbL73B6U.js';
|
|
21
|
+
import { A as Api } from './Api-DAWuvzbl.js';
|
|
22
|
+
import { C as CardBrandLabels } from './payment-method-option-utils-lUHAQVFl.js';
|
|
23
|
+
import './index-B_KxSZIF.js';
|
|
24
|
+
import './package-CnWtPu8L.js';
|
|
25
|
+
import './helpers-Mu7LQT-w.js';
|
|
26
|
+
import './state-options-BX8GieXu.js';
|
|
27
|
+
|
|
28
|
+
const Summary = class {
|
|
29
|
+
constructor(hostRef) {
|
|
30
|
+
registerInstance(this, hostRef);
|
|
31
|
+
}
|
|
32
|
+
render() {
|
|
33
|
+
return (h(StyledHost, { key: 'fccb819d66329424af42e9c53effec29a6c9784d' }, h("section", { key: '0ee7a4e0579f7f222a9db82e6b4db6bb92542d9e' }, h("div", { key: 'bdf74b2bc5db35b96ca75d50783b790bb482a76e' }, h("div", { key: '851b481bd6beb1fcaadc106d27d131f8b07d1c9a', part: text }, checkoutStore === null || checkoutStore === void 0 ? void 0 : checkoutStore.paymentDescription), h("div", { key: '0b261bc0e2d65cf989778e02df51b3265816f7aa' }, h("span", { key: '0eee0017ddf25ae45d6b5c828071098f45e6e19d', part: text }, "Total"), "\u00A0", h("span", { key: 'd21576f14c3437f70a4b85b9dfc01107392d663a', part: text }, formatCurrency(+(checkoutStore === null || checkoutStore === void 0 ? void 0 : checkoutStore.totalAmount))))))));
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
|
|
37
|
+
const Header = class {
|
|
38
|
+
constructor(hostRef) {
|
|
39
|
+
registerInstance(this, hostRef);
|
|
40
|
+
this.levels = {
|
|
41
|
+
h1: Header1,
|
|
42
|
+
h2: Header2,
|
|
43
|
+
h3: Header3,
|
|
44
|
+
};
|
|
45
|
+
this.level = 'h1';
|
|
46
|
+
}
|
|
47
|
+
render() {
|
|
48
|
+
const HeaderComponent = this.levels[this.level];
|
|
49
|
+
return (h(StyledHost, { key: 'ae04a67a1eaf95d6d093fef23911ac4eb1523cfe' }, h(HeaderComponent, { key: '51b27dd180d113ebe9ac52f7ff10c494926f7cdf', text: this.text, class: this.class })));
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const makeGetCheckout = ({ authToken, checkoutId, service }) => async ({ onSuccess, onError }) => {
|
|
54
|
+
var _a;
|
|
55
|
+
try {
|
|
56
|
+
const response = await service.fetchCheckout(authToken, checkoutId);
|
|
57
|
+
if (!response.error) {
|
|
58
|
+
const checkout = response.data;
|
|
59
|
+
onSuccess({ checkout });
|
|
60
|
+
}
|
|
61
|
+
else {
|
|
62
|
+
const responseError = getErrorMessage(response.error);
|
|
63
|
+
const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
|
|
64
|
+
return onError({
|
|
65
|
+
error: responseError,
|
|
66
|
+
code,
|
|
67
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
catch (error) {
|
|
72
|
+
const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
|
|
73
|
+
return onError({
|
|
74
|
+
error: error.message || error,
|
|
75
|
+
code,
|
|
76
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
const makeCheckoutComplete = ({ authToken, checkoutId, service }) => async ({ payment, onSuccess, onError }) => {
|
|
81
|
+
var _a;
|
|
82
|
+
try {
|
|
83
|
+
const response = await service.complete(authToken, checkoutId, payment);
|
|
84
|
+
if (!response.error) {
|
|
85
|
+
const checkout = response.data;
|
|
86
|
+
onSuccess({ checkout });
|
|
87
|
+
}
|
|
88
|
+
else {
|
|
89
|
+
const responseError = getErrorMessage(response.error);
|
|
90
|
+
const code = getErrorCode((_a = response.error) === null || _a === void 0 ? void 0 : _a.code);
|
|
91
|
+
return onError({
|
|
92
|
+
error: responseError,
|
|
93
|
+
code,
|
|
94
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
95
|
+
});
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
catch (error) {
|
|
99
|
+
const code = getErrorCode(error === null || error === void 0 ? void 0 : error.code);
|
|
100
|
+
return onError({
|
|
101
|
+
error: error.message || error,
|
|
102
|
+
code,
|
|
103
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const ModularCheckout = class {
|
|
109
|
+
constructor(hostRef) {
|
|
110
|
+
registerInstance(this, hostRef);
|
|
111
|
+
this.errorEvent = createEvent(this, "error-event");
|
|
112
|
+
this.submitEvent = createEvent(this, "submit-event");
|
|
113
|
+
this.checkoutChangedEvent = createEvent(this, "checkout-changed");
|
|
114
|
+
this.savePaymentMethod = false;
|
|
115
|
+
this.handleApplePayCompleted = (event) => {
|
|
116
|
+
const { success, token, paymentMethodId, error } = event.detail;
|
|
117
|
+
if (success && token) {
|
|
118
|
+
checkoutStore.paymentToken = paymentMethodId;
|
|
119
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.applePay };
|
|
120
|
+
this.submitCheckout();
|
|
121
|
+
}
|
|
122
|
+
else {
|
|
123
|
+
console.error("Apple Pay completed but failed:", error);
|
|
124
|
+
this.errorEvent.emit({
|
|
125
|
+
message: (error === null || error === void 0 ? void 0 : error.message) || "Apple Pay payment failed",
|
|
126
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
127
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
};
|
|
131
|
+
this.handleApplePayError = (event) => {
|
|
132
|
+
const { error } = event.detail;
|
|
133
|
+
console.error("Apple Pay error:", error);
|
|
134
|
+
this.errorEvent.emit({
|
|
135
|
+
message: error || "Apple Pay error occurred",
|
|
136
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
137
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
138
|
+
});
|
|
139
|
+
};
|
|
140
|
+
this.handleApplePayCancelled = () => {
|
|
141
|
+
checkoutStore.paymentToken = undefined;
|
|
142
|
+
checkoutStore.selectedPaymentMethod = undefined;
|
|
143
|
+
};
|
|
144
|
+
}
|
|
145
|
+
savePaymentMethodChanged(newValue) {
|
|
146
|
+
checkoutStore.savePaymentMethod = newValue;
|
|
147
|
+
}
|
|
148
|
+
connectedCallback() {
|
|
149
|
+
this.observer = new MutationObserver(() => {
|
|
150
|
+
this.queryFormRefs();
|
|
151
|
+
this.setupApplePayListeners(); // set up again listeners when DOM changes
|
|
152
|
+
});
|
|
153
|
+
this.observer.observe(this.hostEl, {
|
|
154
|
+
childList: true,
|
|
155
|
+
subtree: true,
|
|
156
|
+
});
|
|
157
|
+
checkoutStore.checkoutId = this.checkoutId;
|
|
158
|
+
const config = {
|
|
159
|
+
authToken: this.authToken,
|
|
160
|
+
checkoutId: this.checkoutId,
|
|
161
|
+
service: new CheckoutService(),
|
|
162
|
+
};
|
|
163
|
+
this.getCheckout = makeGetCheckout(config);
|
|
164
|
+
this.completeCheckout = makeCheckoutComplete(config);
|
|
165
|
+
// Emit checkout-changed whenever any store key changes
|
|
166
|
+
onAnyChange(() => {
|
|
167
|
+
this.emitCheckoutChanged();
|
|
168
|
+
});
|
|
169
|
+
}
|
|
170
|
+
componentWillLoad() {
|
|
171
|
+
this.analytics = new JustifiAnalytics(this);
|
|
172
|
+
checkPkgVersion();
|
|
173
|
+
checkoutStore.authToken = this.authToken;
|
|
174
|
+
checkoutStore.savePaymentMethod = this.savePaymentMethod;
|
|
175
|
+
this.fetchCheckout();
|
|
176
|
+
// Refresh the checkout data when insurance values actually change (not on initial load)
|
|
177
|
+
insuranceValuesOn("set", (key) => {
|
|
178
|
+
const value = insuranceValues[key];
|
|
179
|
+
if (value !== undefined && hasInsuranceValueChanged(key, value)) {
|
|
180
|
+
this.fetchCheckout();
|
|
181
|
+
}
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
componentDidLoad() {
|
|
185
|
+
this.queryFormRefs();
|
|
186
|
+
this.setupApplePayListeners();
|
|
187
|
+
}
|
|
188
|
+
disconnectedCallback() {
|
|
189
|
+
var _a;
|
|
190
|
+
(_a = this.observer) === null || _a === void 0 ? void 0 : _a.disconnect();
|
|
191
|
+
this.removeApplePayListeners();
|
|
192
|
+
}
|
|
193
|
+
fetchCheckout() {
|
|
194
|
+
if (!this.authToken || !this.checkoutId) {
|
|
195
|
+
this.errorEvent.emit({
|
|
196
|
+
message: ComponentErrorMessages.NOT_AUTHENTICATED,
|
|
197
|
+
errorCode: ComponentErrorCodes.NOT_AUTHENTICATED,
|
|
198
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
199
|
+
});
|
|
200
|
+
return;
|
|
201
|
+
}
|
|
202
|
+
if (this.getCheckout) {
|
|
203
|
+
this.getCheckout({
|
|
204
|
+
onSuccess: ({ checkout }) => {
|
|
205
|
+
this.updateStore(checkout);
|
|
206
|
+
if (checkout.status === ICheckoutStatus.completed) {
|
|
207
|
+
this.errorEvent.emit({
|
|
208
|
+
message: ComponentErrorMessages.CHECKOUT_ALREADY_COMPLETED,
|
|
209
|
+
errorCode: ComponentErrorCodes.CHECKOUT_ALREADY_COMPLETED,
|
|
210
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
211
|
+
});
|
|
212
|
+
return;
|
|
213
|
+
}
|
|
214
|
+
else if (checkout.status === ICheckoutStatus.expired) {
|
|
215
|
+
this.errorEvent.emit({
|
|
216
|
+
message: ComponentErrorMessages.CHECKOUT_EXPIRED,
|
|
217
|
+
errorCode: ComponentErrorCodes.CHECKOUT_EXPIRED,
|
|
218
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
219
|
+
});
|
|
220
|
+
return;
|
|
221
|
+
}
|
|
222
|
+
},
|
|
223
|
+
onError: (error) => {
|
|
224
|
+
this.errorEvent.emit({
|
|
225
|
+
message: error.message,
|
|
226
|
+
errorCode: ComponentErrorCodes.FETCH_ERROR,
|
|
227
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
updateStore(checkout) {
|
|
234
|
+
var _a, _b, _c, _d, _e;
|
|
235
|
+
checkoutStore.accountId = checkout.account_id;
|
|
236
|
+
checkoutStore.paymentMethods = checkout.payment_methods;
|
|
237
|
+
checkoutStore.paymentMethodGroupId = checkout.payment_method_group_id;
|
|
238
|
+
checkoutStore.paymentDescription = checkout.payment_description;
|
|
239
|
+
checkoutStore.totalAmount = checkout.total_amount;
|
|
240
|
+
checkoutStore.paymentAmount = checkout.payment_amount;
|
|
241
|
+
checkoutStore.bnplEnabled = checkout.payment_settings.bnpl_payments;
|
|
242
|
+
checkoutStore.insuranceEnabled = checkout.payment_settings.insurance_payments;
|
|
243
|
+
checkoutStore.bankAccountVerification = (_a = checkout.payment_settings) === null || _a === void 0 ? void 0 : _a.bank_account_verification;
|
|
244
|
+
checkoutStore.bnplProviderClientId = (_b = checkout === null || checkout === void 0 ? void 0 : checkout.bnpl) === null || _b === void 0 ? void 0 : _b.provider_client_id;
|
|
245
|
+
checkoutStore.bnplProviderMode = (_c = checkout === null || checkout === void 0 ? void 0 : checkout.bnpl) === null || _c === void 0 ? void 0 : _c.provider_mode;
|
|
246
|
+
checkoutStore.bnplProviderApiVersion = (_d = checkout === null || checkout === void 0 ? void 0 : checkout.bnpl) === null || _d === void 0 ? void 0 : _d.provider_api_version;
|
|
247
|
+
checkoutStore.bnplProviderCheckoutUrl =
|
|
248
|
+
(_e = checkout === null || checkout === void 0 ? void 0 : checkout.bnpl) === null || _e === void 0 ? void 0 : _e.provider_checkout_url;
|
|
249
|
+
}
|
|
250
|
+
emitCheckoutChanged() {
|
|
251
|
+
const detail = {
|
|
252
|
+
availablePaymentMethodTypes: getAvailablePaymentMethodTypes(),
|
|
253
|
+
selectedPaymentMethod: checkoutStore.selectedPaymentMethod,
|
|
254
|
+
savedPaymentMethods: checkoutStore.paymentMethods,
|
|
255
|
+
};
|
|
256
|
+
this.checkoutChangedEvent.emit(detail);
|
|
257
|
+
}
|
|
258
|
+
queryFormRefs() {
|
|
259
|
+
this.billingFormRef = this.hostEl.querySelector("justifi-billing-form, justifi-bank-account-billing-form-simple, justifi-card-billing-form-simple, justifi-billing-form-full");
|
|
260
|
+
this.applePayRef = this.hostEl.querySelector("justifi-apple-pay");
|
|
261
|
+
this.paymentMethodFormRef =
|
|
262
|
+
this.hostEl.querySelector('justifi-card-form, justifi-bank-account-form, justifi-tokenize-payment-method');
|
|
263
|
+
this.insuranceFormRef = this.hostEl.querySelector('justifi-season-interruption-insurance');
|
|
264
|
+
}
|
|
265
|
+
setupApplePayListeners() {
|
|
266
|
+
if (this.applePayRef) {
|
|
267
|
+
this.applePayRef.addEventListener("applePayCompleted", this.handleApplePayCompleted);
|
|
268
|
+
this.applePayRef.addEventListener("applePayError", this.handleApplePayError);
|
|
269
|
+
this.applePayRef.addEventListener("applePayCancelled", this.handleApplePayCancelled);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
removeApplePayListeners() {
|
|
273
|
+
if (this.applePayRef) {
|
|
274
|
+
this.applePayRef.removeEventListener("applePayCompleted", this.handleApplePayCompleted);
|
|
275
|
+
this.applePayRef.removeEventListener("applePayError", this.handleApplePayError);
|
|
276
|
+
this.applePayRef.removeEventListener("applePayCancelled", this.handleApplePayCancelled);
|
|
277
|
+
}
|
|
278
|
+
}
|
|
279
|
+
async tokenizePaymentMethod(tokenizeArgs) {
|
|
280
|
+
var _a, _b, _c;
|
|
281
|
+
const billingInfoValues = (_b = (await ((_a = this.billingFormRef) === null || _a === void 0 ? void 0 : _a.getValues()))) !== null && _b !== void 0 ? _b : {};
|
|
282
|
+
const combinedBillingInfo = Object.assign(Object.assign({}, tokenizeArgs), billingInfoValues);
|
|
283
|
+
const paymentMethodMetadata = Object.assign({ accountId: checkoutStore.accountId, payment_method_group_id: undefined }, combinedBillingInfo);
|
|
284
|
+
if (checkoutStore.savePaymentMethod) {
|
|
285
|
+
paymentMethodMetadata.payment_method_group_id =
|
|
286
|
+
checkoutStore.paymentMethodGroupId;
|
|
287
|
+
}
|
|
288
|
+
const tokenizeResult = await ((_c = this.paymentMethodFormRef) === null || _c === void 0 ? void 0 : _c.tokenize({
|
|
289
|
+
clientId: this.authToken,
|
|
290
|
+
paymentMethodMetadata,
|
|
291
|
+
account: checkoutStore.accountId,
|
|
292
|
+
}));
|
|
293
|
+
if (tokenizeResult.error) {
|
|
294
|
+
return tokenizeResult;
|
|
295
|
+
}
|
|
296
|
+
checkoutStore.paymentToken = tokenizeResult.id;
|
|
297
|
+
return tokenizeResult.id;
|
|
298
|
+
}
|
|
299
|
+
// set the selected payment method to the checkout store from outside the component
|
|
300
|
+
async setSelectedPaymentMethod(paymentMethod) {
|
|
301
|
+
checkoutStore.selectedPaymentMethod = paymentMethod;
|
|
302
|
+
}
|
|
303
|
+
// getAvailablePaymentMethods removed in favor of checkout-changed event
|
|
304
|
+
// if validation fails, the error will be emitted by the component
|
|
305
|
+
async validate() {
|
|
306
|
+
const promises = [];
|
|
307
|
+
if (checkoutStore.insuranceEnabled && this.insuranceFormRef) {
|
|
308
|
+
promises.push(this.insuranceFormRef.validate());
|
|
309
|
+
}
|
|
310
|
+
const isNewCard = checkoutStore.selectedPaymentMethod.type === PaymentMethodTypes.card && checkoutStore.selectedPaymentMethod.id === undefined;
|
|
311
|
+
const isNewBankAccount = checkoutStore.selectedPaymentMethod.type === PaymentMethodTypes.bankAccount && checkoutStore.selectedPaymentMethod.id === undefined;
|
|
312
|
+
// For new card/bank account, validate payment method + billing.
|
|
313
|
+
if (isNewCard ||
|
|
314
|
+
isNewBankAccount) {
|
|
315
|
+
if (this.paymentMethodFormRef)
|
|
316
|
+
promises.push(this.paymentMethodFormRef.validate());
|
|
317
|
+
if (this.billingFormRef)
|
|
318
|
+
promises.push(this.billingFormRef.validate());
|
|
319
|
+
}
|
|
320
|
+
if (promises.length === 0)
|
|
321
|
+
return true;
|
|
322
|
+
try {
|
|
323
|
+
const results = await Promise.all(promises);
|
|
324
|
+
// Normalize different validator return shapes:
|
|
325
|
+
// - boolean -> use it directly
|
|
326
|
+
// - object -> look for isValid; treat missing isValid as falsey only if explicitly false
|
|
327
|
+
const resultsAreValid = results.every(r => typeof r === 'boolean' ? r : (r === null || r === void 0 ? void 0 : r.isValid) !== false);
|
|
328
|
+
if (!resultsAreValid) {
|
|
329
|
+
this.errorEvent.emit({
|
|
330
|
+
message: 'Validation error',
|
|
331
|
+
errorCode: ComponentErrorCodes.VALIDATION_ERROR,
|
|
332
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
333
|
+
});
|
|
334
|
+
return false;
|
|
335
|
+
}
|
|
336
|
+
return true;
|
|
337
|
+
}
|
|
338
|
+
catch (_a) {
|
|
339
|
+
// If any validator throws/rejects, consider the whole validation failed.
|
|
340
|
+
return false;
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
async submitCheckout(submitCheckoutArgs) {
|
|
344
|
+
const isValid = await this.validate();
|
|
345
|
+
const isNewCard = checkoutStore.selectedPaymentMethod.type === PaymentMethodTypes.card &&
|
|
346
|
+
checkoutStore.selectedPaymentMethod.id === undefined;
|
|
347
|
+
const isNewBankAccount = checkoutStore.selectedPaymentMethod.type === PaymentMethodTypes.bankAccount &&
|
|
348
|
+
checkoutStore.selectedPaymentMethod.id === undefined;
|
|
349
|
+
const shouldTokenize = isNewCard || isNewBankAccount;
|
|
350
|
+
if (shouldTokenize) {
|
|
351
|
+
const tokenizeResult = await this.tokenizePaymentMethod(submitCheckoutArgs);
|
|
352
|
+
if (tokenizeResult === null || tokenizeResult === void 0 ? void 0 : tokenizeResult.error) {
|
|
353
|
+
this.errorEvent.emit({
|
|
354
|
+
message: tokenizeResult.error.message,
|
|
355
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
356
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
357
|
+
});
|
|
358
|
+
return;
|
|
359
|
+
}
|
|
360
|
+
}
|
|
361
|
+
if (!isValid) {
|
|
362
|
+
this.errorEvent.emit({
|
|
363
|
+
message: "Please fill in all required fields.",
|
|
364
|
+
errorCode: ComponentErrorCodes.VALIDATION_ERROR,
|
|
365
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
366
|
+
});
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
if (!checkoutStore.paymentToken) {
|
|
370
|
+
this.errorEvent.emit({
|
|
371
|
+
message: 'Payment token not found.',
|
|
372
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
373
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
374
|
+
});
|
|
375
|
+
}
|
|
376
|
+
let payment;
|
|
377
|
+
const mapTypeToPaymentMode = (type) => {
|
|
378
|
+
switch (type) {
|
|
379
|
+
case PaymentMethodTypes.card:
|
|
380
|
+
case PaymentMethodTypes.bankAccount:
|
|
381
|
+
case PaymentMethodTypes.plaid:
|
|
382
|
+
return PAYMENT_MODE.ECOM;
|
|
383
|
+
case PaymentMethodTypes.sezzle:
|
|
384
|
+
return PAYMENT_MODE.BNPL;
|
|
385
|
+
case PaymentMethodTypes.applePay:
|
|
386
|
+
return PAYMENT_MODE.APPLE_PAY;
|
|
387
|
+
default:
|
|
388
|
+
return undefined;
|
|
389
|
+
}
|
|
390
|
+
};
|
|
391
|
+
payment = {
|
|
392
|
+
payment_mode: mapTypeToPaymentMode(checkoutStore.selectedPaymentMethod.type),
|
|
393
|
+
payment_token: checkoutStore.paymentToken,
|
|
394
|
+
};
|
|
395
|
+
this.completeCheckout({
|
|
396
|
+
payment,
|
|
397
|
+
onSuccess: ({ checkout }) => {
|
|
398
|
+
this.submitEvent.emit({
|
|
399
|
+
checkout,
|
|
400
|
+
message: "Checkout completed successfully",
|
|
401
|
+
});
|
|
402
|
+
},
|
|
403
|
+
onError: (error) => {
|
|
404
|
+
this.errorEvent.emit({
|
|
405
|
+
message: error.message,
|
|
406
|
+
errorCode: ComponentErrorCodes.COMPLETE_CHECKOUT_ERROR,
|
|
407
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
408
|
+
});
|
|
409
|
+
},
|
|
410
|
+
});
|
|
411
|
+
}
|
|
412
|
+
render() {
|
|
413
|
+
return h(Host, { key: '4df5d1aa50fbeee7da93f8e19e45f6907b6ae2c7' });
|
|
414
|
+
}
|
|
415
|
+
get hostEl() { return getElement(this); }
|
|
416
|
+
static get watchers() { return {
|
|
417
|
+
"savePaymentMethod": ["savePaymentMethodChanged"]
|
|
418
|
+
}; }
|
|
419
|
+
};
|
|
420
|
+
|
|
421
|
+
const plaidIconSvg = 'data:image/svg+xml;base64,PHN2ZyBoZWlnaHQ9IjQ4IiB2aWV3Qm94PSIwIDAgMjggMjkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgY2xhc3M9ImNzcy0xcmRhajhtIj48ZyBmaWxsPSIjMTExIiBmaWxsLXJ1bGU9ImV2ZW5vZGQiPjxwYXRoIGQ9Ik0yNS43NjI5IDI2LjI2MjhMMjggMTcuNTMwOUwyNC45NjkxIDE0LjUwMDFMMjcuOTk5OSAxMS40NjkxTDI1Ljc2MjggMi43MzcwNkwxNy4wMzA5IDAuNUwxNC4wMDAxIDMuNTMxTDEwLjk2OSAwLjUwMDE0TDIuMjM3MDYgMi43MzczNEwwIDExLjQ2OTFMMy4wMzEyOCAxNC40OTk5TDAuMDAwMTQgMTcuNTMxTDIuMjM3MiAyNi4yNjI5TDEwLjk2OTEgMjguNUwxNC4wMDAxIDI1LjQ2OUwxNy4wMzEgMjguNDk5OUwyNS43NjI5IDI2LjI2MjhaTTE1LjczMjEgMjMuNzM3MUwxOC42MTg2IDIwLjg1MDVMMjIuMjkxMiAyNC41MjMzTDE3LjY5NTYgMjUuNzAwN0wxNS43MzIxIDIzLjczNzFaTTExLjExMzYgOS44ODE1NEwxNC4wMDAzIDYuOTk1MDJMMTYuODg2OCA5Ljg4MTRMMTQuMDAwMSAxMi43Njc5TDExLjExMzYgOS44ODE1NFpNMTIuMjY4MiAxNC41TDkuMzgxNTQgMTcuMzg2NUw2LjQ5NTAyIDE0LjVMOS4zODE1NCAxMS42MTM1TDEyLjI2ODIgMTQuNVpNMTguNjE4NyAxMS42MTMzTDIxLjUwNTMgMTQuNUwxOC42MTg2IDE3LjM4NjVMMTUuNzMyMSAxNC41TDE4LjYxODcgMTEuNjEzM1pNMTYuODg2NyAxOS4xMTg2TDE0LjAwMDEgMjIuMDA1MUwxMS4xMTM1IDE5LjExODVMMTQuMDAwMSAxNi4yMzE5TDE2Ljg4NjcgMTkuMTE4NlpNMTAuMzA0NCAyNS43MDA3TDUuNzA4NjQgMjQuNTIzM0w5LjM4MTU0IDIwLjg1MDRMMTIuMjY4MiAyMy43MzcxTDEwLjMwNDQgMjUuNzAwN1pNNC43NjMwOCAxNi4yMzE5TDcuNjQ5NiAxOS4xMTg1TDMuOTc2NyAyMi43OTE0TDIuNzk5MyAxOC4xOTU3TDQuNzYzMDggMTYuMjMxOVpNMy45NzY3IDYuMjA4MzZMNy42NDk3NCA5Ljg4MTRMNC43NjMwOCAxMi43NjgxTDIuNzk5MyAxMC44MDQxTDMuOTc2NyA2LjIwODM2Wk0xMi4yNjgzIDUuMjYyOTRMOS4zODE2OCA4LjE0OTZMNS43MDg5MiA0LjQ3NjdMMTAuMzA0NyAzLjI5OTNMMTIuMjY4MyA1LjI2Mjk0Wk0xNy42OTU5IDMuMjk5M0wyMi4yOTE1IDQuNDc2N0wxOC42MTg2IDguMTQ5NDZMMTUuNzMyMSA1LjI2Mjk0TDE3LjY5NTkgMy4yOTkzWk0yMy4yMzcyIDEyLjc2ODFMMjAuMzUwNSA5Ljg4MTRMMjQuMDIzMyA2LjIwODc4TDI1LjIwMDcgMTAuODA0NkwyMy4yMzcyIDEyLjc2ODFaTTI0LjAyMzMgMjIuNzkxNEwyMC4zNTA1IDE5LjExODZMMjMuMjM3MiAxNi4yMzIxTDI1LjIwMDcgMTguMTk1N0wyNC4wMjMzIDIyLjc5MTRaIj48L3BhdGg+PC9nPjwvc3ZnPgo=';
|
|
422
|
+
|
|
423
|
+
const api = Api();
|
|
424
|
+
class PlaidService {
|
|
425
|
+
async getLinkToken(authToken, accountId, checkoutId, signal) {
|
|
426
|
+
const endpoint = `plaid/${accountId}/link`;
|
|
427
|
+
const body = { checkout_id: checkoutId };
|
|
428
|
+
return api.post({ endpoint, body, authToken, signal });
|
|
429
|
+
}
|
|
430
|
+
async tokenizeBankAccount(authToken, accountId, publicToken, linkTokenId, paymentMethodGroupId, signal) {
|
|
431
|
+
const endpoint = `plaid/${accountId}/tokenize`;
|
|
432
|
+
const body = { public_token: publicToken };
|
|
433
|
+
if (linkTokenId) {
|
|
434
|
+
body.link_token_id = linkTokenId;
|
|
435
|
+
}
|
|
436
|
+
if (paymentMethodGroupId) {
|
|
437
|
+
body.payment_method_group_id = paymentMethodGroupId;
|
|
438
|
+
}
|
|
439
|
+
return api.post({ endpoint, body, authToken, signal });
|
|
440
|
+
}
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
// Plaid-specific error codes
|
|
444
|
+
var PlaidErrorCodes;
|
|
445
|
+
(function (PlaidErrorCodes) {
|
|
446
|
+
PlaidErrorCodes["PLAID_SDK_LOAD_FAILED"] = "plaid-sdk-load-failed";
|
|
447
|
+
PlaidErrorCodes["PLAID_LINK_INIT_FAILED"] = "plaid-link-init-failed";
|
|
448
|
+
PlaidErrorCodes["PLAID_LINK_TOKEN_FAILED"] = "plaid-link-token-failed";
|
|
449
|
+
PlaidErrorCodes["PLAID_AUTHENTICATION_FAILED"] = "plaid-authentication-failed";
|
|
450
|
+
PlaidErrorCodes["PLAID_BANK_NOT_SUPPORTED"] = "plaid-bank-not-supported";
|
|
451
|
+
PlaidErrorCodes["PLAID_TOKEN_EXPIRED"] = "plaid-token-expired";
|
|
452
|
+
PlaidErrorCodes["PLAID_NETWORK_ERROR"] = "plaid-network-error";
|
|
453
|
+
PlaidErrorCodes["PLAID_USER_CANCELLED"] = "plaid-user-cancelled";
|
|
454
|
+
PlaidErrorCodes["PLAID_TIMEOUT"] = "plaid-timeout";
|
|
455
|
+
PlaidErrorCodes["PLAID_INVALID_CREDENTIALS"] = "plaid-invalid-credentials";
|
|
456
|
+
PlaidErrorCodes["PLAID_ACCOUNT_LOCKED"] = "plaid-account-locked";
|
|
457
|
+
PlaidErrorCodes["PLAID_MAINTENANCE"] = "plaid-maintenance";
|
|
458
|
+
PlaidErrorCodes["PLAID_RATE_LIMITED"] = "plaid-rate-limited";
|
|
459
|
+
})(PlaidErrorCodes || (PlaidErrorCodes = {}));
|
|
460
|
+
// Plaid error message mapping
|
|
461
|
+
const PLAID_ERROR_MESSAGES = {
|
|
462
|
+
[PlaidErrorCodes.PLAID_SDK_LOAD_FAILED]: 'Unable to load Plaid. Please refresh the page and try again.',
|
|
463
|
+
[PlaidErrorCodes.PLAID_LINK_INIT_FAILED]: 'Unable to initialize bank connection. Please try again.',
|
|
464
|
+
[PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED]: 'Unable to connect to bank service. Please try again.',
|
|
465
|
+
[PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED]: 'Bank authentication failed. Please try again.',
|
|
466
|
+
[PlaidErrorCodes.PLAID_BANK_NOT_SUPPORTED]: 'Your bank is not currently supported. Please try a different payment method.',
|
|
467
|
+
[PlaidErrorCodes.PLAID_TOKEN_EXPIRED]: 'Your bank session has expired. Please reconnect your account.',
|
|
468
|
+
[PlaidErrorCodes.PLAID_NETWORK_ERROR]: 'Network connection issue. Please check your internet connection and try again.',
|
|
469
|
+
[PlaidErrorCodes.PLAID_USER_CANCELLED]: 'Bank connection was cancelled. Click to try again.',
|
|
470
|
+
[PlaidErrorCodes.PLAID_TIMEOUT]: 'Bank connection timed out. Please try again.',
|
|
471
|
+
[PlaidErrorCodes.PLAID_INVALID_CREDENTIALS]: 'Invalid bank credentials. Please check your username and password.',
|
|
472
|
+
[PlaidErrorCodes.PLAID_ACCOUNT_LOCKED]: 'Your bank account is temporarily locked. Please contact your bank.',
|
|
473
|
+
[PlaidErrorCodes.PLAID_MAINTENANCE]: 'Bank service is temporarily unavailable. Please try again later.',
|
|
474
|
+
[PlaidErrorCodes.PLAID_RATE_LIMITED]: 'Too many connection attempts. Please wait a moment and try again.',
|
|
475
|
+
};
|
|
476
|
+
// Plaid error severity mapping
|
|
477
|
+
const PLAID_ERROR_SEVERITY = {
|
|
478
|
+
[PlaidErrorCodes.PLAID_SDK_LOAD_FAILED]: ComponentErrorSeverity.ERROR,
|
|
479
|
+
[PlaidErrorCodes.PLAID_LINK_INIT_FAILED]: ComponentErrorSeverity.ERROR,
|
|
480
|
+
[PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED]: ComponentErrorSeverity.ERROR,
|
|
481
|
+
[PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED]: ComponentErrorSeverity.ERROR,
|
|
482
|
+
[PlaidErrorCodes.PLAID_BANK_NOT_SUPPORTED]: ComponentErrorSeverity.WARNING,
|
|
483
|
+
[PlaidErrorCodes.PLAID_TOKEN_EXPIRED]: ComponentErrorSeverity.WARNING,
|
|
484
|
+
[PlaidErrorCodes.PLAID_NETWORK_ERROR]: ComponentErrorSeverity.WARNING,
|
|
485
|
+
[PlaidErrorCodes.PLAID_USER_CANCELLED]: ComponentErrorSeverity.INFO,
|
|
486
|
+
[PlaidErrorCodes.PLAID_TIMEOUT]: ComponentErrorSeverity.WARNING,
|
|
487
|
+
[PlaidErrorCodes.PLAID_INVALID_CREDENTIALS]: ComponentErrorSeverity.ERROR,
|
|
488
|
+
[PlaidErrorCodes.PLAID_ACCOUNT_LOCKED]: ComponentErrorSeverity.ERROR,
|
|
489
|
+
[PlaidErrorCodes.PLAID_MAINTENANCE]: ComponentErrorSeverity.WARNING,
|
|
490
|
+
[PlaidErrorCodes.PLAID_RATE_LIMITED]: ComponentErrorSeverity.WARNING,
|
|
491
|
+
};
|
|
492
|
+
const PlaidPaymentMethod = class {
|
|
493
|
+
constructor(hostRef) {
|
|
494
|
+
registerInstance(this, hostRef);
|
|
495
|
+
this.paymentMethodOptionSelected = createEvent(this, "paymentMethodOptionSelected");
|
|
496
|
+
this.plaidError = createEvent(this, "plaidError");
|
|
497
|
+
this.plaidErrorRecovered = createEvent(this, "plaidErrorRecovered");
|
|
498
|
+
this.isAuthenticating = false;
|
|
499
|
+
this.publicToken = null;
|
|
500
|
+
this.linkToken = null;
|
|
501
|
+
this.linkTokenId = null;
|
|
502
|
+
this.error = null;
|
|
503
|
+
this.plaidLink = null;
|
|
504
|
+
this.isSelected = false;
|
|
505
|
+
this.retryCount = 0;
|
|
506
|
+
this.isRetrying = false;
|
|
507
|
+
this.plaidService = new PlaidService();
|
|
508
|
+
this.maxRetries = 3;
|
|
509
|
+
this.retryDelay = 2000; // 2 seconds
|
|
510
|
+
this.timeoutId = null;
|
|
511
|
+
this.abortController = null;
|
|
512
|
+
this.hasLoggedDisabledWarning = false;
|
|
513
|
+
this.waitForStoreAndInitialize = () => {
|
|
514
|
+
// Check if store has necessary data
|
|
515
|
+
if (checkoutStore.authToken && checkoutStore.accountId && checkoutStore.checkoutId) {
|
|
516
|
+
this.initializePlaidLink();
|
|
517
|
+
}
|
|
518
|
+
else {
|
|
519
|
+
// Wait a bit and try again
|
|
520
|
+
setTimeout(() => {
|
|
521
|
+
this.waitForStoreAndInitialize();
|
|
522
|
+
}, 100);
|
|
523
|
+
}
|
|
524
|
+
};
|
|
525
|
+
this.initializePlaidLink = async () => {
|
|
526
|
+
try {
|
|
527
|
+
// Check if Plaid is available globally
|
|
528
|
+
if (typeof window.Plaid === 'undefined') {
|
|
529
|
+
this.handleError({
|
|
530
|
+
code: PlaidErrorCodes.PLAID_SDK_LOAD_FAILED,
|
|
531
|
+
message: PLAID_ERROR_MESSAGES[PlaidErrorCodes.PLAID_SDK_LOAD_FAILED],
|
|
532
|
+
severity: PLAID_ERROR_SEVERITY[PlaidErrorCodes.PLAID_SDK_LOAD_FAILED],
|
|
533
|
+
retryable: true,
|
|
534
|
+
userAction: 'Refresh the page and try again'
|
|
535
|
+
});
|
|
536
|
+
return;
|
|
537
|
+
}
|
|
538
|
+
// Get link token from backend
|
|
539
|
+
await this.getLinkToken();
|
|
540
|
+
if (!this.linkToken) {
|
|
541
|
+
this.handleError({
|
|
542
|
+
code: PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED,
|
|
543
|
+
message: PLAID_ERROR_MESSAGES[PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED],
|
|
544
|
+
severity: PLAID_ERROR_SEVERITY[PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED],
|
|
545
|
+
retryable: true,
|
|
546
|
+
userAction: 'Click to try again'
|
|
547
|
+
});
|
|
548
|
+
return;
|
|
549
|
+
}
|
|
550
|
+
// Initialize Plaid Link
|
|
551
|
+
const Plaid = window.Plaid;
|
|
552
|
+
this.plaidLink = Plaid.create({
|
|
553
|
+
token: this.linkToken,
|
|
554
|
+
onSuccess: this.handlePlaidSuccess,
|
|
555
|
+
onExit: this.handlePlaidExit,
|
|
556
|
+
onEvent: this.handlePlaidEvent,
|
|
557
|
+
onLoad: this.handlePlaidLoad,
|
|
558
|
+
});
|
|
559
|
+
}
|
|
560
|
+
catch (error) {
|
|
561
|
+
this.handleError({
|
|
562
|
+
code: PlaidErrorCodes.PLAID_LINK_INIT_FAILED,
|
|
563
|
+
message: PLAID_ERROR_MESSAGES[PlaidErrorCodes.PLAID_LINK_INIT_FAILED],
|
|
564
|
+
severity: PLAID_ERROR_SEVERITY[PlaidErrorCodes.PLAID_LINK_INIT_FAILED],
|
|
565
|
+
originalError: error,
|
|
566
|
+
retryable: true,
|
|
567
|
+
userAction: 'Click to try again'
|
|
568
|
+
});
|
|
569
|
+
}
|
|
570
|
+
};
|
|
571
|
+
this.getLinkToken = async () => {
|
|
572
|
+
var _a, _b, _c, _d, _e;
|
|
573
|
+
try {
|
|
574
|
+
if (!checkoutStore.authToken || !checkoutStore.accountId) {
|
|
575
|
+
this.handleError({
|
|
576
|
+
code: PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED,
|
|
577
|
+
message: 'Missing authentication. Please refresh the page and try again.',
|
|
578
|
+
severity: ComponentErrorSeverity.ERROR,
|
|
579
|
+
retryable: false,
|
|
580
|
+
userAction: 'Refresh the page'
|
|
581
|
+
});
|
|
582
|
+
return;
|
|
583
|
+
}
|
|
584
|
+
// Create abort controller for timeout handling
|
|
585
|
+
this.abortController = new AbortController();
|
|
586
|
+
// Set timeout for the request
|
|
587
|
+
this.timeoutId = setTimeout(() => {
|
|
588
|
+
var _a;
|
|
589
|
+
(_a = this.abortController) === null || _a === void 0 ? void 0 : _a.abort();
|
|
590
|
+
}, 30000); // 30 second timeout
|
|
591
|
+
const response = await this.plaidService.getLinkToken(checkoutStore.authToken, checkoutStore.accountId, checkoutStore.checkoutId, this.abortController.signal);
|
|
592
|
+
// Clear timeout
|
|
593
|
+
if (this.timeoutId) {
|
|
594
|
+
clearTimeout(this.timeoutId);
|
|
595
|
+
this.timeoutId = null;
|
|
596
|
+
}
|
|
597
|
+
if (response.error) {
|
|
598
|
+
const errorMessage = typeof response.error === 'string'
|
|
599
|
+
? response.error
|
|
600
|
+
: response.error.message || 'Failed to get link token';
|
|
601
|
+
throw new Error(errorMessage);
|
|
602
|
+
}
|
|
603
|
+
// Some backends may return an id along with the link token
|
|
604
|
+
this.linkToken = response.data.link_token;
|
|
605
|
+
// Try to capture link token id if present in envelope
|
|
606
|
+
this.linkTokenId = (response === null || response === void 0 ? void 0 : response.id) || ((_a = response === null || response === void 0 ? void 0 : response.data) === null || _a === void 0 ? void 0 : _a.id) || null;
|
|
607
|
+
}
|
|
608
|
+
catch (error) {
|
|
609
|
+
// Clear timeout
|
|
610
|
+
if (this.timeoutId) {
|
|
611
|
+
clearTimeout(this.timeoutId);
|
|
612
|
+
this.timeoutId = null;
|
|
613
|
+
}
|
|
614
|
+
let errorCode = PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED;
|
|
615
|
+
let message = PLAID_ERROR_MESSAGES[errorCode];
|
|
616
|
+
let retryable = true;
|
|
617
|
+
// Handle specific error types
|
|
618
|
+
if (error.name === 'AbortError') {
|
|
619
|
+
errorCode = PlaidErrorCodes.PLAID_TIMEOUT;
|
|
620
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
621
|
+
retryable = true;
|
|
622
|
+
}
|
|
623
|
+
else if (((_b = error.message) === null || _b === void 0 ? void 0 : _b.includes('network')) || ((_c = error.message) === null || _c === void 0 ? void 0 : _c.includes('fetch'))) {
|
|
624
|
+
errorCode = PlaidErrorCodes.PLAID_NETWORK_ERROR;
|
|
625
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
626
|
+
retryable = true;
|
|
627
|
+
}
|
|
628
|
+
else if (((_d = error.message) === null || _d === void 0 ? void 0 : _d.includes('401')) || ((_e = error.message) === null || _e === void 0 ? void 0 : _e.includes('unauthorized'))) {
|
|
629
|
+
errorCode = PlaidErrorCodes.PLAID_INVALID_CREDENTIALS;
|
|
630
|
+
message = 'Authentication failed. Please refresh the page and try again.';
|
|
631
|
+
retryable = false;
|
|
632
|
+
}
|
|
633
|
+
this.handleError({
|
|
634
|
+
code: errorCode,
|
|
635
|
+
message: message,
|
|
636
|
+
severity: PLAID_ERROR_SEVERITY[errorCode],
|
|
637
|
+
originalError: error,
|
|
638
|
+
retryable,
|
|
639
|
+
userAction: retryable ? 'Click to try again' : 'Refresh the page'
|
|
640
|
+
});
|
|
641
|
+
}
|
|
642
|
+
};
|
|
643
|
+
this.mapApiErrorToPlaidError = (apiError) => {
|
|
644
|
+
if (typeof apiError === 'string') {
|
|
645
|
+
if (apiError.includes('rate_limit'))
|
|
646
|
+
return PlaidErrorCodes.PLAID_RATE_LIMITED;
|
|
647
|
+
if (apiError.includes('maintenance'))
|
|
648
|
+
return PlaidErrorCodes.PLAID_MAINTENANCE;
|
|
649
|
+
if (apiError.includes('not_authenticated'))
|
|
650
|
+
return PlaidErrorCodes.PLAID_INVALID_CREDENTIALS;
|
|
651
|
+
}
|
|
652
|
+
if (apiError === null || apiError === void 0 ? void 0 : apiError.code) {
|
|
653
|
+
switch (apiError.code) {
|
|
654
|
+
case 'rate_limited': return PlaidErrorCodes.PLAID_RATE_LIMITED;
|
|
655
|
+
case 'maintenance': return PlaidErrorCodes.PLAID_MAINTENANCE;
|
|
656
|
+
case 'not_authenticated': return PlaidErrorCodes.PLAID_INVALID_CREDENTIALS;
|
|
657
|
+
case 'invalid_parameter': return PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED;
|
|
658
|
+
default: return PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED;
|
|
659
|
+
}
|
|
660
|
+
}
|
|
661
|
+
return PlaidErrorCodes.PLAID_LINK_TOKEN_FAILED;
|
|
662
|
+
};
|
|
663
|
+
this.openPlaidLink = () => {
|
|
664
|
+
if (this.plaidLink && this.linkToken) {
|
|
665
|
+
this.isAuthenticating = true;
|
|
666
|
+
this.clearError();
|
|
667
|
+
this.plaidLink.open();
|
|
668
|
+
}
|
|
669
|
+
};
|
|
670
|
+
this.handlePlaidSuccess = (publicToken, _metadata) => {
|
|
671
|
+
this.publicToken = publicToken;
|
|
672
|
+
this.isAuthenticating = false;
|
|
673
|
+
this.clearError();
|
|
674
|
+
this.retryCount = 0; // Reset retry count on success
|
|
675
|
+
// Ensure the component remains selected after successful authentication
|
|
676
|
+
if (!this.isSelected) {
|
|
677
|
+
this.isSelected = true;
|
|
678
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.plaid };
|
|
679
|
+
}
|
|
680
|
+
// Emit success event for parent components
|
|
681
|
+
this.plaidErrorRecovered.emit({
|
|
682
|
+
code: 'plaid-success',
|
|
683
|
+
message: 'Bank account connected successfully',
|
|
684
|
+
severity: ComponentErrorSeverity.INFO
|
|
685
|
+
});
|
|
686
|
+
// Immediately exchange the public token for a payment method token via backend
|
|
687
|
+
this.exchangePublicTokenForPaymentMethod();
|
|
688
|
+
};
|
|
689
|
+
this.exchangePublicTokenForPaymentMethod = async () => {
|
|
690
|
+
var _a;
|
|
691
|
+
if (!this.publicToken) {
|
|
692
|
+
console.error('[PlaidPaymentMethod] exchange: missing publicToken');
|
|
693
|
+
return;
|
|
694
|
+
}
|
|
695
|
+
if (!checkoutStore.authToken || !checkoutStore.accountId) {
|
|
696
|
+
console.error('[PlaidPaymentMethod] exchange: missing auth/account context');
|
|
697
|
+
return;
|
|
698
|
+
}
|
|
699
|
+
try {
|
|
700
|
+
const response = await this.plaidService.tokenizeBankAccount(checkoutStore.authToken, checkoutStore.accountId, this.publicToken, this.linkTokenId || undefined, checkoutStore.savePaymentMethod ? checkoutStore.paymentMethodGroupId : undefined);
|
|
701
|
+
if (response === null || response === void 0 ? void 0 : response.error) {
|
|
702
|
+
console.error('[PlaidPaymentMethod] exchange: backend error', response.error);
|
|
703
|
+
return;
|
|
704
|
+
}
|
|
705
|
+
// Extract token from payment method response
|
|
706
|
+
const paymentMethod = response === null || response === void 0 ? void 0 : response.data;
|
|
707
|
+
const token = ((_a = paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.bank_account) === null || _a === void 0 ? void 0 : _a.token) || (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.token) || (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id);
|
|
708
|
+
if (!token) {
|
|
709
|
+
console.error('[PlaidPaymentMethod] exchange: no token in response');
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
// Save for downstream submit flows
|
|
713
|
+
checkoutStore.paymentToken = token;
|
|
714
|
+
}
|
|
715
|
+
catch (err) {
|
|
716
|
+
console.error('[PlaidPaymentMethod] exchange: exception', {
|
|
717
|
+
message: (err === null || err === void 0 ? void 0 : err.message) || String(err),
|
|
718
|
+
});
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
this.handlePlaidExit = (err, _metadata) => {
|
|
722
|
+
this.isAuthenticating = false;
|
|
723
|
+
if (err) {
|
|
724
|
+
this.handlePlaidError(err);
|
|
725
|
+
}
|
|
726
|
+
};
|
|
727
|
+
this.handlePlaidEvent = (eventName, metadata) => {
|
|
728
|
+
// Handle specific events if needed
|
|
729
|
+
switch (eventName) {
|
|
730
|
+
case 'OPEN':
|
|
731
|
+
this.isAuthenticating = true;
|
|
732
|
+
break;
|
|
733
|
+
case 'CLOSE':
|
|
734
|
+
this.isAuthenticating = false;
|
|
735
|
+
break;
|
|
736
|
+
case 'ERROR':
|
|
737
|
+
this.handlePlaidError(metadata);
|
|
738
|
+
break;
|
|
739
|
+
}
|
|
740
|
+
};
|
|
741
|
+
this.handlePlaidLoad = () => {
|
|
742
|
+
};
|
|
743
|
+
this.handlePlaidError = (error) => {
|
|
744
|
+
let errorCode = PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED;
|
|
745
|
+
let message = PLAID_ERROR_MESSAGES[errorCode];
|
|
746
|
+
let retryable = true;
|
|
747
|
+
let userAction = 'Click to try again';
|
|
748
|
+
// Map Plaid error codes to our error codes
|
|
749
|
+
if (error.error_code) {
|
|
750
|
+
switch (error.error_code) {
|
|
751
|
+
case 'INVALID_CREDENTIALS':
|
|
752
|
+
errorCode = PlaidErrorCodes.PLAID_INVALID_CREDENTIALS;
|
|
753
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
754
|
+
retryable = true;
|
|
755
|
+
break;
|
|
756
|
+
case 'ITEM_LOGIN_REQUIRED':
|
|
757
|
+
errorCode = PlaidErrorCodes.PLAID_INVALID_CREDENTIALS;
|
|
758
|
+
message = 'Your bank requires re-authentication. Please try again.';
|
|
759
|
+
retryable = true;
|
|
760
|
+
break;
|
|
761
|
+
case 'ITEM_LOCKED':
|
|
762
|
+
errorCode = PlaidErrorCodes.PLAID_ACCOUNT_LOCKED;
|
|
763
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
764
|
+
retryable = false;
|
|
765
|
+
userAction = 'Contact your bank';
|
|
766
|
+
break;
|
|
767
|
+
case 'INSTITUTION_NOT_RESPONDING':
|
|
768
|
+
errorCode = PlaidErrorCodes.PLAID_MAINTENANCE;
|
|
769
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
770
|
+
retryable = true;
|
|
771
|
+
break;
|
|
772
|
+
case 'RATE_LIMIT_EXCEEDED':
|
|
773
|
+
errorCode = PlaidErrorCodes.PLAID_RATE_LIMITED;
|
|
774
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
775
|
+
retryable = true;
|
|
776
|
+
break;
|
|
777
|
+
case 'INVALID_REQUEST':
|
|
778
|
+
errorCode = PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED;
|
|
779
|
+
message = 'Invalid request. Please try again.';
|
|
780
|
+
retryable = true;
|
|
781
|
+
break;
|
|
782
|
+
case 'PLAID_ERROR':
|
|
783
|
+
errorCode = PlaidErrorCodes.PLAID_AUTHENTICATION_FAILED;
|
|
784
|
+
message = error.error_message || 'Bank authentication failed. Please try again.';
|
|
785
|
+
retryable = true;
|
|
786
|
+
break;
|
|
787
|
+
default:
|
|
788
|
+
// Use the error message from Plaid if available
|
|
789
|
+
if (error.error_message) {
|
|
790
|
+
message = error.error_message;
|
|
791
|
+
}
|
|
792
|
+
break;
|
|
793
|
+
}
|
|
794
|
+
}
|
|
795
|
+
// Handle specific error messages
|
|
796
|
+
if (error.error_message) {
|
|
797
|
+
const lowerMessage = error.error_message.toLowerCase();
|
|
798
|
+
if (lowerMessage.includes('not supported') || lowerMessage.includes('unsupported')) {
|
|
799
|
+
errorCode = PlaidErrorCodes.PLAID_BANK_NOT_SUPPORTED;
|
|
800
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
801
|
+
retryable = false;
|
|
802
|
+
userAction = 'Try a different payment method';
|
|
803
|
+
}
|
|
804
|
+
else if (lowerMessage.includes('expired') || lowerMessage.includes('timeout')) {
|
|
805
|
+
errorCode = PlaidErrorCodes.PLAID_TOKEN_EXPIRED;
|
|
806
|
+
message = PLAID_ERROR_MESSAGES[errorCode];
|
|
807
|
+
retryable = true;
|
|
808
|
+
}
|
|
809
|
+
}
|
|
810
|
+
this.handleError({
|
|
811
|
+
code: errorCode,
|
|
812
|
+
message,
|
|
813
|
+
severity: PLAID_ERROR_SEVERITY[errorCode],
|
|
814
|
+
originalError: error,
|
|
815
|
+
retryable,
|
|
816
|
+
userAction
|
|
817
|
+
});
|
|
818
|
+
this.isAuthenticating = false;
|
|
819
|
+
};
|
|
820
|
+
this.handleError = (plaidError) => {
|
|
821
|
+
this.error = plaidError;
|
|
822
|
+
// Emit error event for parent components
|
|
823
|
+
this.plaidError.emit({
|
|
824
|
+
code: plaidError.code,
|
|
825
|
+
message: plaidError.message,
|
|
826
|
+
severity: plaidError.severity,
|
|
827
|
+
data: {
|
|
828
|
+
originalError: plaidError.originalError,
|
|
829
|
+
retryable: plaidError.retryable,
|
|
830
|
+
userAction: plaidError.userAction,
|
|
831
|
+
retryCount: this.retryCount
|
|
832
|
+
}
|
|
833
|
+
});
|
|
834
|
+
console.error('Plaid error:', plaidError);
|
|
835
|
+
// Auto-retry for retryable errors if under max retries
|
|
836
|
+
if (plaidError.retryable && this.retryCount < this.maxRetries) {
|
|
837
|
+
this.scheduleRetry();
|
|
838
|
+
}
|
|
839
|
+
};
|
|
840
|
+
this.scheduleRetry = () => {
|
|
841
|
+
if (this.isRetrying)
|
|
842
|
+
return;
|
|
843
|
+
this.isRetrying = true;
|
|
844
|
+
this.retryCount++;
|
|
845
|
+
setTimeout(() => {
|
|
846
|
+
this.isRetrying = false;
|
|
847
|
+
this.clearError();
|
|
848
|
+
this.waitForStoreAndInitialize();
|
|
849
|
+
}, this.retryDelay * this.retryCount); // Exponential backoff
|
|
850
|
+
};
|
|
851
|
+
this.clearError = () => {
|
|
852
|
+
if (this.error) {
|
|
853
|
+
this.error = null;
|
|
854
|
+
this.retryCount = 0;
|
|
855
|
+
}
|
|
856
|
+
};
|
|
857
|
+
// Watch for store changes to sync component state
|
|
858
|
+
this.syncWithStore = () => {
|
|
859
|
+
const shouldBeSelected = checkoutStore.selectedPaymentMethod.type === PaymentMethodTypes.plaid;
|
|
860
|
+
if (this.isSelected !== shouldBeSelected) {
|
|
861
|
+
this.isSelected = shouldBeSelected;
|
|
862
|
+
}
|
|
863
|
+
};
|
|
864
|
+
}
|
|
865
|
+
onSelectionChange(newValue) {
|
|
866
|
+
// Ensure store is updated when component selection changes
|
|
867
|
+
if (newValue && checkoutStore.selectedPaymentMethod.type !== PaymentMethodTypes.plaid) {
|
|
868
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.plaid };
|
|
869
|
+
}
|
|
870
|
+
// Auto-start Plaid flow when selected and ready
|
|
871
|
+
if (newValue &&
|
|
872
|
+
this.plaidLink &&
|
|
873
|
+
!this.publicToken &&
|
|
874
|
+
!this.isAuthenticating &&
|
|
875
|
+
!this.error) {
|
|
876
|
+
this.openPlaidLink();
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
componentDidRender() {
|
|
880
|
+
if (!this.scriptRef)
|
|
881
|
+
return;
|
|
882
|
+
this.scriptRef.onload = () => {
|
|
883
|
+
// Wait for store to be populated before initializing
|
|
884
|
+
this.waitForStoreAndInitialize();
|
|
885
|
+
};
|
|
886
|
+
// Add error handler for script loading failures
|
|
887
|
+
this.scriptRef.onerror = () => {
|
|
888
|
+
this.handleError({
|
|
889
|
+
code: PlaidErrorCodes.PLAID_SDK_LOAD_FAILED,
|
|
890
|
+
message: PLAID_ERROR_MESSAGES[PlaidErrorCodes.PLAID_SDK_LOAD_FAILED],
|
|
891
|
+
severity: PLAID_ERROR_SEVERITY[PlaidErrorCodes.PLAID_SDK_LOAD_FAILED],
|
|
892
|
+
retryable: true,
|
|
893
|
+
userAction: 'Refresh the page and try again'
|
|
894
|
+
});
|
|
895
|
+
};
|
|
896
|
+
}
|
|
897
|
+
componentWillLoad() {
|
|
898
|
+
// Initialize selection state based on store
|
|
899
|
+
this.isSelected = checkoutStore.selectedPaymentMethod.type === PaymentMethodTypes.plaid;
|
|
900
|
+
}
|
|
901
|
+
async resolvePaymentMethod() {
|
|
902
|
+
if (!this.publicToken) {
|
|
903
|
+
return { validationError: true };
|
|
904
|
+
}
|
|
905
|
+
return {
|
|
906
|
+
token: this.publicToken,
|
|
907
|
+
data: {
|
|
908
|
+
type: 'bank_account',
|
|
909
|
+
plaid_public_token: this.publicToken
|
|
910
|
+
}
|
|
911
|
+
};
|
|
912
|
+
}
|
|
913
|
+
// Returns a usable payment method token for checkout completion.
|
|
914
|
+
// Will perform the backend exchange if the token is not yet present in the store.
|
|
915
|
+
async getPaymentToken() {
|
|
916
|
+
if (checkoutStore.paymentToken) {
|
|
917
|
+
return checkoutStore.paymentToken;
|
|
918
|
+
}
|
|
919
|
+
await this.exchangePublicTokenForPaymentMethod();
|
|
920
|
+
return checkoutStore.paymentToken;
|
|
921
|
+
}
|
|
922
|
+
async handleSelectionClick() {
|
|
923
|
+
// Update local selection state
|
|
924
|
+
this.isSelected = true;
|
|
925
|
+
// Update store selection
|
|
926
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.plaid };
|
|
927
|
+
// If there's an error, clear it and try to initialize again
|
|
928
|
+
if (this.error) {
|
|
929
|
+
this.clearError();
|
|
930
|
+
this.waitForStoreAndInitialize();
|
|
931
|
+
return;
|
|
932
|
+
}
|
|
933
|
+
// If Plaid Link is ready and no public token exists, open Plaid Link
|
|
934
|
+
if (this.plaidLink && !this.publicToken && !this.isAuthenticating) {
|
|
935
|
+
this.openPlaidLink();
|
|
936
|
+
}
|
|
937
|
+
}
|
|
938
|
+
// Method to handle external selection changes (e.g., from other payment methods)
|
|
939
|
+
async setSelected(selected) {
|
|
940
|
+
this.isSelected = selected;
|
|
941
|
+
if (selected) {
|
|
942
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.plaid };
|
|
943
|
+
}
|
|
944
|
+
}
|
|
945
|
+
// Method to check if component is currently selected
|
|
946
|
+
async isCurrentlySelected() {
|
|
947
|
+
return this.isSelected;
|
|
948
|
+
}
|
|
949
|
+
// Method to handle external deselection (when another payment method is selected)
|
|
950
|
+
async deselect() {
|
|
951
|
+
this.isSelected = false;
|
|
952
|
+
// Don't clear the public token or error state as they might be needed if user reselects
|
|
953
|
+
}
|
|
954
|
+
// Method to reset component state (useful for testing or error recovery)
|
|
955
|
+
async reset() {
|
|
956
|
+
this.publicToken = null;
|
|
957
|
+
this.clearError();
|
|
958
|
+
this.isAuthenticating = false;
|
|
959
|
+
this.linkToken = null;
|
|
960
|
+
this.plaidLink = null;
|
|
961
|
+
this.retryCount = 0;
|
|
962
|
+
this.isRetrying = false;
|
|
963
|
+
// Clear any pending timeouts
|
|
964
|
+
if (this.timeoutId) {
|
|
965
|
+
clearTimeout(this.timeoutId);
|
|
966
|
+
this.timeoutId = null;
|
|
967
|
+
}
|
|
968
|
+
// Abort any pending requests
|
|
969
|
+
if (this.abortController) {
|
|
970
|
+
this.abortController.abort();
|
|
971
|
+
this.abortController = null;
|
|
972
|
+
}
|
|
973
|
+
}
|
|
974
|
+
// Method to check if component is ready for authentication
|
|
975
|
+
async isReadyForAuthentication() {
|
|
976
|
+
return !!(this.plaidLink && this.linkToken && !this.isAuthenticating);
|
|
977
|
+
}
|
|
978
|
+
// Method to manually retry after an error
|
|
979
|
+
async retry() {
|
|
980
|
+
if (this.error && this.error.retryable) {
|
|
981
|
+
this.clearError();
|
|
982
|
+
this.waitForStoreAndInitialize();
|
|
983
|
+
}
|
|
984
|
+
}
|
|
985
|
+
// Method to get current error information
|
|
986
|
+
async getErrorInfo() {
|
|
987
|
+
return this.error;
|
|
988
|
+
}
|
|
989
|
+
componentDidLoad() {
|
|
990
|
+
// Set up store change listener to keep component in sync
|
|
991
|
+
const unsubscribe = onChange('selectedPaymentMethod', this.syncWithStore);
|
|
992
|
+
// Store unsubscribe function for cleanup
|
|
993
|
+
this.unsubscribeFromStore = unsubscribe;
|
|
994
|
+
}
|
|
995
|
+
disconnectedCallback() {
|
|
996
|
+
// Clean up store subscription
|
|
997
|
+
if (this.unsubscribeFromStore) {
|
|
998
|
+
this.unsubscribeFromStore();
|
|
999
|
+
}
|
|
1000
|
+
// Clean up timeouts and abort controllers
|
|
1001
|
+
if (this.timeoutId) {
|
|
1002
|
+
clearTimeout(this.timeoutId);
|
|
1003
|
+
}
|
|
1004
|
+
if (this.abortController) {
|
|
1005
|
+
this.abortController.abort();
|
|
1006
|
+
}
|
|
1007
|
+
}
|
|
1008
|
+
render() {
|
|
1009
|
+
// Only allow use if enabled in checkout settings
|
|
1010
|
+
if (checkoutStore.bankAccountVerification !== true) {
|
|
1011
|
+
if (!this.hasLoggedDisabledWarning) {
|
|
1012
|
+
// Log once per component lifecycle
|
|
1013
|
+
console.warn('[PlaidPaymentMethod] bank_account_verification is disabled. Component will not render.');
|
|
1014
|
+
this.hasLoggedDisabledWarning = true;
|
|
1015
|
+
}
|
|
1016
|
+
return null;
|
|
1017
|
+
}
|
|
1018
|
+
const plaidLogo = (h("img", { class: "plaid-logo-img", src: plaidIconSvg, alt: "Plaid", title: "Plaid", style: {
|
|
1019
|
+
display: 'inline',
|
|
1020
|
+
width: '20px',
|
|
1021
|
+
height: '20px',
|
|
1022
|
+
marginLeft: '5px',
|
|
1023
|
+
marginTop: '-2px',
|
|
1024
|
+
} }));
|
|
1025
|
+
const renderErrorState = () => {
|
|
1026
|
+
if (!this.error)
|
|
1027
|
+
return null;
|
|
1028
|
+
const errorClass = this.error.severity === ComponentErrorSeverity.ERROR
|
|
1029
|
+
? 'text-danger'
|
|
1030
|
+
: this.error.severity === ComponentErrorSeverity.WARNING
|
|
1031
|
+
? 'text-warning'
|
|
1032
|
+
: 'text-info';
|
|
1033
|
+
return (h("div", { class: `${errorClass} mt-2` }, h("small", null, this.error.message), h("br", null), h("small", { class: "text-muted" }, this.error.userAction, this.error.retryable && this.retryCount < this.maxRetries && (h("span", null, " \u2022 Auto-retry in progress...")))));
|
|
1034
|
+
};
|
|
1035
|
+
const renderStatusState = () => {
|
|
1036
|
+
if (this.error)
|
|
1037
|
+
return null;
|
|
1038
|
+
if (this.isAuthenticating) {
|
|
1039
|
+
return (h("div", { class: "text-info mt-2" }, h("small", null, "Connecting to your bank...")));
|
|
1040
|
+
}
|
|
1041
|
+
if (this.publicToken) {
|
|
1042
|
+
return (h("div", { class: "text-success mt-2" }, h("small", null, "\u2713 Bank account connected successfully")));
|
|
1043
|
+
}
|
|
1044
|
+
if (this.isSelected && !this.publicToken && !this.error && !this.isAuthenticating) {
|
|
1045
|
+
return (h("div", { class: "text-muted mt-2" }, h("small", null, "Click to connect your bank account")));
|
|
1046
|
+
}
|
|
1047
|
+
return null;
|
|
1048
|
+
};
|
|
1049
|
+
return (h(StyledHost, { class: "payment-method" }, h("script", { src: "https://cdn.plaid.com/link/v2/stable/link-initialize.js", async: true, ref: (el) => (this.scriptRef = el) }), h("div", { title: "Pay with Plaid" }, h("div", { onClick: (event) => { event.preventDefault(); this.handleSelectionClick(); } }, "Pay with Bank Account ", plaidLogo, " "), renderErrorState(), renderStatusState())));
|
|
1050
|
+
}
|
|
1051
|
+
static get watchers() { return {
|
|
1052
|
+
"isSelected": ["onSelectionChange"]
|
|
1053
|
+
}; }
|
|
1054
|
+
};
|
|
1055
|
+
|
|
1056
|
+
const SavedPaymentMethods = class {
|
|
1057
|
+
constructor(hostRef) {
|
|
1058
|
+
registerInstance(this, hostRef);
|
|
1059
|
+
this.onPaymentMethodOptionClick = (paymentMethod) => (e) => {
|
|
1060
|
+
e.preventDefault();
|
|
1061
|
+
checkoutStore.selectedPaymentMethod = paymentMethod;
|
|
1062
|
+
checkoutStore.paymentToken = paymentMethod.id;
|
|
1063
|
+
};
|
|
1064
|
+
this.isAllowedPaymentMethod = (paymentMethod) => {
|
|
1065
|
+
if (paymentMethod.type === PAYMENT_METHOD_TYPES.CARD && checkoutStore.disableCreditCard) {
|
|
1066
|
+
return false;
|
|
1067
|
+
}
|
|
1068
|
+
if (paymentMethod.type === PAYMENT_METHOD_TYPES.BANK_ACCOUNT && checkoutStore.disableBankAccount) {
|
|
1069
|
+
return false;
|
|
1070
|
+
}
|
|
1071
|
+
return true;
|
|
1072
|
+
};
|
|
1073
|
+
}
|
|
1074
|
+
componentWillLoad() {
|
|
1075
|
+
if (!checkoutStore.paymentMethods.length) {
|
|
1076
|
+
console.warn('No saved payment methods available.');
|
|
1077
|
+
}
|
|
1078
|
+
if (checkoutStore.disablePaymentMethodGroup) {
|
|
1079
|
+
console.warn('Payment method group is disabled.');
|
|
1080
|
+
}
|
|
1081
|
+
}
|
|
1082
|
+
render() {
|
|
1083
|
+
if (checkoutStore.disablePaymentMethodGroup) {
|
|
1084
|
+
return null;
|
|
1085
|
+
}
|
|
1086
|
+
return (h(StyledHost, null, h("div", { class: "saved-payment-methods" }, checkoutStore.paymentMethods.length ? checkoutStore.paymentMethods
|
|
1087
|
+
.filter(this.isAllowedPaymentMethod)
|
|
1088
|
+
.map((paymentMethod) => (h("div", { class: "radio-list-item p-3", part: radioListItem, onClick: this.onPaymentMethodOptionClick(paymentMethod) }, h("form-control-radio", { name: "paymentMethodType", value: paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id, checked: checkoutStore.paymentToken === (paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.id), label: `${CardBrandLabels[paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.brand] || ''} *${paymentMethod === null || paymentMethod === void 0 ? void 0 : paymentMethod.acct_last_four}` })))) : null)));
|
|
1089
|
+
}
|
|
1090
|
+
};
|
|
1091
|
+
|
|
1092
|
+
const sezzleLogo = (h("img", { class: "sezzle-smart-button-logo-img", src: "https://media.sezzle.com/branding/2.0/Sezzle_Logo_FullColor.svg", alt: "Sezzle", style: {
|
|
1093
|
+
display: 'inline',
|
|
1094
|
+
width: '80px',
|
|
1095
|
+
marginLeft: '5px',
|
|
1096
|
+
marginTop: '-5px',
|
|
1097
|
+
} }));
|
|
1098
|
+
const SezzlePaymentMethod = class {
|
|
1099
|
+
constructor(hostRef) {
|
|
1100
|
+
registerInstance(this, hostRef);
|
|
1101
|
+
this.paymentMethodOptionSelected = createEvent(this, "paymentMethodOptionSelected");
|
|
1102
|
+
this.paymentMethodOptionId = PAYMENT_METHODS.SEZZLE;
|
|
1103
|
+
this.initializeSezzleCheckout = () => {
|
|
1104
|
+
let resolveSezzlePromise;
|
|
1105
|
+
this.sezzlePromise = new Promise((resolve) => { resolveSezzlePromise = resolve; });
|
|
1106
|
+
const amount = Number(checkoutStore.paymentAmount);
|
|
1107
|
+
const Checkout = window.Checkout;
|
|
1108
|
+
const checkout = new Checkout({
|
|
1109
|
+
mode: 'popup',
|
|
1110
|
+
publicKey: checkoutStore.bnplProviderClientId,
|
|
1111
|
+
apiMode: checkoutStore.bnplProviderMode,
|
|
1112
|
+
apiVersion: checkoutStore.bnplProviderApiVersion,
|
|
1113
|
+
});
|
|
1114
|
+
checkout.sezzleButtonElement = this.sezzleButtonRef;
|
|
1115
|
+
checkout.init({
|
|
1116
|
+
onClick: function (event) {
|
|
1117
|
+
event.preventDefault();
|
|
1118
|
+
checkout.startCheckout({
|
|
1119
|
+
checkout_url: checkoutStore.bnplProviderCheckoutUrl,
|
|
1120
|
+
});
|
|
1121
|
+
},
|
|
1122
|
+
onComplete: (event) => resolveSezzlePromise({ bnpl: event.data }),
|
|
1123
|
+
onCancel: (event) => resolveSezzlePromise({ bnpl: event.data }),
|
|
1124
|
+
onFailure: (event) => resolveSezzlePromise({ bnpl: event.data }),
|
|
1125
|
+
});
|
|
1126
|
+
this.sezzleCheckout = checkout;
|
|
1127
|
+
this.installmentPlan = this.sezzleCheckout.getInstallmentPlan(amount);
|
|
1128
|
+
};
|
|
1129
|
+
}
|
|
1130
|
+
componentDidRender() {
|
|
1131
|
+
if (!this.scriptRef)
|
|
1132
|
+
return;
|
|
1133
|
+
this.scriptRef.onload = () => {
|
|
1134
|
+
this.sezzleButtonRef = document.createElement('button');
|
|
1135
|
+
this.initializeSezzleCheckout();
|
|
1136
|
+
};
|
|
1137
|
+
}
|
|
1138
|
+
async resolvePaymentMethod(insuranceValidation) {
|
|
1139
|
+
if (!insuranceValidation.isValid) {
|
|
1140
|
+
return { validationError: true };
|
|
1141
|
+
}
|
|
1142
|
+
this.sezzleButtonRef.click();
|
|
1143
|
+
return this.sezzlePromise;
|
|
1144
|
+
}
|
|
1145
|
+
async handleSelectionClick() {
|
|
1146
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.sezzle };
|
|
1147
|
+
this.paymentMethodOptionSelected.emit(this.paymentMethodOptionId);
|
|
1148
|
+
}
|
|
1149
|
+
render() {
|
|
1150
|
+
var _a, _b;
|
|
1151
|
+
if (!checkoutStore.bnplEnabled || checkoutStore.disableBnpl) {
|
|
1152
|
+
console.warn('justifi-sezzle-payment-method: BNPL is not enabled for this account.');
|
|
1153
|
+
return null;
|
|
1154
|
+
}
|
|
1155
|
+
return (h(StyledHost, { class: "payment-method" }, h("script", { src: "https://checkout-sdk.sezzle.com/checkout.min.js", async: true, ref: (el) => (this.scriptRef = el) }), h("div", null, h("div", null, "Buy now, pay later with ", sezzleLogo), this.installmentPlan && (h("small", null, h("span", null, (_a = this.installmentPlan) === null || _a === void 0 ? void 0 : _a.installments.length), "\u00A0", h("span", null, this.installmentPlan.schedule, " payments of"), "\u00A0", h("span", { class: "fw-bold" }, formatCurrency((_b = this.installmentPlan) === null || _b === void 0 ? void 0 : _b.installments[0].amountInCents)))))));
|
|
1156
|
+
}
|
|
1157
|
+
};
|
|
1158
|
+
|
|
1159
|
+
// Constants
|
|
1160
|
+
const PAYMENT_METHOD_TYPE_LABELS = {
|
|
1161
|
+
[PaymentMethodTypes.bankAccount]: 'New bank account',
|
|
1162
|
+
[PaymentMethodTypes.card]: 'New credit or debit card',
|
|
1163
|
+
};
|
|
1164
|
+
const ERROR_MESSAGES = {
|
|
1165
|
+
AUTH_TOKEN_REQUIRED: 'Auth token is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout',
|
|
1166
|
+
ACCOUNT_ID_REQUIRED: 'Account ID is required when using the tokenize-payment-method component not slotted in justifi-modular-checkout',
|
|
1167
|
+
FORM_NOT_READY: 'Payment form not ready',
|
|
1168
|
+
VALIDATION_ERROR: 'Validation error',
|
|
1169
|
+
};
|
|
1170
|
+
const TokenizePaymentMethod = class {
|
|
1171
|
+
constructor(hostRef) {
|
|
1172
|
+
registerInstance(this, hostRef);
|
|
1173
|
+
this.errorEvent = createEvent(this, "error-event");
|
|
1174
|
+
this.submitEvent = createEvent(this, "submit-event");
|
|
1175
|
+
this.computedHideSubmitButton = false;
|
|
1176
|
+
this.isLoading = false;
|
|
1177
|
+
this.submitButtonText = 'Submit';
|
|
1178
|
+
}
|
|
1179
|
+
paymentMethodsChanged() {
|
|
1180
|
+
this.setDefaultSelectedPaymentMethod();
|
|
1181
|
+
}
|
|
1182
|
+
connectedCallback() {
|
|
1183
|
+
this.setDefaultSelectedPaymentMethod();
|
|
1184
|
+
this.setComputedHideSubmitButton();
|
|
1185
|
+
}
|
|
1186
|
+
disconnectedCallback() {
|
|
1187
|
+
var _a;
|
|
1188
|
+
(_a = this.analytics) === null || _a === void 0 ? void 0 : _a.cleanup();
|
|
1189
|
+
if (this.unsubscribeFromStore) {
|
|
1190
|
+
this.unsubscribeFromStore();
|
|
1191
|
+
}
|
|
1192
|
+
}
|
|
1193
|
+
componentWillLoad() {
|
|
1194
|
+
checkPkgVersion();
|
|
1195
|
+
this.analytics = new JustifiAnalytics(this);
|
|
1196
|
+
}
|
|
1197
|
+
handleRadioClick(event) {
|
|
1198
|
+
this.selectedPaymentMethod = event.detail;
|
|
1199
|
+
checkoutStore.selectedPaymentMethod = { type: event.detail };
|
|
1200
|
+
}
|
|
1201
|
+
async fillBillingForm(fields) {
|
|
1202
|
+
var _a;
|
|
1203
|
+
(_a = this.billingFormRef) === null || _a === void 0 ? void 0 : _a.fill(fields);
|
|
1204
|
+
}
|
|
1205
|
+
async tokenizePaymentMethod(event) {
|
|
1206
|
+
event === null || event === void 0 ? void 0 : event.preventDefault();
|
|
1207
|
+
this.validateRequiredProps();
|
|
1208
|
+
this.isLoading = true;
|
|
1209
|
+
try {
|
|
1210
|
+
const validation = await this.validate();
|
|
1211
|
+
if (!validation.isValid) {
|
|
1212
|
+
this.errorEvent.emit({
|
|
1213
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
1214
|
+
message: ERROR_MESSAGES.VALIDATION_ERROR,
|
|
1215
|
+
});
|
|
1216
|
+
this.isLoading = false;
|
|
1217
|
+
return;
|
|
1218
|
+
}
|
|
1219
|
+
const tokenizeResponse = await this.resolvePaymentMethod({ isValid: true });
|
|
1220
|
+
if (tokenizeResponse.error) {
|
|
1221
|
+
this.emitError({
|
|
1222
|
+
errorCode: tokenizeResponse.error.code,
|
|
1223
|
+
message: tokenizeResponse.error.message,
|
|
1224
|
+
});
|
|
1225
|
+
}
|
|
1226
|
+
this.submitEvent.emit({ response: tokenizeResponse });
|
|
1227
|
+
return tokenizeResponse;
|
|
1228
|
+
}
|
|
1229
|
+
catch (error) {
|
|
1230
|
+
const errorResponse = this.createErrorResponse(ComponentErrorCodes.TOKENIZE_ERROR, error.message);
|
|
1231
|
+
this.emitError({
|
|
1232
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
1233
|
+
message: error.message,
|
|
1234
|
+
});
|
|
1235
|
+
this.submitEvent.emit({ response: errorResponse });
|
|
1236
|
+
return errorResponse;
|
|
1237
|
+
}
|
|
1238
|
+
finally {
|
|
1239
|
+
this.isLoading = false;
|
|
1240
|
+
}
|
|
1241
|
+
}
|
|
1242
|
+
async validate() {
|
|
1243
|
+
if (!this.areFormsReady()) {
|
|
1244
|
+
return { isValid: false, errors: { general: ERROR_MESSAGES.FORM_NOT_READY } };
|
|
1245
|
+
}
|
|
1246
|
+
const [billingValidation, paymentMethodValidation] = await Promise.all([
|
|
1247
|
+
this.billingFormRef.validate(),
|
|
1248
|
+
this.paymentMethodFormRef.validate(),
|
|
1249
|
+
]);
|
|
1250
|
+
const result = {
|
|
1251
|
+
isValid: billingValidation.isValid && paymentMethodValidation.isValid,
|
|
1252
|
+
errors: Object.assign(Object.assign({}, billingValidation.errors), paymentMethodValidation.errors),
|
|
1253
|
+
};
|
|
1254
|
+
return result;
|
|
1255
|
+
}
|
|
1256
|
+
async tokenize() {
|
|
1257
|
+
try {
|
|
1258
|
+
const billingFormFieldValues = await this.billingFormRef.getValues();
|
|
1259
|
+
const config = {
|
|
1260
|
+
clientId: this.authToken || checkoutStore.authToken,
|
|
1261
|
+
account: this.accountId || checkoutStore.accountId,
|
|
1262
|
+
paymentMethodMetadata: this.buildPaymentMethodMetadata(billingFormFieldValues),
|
|
1263
|
+
};
|
|
1264
|
+
return await this.paymentMethodFormRef.tokenize(config);
|
|
1265
|
+
}
|
|
1266
|
+
catch (error) {
|
|
1267
|
+
return error;
|
|
1268
|
+
}
|
|
1269
|
+
}
|
|
1270
|
+
// 9. Local methods
|
|
1271
|
+
validateRequiredProps() {
|
|
1272
|
+
if (!this.authToken && !checkoutStore.authToken) {
|
|
1273
|
+
this.emitError({
|
|
1274
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
1275
|
+
message: ERROR_MESSAGES.AUTH_TOKEN_REQUIRED,
|
|
1276
|
+
});
|
|
1277
|
+
}
|
|
1278
|
+
if (!this.accountId && !checkoutStore.accountId) {
|
|
1279
|
+
this.emitError({
|
|
1280
|
+
errorCode: ComponentErrorCodes.TOKENIZE_ERROR,
|
|
1281
|
+
message: ERROR_MESSAGES.ACCOUNT_ID_REQUIRED,
|
|
1282
|
+
});
|
|
1283
|
+
}
|
|
1284
|
+
}
|
|
1285
|
+
setDefaultSelectedPaymentMethod() {
|
|
1286
|
+
if (this.selectedPaymentMethod) {
|
|
1287
|
+
return;
|
|
1288
|
+
}
|
|
1289
|
+
if (!this.disableCreditCard) {
|
|
1290
|
+
this.selectedPaymentMethod = PaymentMethodTypes.card;
|
|
1291
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.card };
|
|
1292
|
+
}
|
|
1293
|
+
else if (!this.disableBankAccount) {
|
|
1294
|
+
this.selectedPaymentMethod = PaymentMethodTypes.bankAccount;
|
|
1295
|
+
checkoutStore.selectedPaymentMethod = { type: PaymentMethodTypes.bankAccount };
|
|
1296
|
+
}
|
|
1297
|
+
}
|
|
1298
|
+
setComputedHideSubmitButton() {
|
|
1299
|
+
// If hideSubmitButton prop is explicitly set, use that value
|
|
1300
|
+
if (this.hideSubmitButton !== undefined) {
|
|
1301
|
+
this.computedHideSubmitButton = this.hideSubmitButton;
|
|
1302
|
+
return;
|
|
1303
|
+
}
|
|
1304
|
+
// Otherwise, auto-detect if component is slotted within modular-checkout
|
|
1305
|
+
const isWithinModularCheckout = this.isSlottedWithinModularCheckout();
|
|
1306
|
+
this.computedHideSubmitButton = isWithinModularCheckout;
|
|
1307
|
+
}
|
|
1308
|
+
isSlottedWithinModularCheckout() {
|
|
1309
|
+
var _a;
|
|
1310
|
+
let parent = (_a = this.host) === null || _a === void 0 ? void 0 : _a.parentElement;
|
|
1311
|
+
while (parent) {
|
|
1312
|
+
if (parent.tagName === 'JUSTIFI-MODULAR-CHECKOUT') {
|
|
1313
|
+
return true;
|
|
1314
|
+
}
|
|
1315
|
+
parent = parent.parentElement;
|
|
1316
|
+
}
|
|
1317
|
+
return false;
|
|
1318
|
+
}
|
|
1319
|
+
get availablePaymentMethods() {
|
|
1320
|
+
const methods = [];
|
|
1321
|
+
if (!this.disableCreditCard) {
|
|
1322
|
+
methods.push(PaymentMethodTypes.card);
|
|
1323
|
+
}
|
|
1324
|
+
if (!this.disableBankAccount) {
|
|
1325
|
+
methods.push(PaymentMethodTypes.bankAccount);
|
|
1326
|
+
}
|
|
1327
|
+
return methods;
|
|
1328
|
+
}
|
|
1329
|
+
areFormsReady() {
|
|
1330
|
+
return !!(this.billingFormRef && this.paymentMethodFormRef);
|
|
1331
|
+
}
|
|
1332
|
+
emitError(errorData) {
|
|
1333
|
+
this.errorEvent.emit(Object.assign(Object.assign({}, errorData), { severity: ComponentErrorSeverity.ERROR }));
|
|
1334
|
+
}
|
|
1335
|
+
createErrorResponse(code, message) {
|
|
1336
|
+
return {
|
|
1337
|
+
error: {
|
|
1338
|
+
code: code,
|
|
1339
|
+
message,
|
|
1340
|
+
decline_code: undefined,
|
|
1341
|
+
},
|
|
1342
|
+
};
|
|
1343
|
+
}
|
|
1344
|
+
async resolvePaymentMethod(insuranceValidation) {
|
|
1345
|
+
if (!this.areFormsReady()) {
|
|
1346
|
+
return this.createErrorResponse('form_not_ready', ERROR_MESSAGES.FORM_NOT_READY);
|
|
1347
|
+
}
|
|
1348
|
+
try {
|
|
1349
|
+
const validation = await this.validate();
|
|
1350
|
+
if (!validation.isValid || !insuranceValidation.isValid) {
|
|
1351
|
+
const errorMessage = Object.values(validation.errors)[0] || ERROR_MESSAGES.VALIDATION_ERROR;
|
|
1352
|
+
return {
|
|
1353
|
+
validationError: true,
|
|
1354
|
+
error: {
|
|
1355
|
+
code: 'validation_error',
|
|
1356
|
+
message: String(errorMessage),
|
|
1357
|
+
decline_code: undefined,
|
|
1358
|
+
},
|
|
1359
|
+
};
|
|
1360
|
+
}
|
|
1361
|
+
const result = await this.performTokenization();
|
|
1362
|
+
return result;
|
|
1363
|
+
}
|
|
1364
|
+
catch (error) {
|
|
1365
|
+
return { error };
|
|
1366
|
+
}
|
|
1367
|
+
}
|
|
1368
|
+
async performTokenization() {
|
|
1369
|
+
var _a, _b;
|
|
1370
|
+
const tokenizeResponse = await this.tokenize();
|
|
1371
|
+
if (tokenizeResponse.error) {
|
|
1372
|
+
return { error: tokenizeResponse.error };
|
|
1373
|
+
}
|
|
1374
|
+
const tokenizeResponseData = tokenizeResponse.data;
|
|
1375
|
+
return {
|
|
1376
|
+
token: ((_a = tokenizeResponseData.card) === null || _a === void 0 ? void 0 : _a.token) || ((_b = tokenizeResponseData.bank_account) === null || _b === void 0 ? void 0 : _b.token),
|
|
1377
|
+
data: tokenizeResponseData,
|
|
1378
|
+
};
|
|
1379
|
+
}
|
|
1380
|
+
buildPaymentMethodMetadata(billingFormFieldValues) {
|
|
1381
|
+
return this.shouldSavePaymentMethod
|
|
1382
|
+
? Object.assign(Object.assign({}, billingFormFieldValues), { payment_method_group_id: this.paymentMethodGroupID }) : Object.assign({}, billingFormFieldValues);
|
|
1383
|
+
}
|
|
1384
|
+
get paymentMethodGroupID() {
|
|
1385
|
+
return this.paymentMethodGroupId || checkoutStore.paymentMethodGroupId;
|
|
1386
|
+
}
|
|
1387
|
+
get shouldSavePaymentMethod() {
|
|
1388
|
+
return !!(this.paymentMethodGroupId || checkoutStore.savePaymentMethod);
|
|
1389
|
+
}
|
|
1390
|
+
get shouldHideRadioInput() {
|
|
1391
|
+
return this.disableCreditCard || this.disableBankAccount;
|
|
1392
|
+
}
|
|
1393
|
+
renderPaymentMethodOption(paymentMethodType) {
|
|
1394
|
+
const isSelected = this.selectedPaymentMethod === paymentMethodType && checkoutStore.selectedPaymentMethod.id === undefined;
|
|
1395
|
+
return (h("div", { class: "payment-method" }, h("justifi-radio-list-item", { name: "paymentMethodType", value: paymentMethodType, checked: isSelected, label: PAYMENT_METHOD_TYPE_LABELS[paymentMethodType], hidden: this.shouldHideRadioInput }), isSelected && this.renderSelectedPaymentMethodForm(paymentMethodType)));
|
|
1396
|
+
}
|
|
1397
|
+
renderSelectedPaymentMethodForm(paymentMethodId) {
|
|
1398
|
+
return (h("div", { class: "mt-4 pb-4" }, this.renderPaymentMethodForm(paymentMethodId), h("div", { class: "mt-4" }, h("justifi-billing-form", { ref: (el) => (this.billingFormRef = el), hideCardBillingForm: this.hideCardBillingForm, hideBankAccountBillingForm: this.hideBankAccountBillingForm, paymentMethodType: paymentMethodId })), h("div", { class: "mt-4" }, h("justifi-save-new-payment-method", { hidden: !this.paymentMethodGroupID }))));
|
|
1399
|
+
}
|
|
1400
|
+
renderPaymentMethodForm(paymentMethodId) {
|
|
1401
|
+
return paymentMethodId === PaymentMethodTypes.card ? (h("justifi-card-form", { ref: (el) => (this.paymentMethodFormRef = el) })) : (h("justifi-bank-account-form", { ref: (el) => (this.paymentMethodFormRef = el) }));
|
|
1402
|
+
}
|
|
1403
|
+
render() {
|
|
1404
|
+
return (h(StyledHost, { key: 'a89908d2f192d86edf016b052734f81f46e00f8b' }, h("form", { key: '527d1e5ff94a2db8b2d1223d7beda86fdaf08ff0' }, h("fieldset", { key: 'd8479461d3788dbcb319f1eaf99b7e05c00c49f9' }, h("div", { key: '17f68ee0dceb8353ca54ccf383dc2709444a3b26', class: "row gy-3" }, h("div", { key: '3568f3ac4ef04a9a245d61f2b94f3b79371b0a6f', class: "col-12" }, this.availablePaymentMethods.map((method) => this.renderPaymentMethodOption(method))), h("div", { key: '97be6dbaf8373a82a706a7eb97e9107baa6c1823', class: "col-12" }, h("justifi-button", { key: 'afcd192881ad092f8d31a01e571541079d4d33ac', text: this.submitButtonText, variant: "primary", type: "submit", clickHandler: (e) => this.tokenizePaymentMethod(e), isLoading: this.isLoading, "data-testid": "submit-button", hidden: this.computedHideSubmitButton })))))));
|
|
1405
|
+
}
|
|
1406
|
+
get host() { return getElement(this); }
|
|
1407
|
+
static get watchers() { return {
|
|
1408
|
+
"disableCreditCard": ["paymentMethodsChanged"],
|
|
1409
|
+
"disableBankAccount": ["paymentMethodsChanged"]
|
|
1410
|
+
}; }
|
|
1411
|
+
};
|
|
1412
|
+
|
|
1413
|
+
export { Summary as justifi_checkout_summary, Header as justifi_header, ModularCheckout as justifi_modular_checkout, PlaidPaymentMethod as justifi_plaid_payment_method, SavedPaymentMethods as justifi_saved_payment_methods, SezzlePaymentMethod as justifi_sezzle_payment_method, TokenizePaymentMethod as justifi_tokenize_payment_method };
|