@solvimon/solvimon-web 0.1.0-alpha.16 → 0.1.0-alpha.17
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/README.md +5 -5
- package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-BYBAO4Au.mjs → BillingInformation.vue_vue_type_script_setup_true_lang-BrPsTuoW.mjs} +2 -2
- package/dist/{BillingInformation.vue_vue_type_script_setup_true_lang-BI3Lg7nO.js → BillingInformation.vue_vue_type_script_setup_true_lang-BuQ8bzar.js} +1 -1
- package/dist/{CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-C_uHr21N.js → CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-1Op9GjGZ.js} +1 -1
- package/dist/{CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-CTnn1gkW.mjs → CustomerPaymentMethods.vue_vue_type_script_setup_true_lang-CuWrBcoK.mjs} +3 -3
- package/dist/CustomerWalletBalances.vue_vue_type_script_setup_true_lang-C66beqgf.js +1 -0
- package/dist/{useWalletBalanceItems-COQDLfoZ.mjs → CustomerWalletBalances.vue_vue_type_script_setup_true_lang-D2BhuXsh.mjs} +24 -56
- package/dist/EmptyStatePlaceholder.vue_vue_type_script_setup_true_lang-BbuEBiY3.js +1 -0
- package/dist/EmptyStatePlaceholder.vue_vue_type_script_setup_true_lang-C3cqlbGY.mjs +147 -0
- package/dist/{InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-DU6X3zxr.js → InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-dwIv_xxf.js} +1 -1
- package/dist/{InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-ryvFEQMV.mjs → InvoiceDetailsBlock.vue_vue_type_script_setup_true_lang-wxP5IaGt.mjs} +1 -1
- package/dist/{InvoiceHeader.vue_vue_type_script_setup_true_lang-DdpPrYxi.js → InvoiceHeader.vue_vue_type_script_setup_true_lang-05NKI2A0.js} +1 -1
- package/dist/{InvoiceHeader.vue_vue_type_script_setup_true_lang-bAiAbtMi.mjs → InvoiceHeader.vue_vue_type_script_setup_true_lang-17v07F58.mjs} +1 -1
- package/dist/{PaymentHistoryBlock-BKMttUyk.mjs → PaymentHistoryBlock-BitwS9Re.mjs} +1 -1
- package/dist/{PaymentHistoryBlock-BGbTy4Se.js → PaymentHistoryBlock-ZtmPXXwI.js} +1 -1
- package/dist/{PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-tM7f_fQS.mjs → PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-C3ZUDUdw.mjs} +1 -1
- package/dist/{PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-CixdxEGm.js → PaymentHistoryBlock.vue_vue_type_script_setup_true_lang-CMGK71zZ.js} +1 -1
- package/dist/{PaymentIntegrationForm-CypW6fZY.mjs → PaymentIntegrationForm-BK2aLPCo.mjs} +1 -1
- package/dist/{PaymentIntegrationForm-D4QupHWl.js → PaymentIntegrationForm-BZTzCUiu.js} +1 -1
- package/dist/{PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-CrGSfZZs.mjs → PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-B_yDNGK8.mjs} +5 -5
- package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-GN3WAr10.js +1 -0
- package/dist/{PaymentMethodForm.vue_vue_type_script_setup_true_lang-B8eNptZp.mjs → PaymentMethodForm.vue_vue_type_script_setup_true_lang-CIQ0vsko.mjs} +25 -14
- package/dist/PaymentMethodForm.vue_vue_type_script_setup_true_lang-zRr8iihy.js +1 -0
- package/dist/PaymentMethodSelector.vue_vue_type_script_setup_true_lang-BQIN3zuf.mjs +156 -0
- package/dist/PaymentMethodSelector.vue_vue_type_script_setup_true_lang-DyL2-vV0.js +1 -0
- package/dist/{PaymentMethodsList.vue_vue_type_script_setup_true_lang-BUTqn4Ey.mjs → PaymentMethodsList.vue_vue_type_script_setup_true_lang-DVeB_mqK.mjs} +5 -5
- package/dist/{PaymentMethodsList.vue_vue_type_script_setup_true_lang-Be_fF-R_.js → PaymentMethodsList.vue_vue_type_script_setup_true_lang-OvGGejpX.js} +1 -1
- package/dist/SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-BxqIfmkK.js +1 -0
- package/dist/{SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-Cqk-vonA.mjs → SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-D1TcP9PR.mjs} +115 -68
- package/dist/SubscriptionSchedules.vue_vue_type_script_setup_true_lang-BKz2QQn9.js +1 -0
- package/dist/SubscriptionSchedules.vue_vue_type_script_setup_true_lang-BMXr26gF.mjs +37 -0
- package/dist/{SubscriptionsList.vue_vue_type_script_setup_true_lang-DB1p61kZ.mjs → SubscriptionsList.vue_vue_type_script_setup_true_lang-BDqX6OaE.mjs} +22 -119
- package/dist/SubscriptionsList.vue_vue_type_script_setup_true_lang-CyAFjCh7.js +1 -0
- package/dist/component-CUJ_G2Nw.mjs +962 -0
- package/dist/component-CiKxWtdx.js +1 -0
- package/dist/components/BillingInformation/BillingInformation.cjs.js +1 -1
- package/dist/components/BillingInformation/BillingInformation.es.js +4 -4
- package/dist/components/BillingInformationForm/BillingInformationForm.cjs.js +1 -1
- package/dist/components/BillingInformationForm/BillingInformationForm.es.js +3 -3
- package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.cjs.js +1 -1
- package/dist/components/CustomerPaymentMethods/CustomerPaymentMethods.es.js +4 -4
- package/dist/components/Invoice/Invoice.cjs.js +1 -1
- package/dist/components/Invoice/Invoice.es.js +7 -7
- package/dist/components/InvoiceDetails/InvoiceDetails.cjs.js +1 -1
- package/dist/components/InvoiceDetails/InvoiceDetails.es.js +3 -3
- package/dist/components/InvoiceHeader/InvoiceHeader.cjs.js +1 -1
- package/dist/components/InvoiceHeader/InvoiceHeader.es.js +4 -4
- package/dist/components/InvoicesList/InvoicesList.cjs.js +1 -1
- package/dist/components/InvoicesList/InvoicesList.es.js +3 -3
- package/dist/components/PaymentHistory/PaymentHistory.cjs.js +1 -1
- package/dist/components/PaymentHistory/PaymentHistory.es.js +3 -3
- package/dist/components/PaymentMethodForm/PaymentMethodForm.cjs.js +1 -1
- package/dist/components/PaymentMethodForm/PaymentMethodForm.es.js +6 -6
- package/dist/components/SubscriptionSchedules/SubscriptionSchedules.cjs.js +1 -1
- package/dist/components/SubscriptionSchedules/SubscriptionSchedules.es.js +7 -58
- package/dist/components/SubscriptionsList/SubscriptionsList.cjs.js +1 -1
- package/dist/components/SubscriptionsList/SubscriptionsList.es.js +5 -5
- package/dist/components/WalletBalances/WalletBalances.cjs.js +1 -1
- package/dist/components/WalletBalances/WalletBalances.es.js +8 -6
- package/dist/core/action-request.types.d.ts +3 -3
- package/dist/core/index.cjs.js +1 -1
- package/dist/core/index.es.js +1 -1
- package/dist/core/types.d.ts +4 -2
- package/dist/{customer-_W8gIX5m.js → customer-AfRcAZ5P.js} +1 -1
- package/dist/{customer-Bv_fqXzO.mjs → customer-DAgdegIW.mjs} +1 -1
- package/dist/{en-US-DAgOSlgv.mjs → en-US-DSzSbgL5.mjs} +68 -36
- package/dist/en-US-QzQnGXP1.js +1 -0
- package/dist/index.cjs.js +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.es.js +7 -4
- package/dist/invoices-BHgajZHq.js +1 -0
- package/dist/{invoices-BGb0AwVF.mjs → invoices-BXDgW8ch.mjs} +32 -16
- package/dist/nl-NL-C4rr-1tr.js +1 -0
- package/dist/{nl-NL-DCsmrA8A.mjs → nl-NL-Li7RW89R.mjs} +72 -40
- package/dist/{paymentMethods-DIbB759g.js → paymentMethods-BMcc-eTl.js} +1 -1
- package/dist/{paymentMethods-DvqlWe96.mjs → paymentMethods-xzFD2L30.mjs} +2 -2
- package/dist/{payments-DMDDI3MK.js → payments-DMvmB5vg.js} +1 -1
- package/dist/{payments-CpzTVrQM.mjs → payments-DV6csRej.mjs} +1 -1
- package/dist/pricing-B1uImUm4.mjs +19 -0
- package/dist/pricing-BEjY_5wb.js +1 -0
- package/dist/pricingPlanSchedule-B9HFiXy-.js +1 -0
- package/dist/pricingPlanSchedule-C_cqUyTk.mjs +144 -0
- package/dist/registry-CeMxLjwU.js +1 -0
- package/dist/{registry-B-If1W_u.mjs → registry-CyENvS6l.mjs} +7 -4
- package/dist/screens/Checkout/Checkout.cjs.js +1 -1
- package/dist/screens/Checkout/Checkout.es.js +414 -675
- package/dist/screens/CustomerOverview/CustomerOverview.cjs.js +1 -1
- package/dist/screens/CustomerOverview/CustomerOverview.es.js +65 -19
- package/dist/screens/PayInvoice/PayInvoice.cjs.js +1 -1
- package/dist/screens/PayInvoice/PayInvoice.es.js +10 -9
- package/dist/screens/PaymentMethodsManagement/PaymentMethodsManagement.cjs.js +1 -1
- package/dist/screens/PaymentMethodsManagement/PaymentMethodsManagement.es.js +8 -8
- package/dist/screens/SubscriptionDetails/SubscriptionDetails.ce.d.ts +3 -0
- package/dist/screens/SubscriptionDetails/SubscriptionDetails.cjs.js +1 -0
- package/dist/screens/SubscriptionDetails/SubscriptionDetails.es.js +542 -0
- package/dist/screens/SubscriptionManagement/SubscriptionManagement.ce.d.ts +3 -0
- package/dist/screens/SubscriptionManagement/SubscriptionManagement.cjs.js +1 -0
- package/dist/screens/SubscriptionManagement/SubscriptionManagement.es.js +725 -0
- package/dist/solvimon-web.css +1 -1
- package/dist/subscription-B4dBAY9C.mjs +89 -0
- package/dist/subscription-b0OPx8Du.js +1 -0
- package/dist/{subscriptions-BPYyv09M.mjs → subscriptions-CrNDM9qa.mjs} +6 -2
- package/dist/{subscriptions-CC61I6Nj.js → subscriptions-DC-mxa17.js} +1 -1
- package/dist/{url-1Lbg5Yni.mjs → url-BjZ1Pg0l.mjs} +1 -1
- package/dist/url-D8GJi5rF.js +1 -0
- package/dist/{useActionDispatchProvider-BHTknMoH.js → useActionDispatchProvider-bqR_FeM4.js} +1 -1
- package/dist/{useActionDispatchProvider-Dz8-e4gZ.mjs → useActionDispatchProvider-zB_GKeUR.mjs} +1 -1
- package/dist/{useCustomer-VVJi8z2w.mjs → useCustomer-VfeQ6rG2.mjs} +2 -2
- package/dist/{useCustomer-Z24KchWC.js → useCustomer-bO4D6e4Z.js} +1 -1
- package/dist/{useIncrementalLoading-CuSndpP2.js → useIncrementalLoading-BgWuwoMo.js} +1 -1
- package/dist/{useIncrementalLoading-DmOT2MXH.mjs → useIncrementalLoading-C59FXHzp.mjs} +1 -1
- package/dist/{useInvoiceData-Bl87gzIS.js → useInvoiceData-CxxkBTGY.js} +1 -1
- package/dist/{useInvoiceData-Di5pLPM0.mjs → useInvoiceData-Dhg-hx8C.mjs} +2 -2
- package/dist/useInvoicesList-BXZ9uV9i.js +1 -0
- package/dist/{useInvoicesList-z19cteaD.mjs → useInvoicesList-DBz7T7sM.mjs} +4 -4
- package/dist/{useLoadInitialData-CkpryfjF.mjs → useLoadInitialData-BhpIg7OF.mjs} +1 -1
- package/dist/{useLoadInitialData-CTqfiMTN.js → useLoadInitialData-BqiAFNFi.js} +1 -1
- package/dist/{usePaymentMethodOptions-BsCZnCQW.js → usePaymentMethodOptions-DszFvgKX.js} +1 -1
- package/dist/{usePaymentMethodOptions-BoGHJjng.mjs → usePaymentMethodOptions-PcMjtMSF.mjs} +2 -2
- package/dist/{usePaymentMethods-ocHmNoP7.mjs → usePaymentMethods-B5AbGWsn.mjs} +2 -2
- package/dist/{usePaymentMethods-AC-4rrR9.js → usePaymentMethods-Bb1Xbads.js} +1 -1
- package/dist/{usePayments-D85eB5l4.mjs → usePayments-DgoZoBZh.mjs} +3 -3
- package/dist/{usePayments-CgXZeWrU.js → usePayments-is5c66Z6.js} +1 -1
- package/dist/{usePortal-DVD7PcWI.js → usePortal-C4qWsJeq.js} +1 -1
- package/dist/{usePortal-B1O1zgdV.mjs → usePortal-DWLtNqBB.mjs} +1 -1
- package/dist/{useService-DF57xuDd.mjs → useService-BZqFkz7p.mjs} +1 -1
- package/dist/{useService-CHrkefKd.js → useService-DKm3QtT4.js} +1 -1
- package/dist/useSubscription-CEZJw6wZ.mjs +23 -0
- package/dist/useSubscription-DuUNc1_l.js +1 -0
- package/dist/useTopUpModal-DNyWrHDv.mjs +1012 -0
- package/dist/useTopUpModal-DeF-cfCK.js +1 -0
- package/dist/{vendor-ui-B8IlviSs.mjs → vendor-ui-BoGKOJ36.mjs} +8642 -7077
- package/dist/vendor-ui-BuRqLx74.js +1 -0
- package/package.json +14 -7
- package/dist/PaymentIntegrationForm.vue_vue_type_script_setup_true_lang-BBEM-YPz.js +0 -1
- package/dist/PaymentMethodForm.vue_vue_type_script_setup_true_lang-eWmC5GOT.js +0 -1
- package/dist/SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-BVoS3ZXS.js +0 -1
- package/dist/SubscriptionsList.vue_vue_type_script_setup_true_lang-56vu59V4.js +0 -1
- package/dist/component-Bg2JVC_O.mjs +0 -933
- package/dist/component-Bs8oszfD.js +0 -1
- package/dist/en-US-C0gIE4Q1.js +0 -1
- package/dist/invoices-D-OKipCg.js +0 -1
- package/dist/nl-NL-Br7muSHK.js +0 -1
- package/dist/registry-uG2isab0.js +0 -1
- package/dist/screens/UpgradeSubscription/UpgradeSubscription.ce.d.ts +0 -3
- package/dist/screens/UpgradeSubscription/UpgradeSubscription.cjs.js +0 -1
- package/dist/screens/UpgradeSubscription/UpgradeSubscription.es.js +0 -1102
- package/dist/url-B6-3PkW2.js +0 -1
- package/dist/useInvoicesList-CFk-_oVK.js +0 -1
- package/dist/useWalletBalanceItems-BL-R5foK.js +0 -1
- package/dist/vendor-ui-C3Tq-qY_.js +0 -1
|
@@ -0,0 +1,725 @@
|
|
|
1
|
+
import { ref, defineComponent, useModel, computed, watch, openBlock, createElementBlock, withModifiers, createElementVNode, createVNode, unref, mergeModels, inject, createBlock, withCtx, renderSlot, createTextVNode, toDisplayString, createCommentVNode, Fragment } from "vue";
|
|
2
|
+
import { u as useIntl, a5 as _sfc_main$8, a7 as _sfc_main$a, _ as _sfc_main$b, t as _sfc_main$c, e as _sfc_main$e, a4 as _sfc_main$f, M as Modal, c as _sfc_main$i } from "../../vendor-ui-BoGKOJ36.mjs";
|
|
3
|
+
import { C as ContentWithAsideLayout } from "../../ContentWithAsideLayout-Dy9xgxuF.mjs";
|
|
4
|
+
import { a as useLogger, c as createRequestService, u as useConfig, T as TRANSLATION_SETTINGS_KEY, _ as _sfc_main$k, d as defineCustomElement, g as getComponentName } from "../../component-CUJ_G2Nw.mjs";
|
|
5
|
+
import { u as useActionDispatchProvider } from "../../useActionDispatchProvider-zB_GKeUR.mjs";
|
|
6
|
+
import { u as usePortal } from "../../usePortal-DWLtNqBB.mjs";
|
|
7
|
+
import { u as useSubscription } from "../../useSubscription-CEZJw6wZ.mjs";
|
|
8
|
+
import { u as useCustomer } from "../../useCustomer-VfeQ6rG2.mjs";
|
|
9
|
+
import { u as usePaymentMethods } from "../../usePaymentMethods-B5AbGWsn.mjs";
|
|
10
|
+
import { u as usePaymentMethodOptions } from "../../usePaymentMethodOptions-PcMjtMSF.mjs";
|
|
11
|
+
import { u as useLoadInitialData } from "../../useLoadInitialData-BhpIg7OF.mjs";
|
|
12
|
+
import { c as createInvoicesService } from "../../invoices-BXDgW8ch.mjs";
|
|
13
|
+
import { b as getScheduleCustomizations, c as getActiveDefaultScheduleInfo, d as getPricingGroupByPricingId } from "../../pricingPlanSchedule-C_cqUyTk.mjs";
|
|
14
|
+
import { _ as _sfc_main$7, a as _sfc_main$j } from "../../SecurePaymentsKPI.vue_vue_type_script_setup_true_lang-D1TcP9PR.mjs";
|
|
15
|
+
import { _ as _sfc_main$9 } from "../../PaymentMethodSelector.vue_vue_type_script_setup_true_lang-BQIN3zuf.mjs";
|
|
16
|
+
import { _ as _sfc_main$d } from "../../Skeleton.vue_vue_type_script_setup_true_lang-DGMxHc20.mjs";
|
|
17
|
+
import { _ as _sfc_main$g } from "../../url-BjZ1Pg0l.mjs";
|
|
18
|
+
import { _ as _sfc_main$h } from "../../PaymentMethodForm.vue_vue_type_script_setup_true_lang-CIQ0vsko.mjs";
|
|
19
|
+
function useSubscriptionUpgradePreview() {
|
|
20
|
+
const { getInvoicePreview } = createInvoicesService();
|
|
21
|
+
const logger = useLogger();
|
|
22
|
+
const invoice = ref();
|
|
23
|
+
const isPending = ref(false);
|
|
24
|
+
const error = ref();
|
|
25
|
+
let latestRequestId = 0;
|
|
26
|
+
const load = async ({
|
|
27
|
+
subscription,
|
|
28
|
+
enabledPricingIds
|
|
29
|
+
}) => {
|
|
30
|
+
const customizations = getScheduleCustomizations({
|
|
31
|
+
enabledPricings: enabledPricingIds.map((pricingId) => ({ pricing_id: pricingId })),
|
|
32
|
+
pricingPlanScheduleInfos: subscription.pricing_plan_schedule_infos
|
|
33
|
+
});
|
|
34
|
+
if (!customizations) {
|
|
35
|
+
invoice.value = void 0;
|
|
36
|
+
return;
|
|
37
|
+
}
|
|
38
|
+
const requestId = ++latestRequestId;
|
|
39
|
+
isPending.value = true;
|
|
40
|
+
error.value = void 0;
|
|
41
|
+
try {
|
|
42
|
+
const response = await getInvoicePreview({
|
|
43
|
+
// The subscription is running already, so it is priced as itself rather than as the
|
|
44
|
+
// template for a new one — and the customer it is invoiced to is known.
|
|
45
|
+
forExistingSubscription: true,
|
|
46
|
+
pricingPlanSubscriptionId: subscription.id,
|
|
47
|
+
customizations
|
|
48
|
+
});
|
|
49
|
+
if (requestId !== latestRequestId) return;
|
|
50
|
+
invoice.value = response.invoice;
|
|
51
|
+
} catch (previewError) {
|
|
52
|
+
if (requestId !== latestRequestId) return;
|
|
53
|
+
logger.error(
|
|
54
|
+
"INVOICE_PREVIEW_FAILED",
|
|
55
|
+
"Failed to preview the subscription upgrade",
|
|
56
|
+
{},
|
|
57
|
+
previewError
|
|
58
|
+
);
|
|
59
|
+
error.value = previewError;
|
|
60
|
+
invoice.value = void 0;
|
|
61
|
+
} finally {
|
|
62
|
+
if (requestId === latestRequestId) {
|
|
63
|
+
isPending.value = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
return { invoice, isPending, error, load };
|
|
68
|
+
}
|
|
69
|
+
function createPricingPlanSchedulesService() {
|
|
70
|
+
const request = createRequestService();
|
|
71
|
+
const config = useConfig();
|
|
72
|
+
function getOnDemandPricingItems({
|
|
73
|
+
scheduleId
|
|
74
|
+
}) {
|
|
75
|
+
return request({
|
|
76
|
+
url: `${config.apiUrls.config}/portal/pricing-plan-schedules/${scheduleId}/on-demand-pricing-items`
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
function createPricingPlanSchedule({
|
|
80
|
+
pricingPlanSubscriptionId,
|
|
81
|
+
enabledPricings
|
|
82
|
+
}) {
|
|
83
|
+
return request({
|
|
84
|
+
url: `${config.apiUrls.config}/portal/pricing-plan-schedules`,
|
|
85
|
+
options: { method: "POST" },
|
|
86
|
+
data: {
|
|
87
|
+
pricing_plan_subscription_id: pricingPlanSubscriptionId,
|
|
88
|
+
enabled_pricings: enabledPricings
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
return {
|
|
93
|
+
getOnDemandPricingItems,
|
|
94
|
+
createPricingPlanSchedule
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
const _hoisted_1$2 = { class: "sv-subscription-management-form__body grid grid-cols-1 gap-4" };
|
|
98
|
+
const _sfc_main$6 = /* @__PURE__ */ defineComponent({
|
|
99
|
+
__name: "SubscriptionManagementForm",
|
|
100
|
+
props: /* @__PURE__ */ mergeModels({
|
|
101
|
+
pricingGroup: { type: Object },
|
|
102
|
+
paymentMethods: { type: Array },
|
|
103
|
+
paymentMethodOptions: { type: Array },
|
|
104
|
+
billingPeriod: { type: Object },
|
|
105
|
+
currency: { type: String },
|
|
106
|
+
disabled: { type: Boolean }
|
|
107
|
+
}, {
|
|
108
|
+
"enabledPricingIds": { required: true },
|
|
109
|
+
"enabledPricingIdsModifiers": {},
|
|
110
|
+
"paymentMethodId": {},
|
|
111
|
+
"paymentMethodIdModifiers": {}
|
|
112
|
+
}),
|
|
113
|
+
emits: /* @__PURE__ */ mergeModels(["add-payment-method"], ["update:enabledPricingIds", "update:paymentMethodId"]),
|
|
114
|
+
setup(__props, { emit: __emit }) {
|
|
115
|
+
const props = __props;
|
|
116
|
+
const emit = __emit;
|
|
117
|
+
const enabledPricingIds = useModel(__props, "enabledPricingIds");
|
|
118
|
+
const paymentMethodId = useModel(__props, "paymentMethodId");
|
|
119
|
+
const { $t } = useIntl();
|
|
120
|
+
const toTime = (value) => {
|
|
121
|
+
const parsed = value ? Date.parse(value) : NaN;
|
|
122
|
+
return Number.isFinite(parsed) ? parsed : 0;
|
|
123
|
+
};
|
|
124
|
+
const sortedPaymentMethods = computed(
|
|
125
|
+
() => [...props.paymentMethods ?? []].sort((a, b) => toTime(b.created_at) - toTime(a.created_at))
|
|
126
|
+
);
|
|
127
|
+
watch(
|
|
128
|
+
() => props.paymentMethods,
|
|
129
|
+
(paymentMethods, previousPaymentMethods) => {
|
|
130
|
+
var _a;
|
|
131
|
+
const addedPaymentMethod = paymentMethods == null ? void 0 : paymentMethods.find(
|
|
132
|
+
({ id }) => !(previousPaymentMethods == null ? void 0 : previousPaymentMethods.some((previous) => previous.id === id))
|
|
133
|
+
);
|
|
134
|
+
if (addedPaymentMethod && (previousPaymentMethods == null ? void 0 : previousPaymentMethods.length)) {
|
|
135
|
+
paymentMethodId.value = addedPaymentMethod.id;
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
if (paymentMethods == null ? void 0 : paymentMethods.some(({ id }) => id === paymentMethodId.value)) {
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
paymentMethodId.value = (_a = (paymentMethods == null ? void 0 : paymentMethods.find(({ is_default }) => is_default)) ?? sortedPaymentMethods.value[0]) == null ? void 0 : _a.id;
|
|
142
|
+
},
|
|
143
|
+
{ immediate: true }
|
|
144
|
+
);
|
|
145
|
+
return (_ctx, _cache) => {
|
|
146
|
+
return openBlock(), createElementBlock("form", {
|
|
147
|
+
class: "sv-subscription-management-form",
|
|
148
|
+
onSubmit: _cache[3] || (_cache[3] = withModifiers(() => {
|
|
149
|
+
}, ["prevent"]))
|
|
150
|
+
}, [
|
|
151
|
+
createElementVNode("div", _hoisted_1$2, [
|
|
152
|
+
createVNode(_sfc_main$7, {
|
|
153
|
+
modelValue: enabledPricingIds.value,
|
|
154
|
+
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => enabledPricingIds.value = $event),
|
|
155
|
+
class: "sv-subscription-management-form__pricing-group",
|
|
156
|
+
"group-name": __props.pricingGroup.name,
|
|
157
|
+
pricings: __props.pricingGroup.pricings,
|
|
158
|
+
"billing-period": __props.billingPeriod,
|
|
159
|
+
currency: __props.currency
|
|
160
|
+
}, null, 8, ["modelValue", "group-name", "pricings", "billing-period", "currency"]),
|
|
161
|
+
createElementVNode("div", null, [
|
|
162
|
+
createVNode(unref(_sfc_main$8), { spacing: "xs" })
|
|
163
|
+
]),
|
|
164
|
+
createVNode(_sfc_main$9, {
|
|
165
|
+
modelValue: paymentMethodId.value,
|
|
166
|
+
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => paymentMethodId.value = $event),
|
|
167
|
+
class: "sv-subscription-management-form__payment-methods",
|
|
168
|
+
"payment-methods": sortedPaymentMethods.value,
|
|
169
|
+
"payment-method-options": __props.paymentMethodOptions,
|
|
170
|
+
required: "",
|
|
171
|
+
disabled: __props.disabled,
|
|
172
|
+
label: unref($t)({
|
|
173
|
+
defaultMessage: "Payment method",
|
|
174
|
+
id: "subscription_management.payment_method_selector.label",
|
|
175
|
+
description: "Label above the payment method that pays for the subscription change"
|
|
176
|
+
}),
|
|
177
|
+
onAddPaymentMethod: _cache[2] || (_cache[2] = ($event) => emit("add-payment-method"))
|
|
178
|
+
}, null, 8, ["modelValue", "payment-methods", "payment-method-options", "disabled", "label"])
|
|
179
|
+
])
|
|
180
|
+
], 32);
|
|
181
|
+
};
|
|
182
|
+
}
|
|
183
|
+
});
|
|
184
|
+
const _sfc_main$5 = /* @__PURE__ */ defineComponent({
|
|
185
|
+
__name: "TranslationOverride",
|
|
186
|
+
props: {
|
|
187
|
+
messages: { type: Object }
|
|
188
|
+
},
|
|
189
|
+
setup(__props) {
|
|
190
|
+
const props = __props;
|
|
191
|
+
const settings = inject(TRANSLATION_SETTINGS_KEY, void 0);
|
|
192
|
+
const messages = computed(() => ({
|
|
193
|
+
...settings == null ? void 0 : settings.messages.value,
|
|
194
|
+
...props.messages
|
|
195
|
+
}));
|
|
196
|
+
return (_ctx, _cache) => {
|
|
197
|
+
var _a, _b;
|
|
198
|
+
return openBlock(), createBlock(unref(_sfc_main$a), {
|
|
199
|
+
locale: (_a = unref(settings)) == null ? void 0 : _a.locale.value,
|
|
200
|
+
"date-locale": (_b = unref(settings)) == null ? void 0 : _b.dateLocale.value,
|
|
201
|
+
messages: messages.value,
|
|
202
|
+
"show-timezones": false
|
|
203
|
+
}, {
|
|
204
|
+
default: withCtx(() => [
|
|
205
|
+
renderSlot(_ctx.$slots, "default")
|
|
206
|
+
]),
|
|
207
|
+
_: 3
|
|
208
|
+
}, 8, ["locale", "date-locale", "messages"]);
|
|
209
|
+
};
|
|
210
|
+
}
|
|
211
|
+
});
|
|
212
|
+
const _sfc_main$4 = /* @__PURE__ */ defineComponent({
|
|
213
|
+
__name: "SubscriptionManagementSummary",
|
|
214
|
+
props: {
|
|
215
|
+
invoice: { type: Object },
|
|
216
|
+
isPending: { type: Boolean },
|
|
217
|
+
hasError: { type: Boolean }
|
|
218
|
+
},
|
|
219
|
+
setup(__props) {
|
|
220
|
+
const { $t } = useIntl();
|
|
221
|
+
const invoicePreviewMessages = computed(() => ({
|
|
222
|
+
"invoice_preview.total_due_today_heading": $t({
|
|
223
|
+
defaultMessage: "Total due",
|
|
224
|
+
id: "subscription_management.summary.total_due_heading",
|
|
225
|
+
description: 'Heading above the total of the invoice previewing a subscription change, replacing the shared preview’s "Total due today"'
|
|
226
|
+
})
|
|
227
|
+
}));
|
|
228
|
+
return (_ctx, _cache) => {
|
|
229
|
+
return openBlock(), createBlock(unref(_sfc_main$b), {
|
|
230
|
+
class: "sv-subscription-management-summary",
|
|
231
|
+
title: unref($t)({
|
|
232
|
+
defaultMessage: "Order summary",
|
|
233
|
+
id: "subscription_management.summary.title",
|
|
234
|
+
description: "Title of the block previewing what a subscription change is invoiced for"
|
|
235
|
+
})
|
|
236
|
+
}, {
|
|
237
|
+
default: withCtx(() => [
|
|
238
|
+
__props.hasError ? (openBlock(), createBlock(unref(_sfc_main$c), {
|
|
239
|
+
key: 0,
|
|
240
|
+
class: "sv-subscription-management-summary__error sv-error",
|
|
241
|
+
title: unref($t)({
|
|
242
|
+
defaultMessage: "Unable to calculate the total. Please try again.",
|
|
243
|
+
id: "subscription_management.summary.error",
|
|
244
|
+
description: "Error shown when the invoice preview for a subscription change cannot be loaded"
|
|
245
|
+
})
|
|
246
|
+
}, null, 8, ["title"])) : __props.isPending || !__props.invoice ? (openBlock(), createBlock(_sfc_main$d, {
|
|
247
|
+
key: 1,
|
|
248
|
+
variant: "section",
|
|
249
|
+
class: "sv-subscription-management-summary__skeleton min-h-[120px]"
|
|
250
|
+
}, {
|
|
251
|
+
default: withCtx(() => [
|
|
252
|
+
!__props.isPending ? (openBlock(), createBlock(unref(_sfc_main$e), {
|
|
253
|
+
key: 0,
|
|
254
|
+
variant: "body-sm",
|
|
255
|
+
shade: "lighter",
|
|
256
|
+
tag: "div",
|
|
257
|
+
class: "sv-subscription-management-summary__empty-state"
|
|
258
|
+
}, {
|
|
259
|
+
default: withCtx(() => [
|
|
260
|
+
createTextVNode(toDisplayString(unref($t)({
|
|
261
|
+
defaultMessage: "Select your plan to see what it costs.",
|
|
262
|
+
id: "subscription_management.summary.empty_state",
|
|
263
|
+
description: "Shown in the order summary before a plan has been picked to preview"
|
|
264
|
+
})), 1)
|
|
265
|
+
]),
|
|
266
|
+
_: 1
|
|
267
|
+
})) : createCommentVNode("", true)
|
|
268
|
+
]),
|
|
269
|
+
_: 1
|
|
270
|
+
})) : (openBlock(), createBlock(_sfc_main$5, {
|
|
271
|
+
key: 2,
|
|
272
|
+
messages: invoicePreviewMessages.value
|
|
273
|
+
}, {
|
|
274
|
+
default: withCtx(() => [
|
|
275
|
+
createVNode(unref(_sfc_main$f), {
|
|
276
|
+
class: "sv-subscription-management-summary__invoice",
|
|
277
|
+
invoice: __props.invoice,
|
|
278
|
+
"is-customer-facing": ""
|
|
279
|
+
}, null, 8, ["invoice"])
|
|
280
|
+
]),
|
|
281
|
+
_: 1
|
|
282
|
+
}, 8, ["messages"]))
|
|
283
|
+
]),
|
|
284
|
+
_: 1
|
|
285
|
+
}, 8, ["title"]);
|
|
286
|
+
};
|
|
287
|
+
}
|
|
288
|
+
});
|
|
289
|
+
const _hoisted_1$1 = { class: "sv-subscription-management-success grid grid-cols-1 gap-4" };
|
|
290
|
+
const _hoisted_2$1 = { class: "sv-subscription-management-success__message" };
|
|
291
|
+
const _sfc_main$3 = /* @__PURE__ */ defineComponent({
|
|
292
|
+
__name: "SubscriptionManagementSuccess",
|
|
293
|
+
props: {
|
|
294
|
+
pricingGroupName: { type: String }
|
|
295
|
+
},
|
|
296
|
+
setup(__props) {
|
|
297
|
+
const props = __props;
|
|
298
|
+
const { $t } = useIntl();
|
|
299
|
+
const title = computed(
|
|
300
|
+
() => $t({
|
|
301
|
+
defaultMessage: "Subscription updated",
|
|
302
|
+
description: "Title shown on the manage subscription screen once the change is committed",
|
|
303
|
+
id: "subscription_management.success.title"
|
|
304
|
+
})
|
|
305
|
+
);
|
|
306
|
+
const message = computed(
|
|
307
|
+
() => props.pricingGroupName ? $t(
|
|
308
|
+
{
|
|
309
|
+
defaultMessage: "Your {subject} has been changed. Please be aware that it can take some time to reflect this change in your subscription.",
|
|
310
|
+
description: "Confirmation of the pricing group a committed subscription change applied to",
|
|
311
|
+
id: "subscription_management.success.message"
|
|
312
|
+
},
|
|
313
|
+
{ subject: props.pricingGroupName }
|
|
314
|
+
) : $t({
|
|
315
|
+
defaultMessage: "Your subscription has been changed. Please be aware that it can take some time to reflect this change in your subscription.",
|
|
316
|
+
description: "Confirmation of a committed subscription change when the pricing group is not known",
|
|
317
|
+
id: "subscription_management.success.message_generic"
|
|
318
|
+
})
|
|
319
|
+
);
|
|
320
|
+
return (_ctx, _cache) => {
|
|
321
|
+
return openBlock(), createElementBlock("div", _hoisted_1$1, [
|
|
322
|
+
createVNode(_sfc_main$g, {
|
|
323
|
+
status: "success",
|
|
324
|
+
title: title.value
|
|
325
|
+
}, {
|
|
326
|
+
default: withCtx(() => [
|
|
327
|
+
createElementVNode("span", _hoisted_2$1, toDisplayString(message.value), 1)
|
|
328
|
+
]),
|
|
329
|
+
_: 1
|
|
330
|
+
}, 8, ["title"])
|
|
331
|
+
]);
|
|
332
|
+
};
|
|
333
|
+
}
|
|
334
|
+
});
|
|
335
|
+
const _sfc_main$2 = /* @__PURE__ */ defineComponent({
|
|
336
|
+
__name: "AddPaymentMethodModal",
|
|
337
|
+
props: {
|
|
338
|
+
showModal: { type: Boolean },
|
|
339
|
+
customer: { type: Object },
|
|
340
|
+
paymentMethodOptions: { type: Array },
|
|
341
|
+
isLoading: { type: Boolean }
|
|
342
|
+
},
|
|
343
|
+
emits: ["success", "failure", "close"],
|
|
344
|
+
setup(__props, { emit: __emit }) {
|
|
345
|
+
const props = __props;
|
|
346
|
+
const emit = __emit;
|
|
347
|
+
const { $t } = useIntl();
|
|
348
|
+
const paymentMethodFormRef = ref();
|
|
349
|
+
const isSaving = computed(() => {
|
|
350
|
+
var _a;
|
|
351
|
+
return Boolean((_a = paymentMethodFormRef.value) == null ? void 0 : _a.isPaymentPending);
|
|
352
|
+
});
|
|
353
|
+
const hasEverOpened = ref(false);
|
|
354
|
+
watch(
|
|
355
|
+
() => props.showModal,
|
|
356
|
+
(showModal) => {
|
|
357
|
+
hasEverOpened.value = hasEverOpened.value || showModal;
|
|
358
|
+
},
|
|
359
|
+
{ immediate: true }
|
|
360
|
+
);
|
|
361
|
+
const handleConfirm = () => {
|
|
362
|
+
var _a;
|
|
363
|
+
(_a = paymentMethodFormRef.value) == null ? void 0 : _a.submit();
|
|
364
|
+
};
|
|
365
|
+
return (_ctx, _cache) => {
|
|
366
|
+
return openBlock(), createBlock(unref(Modal), {
|
|
367
|
+
"no-click-away": "",
|
|
368
|
+
class: "sv-add-payment-method-modal",
|
|
369
|
+
size: "lg",
|
|
370
|
+
"show-modal": __props.showModal,
|
|
371
|
+
"is-loading": isSaving.value,
|
|
372
|
+
title: unref($t)({
|
|
373
|
+
defaultMessage: "Add payment method",
|
|
374
|
+
id: "add_payment_method_modal.title",
|
|
375
|
+
description: "Title of the modal for adding a payment method"
|
|
376
|
+
}),
|
|
377
|
+
"sub-title": unref($t)({
|
|
378
|
+
defaultMessage: "Add a new payment method to pay with.",
|
|
379
|
+
id: "add_payment_method_modal.subtitle",
|
|
380
|
+
description: "Subtitle of the modal for adding a payment method"
|
|
381
|
+
}),
|
|
382
|
+
"confirm-button-text": unref($t)({
|
|
383
|
+
defaultMessage: "Save payment method",
|
|
384
|
+
id: "add_payment_method_modal.confirm_button.label",
|
|
385
|
+
description: "Label of the button that stores the payment method being added"
|
|
386
|
+
}),
|
|
387
|
+
"cancel-button-text": unref($t)({
|
|
388
|
+
defaultMessage: "Cancel",
|
|
389
|
+
id: "add_payment_method_modal.cancel_button.label",
|
|
390
|
+
description: "Label of the button that abandons adding a payment method"
|
|
391
|
+
}),
|
|
392
|
+
onConfirm: handleConfirm,
|
|
393
|
+
onClose: _cache[2] || (_cache[2] = ($event) => emit("close"))
|
|
394
|
+
}, {
|
|
395
|
+
body: withCtx(() => [
|
|
396
|
+
__props.customer && hasEverOpened.value ? (openBlock(), createBlock(_sfc_main$h, {
|
|
397
|
+
key: 0,
|
|
398
|
+
ref_key: "paymentMethodFormRef",
|
|
399
|
+
ref: paymentMethodFormRef,
|
|
400
|
+
"hide-submit-button": "",
|
|
401
|
+
class: "sv-add-payment-method-modal__form",
|
|
402
|
+
customer: __props.customer,
|
|
403
|
+
"payment-method-options": __props.paymentMethodOptions,
|
|
404
|
+
"is-loading": __props.isLoading,
|
|
405
|
+
onSuccess: _cache[0] || (_cache[0] = ($event) => emit("success")),
|
|
406
|
+
onFailure: _cache[1] || (_cache[1] = (error) => emit("failure", error))
|
|
407
|
+
}, null, 8, ["customer", "payment-method-options", "is-loading"])) : createCommentVNode("", true)
|
|
408
|
+
]),
|
|
409
|
+
_: 1
|
|
410
|
+
}, 8, ["show-modal", "is-loading", "title", "sub-title", "confirm-button-text", "cancel-button-text"]);
|
|
411
|
+
};
|
|
412
|
+
}
|
|
413
|
+
});
|
|
414
|
+
const _hoisted_1 = { class: "sv-subscription-management__header" };
|
|
415
|
+
const _hoisted_2 = { class: "flex flex-col gap-2" };
|
|
416
|
+
const _sfc_main$1 = /* @__PURE__ */ defineComponent({
|
|
417
|
+
__name: "SubscriptionManagement",
|
|
418
|
+
props: {
|
|
419
|
+
configuration: { type: Object }
|
|
420
|
+
},
|
|
421
|
+
setup(__props) {
|
|
422
|
+
const props = __props;
|
|
423
|
+
const { $t } = useIntl();
|
|
424
|
+
const portal = usePortal();
|
|
425
|
+
const logger = useLogger();
|
|
426
|
+
const { dispatchAction } = useActionDispatchProvider();
|
|
427
|
+
const { createPricingPlanSchedule } = createPricingPlanSchedulesService();
|
|
428
|
+
const { subscription, get: fetchSubscription } = useSubscription({
|
|
429
|
+
subscriptionId: props.configuration.subscriptionId
|
|
430
|
+
});
|
|
431
|
+
const { items: paymentMethods, fetchAll: fetchPaymentMethods } = usePaymentMethods({
|
|
432
|
+
customerId: portal.value.customer_id
|
|
433
|
+
});
|
|
434
|
+
const { customer, get: fetchCustomer } = useCustomer({ customerId: portal.value.customer_id });
|
|
435
|
+
const { paymentMethodOptions, get: fetchPaymentMethodOptions } = usePaymentMethodOptions();
|
|
436
|
+
const { isLoading } = useLoadInitialData(
|
|
437
|
+
fetchSubscription(),
|
|
438
|
+
fetchPaymentMethods(),
|
|
439
|
+
fetchCustomer.execute(),
|
|
440
|
+
fetchPaymentMethodOptions({ customerId: portal.value.customer_id })
|
|
441
|
+
);
|
|
442
|
+
const isAddingPaymentMethod = ref(false);
|
|
443
|
+
const handlePaymentMethodAdded = async () => {
|
|
444
|
+
await fetchPaymentMethods();
|
|
445
|
+
isAddingPaymentMethod.value = false;
|
|
446
|
+
};
|
|
447
|
+
const activeScheduleInfo = computed(
|
|
448
|
+
() => {
|
|
449
|
+
var _a;
|
|
450
|
+
return getActiveDefaultScheduleInfo(((_a = subscription.value) == null ? void 0 : _a.pricing_plan_schedule_infos) ?? []);
|
|
451
|
+
}
|
|
452
|
+
);
|
|
453
|
+
const pricingGroup = computed(() => {
|
|
454
|
+
var _a;
|
|
455
|
+
const scheduleInfo = activeScheduleInfo.value;
|
|
456
|
+
if (!scheduleInfo) {
|
|
457
|
+
return void 0;
|
|
458
|
+
}
|
|
459
|
+
const { enabledPricingId } = props.configuration;
|
|
460
|
+
const pricingIds = enabledPricingId ? [enabledPricingId] : (((_a = scheduleInfo.pricing_plan_schedule) == null ? void 0 : _a.enabled_pricings) ?? []).map(
|
|
461
|
+
({ pricing_id }) => pricing_id
|
|
462
|
+
);
|
|
463
|
+
return pricingIds.map(
|
|
464
|
+
(pricingId) => getPricingGroupByPricingId({ pricingPlanScheduleInfo: scheduleInfo, pricingId })
|
|
465
|
+
).find((group) => Boolean(group));
|
|
466
|
+
});
|
|
467
|
+
const title = computed(
|
|
468
|
+
() => {
|
|
469
|
+
var _a;
|
|
470
|
+
return $t(
|
|
471
|
+
{
|
|
472
|
+
defaultMessage: "Manage {subject}",
|
|
473
|
+
id: "subscription_management.title",
|
|
474
|
+
description: "Title for the manage subscription page, naming the pricing group being changed"
|
|
475
|
+
},
|
|
476
|
+
{
|
|
477
|
+
subject: ((_a = pricingGroup.value) == null ? void 0 : _a.name) || $t({
|
|
478
|
+
defaultMessage: "subscription",
|
|
479
|
+
id: "subscription_management.title.default_subject",
|
|
480
|
+
description: 'Stands in for the pricing group name in the manage subscription title when no group is known, e.g. "Manage subscription"'
|
|
481
|
+
})
|
|
482
|
+
}
|
|
483
|
+
);
|
|
484
|
+
}
|
|
485
|
+
);
|
|
486
|
+
const enabledPricingIds = ref([]);
|
|
487
|
+
const paymentMethodId = ref();
|
|
488
|
+
watch(
|
|
489
|
+
[activeScheduleInfo, pricingGroup],
|
|
490
|
+
([scheduleInfo, group]) => {
|
|
491
|
+
var _a;
|
|
492
|
+
const scheduled = (((_a = scheduleInfo == null ? void 0 : scheduleInfo.pricing_plan_schedule) == null ? void 0 : _a.enabled_pricings) ?? []).map(
|
|
493
|
+
({ pricing_id }) => pricing_id
|
|
494
|
+
);
|
|
495
|
+
const { enabledPricingId } = props.configuration;
|
|
496
|
+
const groupPricingIds = ((group == null ? void 0 : group.pricings) ?? []).map(({ id }) => id);
|
|
497
|
+
enabledPricingIds.value = enabledPricingId && groupPricingIds.includes(enabledPricingId) ? [...scheduled.filter((id) => !groupPricingIds.includes(id)), enabledPricingId] : scheduled;
|
|
498
|
+
},
|
|
499
|
+
{ immediate: true }
|
|
500
|
+
);
|
|
501
|
+
const {
|
|
502
|
+
invoice: previewInvoice,
|
|
503
|
+
isPending: isPreviewPending,
|
|
504
|
+
error: previewError,
|
|
505
|
+
load: loadPreview
|
|
506
|
+
} = useSubscriptionUpgradePreview();
|
|
507
|
+
watch(
|
|
508
|
+
[enabledPricingIds, subscription],
|
|
509
|
+
([pricingIds, loadedSubscription]) => {
|
|
510
|
+
if (!loadedSubscription || pricingIds.length === 0) {
|
|
511
|
+
return;
|
|
512
|
+
}
|
|
513
|
+
void loadPreview({
|
|
514
|
+
subscription: loadedSubscription,
|
|
515
|
+
enabledPricingIds: pricingIds
|
|
516
|
+
});
|
|
517
|
+
},
|
|
518
|
+
{ immediate: true }
|
|
519
|
+
);
|
|
520
|
+
const isUpdating = ref(false);
|
|
521
|
+
const updateError = ref();
|
|
522
|
+
const isUpdated = ref(false);
|
|
523
|
+
const canUpdate = computed(
|
|
524
|
+
() => !isLoading.value && !isUpdating.value && enabledPricingIds.value.length > 0 && Boolean(subscription.value) && Boolean(paymentMethodId.value)
|
|
525
|
+
);
|
|
526
|
+
const handleUpdate = async () => {
|
|
527
|
+
if (!canUpdate.value || !subscription.value) {
|
|
528
|
+
return;
|
|
529
|
+
}
|
|
530
|
+
isUpdating.value = true;
|
|
531
|
+
updateError.value = void 0;
|
|
532
|
+
try {
|
|
533
|
+
await createPricingPlanSchedule({
|
|
534
|
+
pricingPlanSubscriptionId: subscription.value.id,
|
|
535
|
+
enabledPricings: enabledPricingIds.value.map((pricingId) => ({
|
|
536
|
+
pricing_id: pricingId
|
|
537
|
+
}))
|
|
538
|
+
});
|
|
539
|
+
isUpdated.value = true;
|
|
540
|
+
} catch (error) {
|
|
541
|
+
logger.error(
|
|
542
|
+
"SUBSCRIPTION_UPDATE_FAILED",
|
|
543
|
+
"Failed to start a new pricing plan schedule",
|
|
544
|
+
{},
|
|
545
|
+
error
|
|
546
|
+
);
|
|
547
|
+
updateError.value = $t({
|
|
548
|
+
defaultMessage: "Something went wrong. Please try again.",
|
|
549
|
+
id: "subscription_management.update_error",
|
|
550
|
+
description: "Error shown when committing a subscription change fails"
|
|
551
|
+
});
|
|
552
|
+
} finally {
|
|
553
|
+
isUpdating.value = false;
|
|
554
|
+
}
|
|
555
|
+
};
|
|
556
|
+
const billingPeriod = computed(
|
|
557
|
+
() => {
|
|
558
|
+
var _a, _b, _c;
|
|
559
|
+
return ((_b = (_a = activeScheduleInfo.value) == null ? void 0 : _a.pricing_plan_schedule) == null ? void 0 : _b.billing_period) ?? ((_c = subscription.value) == null ? void 0 : _c.billing_period);
|
|
560
|
+
}
|
|
561
|
+
);
|
|
562
|
+
return (_ctx, _cache) => {
|
|
563
|
+
return openBlock(), createBlock(unref(ContentWithAsideLayout), { class: "sv-subscription-management sv-root sv-screen" }, {
|
|
564
|
+
header: withCtx(() => [
|
|
565
|
+
createElementVNode("div", _hoisted_1, [
|
|
566
|
+
createVNode(unref(_sfc_main$e), {
|
|
567
|
+
variant: "heading-2",
|
|
568
|
+
tag: "h1",
|
|
569
|
+
class: "sv-subscription-management__title"
|
|
570
|
+
}, {
|
|
571
|
+
default: withCtx(() => [
|
|
572
|
+
createTextVNode(toDisplayString(title.value), 1)
|
|
573
|
+
]),
|
|
574
|
+
_: 1
|
|
575
|
+
})
|
|
576
|
+
])
|
|
577
|
+
]),
|
|
578
|
+
content: withCtx(() => {
|
|
579
|
+
var _a, _b;
|
|
580
|
+
return [
|
|
581
|
+
isUpdated.value ? (openBlock(), createBlock(_sfc_main$3, {
|
|
582
|
+
key: 0,
|
|
583
|
+
class: "sv-subscription-management__success",
|
|
584
|
+
"pricing-group-name": (_a = pricingGroup.value) == null ? void 0 : _a.name
|
|
585
|
+
}, null, 8, ["pricing-group-name"])) : unref(isLoading) ? (openBlock(), createBlock(_sfc_main$d, {
|
|
586
|
+
key: 1,
|
|
587
|
+
variant: "section",
|
|
588
|
+
class: "min-h-[220px]"
|
|
589
|
+
})) : pricingGroup.value && billingPeriod.value ? (openBlock(), createBlock(_sfc_main$6, {
|
|
590
|
+
key: 2,
|
|
591
|
+
"enabled-pricing-ids": enabledPricingIds.value,
|
|
592
|
+
"onUpdate:enabledPricingIds": _cache[0] || (_cache[0] = ($event) => enabledPricingIds.value = $event),
|
|
593
|
+
"payment-method-id": paymentMethodId.value,
|
|
594
|
+
"onUpdate:paymentMethodId": _cache[1] || (_cache[1] = ($event) => paymentMethodId.value = $event),
|
|
595
|
+
class: "sv-subscription-management__form",
|
|
596
|
+
"pricing-group": pricingGroup.value,
|
|
597
|
+
"payment-methods": unref(paymentMethods),
|
|
598
|
+
"payment-method-options": unref(paymentMethodOptions),
|
|
599
|
+
"billing-period": billingPeriod.value,
|
|
600
|
+
currency: (_b = unref(subscription)) == null ? void 0 : _b.billing_currency,
|
|
601
|
+
onAddPaymentMethod: _cache[2] || (_cache[2] = ($event) => isAddingPaymentMethod.value = true)
|
|
602
|
+
}, null, 8, ["enabled-pricing-ids", "payment-method-id", "pricing-group", "payment-methods", "payment-method-options", "billing-period", "currency"])) : createCommentVNode("", true),
|
|
603
|
+
createVNode(_sfc_main$2, {
|
|
604
|
+
"show-modal": isAddingPaymentMethod.value,
|
|
605
|
+
customer: unref(customer),
|
|
606
|
+
"payment-method-options": unref(paymentMethodOptions),
|
|
607
|
+
onSuccess: handlePaymentMethodAdded,
|
|
608
|
+
onClose: _cache[3] || (_cache[3] = ($event) => isAddingPaymentMethod.value = false)
|
|
609
|
+
}, null, 8, ["show-modal", "customer", "payment-method-options"])
|
|
610
|
+
];
|
|
611
|
+
}),
|
|
612
|
+
aside: withCtx(() => [
|
|
613
|
+
isUpdated.value ? (openBlock(), createBlock(unref(_sfc_main$i), {
|
|
614
|
+
key: 0,
|
|
615
|
+
size: "lg",
|
|
616
|
+
class: "sv-action sv-action--primary sv-action--full-width sv-subscription-management__done w-full",
|
|
617
|
+
type: "button",
|
|
618
|
+
onClick: _cache[4] || (_cache[4] = ($event) => unref(dispatchAction)({ action: "navigate-to-customer-overview" }))
|
|
619
|
+
}, {
|
|
620
|
+
default: withCtx(() => [
|
|
621
|
+
createTextVNode(toDisplayString(unref($t)({
|
|
622
|
+
defaultMessage: "Done",
|
|
623
|
+
id: "subscription_management.done_button.label",
|
|
624
|
+
description: "Label of the button that leaves the manage subscription screen once the change is committed"
|
|
625
|
+
})), 1)
|
|
626
|
+
]),
|
|
627
|
+
_: 1
|
|
628
|
+
})) : (openBlock(), createElementBlock(Fragment, { key: 1 }, [
|
|
629
|
+
createVNode(_sfc_main$4, {
|
|
630
|
+
class: "sv-subscription-management__summary",
|
|
631
|
+
invoice: unref(previewInvoice),
|
|
632
|
+
"is-pending": unref(isLoading) || unref(isPreviewPending),
|
|
633
|
+
"has-error": Boolean(unref(previewError))
|
|
634
|
+
}, null, 8, ["invoice", "is-pending", "has-error"]),
|
|
635
|
+
updateError.value ? (openBlock(), createBlock(unref(_sfc_main$c), {
|
|
636
|
+
key: 0,
|
|
637
|
+
class: "sv-subscription-management__update-error sv-error",
|
|
638
|
+
title: updateError.value
|
|
639
|
+
}, null, 8, ["title"])) : createCommentVNode("", true),
|
|
640
|
+
createElementVNode("div", _hoisted_2, [
|
|
641
|
+
createVNode(unref(_sfc_main$i), {
|
|
642
|
+
size: "lg",
|
|
643
|
+
class: "sv-action sv-action--primary sv-action--full-width sv-subscription-management__update w-full",
|
|
644
|
+
type: "button",
|
|
645
|
+
disabled: !canUpdate.value,
|
|
646
|
+
loading: isUpdating.value,
|
|
647
|
+
onClick: handleUpdate
|
|
648
|
+
}, {
|
|
649
|
+
default: withCtx(() => [
|
|
650
|
+
createTextVNode(toDisplayString(unref($t)({
|
|
651
|
+
defaultMessage: "Update subscription",
|
|
652
|
+
id: "subscription_management.update_button.label",
|
|
653
|
+
description: "Label of the button that commits the subscription change"
|
|
654
|
+
})), 1)
|
|
655
|
+
]),
|
|
656
|
+
_: 1
|
|
657
|
+
}, 8, ["disabled", "loading"]),
|
|
658
|
+
createVNode(_sfc_main$j, {
|
|
659
|
+
class: "sv-subscription-management__kpi",
|
|
660
|
+
"payment-method-options": unref(paymentMethodOptions)
|
|
661
|
+
}, null, 8, ["payment-method-options"])
|
|
662
|
+
])
|
|
663
|
+
], 64))
|
|
664
|
+
]),
|
|
665
|
+
_: 1
|
|
666
|
+
});
|
|
667
|
+
};
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
const _sfc_main = /* @__PURE__ */ defineComponent({
|
|
671
|
+
__name: "SubscriptionManagement.entry",
|
|
672
|
+
props: {
|
|
673
|
+
environment: { type: String },
|
|
674
|
+
locale: { type: String },
|
|
675
|
+
dateLocale: { type: String },
|
|
676
|
+
messages: { type: Object },
|
|
677
|
+
primaryColor: { type: String },
|
|
678
|
+
secondaryColor: { type: String },
|
|
679
|
+
isShadowRoot: { type: Boolean },
|
|
680
|
+
experimentalFeatures: { type: Array },
|
|
681
|
+
logLevel: { type: String },
|
|
682
|
+
onLog: { type: Function },
|
|
683
|
+
allowedPortalTypes: { type: Array },
|
|
684
|
+
portalObject: { type: Object },
|
|
685
|
+
cssOverrides: { type: [String, Array] },
|
|
686
|
+
branding: { type: Object },
|
|
687
|
+
configuration: { type: Object }
|
|
688
|
+
},
|
|
689
|
+
setup(__props) {
|
|
690
|
+
return (_ctx, _cache) => {
|
|
691
|
+
var _a, _b, _c, _d;
|
|
692
|
+
return openBlock(), createBlock(_sfc_main$k, {
|
|
693
|
+
"custom-element-name": unref(COMPONENT_NAME),
|
|
694
|
+
environment: __props.environment,
|
|
695
|
+
locale: __props.locale,
|
|
696
|
+
"portal-object": __props.portalObject,
|
|
697
|
+
"allowed-portal-types": ["CUSTOMER"],
|
|
698
|
+
"primary-color": (_b = (_a = __props.branding) == null ? void 0 : _a.colors) == null ? void 0 : _b.primary,
|
|
699
|
+
"secondary-color": (_d = (_c = __props.branding) == null ? void 0 : _c.colors) == null ? void 0 : _d.secondary,
|
|
700
|
+
"experimental-features": __props.experimentalFeatures,
|
|
701
|
+
"log-level": __props.logLevel,
|
|
702
|
+
"on-log": __props.onLog,
|
|
703
|
+
"css-overrides": __props.cssOverrides,
|
|
704
|
+
onError: _cache[0] || (_cache[0] = (error) => _ctx.$emit("error", error))
|
|
705
|
+
}, {
|
|
706
|
+
default: withCtx(() => [
|
|
707
|
+
createVNode(_sfc_main$1, { configuration: __props.configuration }, null, 8, ["configuration"])
|
|
708
|
+
]),
|
|
709
|
+
_: 1
|
|
710
|
+
}, 8, ["custom-element-name", "environment", "locale", "portal-object", "primary-color", "secondary-color", "experimental-features", "log-level", "on-log", "css-overrides"]);
|
|
711
|
+
};
|
|
712
|
+
}
|
|
713
|
+
});
|
|
714
|
+
const SolvimonSubscriptionManagement = defineCustomElement(_sfc_main);
|
|
715
|
+
const COMPONENT_NAME = getComponentName("subscription-management");
|
|
716
|
+
const defineSolvimonSubscriptionManagement = () => {
|
|
717
|
+
if (!customElements.get(COMPONENT_NAME)) {
|
|
718
|
+
customElements.define(COMPONENT_NAME, SolvimonSubscriptionManagement);
|
|
719
|
+
}
|
|
720
|
+
};
|
|
721
|
+
export {
|
|
722
|
+
COMPONENT_NAME,
|
|
723
|
+
SolvimonSubscriptionManagement,
|
|
724
|
+
defineSolvimonSubscriptionManagement
|
|
725
|
+
};
|