@solvimon/solvimon-web 0.1.0-alpha.17 → 0.1.0-alpha.18

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (168) hide show
  1. package/README.md +28 -26
  2. package/dist/AddPaymentMethodPane.vue_vue_type_script_setup_true_lang-C2IRj-FB.mjs +238 -0
  3. package/dist/AddPaymentMethodPane.vue_vue_type_script_setup_true_lang-Rub9ifBk.js +1 -0
  4. package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-BrPsTuoW.mjs → BillingInformation.vue_vue_type_script_setup_true_lang-BWnZ98RQ.mjs} +2 -2
  5. package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-BuQ8bzar.js → BillingInformation.vue_vue_type_script_setup_true_lang-DurgWlLC.js} +1 -1
  6. package/dist/{CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-CuWrBcoK.mjs → CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-D7gL7dZX.mjs} +3 -3
  7. package/dist/CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-Df7CsbiW.js +1 -0
  8. package/dist/CustomerWalletBalances.vue_vue_type_script_setup_true_lang-OUg4yv7r.mjs +2654 -0
  9. package/dist/CustomerWalletBalances.vue_vue_type_script_setup_true_lang-mM5udvi8.js +1 -0
  10. package/dist/EmptyStatePlaceholder.vue_vue_type_script_setup_true_lang-BIpg-MSJ.mjs +53 -0
  11. package/dist/EmptyStatePlaceholder.vue_vue_type_script_setup_true_lang-BM3p8Pk8.js +1 -0
  12. package/dist/InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-D5eSNYH2.js +1 -0
  13. package/dist/{InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-wxP5IaGt.mjs → InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-DbY35gE_.mjs} +1 -1
  14. package/dist/{InvoiceHeader.vue_vue_type_script_setup_true_lang-05NKI2A0.js → InvoiceHeader.vue_vue_type_script_setup_true_lang-Ci8r6tuC.js} +1 -1
  15. package/dist/{InvoiceHeader.vue_vue_type_script_setup_true_lang-17v07F58.mjs → InvoiceHeader.vue_vue_type_script_setup_true_lang-jshby9pF.mjs} +1 -1
  16. package/dist/PaymentErrorCard.vue_vue_type_script_setup_true_lang-CNKxTtO7.js +1 -0
  17. package/dist/PaymentErrorCard.vue_vue_type_script_setup_true_lang-DBMgilG2.mjs +153 -0
  18. package/dist/PaymentFeedbackCard.vue_vue_type_script_setup_true_lang-CupZFJSF.mjs +52 -0
  19. package/dist/PaymentFeedbackCard.vue_vue_type_script_setup_true_lang-D6lpD1zo.js +1 -0
  20. package/dist/{PaymentHistoryBlock-BitwS9Re.mjs → PaymentHistoryBlock-Bxr8lUGs.mjs} +1 -1
  21. package/dist/{PaymentHistoryBlock-ZtmPXXwI.js → PaymentHistoryBlock-COjIVYX4.js} +1 -1
  22. package/dist/PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-Bmgx7PSt.js +1 -0
  23. package/dist/{PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-C3ZUDUdw.mjs → PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-CDjGab5p.mjs} +1 -1
  24. package/dist/{PaymentIntegrationForm-BZTzCUiu.js → PaymentIntegrationForm-BSauhuKv.js} +1 -1
  25. package/dist/{PaymentIntegrationForm-BK2aLPCo.mjs → PaymentIntegrationForm-PIT8gHYN.mjs} +1 -1
  26. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-5XKz3kop.js +1 -0
  27. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-COO2ZUhN.mjs +148 -0
  28. package/dist/PaymentIntegrationFormAdyen-B-Jbu2hU.js +1 -0
  29. package/dist/PaymentIntegrationFormAdyen-Cjj9aK0E.mjs +729 -0
  30. package/dist/PaymentIntegrationFormStripe-Bnn8S1o5.js +1 -0
  31. package/dist/PaymentIntegrationFormStripe-arpua_ZT.mjs +545 -0
  32. package/dist/PaymentMethodForm-B7T5rrNz.mjs +4 -0
  33. package/dist/PaymentMethodForm-CLz3ZS-b.js +1 -0
  34. package/dist/{PaymentMethodForm.vue_vue_type_script_setup_true_lang-CIQ0vsko.mjs → PaymentMethodForm.vue_vue_type_script_setup_true_lang-C4Zf92QP.mjs} +2 -2
  35. package/dist/{PaymentMethodForm.vue_vue_type_script_setup_true_lang-zRr8iihy.js → PaymentMethodForm.vue_vue_type_script_setup_true_lang-UH9AVXnG.js} +1 -1
  36. package/dist/{PaymentMethodsList.vue_vue_type_script_setup_true_lang-DVeB_mqK.mjs → PaymentMethodsList.vue_vue_type_script_setup_true_lang-CIIt6fGp.mjs} +76 -30
  37. package/dist/PaymentMethodsList.vue_vue_type_script_setup_true_lang-ifai5HVr.js +1 -0
  38. package/dist/{SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-D1TcP9PR.mjs → SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-DaWlLor0.mjs} +2 -2
  39. package/dist/SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-DdUoeTUL.js +1 -0
  40. package/dist/{SubscriptionSchedules.vue_vue_type_script_setup_true_lang-BMXr26gF.mjs → SubscriptionSchedules.vue_vue_type_script_setup_true_lang-CyYhYYRp.mjs} +1 -1
  41. package/dist/SubscriptionSchedules.vue_vue_type_script_setup_true_lang-DdjYVNku.js +1 -0
  42. package/dist/SubscriptionSummary.vue_vue_type_script_setup_true_lang-Cu55ZvCH.js +1 -0
  43. package/dist/{EmptyStatePlaceholder.vue_vue_type_script_setup_true_lang-C3cqlbGY.mjs → SubscriptionSummary.vue_vue_type_script_setup_true_lang-z8P1u1Gi.mjs} +16 -63
  44. package/dist/SubscriptionsList.vue_vue_type_script_setup_true_lang-BKDMwuyh.js +1 -0
  45. package/dist/{SubscriptionsList.vue_vue_type_script_setup_true_lang-BDqX6OaE.mjs → SubscriptionsList.vue_vue_type_script_setup_true_lang-BOUSk2ZB.mjs} +5 -5
  46. package/dist/adyen-BMDZQBUG.js +1 -0
  47. package/dist/{url-BjZ1Pg0l.mjs → adyen-Ba-mF3Jy.mjs} +31 -73
  48. package/dist/component--Y7Igv5i.mjs +1022 -0
  49. package/dist/component-DIy1hvJM.js +1 -0
  50. package/dist/components/BillingInformation/BillingInformation.cjs.js +1 -1
  51. package/dist/components/BillingInformation/BillingInformation.es.js +4 -4
  52. package/dist/components/BillingInformationForm/BillingInformationForm.cjs.js +1 -1
  53. package/dist/components/BillingInformationForm/BillingInformationForm.es.js +4 -4
  54. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.cjs.js +1 -1
  55. package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.es.js +4 -4
  56. package/dist/components/Invoice/Invoice.cjs.js +1 -1
  57. package/dist/components/Invoice/Invoice.es.js +7 -7
  58. package/dist/components/InvoiceDetails/InvoiceDetails.cjs.js +1 -1
  59. package/dist/components/InvoiceDetails/InvoiceDetails.es.js +3 -3
  60. package/dist/components/InvoiceHeader/InvoiceHeader.cjs.js +1 -1
  61. package/dist/components/InvoiceHeader/InvoiceHeader.es.js +4 -4
  62. package/dist/components/InvoicesList/InvoicesList.cjs.js +1 -1
  63. package/dist/components/InvoicesList/InvoicesList.es.js +3 -3
  64. package/dist/components/PaymentHistory/PaymentHistory.cjs.js +1 -1
  65. package/dist/components/PaymentHistory/PaymentHistory.es.js +3 -3
  66. package/dist/components/PaymentMethodForm/PaymentMethodForm.cjs.js +1 -1
  67. package/dist/components/PaymentMethodForm/PaymentMethodForm.es.js +6 -6
  68. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.cjs.js +1 -1
  69. package/dist/components/SubscriptionSchedules/SubscriptionSchedules.es.js +4 -4
  70. package/dist/components/SubscriptionsList/SubscriptionsList.cjs.js +1 -1
  71. package/dist/components/SubscriptionsList/SubscriptionsList.es.js +5 -5
  72. package/dist/components/WalletBalances/WalletBalances.cjs.js +1 -1
  73. package/dist/components/WalletBalances/WalletBalances.es.js +21 -7
  74. package/dist/core/action-request.types.d.ts +1 -13
  75. package/dist/core/index.cjs.js +1 -1
  76. package/dist/core/index.es.js +1 -1
  77. package/dist/{customer-DAgdegIW.mjs → customer-DovIxTG1.mjs} +1 -1
  78. package/dist/{customer-AfRcAZ5P.js → customer-brfznoHY.js} +1 -1
  79. package/dist/en-US-BvOHPudj.js +1 -0
  80. package/dist/{en-US-DSzSbgL5.mjs → en-US-CXDO3qhq.mjs} +53 -0
  81. package/dist/index-BMWWP8xj.js +1 -0
  82. package/dist/index-Do7kzLpg.mjs +265 -0
  83. package/dist/index.cjs.js +1 -1
  84. package/dist/index.es.js +1 -1
  85. package/dist/{invoices-BHgajZHq.js → invoices-Cf3dSYSj.js} +1 -1
  86. package/dist/{invoices-BXDgW8ch.mjs → invoices-Dk-z04lg.mjs} +2 -2
  87. package/dist/{nl-NL-Li7RW89R.mjs → nl-NL-BgL_PuBn.mjs} +55 -1
  88. package/dist/nl-NL-COGUFg60.js +1 -0
  89. package/dist/{paymentMethods-xzFD2L30.mjs → paymentMethods-BnF1XYS1.mjs} +21 -5
  90. package/dist/paymentMethods-DVDC_WfL.js +1 -0
  91. package/dist/{payments-DMvmB5vg.js → payments-DVZFO5yb.js} +1 -1
  92. package/dist/{payments-DV6csRej.mjs → payments-TnRjtlOw.mjs} +1 -1
  93. package/dist/{pricing-BEjY_5wb.js → pricing-CuYndX6t.js} +1 -1
  94. package/dist/{pricing-B1uImUm4.mjs → pricing-GwLCiSzs.mjs} +1 -1
  95. package/dist/{pricingPlanSchedule-C_cqUyTk.mjs → pricingPlanSchedule-CXG3CQ61.mjs} +3 -1
  96. package/dist/{registry-CyENvS6l.mjs → registry-Ck0Gb6rj.mjs} +1 -1
  97. package/dist/{registry-CeMxLjwU.js → registry-Cra6yoB4.js} +1 -1
  98. package/dist/screens/Checkout/Checkout.cjs.js +1 -1
  99. package/dist/screens/Checkout/Checkout.es.js +37 -36
  100. package/dist/screens/CustomerOverview/CustomerOverview.cjs.js +1 -1
  101. package/dist/screens/CustomerOverview/CustomerOverview.es.js +32 -56
  102. package/dist/screens/PayInvoice/PayInvoice.cjs.js +1 -1
  103. package/dist/screens/PayInvoice/PayInvoice.es.js +28 -12
  104. package/dist/screens/PaymentMethodsManagement/PaymentMethodsManagement.cjs.js +1 -1
  105. package/dist/screens/PaymentMethodsManagement/PaymentMethodsManagement.es.js +28 -18
  106. package/dist/screens/SubscriptionDetails/SubscriptionDetails.cjs.js +1 -1
  107. package/dist/screens/SubscriptionDetails/SubscriptionDetails.es.js +436 -89
  108. package/dist/screens/SubscriptionManagement/SubscriptionManagement.cjs.js +1 -1
  109. package/dist/screens/SubscriptionManagement/SubscriptionManagement.es.js +28 -37
  110. package/dist/solvimon-web.css +1 -1
  111. package/dist/{subscription-B4dBAY9C.mjs → subscription-C41lG-rH.mjs} +1 -1
  112. package/dist/subscriptions-BFCKVHnP.js +1 -0
  113. package/dist/subscriptions-vEE4Y7qm.mjs +58 -0
  114. package/dist/{useActionDispatchProvider-zB_GKeUR.mjs → useActionDispatchProvider-BlEf-RZ5.mjs} +1 -1
  115. package/dist/{useActionDispatchProvider-bqR_FeM4.js → useActionDispatchProvider-aJOy3kr1.js} +1 -1
  116. package/dist/{useCustomer-bO4D6e4Z.js → useCustomer-C1XTqmrQ.js} +1 -1
  117. package/dist/{useCustomer-VfeQ6rG2.mjs → useCustomer-Cw8LXT6S.mjs} +2 -2
  118. package/dist/{useIncrementalLoading-C59FXHzp.mjs → useIncrementalLoading-8WtKZ-mP.mjs} +2 -2
  119. package/dist/useIncrementalLoading-CkY2klIW.js +1 -0
  120. package/dist/{useInvoiceData-CxxkBTGY.js → useInvoiceData-BrxMo4Zt.js} +1 -1
  121. package/dist/{useInvoiceData-Dhg-hx8C.mjs → useInvoiceData-Cy_ysMsq.mjs} +2 -2
  122. package/dist/{useInvoicesList-DBz7T7sM.mjs → useInvoicesList-DMsZn1tE.mjs} +4 -4
  123. package/dist/{useInvoicesList-BXZ9uV9i.js → useInvoicesList-DmisMQzy.js} +1 -1
  124. package/dist/{useLoadInitialData-BhpIg7OF.mjs → useLoadInitialData-BP1v7qhd.mjs} +1 -1
  125. package/dist/{useLoadInitialData-BqiAFNFi.js → useLoadInitialData-_BjCD0Jc.js} +1 -1
  126. package/dist/{usePaymentMethodOptions-PcMjtMSF.mjs → usePaymentMethodOptions-CWfGvW0U.mjs} +9 -3
  127. package/dist/{usePaymentMethodOptions-DszFvgKX.js → usePaymentMethodOptions-xeSTmaVo.js} +1 -1
  128. package/dist/{usePaymentMethods-Bb1Xbads.js → usePaymentMethods-CAFMvSOr.js} +1 -1
  129. package/dist/{usePaymentMethods-B5AbGWsn.mjs → usePaymentMethods-Cyk4cjoE.mjs} +2 -2
  130. package/dist/{usePayments-is5c66Z6.js → usePayments-BieVBaz-.js} +1 -1
  131. package/dist/{usePayments-DgoZoBZh.mjs → usePayments-D88XSZfS.mjs} +10 -4
  132. package/dist/{usePortal-DWLtNqBB.mjs → usePortal-0NDlbFr9.mjs} +1 -1
  133. package/dist/{usePortal-C4qWsJeq.js → usePortal-B954nyEB.js} +1 -1
  134. package/dist/{useService-DKm3QtT4.js → useService-BiljI7XA.js} +1 -1
  135. package/dist/{useService-BZqFkz7p.mjs → useService-CqfJi5ST.mjs} +1 -1
  136. package/dist/{useSubscription-CEZJw6wZ.mjs → useSubscription-9rJpFNUF.mjs} +9 -3
  137. package/dist/{useSubscription-DuUNc1_l.js → useSubscription-k3limdu_.js} +1 -1
  138. package/dist/vendor-ui-Dfh3_g4q.js +1 -0
  139. package/dist/{vendor-ui-BoGKOJ36.mjs → vendor-ui-ItGf7wJV.mjs} +1912 -1800
  140. package/package.json +12 -5
  141. package/dist/CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-1Op9GjGZ.js +0 -1
  142. package/dist/CustomerWalletBalances.vue_vue_type_script_setup_true_lang-C66beqgf.js +0 -1
  143. package/dist/CustomerWalletBalances.vue_vue_type_script_setup_true_lang-D2BhuXsh.mjs +0 -77
  144. package/dist/EmptyStatePlaceholder.vue_vue_type_script_setup_true_lang-BbuEBiY3.js +0 -1
  145. package/dist/InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-dwIv_xxf.js +0 -1
  146. package/dist/PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-CMGK71zZ.js +0 -1
  147. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-B_yDNGK8.mjs +0 -1537
  148. package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-GN3WAr10.js +0 -1
  149. package/dist/PaymentMethodSelector.vue_vue_type_script_setup_true_lang-BQIN3zuf.mjs +0 -156
  150. package/dist/PaymentMethodSelector.vue_vue_type_script_setup_true_lang-DyL2-vV0.js +0 -1
  151. package/dist/PaymentMethodsList.vue_vue_type_script_setup_true_lang-OvGGejpX.js +0 -1
  152. package/dist/SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-BxqIfmkK.js +0 -1
  153. package/dist/SubscriptionSchedules.vue_vue_type_script_setup_true_lang-BKz2QQn9.js +0 -1
  154. package/dist/SubscriptionsList.vue_vue_type_script_setup_true_lang-CyAFjCh7.js +0 -1
  155. package/dist/component-CUJ_G2Nw.mjs +0 -962
  156. package/dist/component-CiKxWtdx.js +0 -1
  157. package/dist/en-US-QzQnGXP1.js +0 -1
  158. package/dist/index-CzL1ZcGi.mjs +0 -85
  159. package/dist/index-DRdBmZ2-.js +0 -1
  160. package/dist/nl-NL-C4rr-1tr.js +0 -1
  161. package/dist/paymentMethods-BMcc-eTl.js +0 -1
  162. package/dist/subscriptions-CrNDM9qa.mjs +0 -79
  163. package/dist/subscriptions-DC-mxa17.js +0 -1
  164. package/dist/url-D8GJi5rF.js +0 -1
  165. package/dist/useIncrementalLoading-BgWuwoMo.js +0 -1
  166. package/dist/useTopUpModal-DNyWrHDv.mjs +0 -1012
  167. package/dist/useTopUpModal-DeF-cfCK.js +0 -1
  168. package/dist/vendor-ui-BuRqLx74.js +0 -1
