@burdenoff/microfe-billing 2026.612.1 → 2026.623.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/billing/BillingAdminRoutes.js +7 -6
- package/dist/billing/BillingAdminRoutes.js.map +1 -1
- package/dist/billing/BillingRoot.js +1 -1
- package/dist/billing/BillingRoot.js.map +1 -1
- package/dist/billing/modules/addons/components/FloatingCartDrawer.js +22 -22
- package/dist/billing/modules/addons/components/FloatingCartDrawer.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonCreatePage.js +31 -31
- package/dist/billing/modules/addons/pages/AddonCreatePage.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonDetailPage.js +39 -39
- package/dist/billing/modules/addons/pages/AddonDetailPage.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonEditPage.js +29 -29
- package/dist/billing/modules/addons/pages/AddonEditPage.js.map +1 -1
- package/dist/billing/modules/addons/pages/AddonsListPage.js +91 -91
- package/dist/billing/modules/addons/pages/AddonsListPage.js.map +1 -1
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js +40 -40
- package/dist/billing/modules/analytics/pages/AnalyticsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoiceDetailPage.js +115 -115
- package/dist/billing/modules/billing/pages/InvoiceDetailPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +75 -72
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/RefundsPage.js +126 -126
- package/dist/billing/modules/billing/pages/RefundsPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +45 -45
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -1
- package/dist/billing/modules/checkout/components/BillingAccountSelector.js +25 -25
- package/dist/billing/modules/checkout/components/BillingAccountSelector.js.map +1 -1
- package/dist/billing/modules/checkout/components/CompleteBillingAccountModal.js +31 -35
- package/dist/billing/modules/checkout/components/CompleteBillingAccountModal.js.map +1 -1
- package/dist/billing/modules/checkout/components/CreditsAmountInput.js +9 -9
- package/dist/billing/modules/checkout/components/CreditsAmountInput.js.map +1 -1
- package/dist/billing/modules/checkout/components/OrderSummary.js +31 -31
- package/dist/billing/modules/checkout/components/OrderSummary.js.map +1 -1
- package/dist/billing/modules/checkout/components/PromoCodeInput.js +8 -8
- package/dist/billing/modules/checkout/components/PromoCodeInput.js.map +1 -1
- package/dist/billing/modules/checkout/components/RazorpayPaymentButton.js +5 -5
- package/dist/billing/modules/checkout/components/RazorpayPaymentButton.js.map +1 -1
- package/dist/billing/modules/checkout/components/SimpleAutoPayToggle.js +9 -9
- package/dist/billing/modules/checkout/components/SimpleAutoPayToggle.js.map +1 -1
- package/dist/billing/modules/checkout/components/StripePaymentForm.js +21 -21
- package/dist/billing/modules/checkout/components/StripePaymentForm.js.map +1 -1
- package/dist/billing/modules/checkout/components/SubscriptionSelector.js +11 -11
- package/dist/billing/modules/checkout/components/SubscriptionSelector.js.map +1 -1
- package/dist/billing/modules/checkout/components/UnifiedPaymentMethodSelector.js +31 -31
- package/dist/billing/modules/checkout/components/UnifiedPaymentMethodSelector.js.map +1 -1
- package/dist/billing/modules/checkout/components/WorkspaceQuotaAssignmentModal.js +23 -23
- package/dist/billing/modules/checkout/components/WorkspaceQuotaAssignmentModal.js.map +1 -1
- package/dist/billing/modules/checkout/hooks/useCheckout.js +215 -174
- package/dist/billing/modules/checkout/hooks/useCheckout.js.map +1 -1
- package/dist/billing/modules/checkout/pages/CheckoutPage.js +93 -93
- package/dist/billing/modules/checkout/pages/CheckoutPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js +62 -62
- package/dist/billing/modules/coupons/pages/CouponDetailPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CouponsListPage.js +72 -60
- package/dist/billing/modules/coupons/pages/CouponsListPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js +66 -66
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
- package/dist/billing/modules/coupons/pages/EditCouponPage.js +46 -46
- package/dist/billing/modules/coupons/pages/EditCouponPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/AdminCreditsPage.js +19 -19
- package/dist/billing/modules/credits/pages/AdminCreditsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js +37 -37
- package/dist/billing/modules/credits/pages/CreditTransactionsPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js +90 -90
- package/dist/billing/modules/credits/pages/CreditWithdrawalPage.js.map +1 -1
- package/dist/billing/modules/credits/pages/CreditsPage.js +41 -41
- package/dist/billing/modules/credits/pages/CreditsPage.js.map +1 -1
- package/dist/billing/modules/dashboard/components/ActiveSubscriptionCard.js +31 -31
- package/dist/billing/modules/dashboard/components/ActiveSubscriptionCard.js.map +1 -1
- package/dist/billing/modules/dashboard/components/AddPaymentMethodModal.js +35 -35
- package/dist/billing/modules/dashboard/components/AddPaymentMethodModal.js.map +1 -1
- package/dist/billing/modules/dashboard/components/BillingAccountCard.js +24 -24
- package/dist/billing/modules/dashboard/components/BillingAccountCard.js.map +1 -1
- package/dist/billing/modules/dashboard/components/CreateBillingAccountModal.js +99 -99
- package/dist/billing/modules/dashboard/components/CreateBillingAccountModal.js.map +1 -1
- package/dist/billing/modules/dashboard/components/PaymentMethodsSection.js +23 -23
- package/dist/billing/modules/dashboard/components/PaymentMethodsSection.js.map +1 -1
- package/dist/billing/modules/dashboard/components/RecommendedAddonsSection.js +22 -22
- package/dist/billing/modules/dashboard/components/RecommendedAddonsSection.js.map +1 -1
- package/dist/billing/modules/dashboard/pages/OverviewPage.js +58 -58
- package/dist/billing/modules/dashboard/pages/OverviewPage.js.map +1 -1
- package/dist/billing/modules/discounts/pages/DiscountsListPage.js +126 -126
- package/dist/billing/modules/discounts/pages/DiscountsListPage.js.map +1 -1
- package/dist/billing/modules/earnings/pages/PayoutAdminPage.js +83 -79
- package/dist/billing/modules/earnings/pages/PayoutAdminPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +16 -16
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js +40 -40
- package/dist/billing/modules/plans/pages/PlanBrowseDetailPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanCreatePage.js +35 -35
- package/dist/billing/modules/plans/pages/PlanCreatePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanDetailPage.js +57 -57
- package/dist/billing/modules/plans/pages/PlanDetailPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +35 -35
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +57 -57
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansListPage.js +52 -52
- package/dist/billing/modules/plans/pages/PlansListPage.js.map +1 -1
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js +40 -39
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js.map +1 -1
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js +22 -19
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js.map +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js +34 -34
- package/dist/billing/modules/quota/pages/QuotaTemplateCreatePage.js.map +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js +46 -46
- package/dist/billing/modules/quota/pages/QuotaTemplateDetailPage.js.map +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js +39 -39
- package/dist/billing/modules/quota/pages/QuotaTemplateEditPage.js.map +1 -1
- package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js +50 -50
- package/dist/billing/modules/quota/pages/QuotaTemplatesListPage.js.map +1 -1
- package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js +23 -23
- package/dist/billing/modules/subscriptions/components/ManageSeatsModal.js.map +1 -1
- package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js +259 -246
- package/dist/billing/modules/subscriptions/pages/SubscriptionDetailPage.js.map +1 -1
- package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js +88 -85
- package/dist/billing/modules/subscriptions/pages/SubscriptionsListPage.js.map +1 -1
- package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js +51 -51
- package/dist/billing/modules/subscriptions/pages/UpgradeSubscriptionPage.js.map +1 -1
- package/dist/billing/modules/usage/pages/UsagePage.js +206 -196
- package/dist/billing/modules/usage/pages/UsagePage.js.map +1 -1
- package/dist/billing/shared/components/ServerError.js +4 -4
- package/dist/billing/shared/components/ServerError.js.map +1 -1
- package/dist/billing/shared/components/StatCard.js +11 -33
- package/dist/billing/shared/components/StatCard.js.map +1 -1
- package/dist/billing/shared/ui/Card.js +15 -0
- package/dist/billing/shared/ui/Card.js.map +1 -0
- package/dist/billing/shared/ui/MetricCard.js +44 -0
- package/dist/billing/shared/ui/MetricCard.js.map +1 -0
- package/dist/billing/shared/ui/ProgressBar.js +30 -0
- package/dist/billing/shared/ui/ProgressBar.js.map +1 -0
- package/dist/billing/shared/ui/SectionHeader.js +2 -0
- package/dist/billing/shared/ui/StatusPill.js +28 -0
- package/dist/billing/shared/ui/StatusPill.js.map +1 -0
- package/dist/billing/shared/ui/index.js +5 -0
- package/dist/billing/shared/utils/tokens.js +13 -30
- package/dist/billing/shared/utils/tokens.js.map +1 -1
- package/dist/generated/global-operations.js +265 -245
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,60 +1,60 @@
|
|
|
1
1
|
import { useBilling as e } from "../../../providers/BillingProvider.js";
|
|
2
|
-
import { useConvertCurrencyLazyQuery as t,
|
|
3
|
-
import { useCallback as
|
|
2
|
+
import { useConvertCurrencyLazyQuery as t, useCreateBillingOrderCheckoutMutation as n, useInitiatePaymentCheckoutMutation as r, useSpendCreditsCheckoutMutation as i, useValidateCouponLazyQuery as a } from "../../../../generated/global-operations.js";
|
|
3
|
+
import { useCallback as o, useEffect as s, useMemo as c, useState as l } from "react";
|
|
4
4
|
//#region src/billing/modules/checkout/hooks/useCheckout.ts
|
|
5
5
|
var ee = 100;
|
|
6
|
-
function
|
|
7
|
-
let { currentUser:
|
|
6
|
+
function u(u = {}) {
|
|
7
|
+
let { currentUser: d } = e(), { defaultCurrency: f = "USD", defaultSaveCard: p = !1, upgradeFromSubscriptionId: m, downgradeFromSubscriptionId: h, defaultSubscriptionId: g } = u, [_, v] = l([]), [y, te] = l(null), [b, x] = l("AUTO"), [S, C] = l(f), [w, T] = l(""), [E, D] = l(0), [ne, O] = l("PERCENTAGE"), [k, A] = l(!1), [j, M] = l(0), [N, P] = l("idle"), [re, F] = l(null), [I, L] = l(0), [ie, R] = l(0), [ae, z] = l("NONE"), [B, V] = l(null), [H, oe] = l(p), [U, se] = l(!1), [W, G] = l(null), [K, ce] = l(g ?? null), [le] = r(), [ue] = n(), [de] = i(), [q, { data: fe, loading: pe }] = t(), [me] = a(), J = c(() => _.reduce((e, t) => e + t.price * t.quantity, 0), [_]), Y = c(() => _.reduce((e, t) => e + (t.priceUSD ?? t.price) * t.quantity, 0), [_]), X = c(() => E ? Math.min(E, J) : 0, [J, E]), Z = c(() => {
|
|
8
8
|
let e = J - X;
|
|
9
|
-
return (
|
|
9
|
+
return (k ? Math.max(0, e - j) : e) + I;
|
|
10
10
|
}, [
|
|
11
11
|
J,
|
|
12
12
|
X,
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
]), Q =
|
|
17
|
-
|
|
18
|
-
if (
|
|
19
|
-
if (
|
|
13
|
+
k,
|
|
14
|
+
j,
|
|
15
|
+
I
|
|
16
|
+
]), Q = y?.creditAmount ?? 0, he = c(() => Q >= Y * ee, [Q, Y]), ge = c(() => !_.some((e) => e.type === "CREDITS") && Q > 0, [_, Q]), _e = fe?.convertCurrency?.amount ?? null, ve = fe?.convertCurrency?.exchangeRate ?? 1, ye = _e ?? Z, be = N === "loading" || pe, xe = N === "processing";
|
|
17
|
+
s(() => {
|
|
18
|
+
if (b !== "CREDITS" && _.length !== 0 && !_.every((e) => e.currency === S || e.type === "CREDITS") && Z > 0 && S !== "USD") {
|
|
19
|
+
if (S === "INR" && I === 0 && J > 0) return;
|
|
20
20
|
q({ variables: {
|
|
21
21
|
amount: Z,
|
|
22
|
-
toCurrency:
|
|
22
|
+
toCurrency: S,
|
|
23
23
|
fromCurrency: "USD"
|
|
24
24
|
} });
|
|
25
25
|
}
|
|
26
26
|
}, [
|
|
27
27
|
Z,
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
S,
|
|
29
|
+
b,
|
|
30
30
|
q,
|
|
31
|
-
|
|
31
|
+
I,
|
|
32
32
|
J,
|
|
33
|
-
|
|
34
|
-
]),
|
|
35
|
-
if (!
|
|
36
|
-
|
|
33
|
+
_
|
|
34
|
+
]), s(() => {
|
|
35
|
+
if (!y || J <= 0) {
|
|
36
|
+
L(0), R(0), z("NONE");
|
|
37
37
|
return;
|
|
38
38
|
}
|
|
39
|
-
if (
|
|
40
|
-
|
|
39
|
+
if (b === "CREDITS") {
|
|
40
|
+
L(0), R(0), z("NONE");
|
|
41
41
|
return;
|
|
42
42
|
}
|
|
43
|
-
if (
|
|
44
|
-
|
|
43
|
+
if (S !== "INR") {
|
|
44
|
+
L(0), R(0), z("NONE");
|
|
45
45
|
return;
|
|
46
46
|
}
|
|
47
47
|
let e = J - X, t = .18;
|
|
48
|
-
|
|
48
|
+
L(e * t), R(t), z("GST");
|
|
49
49
|
}, [
|
|
50
|
-
|
|
50
|
+
y,
|
|
51
51
|
J,
|
|
52
52
|
X,
|
|
53
|
-
|
|
54
|
-
|
|
53
|
+
S,
|
|
54
|
+
b
|
|
55
55
|
]);
|
|
56
|
-
let
|
|
57
|
-
|
|
56
|
+
let Se = o((e) => {
|
|
57
|
+
v((t) => e.type === "PLAN" ? t.find((e) => e.type === "PLAN") ? t.map((t) => t.type === "PLAN" ? {
|
|
58
58
|
...e,
|
|
59
59
|
quantity: 1
|
|
60
60
|
} : t) : [...t, {
|
|
@@ -64,22 +64,22 @@ function l(l = {}) {
|
|
|
64
64
|
...t,
|
|
65
65
|
quantity: t.quantity + e.quantity
|
|
66
66
|
} : t) : [...t, e]);
|
|
67
|
-
}, []), $ =
|
|
68
|
-
|
|
69
|
-
}, []),
|
|
67
|
+
}, []), $ = o((e) => {
|
|
68
|
+
v((t) => t.filter((t) => t.id !== e));
|
|
69
|
+
}, []), Ce = o((e, t) => {
|
|
70
70
|
if (t <= 0) {
|
|
71
71
|
$(e);
|
|
72
72
|
return;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
v((n) => n.map((n) => n.id === e ? n.type === "PLAN" ? {
|
|
75
75
|
...n,
|
|
76
76
|
quantity: 1
|
|
77
77
|
} : {
|
|
78
78
|
...n,
|
|
79
79
|
quantity: t
|
|
80
80
|
} : n));
|
|
81
|
-
}, [$]),
|
|
82
|
-
|
|
81
|
+
}, [$]), we = o((e, t, n) => {
|
|
82
|
+
v((r) => r.map((r) => {
|
|
83
83
|
if (r.id !== e) return r;
|
|
84
84
|
let i = { price: t };
|
|
85
85
|
return n && (i.currency = n), {
|
|
@@ -87,13 +87,13 @@ function l(l = {}) {
|
|
|
87
87
|
...i
|
|
88
88
|
};
|
|
89
89
|
}));
|
|
90
|
-
}, []),
|
|
91
|
-
|
|
92
|
-
}, []),
|
|
93
|
-
te(e),
|
|
94
|
-
}, []),
|
|
95
|
-
|
|
96
|
-
let t =
|
|
90
|
+
}, []), Te = o(() => {
|
|
91
|
+
v([]);
|
|
92
|
+
}, []), Ee = o((e) => {
|
|
93
|
+
te(e), A(!1), M(0);
|
|
94
|
+
}, []), De = o((e) => {
|
|
95
|
+
C(e);
|
|
96
|
+
let t = _.every((t) => t.currency === e || t.type === "CREDITS");
|
|
97
97
|
Z > 0 && e !== "USD" && !t && q({ variables: {
|
|
98
98
|
amount: Z,
|
|
99
99
|
toCurrency: e,
|
|
@@ -102,54 +102,54 @@ function l(l = {}) {
|
|
|
102
102
|
}, [
|
|
103
103
|
Z,
|
|
104
104
|
q,
|
|
105
|
-
|
|
105
|
+
_
|
|
106
106
|
]);
|
|
107
107
|
return {
|
|
108
|
-
items:
|
|
109
|
-
billingAccount:
|
|
110
|
-
selectedProvider:
|
|
111
|
-
selectedCurrency:
|
|
112
|
-
promoCode:
|
|
113
|
-
promoDiscount:
|
|
108
|
+
items: _,
|
|
109
|
+
billingAccount: y,
|
|
110
|
+
selectedProvider: b,
|
|
111
|
+
selectedCurrency: S,
|
|
112
|
+
promoCode: w,
|
|
113
|
+
promoDiscount: E,
|
|
114
114
|
promoDiscountType: ne,
|
|
115
|
-
useCredits:
|
|
116
|
-
creditsToUse:
|
|
117
|
-
checkoutState:
|
|
115
|
+
useCredits: k,
|
|
116
|
+
creditsToUse: j,
|
|
117
|
+
checkoutState: N,
|
|
118
118
|
error: re,
|
|
119
|
-
selectedPaymentMethodId:
|
|
120
|
-
saveCard:
|
|
121
|
-
autoRenew:
|
|
122
|
-
autoRenewPaymentMethodId:
|
|
123
|
-
selectedSubscriptionId:
|
|
119
|
+
selectedPaymentMethodId: B,
|
|
120
|
+
saveCard: H,
|
|
121
|
+
autoRenew: U,
|
|
122
|
+
autoRenewPaymentMethodId: W,
|
|
123
|
+
selectedSubscriptionId: K,
|
|
124
124
|
subtotal: J,
|
|
125
125
|
subtotalUSD: Y,
|
|
126
126
|
discountAmount: X,
|
|
127
|
-
taxAmount:
|
|
127
|
+
taxAmount: I,
|
|
128
128
|
taxRate: ie,
|
|
129
129
|
taxType: ae,
|
|
130
130
|
total: Z,
|
|
131
|
-
totalInSelectedCurrency:
|
|
131
|
+
totalInSelectedCurrency: ye,
|
|
132
132
|
availableCredits: Q,
|
|
133
|
-
hasEnoughCredits:
|
|
134
|
-
canPayWithCredits:
|
|
135
|
-
isLoading:
|
|
136
|
-
isProcessing:
|
|
133
|
+
hasEnoughCredits: he,
|
|
134
|
+
canPayWithCredits: ge,
|
|
135
|
+
isLoading: be,
|
|
136
|
+
isProcessing: xe,
|
|
137
137
|
isCalculatingTax: !1,
|
|
138
|
-
conversionRate:
|
|
139
|
-
convertedAmount:
|
|
140
|
-
addItem:
|
|
138
|
+
conversionRate: ve,
|
|
139
|
+
convertedAmount: _e,
|
|
140
|
+
addItem: Se,
|
|
141
141
|
removeItem: $,
|
|
142
|
-
updateItemQuantity:
|
|
143
|
-
updateItemPrice:
|
|
144
|
-
clearItems:
|
|
145
|
-
setBillingAccount:
|
|
146
|
-
setPaymentProvider:
|
|
147
|
-
|
|
148
|
-
}, [
|
|
149
|
-
setCurrency:
|
|
150
|
-
setPromoCode:
|
|
151
|
-
validatePromoCode:
|
|
152
|
-
if (!
|
|
142
|
+
updateItemQuantity: Ce,
|
|
143
|
+
updateItemPrice: we,
|
|
144
|
+
clearItems: Te,
|
|
145
|
+
setBillingAccount: Ee,
|
|
146
|
+
setPaymentProvider: o((e) => {
|
|
147
|
+
x(e), e === "RAZORPAY" && S !== "INR" && C("INR");
|
|
148
|
+
}, [S]),
|
|
149
|
+
setCurrency: De,
|
|
150
|
+
setPromoCode: T,
|
|
151
|
+
validatePromoCode: o(async () => {
|
|
152
|
+
if (!w.trim()) return {
|
|
153
153
|
valid: !1,
|
|
154
154
|
code: "",
|
|
155
155
|
discountType: "PERCENTAGE",
|
|
@@ -157,81 +157,81 @@ function l(l = {}) {
|
|
|
157
157
|
error: "Please enter a promo code"
|
|
158
158
|
};
|
|
159
159
|
try {
|
|
160
|
-
|
|
161
|
-
let { data: e, error: t } = await
|
|
162
|
-
code:
|
|
163
|
-
userId:
|
|
164
|
-
userEmail:
|
|
160
|
+
P("loading");
|
|
161
|
+
let { data: e, error: t } = await me({ variables: { input: {
|
|
162
|
+
code: w.trim().toUpperCase(),
|
|
163
|
+
userId: d?.id ?? "",
|
|
164
|
+
userEmail: d?.email,
|
|
165
165
|
amount: J,
|
|
166
|
-
currency:
|
|
166
|
+
currency: S
|
|
167
167
|
} } });
|
|
168
|
-
if (t || !e?.validateCoupon) return
|
|
168
|
+
if (t || !e?.validateCoupon) return D(0), P("idle"), {
|
|
169
169
|
valid: !1,
|
|
170
|
-
code:
|
|
170
|
+
code: w,
|
|
171
171
|
discountType: "PERCENTAGE",
|
|
172
172
|
discountValue: 0,
|
|
173
173
|
error: "Failed to validate coupon"
|
|
174
174
|
};
|
|
175
175
|
let n = e.validateCoupon;
|
|
176
|
-
if (!n.valid) return
|
|
176
|
+
if (!n.valid) return D(0), P("idle"), {
|
|
177
177
|
valid: !1,
|
|
178
|
-
code:
|
|
178
|
+
code: w,
|
|
179
179
|
discountType: "PERCENTAGE",
|
|
180
180
|
discountValue: 0,
|
|
181
181
|
error: n.error || "Invalid coupon code"
|
|
182
182
|
};
|
|
183
183
|
let r = n.coupon;
|
|
184
|
-
if (!r) return
|
|
184
|
+
if (!r) return D(0), P("idle"), {
|
|
185
185
|
valid: !1,
|
|
186
|
-
code:
|
|
186
|
+
code: w,
|
|
187
187
|
discountType: "PERCENTAGE",
|
|
188
188
|
discountValue: 0,
|
|
189
189
|
error: "Coupon data not found"
|
|
190
190
|
};
|
|
191
191
|
let i = n.discountAmount || 0, a = r.type === "FIXED_AMOUNT" ? "FIXED" : "PERCENTAGE";
|
|
192
|
-
return
|
|
192
|
+
return D(i), O(a), P("idle"), {
|
|
193
193
|
valid: !0,
|
|
194
194
|
code: r.code,
|
|
195
195
|
discountType: a,
|
|
196
196
|
discountValue: i
|
|
197
197
|
};
|
|
198
198
|
} catch {
|
|
199
|
-
return
|
|
199
|
+
return D(0), P("idle"), {
|
|
200
200
|
valid: !1,
|
|
201
|
-
code:
|
|
201
|
+
code: w,
|
|
202
202
|
discountType: "PERCENTAGE",
|
|
203
203
|
discountValue: 0,
|
|
204
204
|
error: "Failed to validate coupon"
|
|
205
205
|
};
|
|
206
206
|
}
|
|
207
207
|
}, [
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
208
|
+
y?.id,
|
|
209
|
+
d?.email,
|
|
210
|
+
d?.id,
|
|
211
|
+
w,
|
|
212
|
+
S,
|
|
213
213
|
J,
|
|
214
|
-
|
|
214
|
+
me
|
|
215
215
|
]),
|
|
216
|
-
clearPromoCode:
|
|
217
|
-
|
|
216
|
+
clearPromoCode: o(() => {
|
|
217
|
+
T(""), D(0), O("PERCENTAGE");
|
|
218
218
|
}, []),
|
|
219
|
-
setUseCredits:
|
|
220
|
-
setCreditsToUse:
|
|
219
|
+
setUseCredits: A,
|
|
220
|
+
setCreditsToUse: o((e) => {
|
|
221
221
|
let t = Math.min(e, Q, J - X);
|
|
222
|
-
|
|
222
|
+
M(Math.max(0, t));
|
|
223
223
|
}, [
|
|
224
224
|
Q,
|
|
225
225
|
J,
|
|
226
226
|
X
|
|
227
227
|
]),
|
|
228
|
-
setSelectedPaymentMethodId:
|
|
229
|
-
setSaveCard:
|
|
230
|
-
setAutoRenew:
|
|
231
|
-
setAutoRenewPaymentMethodId:
|
|
232
|
-
setSelectedSubscriptionId:
|
|
233
|
-
initiatePayment:
|
|
234
|
-
if (!
|
|
228
|
+
setSelectedPaymentMethodId: V,
|
|
229
|
+
setSaveCard: oe,
|
|
230
|
+
setAutoRenew: se,
|
|
231
|
+
setAutoRenewPaymentMethodId: G,
|
|
232
|
+
setSelectedSubscriptionId: ce,
|
|
233
|
+
initiatePayment: o(async () => {
|
|
234
|
+
if (!y) return {
|
|
235
235
|
success: !1,
|
|
236
236
|
provider: "AUTO",
|
|
237
237
|
subtotal: 0,
|
|
@@ -240,10 +240,10 @@ function l(l = {}) {
|
|
|
240
240
|
total: 0,
|
|
241
241
|
taxType: "NONE",
|
|
242
242
|
jurisdiction: "UNKNOWN",
|
|
243
|
-
currency:
|
|
243
|
+
currency: S,
|
|
244
244
|
error: "Please select a billing account"
|
|
245
245
|
};
|
|
246
|
-
if (
|
|
246
|
+
if (_.length === 0) return {
|
|
247
247
|
success: !1,
|
|
248
248
|
provider: "AUTO",
|
|
249
249
|
subtotal: 0,
|
|
@@ -252,90 +252,130 @@ function l(l = {}) {
|
|
|
252
252
|
total: 0,
|
|
253
253
|
taxType: "NONE",
|
|
254
254
|
jurisdiction: "UNKNOWN",
|
|
255
|
-
currency:
|
|
255
|
+
currency: S,
|
|
256
256
|
error: "No items in checkout"
|
|
257
257
|
};
|
|
258
258
|
try {
|
|
259
|
-
|
|
260
|
-
let e =
|
|
259
|
+
P("processing"), F(null);
|
|
260
|
+
let e = _[0], t = e.type, n = _.find((e) => e.metadata?.storeOrderId)?.metadata?.storeOrderId, r = _.find((e) => e.metadata?.billingOrderId)?.metadata?.billingOrderId || void 0;
|
|
261
261
|
n && (t = "ORDER");
|
|
262
|
-
let
|
|
263
|
-
if (
|
|
264
|
-
let e =
|
|
265
|
-
|
|
262
|
+
let i = J - X, a = b;
|
|
263
|
+
if (a === "AUTO" && (a = S === "INR" ? "RAZORPAY" : "STRIPE"), t === "ORDER" && !r && n && y) {
|
|
264
|
+
let e = _.filter((e) => e.type === "ORDER").map((e) => ({
|
|
265
|
+
name: e.name,
|
|
266
|
+
description: e.description ?? void 0,
|
|
267
|
+
quantity: e.quantity,
|
|
268
|
+
unitPrice: e.price,
|
|
269
|
+
metadata: {
|
|
270
|
+
productId: e.metadata?.productId ?? void 0,
|
|
271
|
+
variantId: e.metadata?.variantId ?? void 0
|
|
272
|
+
}
|
|
273
|
+
})), { data: t } = await ue({ variables: { input: {
|
|
274
|
+
billingAccountId: y.id,
|
|
275
|
+
externalOrderId: n,
|
|
276
|
+
externalService: "STORE",
|
|
277
|
+
currency: S,
|
|
278
|
+
subtotal: i,
|
|
279
|
+
description: `Store order ${n}`,
|
|
280
|
+
items: e,
|
|
281
|
+
callbackGraphQL: {
|
|
282
|
+
endpoint: "http://global-int-gateway:4002/global/graphql",
|
|
283
|
+
mutationName: "updateStoreOrderPaymentStatus"
|
|
284
|
+
}
|
|
285
|
+
} } });
|
|
286
|
+
if (t?.createBillingOrder?.success) r = t.createBillingOrder.order?.id;
|
|
287
|
+
else {
|
|
288
|
+
let e = t?.createBillingOrder?.error ?? "Failed to create billing order";
|
|
289
|
+
return P("error"), F(e), {
|
|
290
|
+
success: !1,
|
|
291
|
+
provider: a,
|
|
292
|
+
subtotal: i,
|
|
293
|
+
taxAmount: 0,
|
|
294
|
+
taxRate: 0,
|
|
295
|
+
total: i,
|
|
296
|
+
taxType: "NONE",
|
|
297
|
+
jurisdiction: "UNKNOWN",
|
|
298
|
+
currency: S,
|
|
299
|
+
error: e
|
|
300
|
+
};
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
if (a === "CREDITS") {
|
|
304
|
+
let e = _.filter((e) => e.type === "ADDON"), t = _.find((e) => e.type === "PLAN"), { data: n } = await de({ variables: { input: {
|
|
305
|
+
billingAccountId: y.id,
|
|
266
306
|
planId: t ? t.metadata?.planId || t.id : void 0,
|
|
267
307
|
addOnIds: e.length > 0 ? e.map((e) => ({
|
|
268
308
|
id: e.metadata?.addonId || e.id,
|
|
269
309
|
quantity: e.quantity
|
|
270
310
|
})) : void 0,
|
|
271
311
|
isAnnual: t?.metadata?.duration === "yearly",
|
|
272
|
-
upgradeFromSubscriptionId:
|
|
273
|
-
downgradeFromSubscriptionId:
|
|
274
|
-
subscriptionId: e.length > 0 ?
|
|
312
|
+
upgradeFromSubscriptionId: m || void 0,
|
|
313
|
+
downgradeFromSubscriptionId: h || void 0,
|
|
314
|
+
subscriptionId: e.length > 0 ? K : void 0,
|
|
275
315
|
seatCount: t?.metadata?.seatCount
|
|
276
|
-
} } }),
|
|
277
|
-
return
|
|
316
|
+
} } }), r = n?.spendCredits;
|
|
317
|
+
return r?.creditTransactionID ? (P("success"), {
|
|
278
318
|
success: !0,
|
|
279
319
|
provider: "CREDITS",
|
|
280
|
-
subtotal:
|
|
320
|
+
subtotal: i,
|
|
281
321
|
taxAmount: 0,
|
|
282
322
|
taxRate: 0,
|
|
283
|
-
total:
|
|
323
|
+
total: i,
|
|
284
324
|
taxType: "NONE",
|
|
285
325
|
jurisdiction: "UNKNOWN",
|
|
286
|
-
currency:
|
|
287
|
-
orderId:
|
|
288
|
-
}) : (
|
|
326
|
+
currency: S,
|
|
327
|
+
orderId: r.creditTransactionID
|
|
328
|
+
}) : (P("error"), F("Failed to process credit payment"), {
|
|
289
329
|
success: !1,
|
|
290
330
|
provider: "CREDITS",
|
|
291
|
-
subtotal:
|
|
331
|
+
subtotal: i,
|
|
292
332
|
taxAmount: 0,
|
|
293
333
|
taxRate: 0,
|
|
294
|
-
total:
|
|
334
|
+
total: i,
|
|
295
335
|
taxType: "NONE",
|
|
296
336
|
jurisdiction: "UNKNOWN",
|
|
297
|
-
currency:
|
|
337
|
+
currency: S,
|
|
298
338
|
error: "Failed to process credit payment"
|
|
299
339
|
});
|
|
300
340
|
}
|
|
301
|
-
let
|
|
302
|
-
billingAccountId:
|
|
303
|
-
amount:
|
|
304
|
-
currency:
|
|
341
|
+
let o = _.filter((e) => e.type === "ADDON"), s = o.length > 0 ? o.map((e) => e.metadata?.addonId || e.id) : void 0, c = o.length > 0 ? o.map((e) => e.quantity) : void 0, l = _.find((e) => e.type === "PLAN")?.metadata?.duration === "yearly", ee = t === "PLAN" && U && (W || B) || void 0, { data: u } = await le({ variables: { input: {
|
|
342
|
+
billingAccountId: y.id,
|
|
343
|
+
amount: i,
|
|
344
|
+
currency: S,
|
|
305
345
|
purchaseType: t,
|
|
306
|
-
provider:
|
|
307
|
-
orderId:
|
|
346
|
+
provider: a,
|
|
347
|
+
orderId: r || void 0,
|
|
308
348
|
creditAmount: t === "CREDITS" ? e.quantity : void 0,
|
|
309
349
|
planId: t === "PLAN" ? e.metadata?.planId || e.id : void 0,
|
|
310
|
-
addonId: t === "ADDON" &&
|
|
311
|
-
quantity: t === "ADDON" &&
|
|
312
|
-
addonIds: t === "ADDON" &&
|
|
313
|
-
quantities: t === "ADDON" &&
|
|
314
|
-
subscriptionId: t === "ADDON" && !
|
|
315
|
-
paymentMethodId:
|
|
316
|
-
saveCard:
|
|
317
|
-
upgradeFromSubscriptionId:
|
|
318
|
-
downgradeFromSubscriptionId:
|
|
319
|
-
isAnnual:
|
|
320
|
-
promoCode:
|
|
321
|
-
autoRenew: t === "PLAN" &&
|
|
350
|
+
addonId: t === "ADDON" && o.length === 1 && !r ? o[0].metadata?.addonId || o[0].id : void 0,
|
|
351
|
+
quantity: t === "ADDON" && o.length === 1 && !r ? o[0].quantity : void 0,
|
|
352
|
+
addonIds: t === "ADDON" && o.length > 1 && !r ? s : void 0,
|
|
353
|
+
quantities: t === "ADDON" && o.length > 1 && !r ? c : void 0,
|
|
354
|
+
subscriptionId: t === "ADDON" && !r ? K : void 0,
|
|
355
|
+
paymentMethodId: B || void 0,
|
|
356
|
+
saveCard: B ? void 0 : H || U,
|
|
357
|
+
upgradeFromSubscriptionId: m || void 0,
|
|
358
|
+
downgradeFromSubscriptionId: h || void 0,
|
|
359
|
+
isAnnual: l || void 0,
|
|
360
|
+
promoCode: w || void 0,
|
|
361
|
+
autoRenew: t === "PLAN" && U ? !0 : void 0,
|
|
322
362
|
autoRenewPaymentMethodId: ee
|
|
323
|
-
} } }),
|
|
324
|
-
return
|
|
363
|
+
} } }), d = u?.initiatePayment;
|
|
364
|
+
return d?.success ? (P("success"), d) : (P("error"), F(d?.error ?? "Payment initiation failed"), {
|
|
325
365
|
success: !1,
|
|
326
|
-
provider:
|
|
327
|
-
subtotal:
|
|
366
|
+
provider: a,
|
|
367
|
+
subtotal: i,
|
|
328
368
|
taxAmount: 0,
|
|
329
369
|
taxRate: 0,
|
|
330
|
-
total:
|
|
370
|
+
total: i,
|
|
331
371
|
taxType: "NONE",
|
|
332
372
|
jurisdiction: "UNKNOWN",
|
|
333
|
-
currency:
|
|
334
|
-
error:
|
|
373
|
+
currency: S,
|
|
374
|
+
error: d?.error ?? "Payment initiation failed"
|
|
335
375
|
});
|
|
336
376
|
} catch (e) {
|
|
337
377
|
let t = e instanceof Error ? e.message : "An error occurred";
|
|
338
|
-
return
|
|
378
|
+
return P("error"), F(t), {
|
|
339
379
|
success: !1,
|
|
340
380
|
provider: "AUTO",
|
|
341
381
|
subtotal: 0,
|
|
@@ -344,38 +384,39 @@ function l(l = {}) {
|
|
|
344
384
|
total: 0,
|
|
345
385
|
taxType: "NONE",
|
|
346
386
|
jurisdiction: "UNKNOWN",
|
|
347
|
-
currency:
|
|
387
|
+
currency: S,
|
|
348
388
|
error: t
|
|
349
389
|
};
|
|
350
390
|
}
|
|
351
391
|
}, [
|
|
352
|
-
v,
|
|
353
|
-
g,
|
|
354
|
-
x,
|
|
355
392
|
y,
|
|
393
|
+
_,
|
|
394
|
+
S,
|
|
395
|
+
b,
|
|
356
396
|
J,
|
|
357
397
|
X,
|
|
358
|
-
|
|
359
|
-
z,
|
|
398
|
+
w,
|
|
360
399
|
B,
|
|
361
|
-
V,
|
|
362
400
|
H,
|
|
401
|
+
U,
|
|
363
402
|
W,
|
|
364
|
-
p,
|
|
365
|
-
m,
|
|
366
403
|
K,
|
|
367
|
-
|
|
404
|
+
m,
|
|
405
|
+
h,
|
|
406
|
+
le,
|
|
407
|
+
ue,
|
|
408
|
+
de
|
|
368
409
|
]),
|
|
369
|
-
reset:
|
|
370
|
-
|
|
410
|
+
reset: o(() => {
|
|
411
|
+
v([]), te(null), x("AUTO"), C(f), T(""), D(0), O("PERCENTAGE"), A(!1), M(0), P("idle"), F(null), L(0), R(0), z("NONE"), V(null), oe(p), se(!1), G(null), ce(g ?? null);
|
|
371
412
|
}, [
|
|
372
|
-
d,
|
|
373
413
|
f,
|
|
374
|
-
|
|
414
|
+
p,
|
|
415
|
+
g
|
|
375
416
|
])
|
|
376
417
|
};
|
|
377
418
|
}
|
|
378
419
|
//#endregion
|
|
379
|
-
export {
|
|
420
|
+
export { u as useCheckout };
|
|
380
421
|
|
|
381
422
|
//# sourceMappingURL=useCheckout.js.map
|