@@ -1,1537 +0,0 @@
1
- import { defineComponent, ref, onMounted, onBeforeUnmount, watch, openBlock, createElementBlock, computed, createBlock, withCtx, unref, createVNode, createTextVNode, toDisplayString, createCommentVNode, createElementVNode, inject, Fragment, renderList } from "vue";
2
- import { r as isEqual, u as useIntl, e as _sfc_main$7, q as _sfc_main$8, E as formatAmount, c as _sfc_main$9, a8 as _sfc_main$a } from "./vendor-ui-BoGKOJ36.mjs";
3
- import { t as toMinorUnitAmount, _ as _sfc_main$6, c as createReturnUrl, g as getQueryParam, P as PAYMENT_ACCEPTOR_ID_QUERY_STRING, m as mapAdyenPaymentMethods, a as getAdyenEnvironmentFromPaymentMethodOptionsResponse, b as getAdyenClientKeyFromPaymentMethodOptionsResponse, R as REDIRECT_RESULT_QUERY_STRING, d as transformObjectToAdyenObject } from "./url-BjZ1Pg0l.mjs";
4
- import { c as createPaymentsService } from "./payments-DV6csRej.mjs";
5
- import { c as createPaymentMethodsService } from "./paymentMethods-xzFD2L30.mjs";
6
- import { a as useLogger, E as EXPERIMENTAL_FEATURE_INJECTION_KEY } from "./component-CUJ_G2Nw.mjs";
7
- const isAdyenPaymentIntegration = (paymentMethodOption) => {
8
- var _a;
9
- return ((_a = paymentMethodOption.integration.payment_gateway) == null ? void 0 : _a.variant) === "ADYEN";
10
- };
11
- const isStripePaymentIntegration = (paymentMethodOption) => {
12
- var _a;
13
- return ((_a = paymentMethodOption.integration.payment_gateway) == null ? void 0 : _a.variant) === "STRIPE";
14
- };
15
- const isSelectedIntegration = ({
16
- selectedIntegration,
17
- paymentMethodOption
18
- }) => {
19
- var _a, _b;
20
- return selectedIntegration === ((_b = (_a = paymentMethodOption.integration) == null ? void 0 : _a.payment_gateway) == null ? void 0 : _b.variant);
21
- };
22
- const STRIPE_SCRIPT_URL = "https://js.stripe.com/dahlia/stripe.js";
23
- const STRIPE_FRAME_SRCDOC = `<!DOCTYPE html>
24
- <html>
25
- <head>
26
- <meta charset="UTF-8">
27
- <meta name="viewport" content="width=device-width, initial-scale=1">
28
- <style>
29
- * { box-sizing: border-box; margin: 0; padding: 0; }
30
- body { overflow: hidden; }
31
- </style>
32
- </head>
33
- <body>
34
- <div id="stripe-root"></div>
35
- <script src="${STRIPE_SCRIPT_URL}"><\/script>
36
- <script>
37
- (function () {
38
- let stripe, elements, countryCode, email, name, parentOrigin;
39
-
40
- window.addEventListener('message', function (event) {
41
- if (!event.data || typeof event.data !== 'object') return;
42
- if (event.source !== window.parent) return;
43
-
44
- if (event.data.type === 'stripe:init') {
45
- parentOrigin = event.origin;
46
- countryCode = event.data.countryCode;
47
- email = event.data.email;
48
- name = event.data.name;
49
- stripe = Stripe(event.data.publicKey);
50
- elements = stripe.elements(event.data.options);
51
- const paymentElement = elements.create('payment', { layout: { type: 'accordion', defaultCollapsed: false }, wallets: event.data.options.wallets, fields: event.data.options.fields });
52
-
53
- paymentElement.on('ready', function () {
54
- parent.postMessage({ type: 'stripe:ready' }, parentOrigin);
55
- });
56
-
57
- paymentElement.on('change', function (e) {
58
- parent.postMessage({ type: 'stripe:change', paymentMethodType: e.value.type }, parentOrigin);
59
- });
60
-
61
- paymentElement.on('loaderror', function (e) {
62
- parent.postMessage({
63
- type: 'stripe:loaderror',
64
- error: { message: e.error.message, type: e.error.type }
65
- }, parentOrigin);
66
- });
67
-
68
- paymentElement.mount('#stripe-root');
69
-
70
- new ResizeObserver(function () {
71
- parent.postMessage({
72
- type: 'stripe:resize',
73
- height: document.documentElement.scrollHeight
74
- }, parentOrigin);
75
- }).observe(document.documentElement);
76
- }
77
-
78
- if (event.data.type === 'stripe:submit') {
79
- if (!elements || !parentOrigin || event.origin !== parentOrigin) return;
80
- const submitEmail = 'email' in event.data ? event.data.email : email;
81
- const submitName = 'name' in event.data ? event.data.name : name;
82
- elements.submit().then(function (submitResult) {
83
- if (submitResult.error) {
84
- parent.postMessage({
85
- type: 'stripe:submit:error',
86
- error: {
87
- message: submitResult.error.message,
88
- type: submitResult.error.type,
89
- code: submitResult.error.code
90
- }
91
- }, parentOrigin);
92
- return;
93
- }
94
- const billingDetails = {};
95
- if (countryCode) billingDetails.address = { country: countryCode };
96
- if (submitEmail) billingDetails.email = submitEmail;
97
- if (submitName) billingDetails.name = submitName;
98
- const tokenParams = Object.keys(billingDetails).length
99
- ? { payment_method_data: { billing_details: billingDetails } }
100
- : {};
101
- stripe.createConfirmationToken({ elements: elements, params: tokenParams }).then(function (tokenResult) {
102
- if (tokenResult.error) {
103
- parent.postMessage({
104
- type: 'stripe:submit:error',
105
- error: {
106
- message: tokenResult.error.message,
107
- type: tokenResult.error.type,
108
- code: tokenResult.error.code
109
- }
110
- }, parentOrigin);
111
- return;
112
- }
113
- parent.postMessage({
114
- type: 'stripe:submit:success',
115
- confirmationTokenId: tokenResult.confirmationToken.id
116
- }, parentOrigin);
117
- });
118
- });
119
- }
120
- });
121
- })();
122
- <\/script>
123
- </body>
124
- </html>`;
125
- const _hoisted_1$1 = ["src", "height"];
126
- const _sfc_main$5 = /* @__PURE__ */ defineComponent({
127
- __name: "PaymentIntegrationFormStripeFrame",
128
- props: {
129
- publicKey: { type: String },
130
- options: { type: Object },
131
- countryCode: { type: String },
132
- email: { type: String },
133
- name: { type: String }
134
- },
135
- emits: ["ready", "change", "loaderror", "submit-success", "submit-error"],
136
- setup(__props, { expose: __expose, emit: __emit }) {
137
- const props = __props;
138
- const emit = __emit;
139
- __expose({ triggerSubmit });
140
- const iframeRef = ref();
141
- const iframeHeight = ref(0);
142
- const iframeSrc = ref();
143
- function sendInit() {
144
- var _a, _b;
145
- (_b = (_a = iframeRef.value) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(
146
- {
147
- type: "stripe:init",
148
- publicKey: props.publicKey,
149
- options: props.options,
150
- countryCode: props.countryCode,
151
- email: props.email,
152
- name: props.name
153
- },
154
- "*"
155
- );
156
- }
157
- function triggerSubmit() {
158
- var _a, _b;
159
- (_b = (_a = iframeRef.value) == null ? void 0 : _a.contentWindow) == null ? void 0 : _b.postMessage(
160
- { type: "stripe:submit", email: props.email, name: props.name },
161
- "*"
162
- );
163
- }
164
- function isRecord(value) {
165
- return typeof value === "object" && value !== null;
166
- }
167
- function handleMessage(event) {
168
- if (!iframeRef.value || event.source !== iframeRef.value.contentWindow) return;
169
- if (!isRecord(event.data)) return;
170
- const data = event.data;
171
- const type = data["type"];
172
- if (typeof type !== "string" || !type.startsWith("stripe:")) return;
173
- switch (type) {
174
- case "stripe:ready":
175
- emit("ready");
176
- break;
177
- case "stripe:change":
178
- emit(
179
- "change",
180
- typeof data["paymentMethodType"] === "string" ? data["paymentMethodType"] : "card"
181
- );
182
- break;
183
- case "stripe:loaderror": {
184
- const raw = isRecord(data["error"]) ? data["error"] : {};
185
- emit("loaderror", {
186
- message: typeof raw["message"] === "string" ? raw["message"] : void 0,
187
- type: typeof raw["type"] === "string" ? raw["type"] : void 0
188
- });
189
- break;
190
- }
191
- case "stripe:resize":
192
- if (typeof data["height"] === "number") {
193
- iframeHeight.value = data["height"];
194
- }
195
- break;
196
- case "stripe:submit:success":
197
- if (typeof data["confirmationTokenId"] === "string") {
198
- emit("submit-success", data["confirmationTokenId"]);
199
- }
200
- break;
201
- case "stripe:submit:error": {
202
- const raw = isRecord(data["error"]) ? data["error"] : {};
203
- emit("submit-error", {
204
- message: typeof raw["message"] === "string" ? raw["message"] : void 0,
205
- type: typeof raw["type"] === "string" ? raw["type"] : void 0,
206
- code: typeof raw["code"] === "string" ? raw["code"] : void 0
207
- });
208
- break;
209
- }
210
- }
211
- }
212
- onMounted(() => {
213
- const blob = new Blob([STRIPE_FRAME_SRCDOC], { type: "text/html" });
214
- iframeSrc.value = URL.createObjectURL(blob);
215
- window.addEventListener("message", handleMessage);
216
- });
217
- onBeforeUnmount(() => {
218
- window.removeEventListener("message", handleMessage);
219
- if (iframeSrc.value) URL.revokeObjectURL(iframeSrc.value);
220
- });
221
- watch(
222
- () => props.options,
223
- (newOptions, oldOptions) => {
224
- if (isEqual(newOptions, oldOptions)) return;
225
- sendInit();
226
- },
227
- { deep: true }
228
- );
229
- return (_ctx, _cache) => {
230
- return openBlock(), createElementBlock("iframe", {
231
- ref_key: "iframeRef",
232
- ref: iframeRef,
233
- src: iframeSrc.value,
234
- height: iframeHeight.value || void 0,
235
- frameborder: "0",
236
- style: { "width": "100%", "display": "block", "border": "none" },
237
- title: "Payment form",
238
- onLoad: sendInit
239
- }, null, 40, _hoisted_1$1);
240
- };
241
- }
242
- });
243
- const STRIPE_WALLETS = { link: "never" };
244
- const STRIPE_APPEARANCE = {
245
- variables: { borderRadius: "4px", colorBackground: "rgba(243, 244, 246, 0.5)" },
246
- rules: {
247
- ".TermsText": { fontSize: "14px" },
248
- ".Input": {
249
- backgroundColor: "rgba(243, 244, 246, 0.5)",
250
- fontSize: "14px",
251
- borderColor: "rgb(229, 231, 235)"
252
- }
253
- }
254
- };
255
- function getFields(email, name) {
256
- return {
257
- billingDetails: {
258
- address: { country: "never" },
259
- ...email ? { email: "never" } : {},
260
- ...name ? { name: "never" } : {}
261
- }
262
- };
263
- }
264
- function getFrameOptions({
265
- amount,
266
- email,
267
- name,
268
- variant
269
- }) {
270
- const currency = amount.currency.toLowerCase();
271
- const fields = getFields(email, name);
272
- if (variant === "TOKENIZE") {
273
- return {
274
- mode: "setup",
275
- currency,
276
- setup_future_usage: "off_session",
277
- wallets: STRIPE_WALLETS,
278
- fields,
279
- appearance: STRIPE_APPEARANCE
280
- };
281
- }
282
- return {
283
- mode: "payment",
284
- currency,
285
- amount: toMinorUnitAmount(amount).value,
286
- setup_future_usage: "off_session",
287
- wallets: STRIPE_WALLETS,
288
- fields,
289
- appearance: STRIPE_APPEARANCE
290
- };
291
- }
292
- const _sfc_main$4 = /* @__PURE__ */ defineComponent({
293
- __name: "PaymentCompletedCard",
294
- props: {
295
- amount: { type: Object },
296
- variant: { type: String }
297
- },
298
- setup(__props) {
299
- const props = __props;
300
- const { $t } = useIntl();
301
- const title = computed(
302
- () => props.variant === "AUTHORIZE" ? $t({
303
- defaultMessage: "Payment successful",
304
- description: "The title for when a payment has been successful",
305
- id: "payment_completed_card.title.authorize"
306
- }) : $t({
307
- defaultMessage: "Your payment method is added",
308
- description: "The title for when a payment method was successfully added",
309
- id: "payment_completed_card.title.tokenize"
310
- })
311
- );
312
- return (_ctx, _cache) => {
313
- return openBlock(), createBlock(_sfc_main$6, {
314
- status: "success",
315
- title: title.value
316
- }, {
317
- default: withCtx(() => [
318
- __props.amount ? (openBlock(), createBlock(unref(_sfc_main$7), {
319
- key: 0,
320
- variant: "body-sm",
321
- class: "mt-1"
322
- }, {
323
- default: withCtx(() => [
324
- createVNode(unref(_sfc_main$8), { icon: "check" }),
325
- createTextVNode(toDisplayString(unref(formatAmount)(__props.amount)), 1)
326
- ]),
327
- _: 1
328
- })) : createCommentVNode("", true),
329
- createVNode(unref(_sfc_main$7), {
330
- variant: "body-xs",
331
- shade: "lighter"
332
- }, {
333
- default: withCtx(() => [
334
- createTextVNode(toDisplayString(unref($t)({
335
- defaultMessage: "You are being redirected...",
336
- description: "The text shown after a successful message before a redirect",
337
- id: "payment_completed_card.redirect_message"
338
- })), 1)
339
- ]),
340
- _: 1
341
- })
342
- ]),
343
- _: 1
344
- }, 8, ["title"]);
345
- };
346
- }
347
- });
348
- const ErrorMap = {
349
- UNKNOWN_ERROR: {
350
- title: "Something went wrong",
351
- message: "An unknown error has occurred",
352
- isReloadButtonVisible: true
353
- },
354
- AUTHORIZATION_FAILED: {
355
- title: "Payment failed",
356
- message: "The payment failed"
357
- },
358
- PAYMENT_DETAILS_CALL_FAILED: {
359
- title: "Payment details call failed",
360
- message: "There was a problem getting the payment details"
361
- },
362
- PAYMENT_METHOD_STORAGE_FAILED: {
363
- title: "Failed storing payment method",
364
- message: "Something went wrong with storing the payment method"
365
- },
366
- REDIRECT_RESULT_PAYMENT_ACCEPTOR_MISSING: {
367
- title: "Missing payment acceptor",
368
- message: "A redirect result is set, but a payment acceptor is missing in the url"
369
- },
370
- TOKENIZE_FAILED: {
371
- title: "Tokenization failed",
372
- message: "The tokenization of the payment method has failed"
373
- },
374
- PAYMENT_INTEGRATION_INITIALIZATION_FAILED: {
375
- title: "Failed loading payment methods",
376
- message: "Failed loading payment integration",
377
- isReloadButtonVisible: true
378
- },
379
- RESOURCE_REVOKED: {
380
- title: "Resource revoked",
381
- message: "The resource has been revoked",
382
- isReloadButtonVisible: true
383
- }
384
- };
385
- const _hoisted_1 = { class: "flex flex-col items-center gap-6" };
386
- const _sfc_main$3 = /* @__PURE__ */ defineComponent({
387
- __name: "PaymentErrorCard",
388
- props: {
389
- error: { type: Object }
390
- },
391
- setup(__props) {
392
- const props = __props;
393
- const { $t } = useIntl();
394
- const errorConfig = computed(() => ErrorMap[props.error.code]);
395
- const reload = () => {
396
- window.location.reload();
397
- };
398
- return (_ctx, _cache) => {
399
- return openBlock(), createBlock(_sfc_main$6, {
400
- status: "error",
401
- title: errorConfig.value.title
402
- }, {
403
- default: withCtx(() => [
404
- createElementVNode("div", _hoisted_1, [
405
- createVNode(unref(_sfc_main$7), {
406
- variant: "body-xs",
407
- shade: "lighter",
408
- class: "mt-3"
409
- }, {
410
- default: withCtx(() => [
411
- createTextVNode(toDisplayString(errorConfig.value.message), 1)
412
- ]),
413
- _: 1
414
- }),
415
- errorConfig.value.isReloadButtonVisible ? (openBlock(), createBlock(unref(_sfc_main$9), {
416
- key: 0,
417
- type: "button",
418
- color: "gray",
419
- variant: "outline",
420
- onClick: reload
421
- }, {
422
- default: withCtx(() => [
423
- createTextVNode(toDisplayString(unref($t)({
424
- defaultMessage: "Try again",
425
- description: "Retry button text when an error has happened during a payment",
426
- id: "payments.retry_button.label"
427
- })), 1)
428
- ]),
429
- _: 1
430
- })) : createCommentVNode("", true)
431
- ])
432
- ]),
433
- _: 1
434
- }, 8, ["title"]);
435
- };
436
- }
437
- });
438
- const PAYMENT_GATEWAY_VARIANT_STRIPE = "STRIPE";
439
- const _sfc_main$2 = /* @__PURE__ */ defineComponent({
440
- __name: "PaymentIntegrationFormStripe",
441
- props: {
442
- countryCode: { type: String },
443
- customerId: { type: String },
444
- invoiceId: { type: String },
445
- paymentMethodOptionResponseEntry: { type: Object },
446
- variant: { type: String },
447
- selected: { type: Boolean },
448
- amount: { type: Object },
449
- validateOnSubmit: { type: Function, default: () => Promise.resolve(true) },
450
- context: { type: Object },
451
- email: { type: String },
452
- name: { type: String },
453
- forceStorePaymentMethod: { type: Boolean }
454
- },
455
- emits: ["select", "payment-failed", "payment-success", "ready"],
456
- setup(__props, { expose: __expose, emit: __emit }) {
457
- const props = __props;
458
- const emit = __emit;
459
- __expose({ submit });
460
- const showPaymentSuccess = ref(false);
461
- const integrationError = ref();
462
- const frameRef = ref();
463
- const frameOptions = computed(
464
- () => getFrameOptions({ amount: props.amount, email: props.email, name: props.name, variant: props.variant })
465
- );
466
- const stripeInstance = ref(null);
467
- const logger = useLogger();
468
- const { authorizePayment } = createPaymentsService();
469
- const { tokenizePaymentMethod } = createPaymentMethodsService();
470
- const publicKey = computed(
471
- () => {
472
- var _a, _b;
473
- return (_b = (_a = props.paymentMethodOptionResponseEntry.integration.payment_gateway) == null ? void 0 : _a.stripe) == null ? void 0 : _b.public_key;
474
- }
475
- );
476
- function submit() {
477
- handleSubmit().catch((error) => {
478
- logger.error(
479
- "STRIPE_SUBMIT_FAILED",
480
- "Unexpected error during Stripe submission",
481
- {},
482
- error
483
- );
484
- });
485
- }
486
- async function handleSubmit() {
487
- var _a;
488
- const isValid = await props.validateOnSubmit();
489
- if (!isValid) {
490
- return;
491
- }
492
- (_a = frameRef.value) == null ? void 0 : _a.triggerSubmit();
493
- }
494
- function loadStripeDahlia(key) {
495
- return new Promise((resolve, reject) => {
496
- if (window.Stripe) {
497
- resolve(window.Stripe(key));
498
- return;
499
- }
500
- const script = document.createElement("script");
501
- script.src = STRIPE_SCRIPT_URL;
502
- script.onload = () => {
503
- if (!window.Stripe) {
504
- reject(new Error("Stripe not available after script load"));
505
- return;
506
- }
507
- resolve(window.Stripe(key));
508
- };
509
- script.onerror = () => reject(new Error("Failed to load Stripe.js"));
510
- document.head.appendChild(script);
511
- });
512
- }
513
- async function getStripeInstance() {
514
- if (stripeInstance.value) {
515
- return stripeInstance.value;
516
- }
517
- const key = publicKey.value;
518
- if (!key) {
519
- throw new Error("Missing Stripe public key");
520
- }
521
- const stripe = await loadStripeDahlia(key);
522
- stripeInstance.value = stripe;
523
- return stripe;
524
- }
525
- async function handleConfirmationToken(confirmationTokenId) {
526
- const paymentAcceptorId = props.paymentMethodOptionResponseEntry.payment_acceptor.id;
527
- const returnUrl = createReturnUrl({
528
- paymentAcceptorId,
529
- redirectUrl: window.location.href
530
- });
531
- if (props.variant === "AUTHORIZE") {
532
- try {
533
- const result = await authorizePayment({
534
- payment_acceptor_id: paymentAcceptorId,
535
- ...props.customerId ? { customer_id: props.customerId } : {},
536
- payment_gateway_variant: PAYMENT_GATEWAY_VARIANT_STRIPE,
537
- stripe: { confirmation_token_id: confirmationTokenId },
538
- amount: props.amount,
539
- ...props.context && props.context.type !== "CHARGE_ON_DEMAND" ? { context: props.context } : {},
540
- return_url: returnUrl
541
- });
542
- await handlePaymentResult(result);
543
- } catch (error) {
544
- logger.error(
545
- "PAYMENT_AUTHORIZATION_FAILED",
546
- `Failed payment authorization for payment acceptor with id ${paymentAcceptorId}`,
547
- { error }
548
- );
549
- emitError({ code: "UNKNOWN_ERROR", message: "Payment authorization failed", error });
550
- }
551
- return;
552
- }
553
- if (props.variant === "TOKENIZE") {
554
- if (!props.customerId) {
555
- logger.error(
556
- "TOKENIZATION_FAILED",
557
- `Missing customer id for payment acceptor with id ${paymentAcceptorId}`
558
- );
559
- return;
560
- }
561
- try {
562
- const result = await tokenizePaymentMethod({
563
- customer_id: props.customerId,
564
- payment_acceptor_id: paymentAcceptorId,
565
- payment_gateway_variant: PAYMENT_GATEWAY_VARIANT_STRIPE,
566
- stripe: { confirmation_token_id: confirmationTokenId },
567
- return_url: returnUrl
568
- });
569
- await handlePaymentResult(result);
570
- } catch (error) {
571
- logger.error(
572
- "TOKENIZATION_FAILED",
573
- `Tokenization failed for payment acceptor with id ${paymentAcceptorId}`,
574
- { error }
575
- );
576
- emitError({ code: "UNKNOWN_ERROR", message: "Tokenization failed", error });
577
- }
578
- }
579
- }
580
- async function handlePaymentResult(result) {
581
- var _a;
582
- if (result.status === "ACTION_REQUIRED" && result.action.payment_gateway_variant === PAYMENT_GATEWAY_VARIANT_STRIPE) {
583
- const clientSecret = result.action.client_secret || ((_a = result.action.data) == null ? void 0 : _a.client_secret);
584
- if (!clientSecret) {
585
- logger.error(
586
- "STRIPE_ACTION_FAILED",
587
- "Missing client_secret in Stripe ACTION_REQUIRED response"
588
- );
589
- emitError({ code: "UNKNOWN_ERROR", message: "Payment action failed", error: result });
590
- return;
591
- }
592
- let stripe;
593
- try {
594
- stripe = await getStripeInstance();
595
- } catch (error2) {
596
- logger.error("STRIPE_ACTION_FAILED", "Failed to load Stripe.js", { error: error2 });
597
- emitError({ code: "UNKNOWN_ERROR", message: "Payment action failed", error: error2 });
598
- return;
599
- }
600
- const { error } = await stripe.handleNextAction({ clientSecret });
601
- if (error) {
602
- logger.error("STRIPE_ACTION_FAILED", "Stripe handleNextAction failed", { error });
603
- emitError({ code: "UNKNOWN_ERROR", message: "Payment action failed", error });
604
- return;
605
- }
606
- showPaymentSuccess.value = true;
607
- emit("payment-success");
608
- return;
609
- }
610
- if (result.status === "SUCCESS") {
611
- showPaymentSuccess.value = true;
612
- emit("payment-success");
613
- return;
614
- }
615
- logger.error("STRIPE_ACTION_FAILED", "Unexpected payment result status", { error: result });
616
- emitError({ code: "UNKNOWN_ERROR", message: "Payment failed", error: result });
617
- }
618
- async function handleRedirectReturn() {
619
- const paymentAcceptorId = props.paymentMethodOptionResponseEntry.payment_acceptor.id;
620
- const urlPaymentAcceptorId = getQueryParam(PAYMENT_ACCEPTOR_ID_QUERY_STRING);
621
- if (urlPaymentAcceptorId !== paymentAcceptorId) return;
622
- const redirectStatus = getQueryParam("redirect_status");
623
- const paymentIntentClientSecret = getQueryParam("payment_intent_client_secret");
624
- const setupIntentClientSecret = getQueryParam("setup_intent_client_secret");
625
- if (!redirectStatus || !paymentIntentClientSecret && !setupIntentClientSecret) return;
626
- if (redirectStatus === "succeeded") {
627
- showPaymentSuccess.value = true;
628
- emit("payment-success");
629
- return;
630
- }
631
- logger.error("STRIPE_REDIRECT_RETURN_FAILED", "Stripe redirect returned non-succeeded status", {
632
- redirectStatus
633
- });
634
- emitError({
635
- code: "UNKNOWN_ERROR",
636
- message: "Payment failed",
637
- error: new globalThis.Error(`Stripe redirect returned status: ${redirectStatus}`)
638
- });
639
- }
640
- function handleReady() {
641
- emit("select", {
642
- paymentMethodType: "card",
643
- paymentGatewayVariant: PAYMENT_GATEWAY_VARIANT_STRIPE
644
- });
645
- emit("ready");
646
- }
647
- function handleLoadError(error) {
648
- emitError({
649
- code: "UNKNOWN_ERROR",
650
- message: error.message ?? "Failed to load payment form",
651
- error
652
- });
653
- }
654
- function emitError(err) {
655
- integrationError.value = err;
656
- emit("payment-failed", err);
657
- }
658
- onMounted(() => {
659
- handleRedirectReturn().catch((error) => {
660
- logger.error("STRIPE_REDIRECT_RETURN_FAILED", "handleRedirectReturn threw unexpectedly", {
661
- error
662
- });
663
- });
664
- });
665
- onBeforeUnmount(() => {
666
- stripeInstance.value = null;
667
- });
668
- return (_ctx, _cache) => {
669
- return showPaymentSuccess.value ? (openBlock(), createBlock(_sfc_main$4, {
670
- key: 0,
671
- variant: __props.variant
672
- }, null, 8, ["variant"])) : integrationError.value ? (openBlock(), createBlock(_sfc_main$3, {
673
- key: 1,
674
- error: integrationError.value
675
- }, null, 8, ["error"])) : publicKey.value ? (openBlock(), createBlock(_sfc_main$5, {
676
- key: 2,
677
- ref_key: "frameRef",
678
- ref: frameRef,
679
- "public-key": publicKey.value,
680
- options: frameOptions.value,
681
- "country-code": __props.countryCode,
682
- email: __props.email,
683
- name: __props.name,
684
- onReady: handleReady,
685
- onChange: _cache[0] || (_cache[0] = (type) => emit("select", {
686
- paymentMethodType: type,
687
- paymentGatewayVariant: PAYMENT_GATEWAY_VARIANT_STRIPE
688
- })),
689
- onLoaderror: handleLoadError,
690
- onSubmitSuccess: handleConfirmationToken,
691
- onSubmitError: _cache[1] || (_cache[1] = (error) => unref(logger).error("STRIPE_CONFIRMATION_TOKEN_FAILED", "Stripe submission failed", {
692
- error
693
- }))
694
- }, null, 8, ["public-key", "options", "country-code", "email", "name"])) : createCommentVNode("", true);
695
- };
696
- }
697
- });
698
- const getOverriddenTranslations = (variant) => {
699
- let result = {};
700
- if (variant === "TOKENIZE") {
701
- result = {
702
- "en-US": {
703
- payButton: "Add payment method",
704
- confirmPurchase: "Add payment method"
705
- },
706
- "fr-FR": {
707
- payButton: "Ajouter un moyen de paiement",
708
- confirmPurchase: "Ajouter un moyen de paiement"
709
- },
710
- "de-DE": {
711
- payButton: "Zahlungsmethode hinzufügen",
712
- confirmPurchase: "Zahlungsmethode hinzufügen"
713
- },
714
- "it-IT": {
715
- payButton: "Aggiungi metodo di pagamento",
716
- confirmPurchase: "Aggiungi metodo di pagamento"
717
- },
718
- "es-ES": {
719
- payButton: "Añadir método de pago",
720
- confirmPurchase: "Añadir método de pago"
721
- },
722
- "nl-NL": {
723
- payButton: "Betaalmethode toevoegen",
724
- confirmPurchase: "Betaalmethode toevoegen"
725
- },
726
- "pt-BR": {
727
- payButton: "Adicionar método de pagamento",
728
- confirmPurchase: "Adicionar método de pagamento"
729
- },
730
- "pt-PT": {
731
- payButton: "Adicionar método de pagamento",
732
- confirmPurchase: "Adicionar método de pagamento"
733
- },
734
- "pl-PL": {
735
- payButton: "Dodaj metodę płatności",
736
- confirmPurchase: "Dodaj metodę płatności"
737
- },
738
- "ru-RU": {
739
- payButton: "Добавить способ оплаты",
740
- confirmPurchase: "Добавить способ оплаты"
741
- },
742
- "sv-SE": {
743
- payButton: "Lägg till betalningsmetod",
744
- confirmPurchase: "Lägg till betalningsmetod"
745
- },
746
- "da-DK": {
747
- payButton: "Tilføj betalingsmetode",
748
- confirmPurchase: "Tilføj betalingsmetode"
749
- },
750
- "fi-FI": {
751
- payButton: "Lisää maksutapa",
752
- confirmPurchase: "Lisää maksutapa"
753
- },
754
- "no-NO": {
755
- payButton: "Legg til betalingsmetode",
756
- confirmPurchase: "Legg til betalingsmetode"
757
- },
758
- "cs-CZ": {
759
- payButton: "Přidat platební metodu",
760
- confirmPurchase: "Přidat platební metodu"
761
- },
762
- "hu-HU": {
763
- payButton: "Fizetési mód hozzáadása",
764
- confirmPurchase: "Fizetési mód hozzáadása"
765
- },
766
- "ro-RO": {
767
- payButton: "Adăugați metodă de plată",
768
- confirmPurchase: "Adăugați metodă de plată"
769
- },
770
- "ja-JP": {
771
- payButton: "支払い方法を追加",
772
- confirmPurchase: "支払い方法を追加"
773
- },
774
- "ko-KR": {
775
- payButton: "결제 수단 추가",
776
- confirmPurchase: "결제 수단 추가"
777
- },
778
- "zh-CN": {
779
- payButton: "添加支付方式",
780
- confirmPurchase: "添加支付方式"
781
- },
782
- "zh-TW": {
783
- payButton: "新增付款方式",
784
- confirmPurchase: "新增付款方式"
785
- },
786
- ar: {
787
- payButton: "إضافة وسيلة دفع",
788
- confirmPurchase: "إضافة وسيلة دفع"
789
- },
790
- "hr-HR": {
791
- payButton: "Dodajte način plačanja",
792
- confirmPurchase: "Dodajte način plačanja"
793
- },
794
- "el-GR": {
795
- payButton: "Προσθήκη μεθόδου πληρωμής",
796
- confirmPurchase: "Προσθήκη μεθόδου πληρωμής"
797
- },
798
- "sk-SK": {
799
- payButton: "Pridať spôsob platby",
800
- confirmPurchase: "Pridať spôsob platby"
801
- },
802
- "sl-SI": {
803
- payButton: "Dodajte način plačanja",
804
- confirmPurchase: "Dodajte način plačanja"
805
- },
806
- "bg-BG": {
807
- payButton: "Добавяне на начин на плащане",
808
- confirmPurchase: "Добавяне на начин на плащане"
809
- },
810
- "ca-ES": {
811
- payButton: "Afegir mètode de pagament",
812
- confirmPurchase: "Afegir mètode de pagament"
813
- },
814
- "et-EE": {
815
- payButton: "Lisa makseviis",
816
- confirmPurchase: "Lisa makseviis"
817
- },
818
- "lv-LV": {
819
- payButton: "Pievienot maksājuma veidu",
820
- confirmPurchase: "Pievienot maksājuma veidu"
821
- },
822
- "lt-LT": {
823
- payButton: "Pridėti mokėjimo metodą",
824
- confirmPurchase: "Pridėti mokėjimo metodą"
825
- }
826
- };
827
- }
828
- return result;
829
- };
830
- const useExperimentalFeature = () => {
831
- const experimentalFeature = inject(EXPERIMENTAL_FEATURE_INJECTION_KEY);
832
- return experimentalFeature;
833
- };
834
- const EXPRESS_PAYMENT_METHOD_TYPES = ["applepay"];
835
- function filterOutExpressPaymentMethods(paymentMethods) {
836
- return paymentMethods.filter(
837
- (method) => !EXPRESS_PAYMENT_METHOD_TYPES.some((type) => {
838
- var _a;
839
- return type === ((_a = method.type) == null ? void 0 : _a.toLowerCase());
840
- })
841
- );
842
- }
843
- const PAYMENT_GATEWAY_VARIANT_ADYEN = "ADYEN";
844
- const _sfc_main$1 = /* @__PURE__ */ defineComponent({
845
- __name: "PaymentIntegrationFormAdyen",
846
- props: {
847
- countryCode: { type: String },
848
- customerId: { type: String },
849
- invoiceId: { type: String },
850
- paymentMethodOptionResponseEntry: { type: Object },
851
- variant: { type: String },
852
- selected: { type: Boolean },
853
- amount: { type: Object },
854
- validateOnSubmit: { type: Function, default: () => Promise.resolve(true) },
855
- context: { type: Object },
856
- forceStorePaymentMethod: { type: Boolean }
857
- },
858
- emits: ["select", "payment-failed", "payment-success", "ready"],
859
- setup(__props, { expose: __expose, emit: __emit }) {
860
- let dropInInstance = null;
861
- let checkoutInstance = null;
862
- const props = __props;
863
- const emit = __emit;
864
- __expose({ submit });
865
- const dropInContainerRef = ref();
866
- const showPaymentSuccess = ref(false);
867
- const integrationError = ref();
868
- const logger = useLogger();
869
- const { locale } = useIntl();
870
- const { authorizePayment, getPaymentDetails } = createPaymentsService();
871
- const { tokenizePaymentMethod } = createPaymentMethodsService();
872
- const experimentalFeatures = useExperimentalFeature();
873
- function submit() {
874
- try {
875
- dropInInstance == null ? void 0 : dropInInstance.submit();
876
- } catch (error) {
877
- logger.error("ADYEN_SUBMIT_FAILED", "Failed to submit Adyen drop-in", {}, error);
878
- }
879
- }
880
- async function getConfiguration() {
881
- var _a;
882
- const adyenAmount = toMinorUnitAmount(props.amount);
883
- const paymentMethods = ((_a = experimentalFeatures == null ? void 0 : experimentalFeatures.value) == null ? void 0 : _a["express-checkout"]) ? filterOutExpressPaymentMethods(
884
- mapAdyenPaymentMethods(props.paymentMethodOptionResponseEntry)
885
- ) : mapAdyenPaymentMethods(props.paymentMethodOptionResponseEntry);
886
- return {
887
- checkoutConfig: {
888
- amount: adyenAmount,
889
- clientKey: getAdyenClientKeyFromPaymentMethodOptionsResponse(
890
- props.paymentMethodOptionResponseEntry
891
- ),
892
- environment: getAdyenEnvironmentFromPaymentMethodOptionsResponse(
893
- props.paymentMethodOptionResponseEntry,
894
- logger
895
- ),
896
- locale,
897
- translations: getOverriddenTranslations(props.variant),
898
- countryCode: props.countryCode,
899
- analytics: { enabled: false },
900
- paymentMethodsResponse: { paymentMethods },
901
- onSubmit: handleOnSubmit,
902
- onAdditionalDetails: handleOnAdditionalDetails,
903
- onPaymentCompleted: handleOnPaymentCompleted,
904
- onPaymentFailed: handleOnPaymentFailed,
905
- onError: handleOnError,
906
- showPayButton: false
907
- },
908
- dropInConfig: {
909
- disableFinalAnimation: true,
910
- paymentMethodsConfiguration: {
911
- card: {
912
- hasHolderName: true,
913
- holderNameRequired: true,
914
- enableStoreDetails: !props.forceStorePaymentMethod && props.variant === "AUTHORIZE"
915
- },
916
- paypal: {
917
- intent: adyenAmount.value > 0 ? "authorize" : "tokenize",
918
- showPayButton: true
919
- }
920
- },
921
- openFirstPaymentMethod: props.selected,
922
- onSelect: ({ props: { type } }) => {
923
- if (!type) return;
924
- emit("select", { paymentMethodType: type, paymentGatewayVariant: "ADYEN" });
925
- },
926
- onReady: () => emit("ready")
927
- }
928
- };
929
- }
930
- async function mountDropIn() {
931
- if (!dropInContainerRef.value) return;
932
- try {
933
- await unmountDropIn();
934
- const [adyenModule, { default: adyenCss }] = await Promise.all([
935
- import("./index-DyvRdSR7.mjs"),
936
- import("./adyen-51SvcyqV.mjs")
937
- ]);
938
- const {
939
- AdyenCheckout,
940
- Dropin,
941
- Card,
942
- Bancontact,
943
- Ach,
944
- AmazonPay,
945
- ApplePay,
946
- BcmcMobile,
947
- BacsDirectDebit,
948
- CashAppPay,
949
- EPS,
950
- GooglePay,
951
- Klarna,
952
- PayByBank,
953
- PayPal,
954
- SepaDirectDebit,
955
- Trustly,
956
- Twint,
957
- PayByBankUS,
958
- Redirect
959
- } = adyenModule;
960
- const { checkoutConfig, dropInConfig } = await getConfiguration();
961
- checkoutInstance = await AdyenCheckout(checkoutConfig);
962
- dropInInstance = new Dropin(checkoutInstance, {
963
- ...dropInConfig,
964
- paymentMethodComponents: [
965
- Card,
966
- Bancontact,
967
- Ach,
968
- AmazonPay,
969
- ApplePay,
970
- BcmcMobile,
971
- BacsDirectDebit,
972
- CashAppPay,
973
- EPS,
974
- GooglePay,
975
- Klarna,
976
- PayByBank,
977
- PayPal,
978
- SepaDirectDebit,
979
- Trustly,
980
- Twint,
981
- PayByBankUS,
982
- Redirect
983
- ]
984
- }).mount(dropInContainerRef.value);
985
- injectStylesToShadowRoot(adyenCss);
986
- } catch (error) {
987
- logger.error(
988
- "PAYMENT_INTEGRATION_INITIALIZATION_FAILED",
989
- "Failed to mount Adyen web drop-in",
990
- { error }
991
- );
992
- }
993
- }
994
- async function unmountDropIn() {
995
- if (dropInInstance) {
996
- dropInInstance.unmount();
997
- dropInInstance = null;
998
- }
999
- if (dropInContainerRef.value) {
1000
- dropInContainerRef.value.innerHTML = "";
1001
- }
1002
- }
1003
- function injectStylesToShadowRoot(adyenCss) {
1004
- var _a;
1005
- const root = (_a = dropInContainerRef.value) == null ? void 0 : _a.getRootNode();
1006
- if (root instanceof ShadowRoot) {
1007
- const adyenStyle = document.createElement("style");
1008
- adyenStyle.textContent = adyenCss;
1009
- root.appendChild(adyenStyle);
1010
- const style = document.createElement("style");
1011
- style.textContent = `
1012
- :host {
1013
- --adyen-sdk-color-background-secondary: transparent;
1014
- --adyen-sdk-color-background-primary: rgb(243 244 246 / 0.5);
1015
- --adyen-sdk-color-outline-secondary: #e5e7eb;
1016
- --adyen-sdk-color-outline-primary: transparent;
1017
- --adyen-sdk-color-background-always-dark: var(--color-primary-500);
1018
- --adyen-sdk-color-background-inverse-primary-hover: var(--color-primary-600);
1019
- }
1020
-
1021
- .adyen-checkout__payment-method__image__wrapper {
1022
- width: 32px;
1023
- height: 32px;
1024
- }
1025
-
1026
- .adyen-checkout__payment-method__image {
1027
- height: 32px;
1028
- }
1029
-
1030
- .adyen-checkout__input-wrapper,
1031
- .adyen-checkout__input {
1032
- border-color: rgb(229, 231, 235);
1033
- border-radius: var(--adyen-sdk-border-radius-s, 4px);
1034
- }
1035
-
1036
- .adyen-checkout__button,
1037
- .adyen-checkout__payment-method {
1038
- border-radius: var(--adyen-sdk-border-radius-s, 4px);
1039
- }
1040
-
1041
- .adyen-checkout__payment-method {
1042
- border-color: rgb(229, 231, 235);
1043
- box-shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
1044
- transition: box-shadow 0.2s ease-in-out;
1045
- }
1046
-
1047
- .adyen-checkout__payment-method--selected {
1048
- box-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
1049
- }
1050
-
1051
- .adyen-checkout__payment-method:after {
1052
- transform: scale(0%);
1053
- }
1054
-
1055
- .adyen-checkout__paypal__button {
1056
- display: block !important;
1057
- }
1058
-
1059
- .adyen-checkout__payment-methods-list {
1060
- gap: 4px;
1061
- }
1062
-
1063
- .adyen-checkout__dropdown__list {
1064
- background-color: white;
1065
- border-radius: var(--adyen-sdk-border-radius-s, 4px);
1066
- }
1067
-
1068
- .adyen-checkout__payment-method.adyen-checkout__payment-method--selected:after {
1069
- content: '✓';
1070
- width: 20px;
1071
- height: 20px;
1072
- border-radius: 10px;
1073
- background-color: var(--color-primary-600);
1074
- position: absolute;
1075
- top: 14px;
1076
- right: 14px;
1077
- text-align: center;
1078
- line-height: 20px;
1079
- color: white;
1080
- transform: scale(100%);
1081
- font-size: 12px;
1082
- }
1083
-
1084
- .adyen-checkout__payment-method__header {
1085
- padding: 8px 16px !important;
1086
- }
1087
-
1088
- .adyen-checkout__payment-method__brands {
1089
- align-items: center;
1090
- }
1091
- .adyen-checkout__payment-method__brand-number {
1092
- line-height: 1;
1093
- }
1094
- .adyen-checkout__button__text {
1095
- font-size: 14px;
1096
- }
1097
- .adyen-checkout__store-details {
1098
- background: transparent;
1099
- padding: 0;
1100
- }
1101
- .adyen-checkout__checkbox__input + .adyen-checkout__checkbox__label:after {
1102
- border-color: rgb(229, 231, 235);
1103
- }
1104
- `;
1105
- if (props.variant === "AUTHORIZE") {
1106
- style.textContent += `
1107
- .adyen-checkout__payment-method--cashapp .adyen-checkout-pm-details-wrapper {
1108
- display: none;
1109
- }
1110
- `;
1111
- }
1112
- root.appendChild(style);
1113
- }
1114
- }
1115
- function handleOnSubmit(...args) {
1116
- const [state, _component, actions] = args;
1117
- props.validateOnSubmit().then((isValid) => {
1118
- if (!isValid) {
1119
- return;
1120
- }
1121
- const paymentAcceptorId = props.paymentMethodOptionResponseEntry.payment_acceptor.id;
1122
- const adyen = {
1123
- risk_data: transformObjectToAdyenObject(state.data.riskData),
1124
- payment_method: transformObjectToAdyenObject(state.data.paymentMethod),
1125
- browser_info: transformObjectToAdyenObject(state.data.browserInfo)
1126
- };
1127
- if (props.variant === "AUTHORIZE") {
1128
- const returnUrl = createReturnUrl({
1129
- paymentAcceptorId: props.paymentMethodOptionResponseEntry.payment_acceptor.id,
1130
- redirectUrl: window.location.href
1131
- });
1132
- authorizePayment({
1133
- payment_acceptor_id: paymentAcceptorId,
1134
- ...props.customerId ? { customer_id: props.customerId } : {},
1135
- payment_gateway_variant: PAYMENT_GATEWAY_VARIANT_ADYEN,
1136
- adyen: {
1137
- ...adyen,
1138
- store_payment_method: props.forceStorePaymentMethod || state.data.storePaymentMethod
1139
- },
1140
- amount: props.amount,
1141
- ...props.context ? { context: props.context } : {},
1142
- return_url: returnUrl
1143
- }).then((paymentResult) => {
1144
- const paymentMethodType = state.data.paymentMethod.type;
1145
- if (paymentResult.status === "ACTION_REQUIRED" && paymentResult.action.payment_gateway_variant === PAYMENT_GATEWAY_VARIANT_ADYEN) {
1146
- const requiredAction = handleActionRequiredPaymentAction(
1147
- paymentResult,
1148
- paymentMethodType
1149
- );
1150
- if (!requiredAction) {
1151
- logger.error(
1152
- "PAYMENT_AUTHORIZATION_FAILED",
1153
- `Failed payment authorization for payment acceptor with id ${paymentAcceptorId}`,
1154
- { error: paymentResult }
1155
- );
1156
- return;
1157
- }
1158
- dropInInstance.handleAction(requiredAction);
1159
- actions.resolve({
1160
- resultCode: paymentResult.action.adyen.result_code,
1161
- action: requiredAction
1162
- });
1163
- return;
1164
- }
1165
- if (paymentResult.payment.result === "AUTHORIZED") {
1166
- showPaymentSuccess.value = true;
1167
- actions.resolve({ resultCode: "Authorised" });
1168
- return;
1169
- }
1170
- logger.error(
1171
- "PAYMENT_AUTHORIZATION_FAILED",
1172
- `Failed payment authorization for payment acceptor with id ${paymentAcceptorId}`,
1173
- { error: paymentResult }
1174
- );
1175
- actions.resolve({ resultCode: "Error" });
1176
- }).catch((error) => {
1177
- logger.error(
1178
- "PAYMENT_AUTHORIZATION_FAILED",
1179
- `Failed payment authorization for payment acceptor with id ${paymentAcceptorId}`,
1180
- { error }
1181
- );
1182
- actions.resolve({ resultCode: "Error" });
1183
- });
1184
- return;
1185
- }
1186
- if (props.variant === "TOKENIZE") {
1187
- const returnUrl = createReturnUrl({
1188
- paymentAcceptorId: props.paymentMethodOptionResponseEntry.payment_acceptor.id,
1189
- redirectUrl: window.location.href
1190
- });
1191
- if (!props.customerId) {
1192
- logger.error(
1193
- "TOKENIZATION_FAILED",
1194
- `Missing customer id for payment acceptor with id ${paymentAcceptorId}`
1195
- );
1196
- return;
1197
- }
1198
- tokenizePaymentMethod({
1199
- customer_id: props.customerId,
1200
- payment_acceptor_id: paymentAcceptorId,
1201
- payment_gateway_variant: PAYMENT_GATEWAY_VARIANT_ADYEN,
1202
- adyen,
1203
- return_url: returnUrl
1204
- }).then((paymentResult) => {
1205
- const paymentMethodType = state.data.paymentMethod.type;
1206
- if (paymentResult.status === "ACTION_REQUIRED" && paymentResult.action.payment_gateway_variant === PAYMENT_GATEWAY_VARIANT_ADYEN) {
1207
- const requiredAction = handleActionRequiredPaymentAction(
1208
- paymentResult,
1209
- paymentMethodType
1210
- );
1211
- if (!requiredAction) {
1212
- logger.error(
1213
- "TOKENIZATION_FAILED",
1214
- `Tokenization failed for payment acceptor with id ${paymentAcceptorId}`,
1215
- { error: paymentResult }
1216
- );
1217
- return;
1218
- }
1219
- dropInInstance.handleAction(requiredAction);
1220
- actions.resolve({
1221
- resultCode: paymentResult.action.adyen.result_code,
1222
- action: requiredAction
1223
- });
1224
- return;
1225
- }
1226
- if (paymentResult.payment.result === "AUTHORIZED") {
1227
- showPaymentSuccess.value = true;
1228
- actions.resolve({ resultCode: "Authorised" });
1229
- return;
1230
- }
1231
- logger.error(
1232
- "TOKENIZATION_FAILED",
1233
- `Tokenization failed for payment acceptor with id ${paymentAcceptorId}`,
1234
- { error: paymentResult }
1235
- );
1236
- actions.resolve({ resultCode: "Error" });
1237
- }).catch((error) => {
1238
- logger.error(
1239
- "TOKENIZATION_FAILED",
1240
- `Tokenization failed for payment acceptor with id ${paymentAcceptorId}`,
1241
- { error }
1242
- );
1243
- actions.resolve({ resultCode: "Error" });
1244
- });
1245
- }
1246
- }).catch((error) => {
1247
- logger.error(
1248
- "INTEGRATION_ERROR",
1249
- "Unhandled error in payment submission flow",
1250
- {},
1251
- error
1252
- );
1253
- });
1254
- }
1255
- function handleActionRequiredPaymentAction(response, paymentMethodType) {
1256
- if (response.status !== "ACTION_REQUIRED") {
1257
- return void 0;
1258
- }
1259
- const action = response.action;
1260
- if (action.payment_gateway_variant != "ADYEN") {
1261
- return void 0;
1262
- }
1263
- const adyenRequiredAction = action.adyen;
1264
- return {
1265
- paymentMethodType: (adyenRequiredAction == null ? void 0 : adyenRequiredAction.payment_method_type) ?? paymentMethodType,
1266
- method: action.method,
1267
- url: action.url,
1268
- data: action.data,
1269
- type: adyenRequiredAction == null ? void 0 : adyenRequiredAction.action_type,
1270
- paymentData: adyenRequiredAction == null ? void 0 : adyenRequiredAction.payment_data,
1271
- sdkData: adyenRequiredAction == null ? void 0 : adyenRequiredAction.sdk_data
1272
- };
1273
- }
1274
- function handleOnAdditionalDetails(...args) {
1275
- const [state] = args;
1276
- const detailsResult = state.data.details;
1277
- const paymentDataResult = state.data.paymentData;
1278
- if (props.paymentMethodOptionResponseEntry.payment_acceptor.id) {
1279
- handlePaymentDetails({
1280
- // For the moment: Adyen gives a null value back which is not accepted by Solvimon API, so filter that out
1281
- detailsResult: detailsResult ? removeEmptyValues(detailsResult) : void 0,
1282
- paymentDataResult,
1283
- paymentAcceptorId: props.paymentMethodOptionResponseEntry.payment_acceptor.id
1284
- });
1285
- return;
1286
- }
1287
- const error = {
1288
- code: "UNKNOWN_ERROR",
1289
- message: "Payment failed",
1290
- error: args
1291
- };
1292
- emit("payment-failed", error);
1293
- integrationError.value = error;
1294
- }
1295
- function removeEmptyValues(obj) {
1296
- return Object.fromEntries(
1297
- Object.entries(obj).filter(([, value]) => value !== null && value !== void 0)
1298
- );
1299
- }
1300
- function handleOnPaymentFailed(...args) {
1301
- const [data] = args;
1302
- const error = {
1303
- code: "UNKNOWN_ERROR",
1304
- message: "Payment failed",
1305
- error: data
1306
- };
1307
- emit("payment-failed", error);
1308
- integrationError.value = error;
1309
- }
1310
- function handleOnPaymentCompleted(...args) {
1311
- const [, component] = args;
1312
- component == null ? void 0 : component.unmount();
1313
- emit("payment-success");
1314
- }
1315
- function handleOnError(...args) {
1316
- const [data, component] = args;
1317
- if (data.name === "CANCEL") {
1318
- return;
1319
- }
1320
- const error = {
1321
- code: "UNKNOWN_ERROR",
1322
- message: "Something went wrong",
1323
- error: data
1324
- };
1325
- logger.error("INTEGRATION_ERROR", "Something went wrong", { error: data });
1326
- integrationError.value = error;
1327
- component == null ? void 0 : component.unmount();
1328
- }
1329
- function handlePaymentDetails({
1330
- detailsResult,
1331
- threeDSResult,
1332
- redirectResult,
1333
- paymentDataResult,
1334
- paymentAcceptorId
1335
- }) {
1336
- getPaymentDetails({
1337
- paymentAcceptorId,
1338
- paymentGatewayVariant: PAYMENT_GATEWAY_VARIANT_ADYEN,
1339
- adyen: {
1340
- ...detailsResult ? { details: detailsResult } : {},
1341
- ...redirectResult ? { redirect_result: redirectResult } : {},
1342
- ...threeDSResult ? { threeds_result: threeDSResult } : {},
1343
- ...paymentDataResult ? { payment_data: paymentDataResult } : {}
1344
- }
1345
- }).then((result) => {
1346
- if (result.payment_status === "FAILURE") {
1347
- emit("payment-failed", {
1348
- code: "UNKNOWN_ERROR",
1349
- message: "Failed getting payment details",
1350
- error: result
1351
- });
1352
- return;
1353
- }
1354
- if (result.payment_status === "SUCCESS") {
1355
- emit("payment-success");
1356
- return;
1357
- }
1358
- }).catch((error) => {
1359
- logger.error("PAYMENT_DETAILS_CALL_FAILED", "Failed fetching payment details", {
1360
- error
1361
- });
1362
- });
1363
- }
1364
- function handleRedirectResult() {
1365
- const redirectResult = getQueryParam(REDIRECT_RESULT_QUERY_STRING);
1366
- const paymentAcceptorId = getQueryParam(PAYMENT_ACCEPTOR_ID_QUERY_STRING);
1367
- if (!redirectResult) {
1368
- return;
1369
- }
1370
- if (!paymentAcceptorId) {
1371
- logger.error(
1372
- "INVALID_REDIRECT_RESULT",
1373
- "Redirect result is set but payment acceptor id is missing",
1374
- { context: { redirectResult } }
1375
- );
1376
- return;
1377
- }
1378
- handlePaymentDetails({
1379
- paymentAcceptorId,
1380
- detailsResult: {
1381
- redirectResult: decodeURI(redirectResult)
1382
- }
1383
- });
1384
- }
1385
- onMounted(() => {
1386
- void mountDropIn();
1387
- handleRedirectResult();
1388
- });
1389
- onBeforeUnmount(() => {
1390
- void unmountDropIn();
1391
- });
1392
- watch(
1393
- () => props.paymentMethodOptionResponseEntry,
1394
- (newValue, oldValue) => {
1395
- if (isEqual(newValue, oldValue)) return;
1396
- void mountDropIn();
1397
- },
1398
- { deep: true }
1399
- );
1400
- return (_ctx, _cache) => {
1401
- return openBlock(), createElementBlock(Fragment, null, [
1402
- showPaymentSuccess.value ? (openBlock(), createBlock(_sfc_main$4, {
1403
- key: 0,
1404
- variant: __props.variant
1405
- }, null, 8, ["variant"])) : integrationError.value ? (openBlock(), createBlock(_sfc_main$3, {
1406
- key: 1,
1407
- error: integrationError.value
1408
- }, null, 8, ["error"])) : createCommentVNode("", true),
1409
- createElementVNode("div", {
1410
- ref_key: "dropInContainerRef",
1411
- ref: dropInContainerRef
1412
- }, null, 512)
1413
- ], 64);
1414
- };
1415
- }
1416
- });
1417
- const _sfc_main = /* @__PURE__ */ defineComponent({
1418
- __name: "PaymentIntegrationForm",
1419
- props: {
1420
- customerId: { type: String },
1421
- variant: { type: String },
1422
- context: { type: Object },
1423
- paymentMethodOptions: { type: Array },
1424
- countryCode: { type: String },
1425
- invoiceId: { type: String },
1426
- amount: { type: Object },
1427
- selectedOption: { type: String },
1428
- email: { type: String },
1429
- name: { type: String },
1430
- validateOnSubmit: { type: Function },
1431
- forceStorePaymentMethod: { type: Boolean }
1432
- },
1433
- emits: ["select", "payment-failed", "payment-success", "ready"],
1434
- setup(__props, { expose: __expose, emit: __emit }) {
1435
- const props = __props;
1436
- const emit = __emit;
1437
- __expose({ submit });
1438
- const { $t } = useIntl();
1439
- const userSelectedIntegration = ref();
1440
- const selectedIntegration = computed(
1441
- () => {
1442
- var _a, _b;
1443
- return userSelectedIntegration.value ?? ((_b = (_a = props.paymentMethodOptions[0]) == null ? void 0 : _a.integration.payment_gateway) == null ? void 0 : _b.variant);
1444
- }
1445
- );
1446
- const integrationRefs = ref(/* @__PURE__ */ new Map());
1447
- const showIntegrationError = ref(false);
1448
- const handleSelect = ({
1449
- paymentGatewayVariant,
1450
- paymentMethodType
1451
- }) => {
1452
- showIntegrationError.value = false;
1453
- userSelectedIntegration.value = paymentGatewayVariant;
1454
- emit("select", { paymentGatewayVariant, paymentMethodType });
1455
- };
1456
- const setIntegrationRef = (paymentMethodOption) => {
1457
- return (el) => {
1458
- var _a;
1459
- return integrationRefs.value.set((_a = paymentMethodOption.integration.payment_gateway) == null ? void 0 : _a.variant, el);
1460
- };
1461
- };
1462
- function submit() {
1463
- var _a, _b;
1464
- if (!selectedIntegration.value) {
1465
- showIntegrationError.value = true;
1466
- void ((_a = props.validateOnSubmit) == null ? void 0 : _a.call(props));
1467
- }
1468
- (_b = integrationRefs.value.get(selectedIntegration.value)) == null ? void 0 : _b.submit();
1469
- }
1470
- return (_ctx, _cache) => {
1471
- return openBlock(), createElementBlock(Fragment, null, [
1472
- (openBlock(true), createElementBlock(Fragment, null, renderList(__props.paymentMethodOptions, (paymentMethodOption) => {
1473
- return openBlock(), createElementBlock(Fragment, {
1474
- key: paymentMethodOption.integration.id
1475
- }, [
1476
- unref(isAdyenPaymentIntegration)(paymentMethodOption) ? (openBlock(), createBlock(_sfc_main$1, {
1477
- key: 0,
1478
- ref_for: true,
1479
- ref: setIntegrationRef(paymentMethodOption),
1480
- context: __props.context,
1481
- "payment-method-option-response-entry": paymentMethodOption,
1482
- "country-code": __props.countryCode,
1483
- "customer-id": __props.customerId,
1484
- variant: __props.variant,
1485
- amount: __props.amount,
1486
- "invoice-id": __props.invoiceId,
1487
- selected: unref(isSelectedIntegration)({ selectedIntegration: selectedIntegration.value, paymentMethodOption }),
1488
- "validate-on-submit": __props.validateOnSubmit,
1489
- "force-store-payment-method": __props.forceStorePaymentMethod,
1490
- onSelect: handleSelect,
1491
- onPaymentFailed: _cache[0] || (_cache[0] = ($event) => _ctx.$emit("payment-failed", $event)),
1492
- onPaymentSuccess: _cache[1] || (_cache[1] = ($event) => _ctx.$emit("payment-success")),
1493
- onReady: _cache[2] || (_cache[2] = ($event) => _ctx.$emit("ready"))
1494
- }, null, 8, ["context", "payment-method-option-response-entry", "country-code", "customer-id", "variant", "amount", "invoice-id", "selected", "validate-on-submit", "force-store-payment-method"])) : unref(isStripePaymentIntegration)(paymentMethodOption) ? (openBlock(), createBlock(_sfc_main$2, {
1495
- key: 1,
1496
- ref_for: true,
1497
- ref: setIntegrationRef(paymentMethodOption),
1498
- context: __props.context,
1499
- "payment-method-option-response-entry": paymentMethodOption,
1500
- "country-code": __props.countryCode,
1501
- "customer-id": __props.customerId,
1502
- variant: __props.variant,
1503
- amount: __props.amount,
1504
- "invoice-id": __props.invoiceId,
1505
- selected: unref(isSelectedIntegration)({ selectedIntegration: selectedIntegration.value, paymentMethodOption }),
1506
- email: __props.email,
1507
- name: __props.name,
1508
- "validate-on-submit": __props.validateOnSubmit,
1509
- "force-store-payment-method": __props.forceStorePaymentMethod,
1510
- onSelect: handleSelect,
1511
- onPaymentFailed: _cache[3] || (_cache[3] = ($event) => _ctx.$emit("payment-failed", $event)),
1512
- onPaymentSuccess: _cache[4] || (_cache[4] = ($event) => _ctx.$emit("payment-success")),
1513
- onReady: _cache[5] || (_cache[5] = ($event) => _ctx.$emit("ready"))
1514
- }, null, 8, ["context", "payment-method-option-response-entry", "country-code", "customer-id", "variant", "amount", "invoice-id", "selected", "email", "name", "validate-on-submit", "force-store-payment-method"])) : createCommentVNode("", true)
1515
- ], 64);
1516
- }), 128)),
1517
- showIntegrationError.value ? (openBlock(), createBlock(unref(_sfc_main$a), {
1518
- key: 0,
1519
- variant: "error",
1520
- class: "mt-2"
1521
- }, {
1522
- default: withCtx(() => [
1523
- createTextVNode(toDisplayString(unref($t)({
1524
- defaultMessage: "Select a payment method",
1525
- id: "payment_integration_form.select_payment_method_error",
1526
- description: "Error shown when no payment method is selected"
1527
- })), 1)
1528
- ]),
1529
- _: 1
1530
- })) : createCommentVNode("", true)
1531
- ], 64);
1532
- };
1533
- }
1534
- });
1535
- export {
1536
- _sfc_main as _
1537
- };