@burdenoff/microfe-billing 2026.530.2 → 2026.530.4
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 +110 -71
- package/dist/billing/BillingAdminRoutes.js.map +1 -1
- package/dist/billing/BillingRoot.js +81 -73
- package/dist/billing/BillingRoot.js.map +1 -1
- package/dist/billing/BillingUserRoutes.js +103 -90
- package/dist/billing/BillingUserRoutes.js.map +1 -1
- package/dist/billing/modules/billing/index.js +2 -1
- package/dist/billing/modules/billing/pages/InvoicesListPage.js +135 -126
- package/dist/billing/modules/billing/pages/InvoicesListPage.js.map +1 -1
- package/dist/billing/modules/billing/pages/UserRefundsPage.js +417 -0
- package/dist/billing/modules/billing/pages/UserRefundsPage.js.map +1 -0
- package/dist/billing/modules/billing/pages/index.js +1 -0
- package/dist/billing/modules/checkout/hooks/useCheckout.js +163 -161
- package/dist/billing/modules/checkout/hooks/useCheckout.js.map +1 -1
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js +344 -167
- package/dist/billing/modules/coupons/pages/CreateCouponPage.js.map +1 -1
- package/dist/billing/modules/plans/constants/featuredQuotas.js +37 -0
- package/dist/billing/modules/plans/constants/featuredQuotas.js.map +1 -0
- package/dist/billing/modules/plans/index.js +2 -1
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js +205 -0
- package/dist/billing/modules/plans/pages/PlanAssignFreePage.js.map +1 -0
- package/dist/billing/modules/plans/pages/PlanCreatePage.js +51 -33
- package/dist/billing/modules/plans/pages/PlanCreatePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlanEditPage.js +78 -60
- package/dist/billing/modules/plans/pages/PlanEditPage.js.map +1 -1
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js +246 -126
- package/dist/billing/modules/plans/pages/PlansBrowsePage.js.map +1 -1
- package/dist/billing/modules/plans/pages/index.js +1 -0
- package/dist/billing/modules/promotions/index.js +4 -0
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js +289 -0
- package/dist/billing/modules/promotions/pages/CreatePromotionPage.js.map +1 -0
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js +168 -0
- package/dist/billing/modules/promotions/pages/PromotionsListPage.js.map +1 -0
- package/dist/billing/modules/promotions/pages/index.js +2 -0
- package/dist/billing/shared/types/graphql.js.map +1 -1
- package/dist/generated/global-operations.js +422 -290
- package/dist/generated/global-operations.js.map +1 -1
- package/dist/generated/global-types.js +3 -1
- package/dist/generated/global-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,59 +1,60 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { useBilling as e } from "../../../providers/BillingProvider.js";
|
|
2
|
+
import { useConvertCurrencyLazyQuery as t, useInitiatePaymentCheckoutMutation as n, useSpendCreditsCheckoutMutation as r, useValidateCouponLazyQuery as i } from "../../../../generated/global-operations.js";
|
|
3
|
+
import { useCallback as a, useEffect as o, useMemo as s, useState as c } from "react";
|
|
3
4
|
//#region src/billing/modules/checkout/hooks/useCheckout.ts
|
|
4
5
|
var ee = 100;
|
|
5
|
-
function
|
|
6
|
-
let { defaultCurrency:
|
|
6
|
+
function l(l = {}) {
|
|
7
|
+
let { currentUser: u } = e(), { defaultCurrency: d = "USD", defaultSaveCard: f = !1, upgradeFromSubscriptionId: p, downgradeFromSubscriptionId: m, defaultSubscriptionId: h } = l, [g, _] = c([]), [v, te] = c(null), [y, b] = c("AUTO"), [x, S] = c(d), [C, w] = c(""), [T, E] = c(0), [ne, D] = c("PERCENTAGE"), [O, k] = c(!1), [A, j] = c(0), [M, N] = c("idle"), [re, P] = c(null), [F, I] = c(0), [ie, L] = c(0), [ae, R] = c("NONE"), [z, oe] = c(null), [B, se] = c(f), [V, ce] = c(!1), [H, U] = c(null), [W, G] = c(h ?? null), [K] = n(), [le] = r(), [q, { data: ue, loading: de }] = t(), [fe] = i(), J = s(() => g.reduce((e, t) => e + t.price * t.quantity, 0), [g]), Y = s(() => g.reduce((e, t) => e + (t.priceUSD ?? t.price) * t.quantity, 0), [g]), X = s(() => T ? Math.min(T, J) : 0, [J, T]), Z = s(() => {
|
|
7
8
|
let e = J - X;
|
|
8
|
-
return (
|
|
9
|
+
return (O ? Math.max(0, e - A) : e) + F;
|
|
9
10
|
}, [
|
|
10
11
|
J,
|
|
11
12
|
X,
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
]), Q =
|
|
16
|
-
|
|
17
|
-
if (
|
|
18
|
-
if (
|
|
19
|
-
|
|
13
|
+
O,
|
|
14
|
+
A,
|
|
15
|
+
F
|
|
16
|
+
]), Q = v?.creditAmount ?? 0, pe = s(() => Q >= Y * ee, [Q, Y]), me = s(() => !g.some((e) => e.type === "CREDITS") && Q > 0, [g, Q]), he = ue?.convertCurrency?.amount ?? null, ge = ue?.convertCurrency?.exchangeRate ?? 1, _e = he ?? Z, ve = M === "loading" || de, ye = M === "processing";
|
|
17
|
+
o(() => {
|
|
18
|
+
if (y !== "CREDITS" && g.length !== 0 && !g.every((e) => e.currency === x || e.type === "CREDITS") && Z > 0 && x !== "USD") {
|
|
19
|
+
if (x === "INR" && F === 0 && J > 0) return;
|
|
20
|
+
q({ variables: {
|
|
20
21
|
amount: Z,
|
|
21
|
-
toCurrency:
|
|
22
|
+
toCurrency: x,
|
|
22
23
|
fromCurrency: "USD"
|
|
23
24
|
} });
|
|
24
25
|
}
|
|
25
26
|
}, [
|
|
26
27
|
Z,
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
28
|
+
x,
|
|
29
|
+
y,
|
|
30
|
+
q,
|
|
31
|
+
F,
|
|
31
32
|
J,
|
|
32
|
-
|
|
33
|
-
]),
|
|
34
|
-
if (!
|
|
35
|
-
|
|
33
|
+
g
|
|
34
|
+
]), o(() => {
|
|
35
|
+
if (!v || J <= 0) {
|
|
36
|
+
I(0), L(0), R("NONE");
|
|
36
37
|
return;
|
|
37
38
|
}
|
|
38
|
-
if (
|
|
39
|
-
|
|
39
|
+
if (y === "CREDITS") {
|
|
40
|
+
I(0), L(0), R("NONE");
|
|
40
41
|
return;
|
|
41
42
|
}
|
|
42
|
-
if (
|
|
43
|
-
|
|
43
|
+
if (x !== "INR") {
|
|
44
|
+
I(0), L(0), R("NONE");
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
let e = J - X, t = .18;
|
|
47
|
-
|
|
48
|
+
I(e * t), L(t), R("GST");
|
|
48
49
|
}, [
|
|
49
|
-
|
|
50
|
+
v,
|
|
50
51
|
J,
|
|
51
52
|
X,
|
|
52
|
-
|
|
53
|
-
|
|
53
|
+
x,
|
|
54
|
+
y
|
|
54
55
|
]);
|
|
55
|
-
let
|
|
56
|
-
|
|
56
|
+
let be = a((e) => {
|
|
57
|
+
_((t) => e.type === "PLAN" ? t.find((e) => e.type === "PLAN") ? t.map((t) => t.type === "PLAN" ? {
|
|
57
58
|
...e,
|
|
58
59
|
quantity: 1
|
|
59
60
|
} : t) : [...t, {
|
|
@@ -63,22 +64,22 @@ function c(c = {}) {
|
|
|
63
64
|
...t,
|
|
64
65
|
quantity: t.quantity + e.quantity
|
|
65
66
|
} : t) : [...t, e]);
|
|
66
|
-
}, []), $ =
|
|
67
|
-
|
|
68
|
-
}, []),
|
|
67
|
+
}, []), $ = a((e) => {
|
|
68
|
+
_((t) => t.filter((t) => t.id !== e));
|
|
69
|
+
}, []), xe = a((e, t) => {
|
|
69
70
|
if (t <= 0) {
|
|
70
71
|
$(e);
|
|
71
72
|
return;
|
|
72
73
|
}
|
|
73
|
-
|
|
74
|
+
_((n) => n.map((n) => n.id === e ? n.type === "PLAN" ? {
|
|
74
75
|
...n,
|
|
75
76
|
quantity: 1
|
|
76
77
|
} : {
|
|
77
78
|
...n,
|
|
78
79
|
quantity: t
|
|
79
80
|
} : n));
|
|
80
|
-
}, [$]),
|
|
81
|
-
|
|
81
|
+
}, [$]), Se = a((e, t, n) => {
|
|
82
|
+
_((r) => r.map((r) => {
|
|
82
83
|
if (r.id !== e) return r;
|
|
83
84
|
let i = { price: t };
|
|
84
85
|
return n && (i.currency = n), {
|
|
@@ -86,69 +87,69 @@ function c(c = {}) {
|
|
|
86
87
|
...i
|
|
87
88
|
};
|
|
88
89
|
}));
|
|
89
|
-
}, []),
|
|
90
|
-
|
|
91
|
-
}, []),
|
|
92
|
-
te(e),
|
|
93
|
-
}, []),
|
|
94
|
-
|
|
95
|
-
let t =
|
|
96
|
-
Z > 0 && e !== "USD" && !t &&
|
|
90
|
+
}, []), Ce = a(() => {
|
|
91
|
+
_([]);
|
|
92
|
+
}, []), we = a((e) => {
|
|
93
|
+
te(e), k(!1), j(0);
|
|
94
|
+
}, []), Te = a((e) => {
|
|
95
|
+
S(e);
|
|
96
|
+
let t = g.every((t) => t.currency === e || t.type === "CREDITS");
|
|
97
|
+
Z > 0 && e !== "USD" && !t && q({ variables: {
|
|
97
98
|
amount: Z,
|
|
98
99
|
toCurrency: e,
|
|
99
100
|
fromCurrency: "USD"
|
|
100
101
|
} });
|
|
101
102
|
}, [
|
|
102
103
|
Z,
|
|
103
|
-
|
|
104
|
-
|
|
104
|
+
q,
|
|
105
|
+
g
|
|
105
106
|
]);
|
|
106
107
|
return {
|
|
107
|
-
items:
|
|
108
|
-
billingAccount:
|
|
109
|
-
selectedProvider:
|
|
110
|
-
selectedCurrency:
|
|
111
|
-
promoCode:
|
|
112
|
-
promoDiscount:
|
|
113
|
-
promoDiscountType:
|
|
114
|
-
useCredits:
|
|
115
|
-
creditsToUse:
|
|
116
|
-
checkoutState:
|
|
117
|
-
error:
|
|
118
|
-
selectedPaymentMethodId:
|
|
119
|
-
saveCard:
|
|
120
|
-
autoRenew:
|
|
121
|
-
autoRenewPaymentMethodId:
|
|
122
|
-
selectedSubscriptionId:
|
|
108
|
+
items: g,
|
|
109
|
+
billingAccount: v,
|
|
110
|
+
selectedProvider: y,
|
|
111
|
+
selectedCurrency: x,
|
|
112
|
+
promoCode: C,
|
|
113
|
+
promoDiscount: T,
|
|
114
|
+
promoDiscountType: ne,
|
|
115
|
+
useCredits: O,
|
|
116
|
+
creditsToUse: A,
|
|
117
|
+
checkoutState: M,
|
|
118
|
+
error: re,
|
|
119
|
+
selectedPaymentMethodId: z,
|
|
120
|
+
saveCard: B,
|
|
121
|
+
autoRenew: V,
|
|
122
|
+
autoRenewPaymentMethodId: H,
|
|
123
|
+
selectedSubscriptionId: W,
|
|
123
124
|
subtotal: J,
|
|
124
125
|
subtotalUSD: Y,
|
|
125
126
|
discountAmount: X,
|
|
126
|
-
taxAmount:
|
|
127
|
-
taxRate:
|
|
128
|
-
taxType:
|
|
127
|
+
taxAmount: F,
|
|
128
|
+
taxRate: ie,
|
|
129
|
+
taxType: ae,
|
|
129
130
|
total: Z,
|
|
130
|
-
totalInSelectedCurrency:
|
|
131
|
+
totalInSelectedCurrency: _e,
|
|
131
132
|
availableCredits: Q,
|
|
132
|
-
hasEnoughCredits:
|
|
133
|
-
canPayWithCredits:
|
|
134
|
-
isLoading:
|
|
135
|
-
isProcessing:
|
|
133
|
+
hasEnoughCredits: pe,
|
|
134
|
+
canPayWithCredits: me,
|
|
135
|
+
isLoading: ve,
|
|
136
|
+
isProcessing: ye,
|
|
136
137
|
isCalculatingTax: !1,
|
|
137
|
-
conversionRate:
|
|
138
|
-
convertedAmount:
|
|
139
|
-
addItem:
|
|
138
|
+
conversionRate: ge,
|
|
139
|
+
convertedAmount: he,
|
|
140
|
+
addItem: be,
|
|
140
141
|
removeItem: $,
|
|
141
|
-
updateItemQuantity:
|
|
142
|
-
updateItemPrice:
|
|
143
|
-
clearItems:
|
|
144
|
-
setBillingAccount:
|
|
145
|
-
setPaymentProvider:
|
|
146
|
-
|
|
147
|
-
}, [
|
|
148
|
-
setCurrency:
|
|
149
|
-
setPromoCode:
|
|
150
|
-
validatePromoCode:
|
|
151
|
-
if (!
|
|
142
|
+
updateItemQuantity: xe,
|
|
143
|
+
updateItemPrice: Se,
|
|
144
|
+
clearItems: Ce,
|
|
145
|
+
setBillingAccount: we,
|
|
146
|
+
setPaymentProvider: a((e) => {
|
|
147
|
+
b(e), e === "RAZORPAY" && x !== "INR" && S("INR");
|
|
148
|
+
}, [x]),
|
|
149
|
+
setCurrency: Te,
|
|
150
|
+
setPromoCode: w,
|
|
151
|
+
validatePromoCode: a(async () => {
|
|
152
|
+
if (!C.trim()) return {
|
|
152
153
|
valid: !1,
|
|
153
154
|
code: "",
|
|
154
155
|
discountType: "PERCENTAGE",
|
|
@@ -156,78 +157,79 @@ function c(c = {}) {
|
|
|
156
157
|
error: "Please enter a promo code"
|
|
157
158
|
};
|
|
158
159
|
try {
|
|
159
|
-
|
|
160
|
-
let { data: e, error: t } = await
|
|
161
|
-
code:
|
|
162
|
-
userId:
|
|
160
|
+
N("loading");
|
|
161
|
+
let { data: e, error: t } = await fe({ variables: { input: {
|
|
162
|
+
code: C.trim().toUpperCase(),
|
|
163
|
+
userId: u?.id ?? "",
|
|
164
|
+
userEmail: u?.email,
|
|
163
165
|
amount: J,
|
|
164
|
-
currency:
|
|
166
|
+
currency: x
|
|
165
167
|
} } });
|
|
166
|
-
if (t || !e?.validateCoupon) return
|
|
168
|
+
if (t || !e?.validateCoupon) return E(0), N("idle"), {
|
|
167
169
|
valid: !1,
|
|
168
|
-
code:
|
|
170
|
+
code: C,
|
|
169
171
|
discountType: "PERCENTAGE",
|
|
170
172
|
discountValue: 0,
|
|
171
173
|
error: "Failed to validate coupon"
|
|
172
174
|
};
|
|
173
175
|
let n = e.validateCoupon;
|
|
174
|
-
if (!n.valid) return
|
|
176
|
+
if (!n.valid) return E(0), N("idle"), {
|
|
175
177
|
valid: !1,
|
|
176
|
-
code:
|
|
178
|
+
code: C,
|
|
177
179
|
discountType: "PERCENTAGE",
|
|
178
180
|
discountValue: 0,
|
|
179
181
|
error: n.error || "Invalid coupon code"
|
|
180
182
|
};
|
|
181
183
|
let r = n.coupon;
|
|
182
|
-
if (!r) return
|
|
184
|
+
if (!r) return E(0), N("idle"), {
|
|
183
185
|
valid: !1,
|
|
184
|
-
code:
|
|
186
|
+
code: C,
|
|
185
187
|
discountType: "PERCENTAGE",
|
|
186
188
|
discountValue: 0,
|
|
187
189
|
error: "Coupon data not found"
|
|
188
190
|
};
|
|
189
191
|
let i = n.discountAmount || 0, a = r.type === "FIXED_AMOUNT" ? "FIXED" : "PERCENTAGE";
|
|
190
|
-
return
|
|
192
|
+
return E(i), D(a), N("idle"), {
|
|
191
193
|
valid: !0,
|
|
192
194
|
code: r.code,
|
|
193
195
|
discountType: a,
|
|
194
196
|
discountValue: i
|
|
195
197
|
};
|
|
196
198
|
} catch {
|
|
197
|
-
return
|
|
199
|
+
return E(0), N("idle"), {
|
|
198
200
|
valid: !1,
|
|
199
|
-
code:
|
|
201
|
+
code: C,
|
|
200
202
|
discountType: "PERCENTAGE",
|
|
201
203
|
discountValue: 0,
|
|
202
204
|
error: "Failed to validate coupon"
|
|
203
205
|
};
|
|
204
206
|
}
|
|
205
207
|
}, [
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
208
|
+
v?.id,
|
|
209
|
+
C,
|
|
210
|
+
x,
|
|
209
211
|
J,
|
|
210
|
-
|
|
212
|
+
fe
|
|
211
213
|
]),
|
|
212
|
-
clearPromoCode:
|
|
213
|
-
|
|
214
|
+
clearPromoCode: a(() => {
|
|
215
|
+
w(""), E(0), D("PERCENTAGE");
|
|
214
216
|
}, []),
|
|
215
|
-
setUseCredits:
|
|
216
|
-
setCreditsToUse:
|
|
217
|
+
setUseCredits: k,
|
|
218
|
+
setCreditsToUse: a((e) => {
|
|
217
219
|
let t = Math.min(e, Q, J - X);
|
|
218
|
-
|
|
220
|
+
j(Math.max(0, t));
|
|
219
221
|
}, [
|
|
220
222
|
Q,
|
|
221
223
|
J,
|
|
222
224
|
X
|
|
223
225
|
]),
|
|
224
|
-
setSelectedPaymentMethodId:
|
|
226
|
+
setSelectedPaymentMethodId: oe,
|
|
225
227
|
setSaveCard: se,
|
|
226
228
|
setAutoRenew: ce,
|
|
227
|
-
setAutoRenewPaymentMethodId:
|
|
228
|
-
setSelectedSubscriptionId:
|
|
229
|
-
initiatePayment:
|
|
230
|
-
if (!
|
|
229
|
+
setAutoRenewPaymentMethodId: U,
|
|
230
|
+
setSelectedSubscriptionId: G,
|
|
231
|
+
initiatePayment: a(async () => {
|
|
232
|
+
if (!v) return {
|
|
231
233
|
success: !1,
|
|
232
234
|
provider: "AUTO",
|
|
233
235
|
subtotal: 0,
|
|
@@ -236,10 +238,10 @@ function c(c = {}) {
|
|
|
236
238
|
total: 0,
|
|
237
239
|
taxType: "NONE",
|
|
238
240
|
jurisdiction: "UNKNOWN",
|
|
239
|
-
currency:
|
|
241
|
+
currency: x,
|
|
240
242
|
error: "Please select a billing account"
|
|
241
243
|
};
|
|
242
|
-
if (
|
|
244
|
+
if (g.length === 0) return {
|
|
243
245
|
success: !1,
|
|
244
246
|
provider: "AUTO",
|
|
245
247
|
subtotal: 0,
|
|
@@ -248,29 +250,29 @@ function c(c = {}) {
|
|
|
248
250
|
total: 0,
|
|
249
251
|
taxType: "NONE",
|
|
250
252
|
jurisdiction: "UNKNOWN",
|
|
251
|
-
currency:
|
|
253
|
+
currency: x,
|
|
252
254
|
error: "No items in checkout"
|
|
253
255
|
};
|
|
254
256
|
try {
|
|
255
|
-
|
|
256
|
-
let e =
|
|
257
|
+
N("processing"), P(null);
|
|
258
|
+
let e = g[0], t = e.type, n = g.find((e) => e.metadata?.billingOrderId)?.metadata?.billingOrderId;
|
|
257
259
|
n && (t = "ORDER");
|
|
258
|
-
let r = J - X, i =
|
|
259
|
-
if (i === "AUTO" && (i =
|
|
260
|
-
let e =
|
|
261
|
-
billingAccountId:
|
|
260
|
+
let r = J - X, i = y;
|
|
261
|
+
if (i === "AUTO" && (i = x === "INR" ? "RAZORPAY" : "STRIPE"), i === "CREDITS") {
|
|
262
|
+
let e = g.filter((e) => e.type === "ADDON"), t = g.find((e) => e.type === "PLAN"), { data: n } = await le({ variables: { input: {
|
|
263
|
+
billingAccountId: v.id,
|
|
262
264
|
planId: t ? t.metadata?.planId || t.id : void 0,
|
|
263
265
|
addOnIds: e.length > 0 ? e.map((e) => ({
|
|
264
266
|
id: e.metadata?.addonId || e.id,
|
|
265
267
|
quantity: e.quantity
|
|
266
268
|
})) : void 0,
|
|
267
269
|
isAnnual: t?.metadata?.duration === "yearly",
|
|
268
|
-
upgradeFromSubscriptionId:
|
|
269
|
-
downgradeFromSubscriptionId:
|
|
270
|
-
subscriptionId: e.length > 0 ?
|
|
270
|
+
upgradeFromSubscriptionId: p || void 0,
|
|
271
|
+
downgradeFromSubscriptionId: m || void 0,
|
|
272
|
+
subscriptionId: e.length > 0 ? W : void 0,
|
|
271
273
|
seatCount: t?.metadata?.seatCount
|
|
272
274
|
} } }), i = n?.spendCredits;
|
|
273
|
-
return i?.creditTransactionID ? (
|
|
275
|
+
return i?.creditTransactionID ? (N("success"), {
|
|
274
276
|
success: !0,
|
|
275
277
|
provider: "CREDITS",
|
|
276
278
|
subtotal: r,
|
|
@@ -279,9 +281,9 @@ function c(c = {}) {
|
|
|
279
281
|
total: r,
|
|
280
282
|
taxType: "NONE",
|
|
281
283
|
jurisdiction: "UNKNOWN",
|
|
282
|
-
currency:
|
|
284
|
+
currency: x,
|
|
283
285
|
orderId: i.creditTransactionID
|
|
284
|
-
}) : (
|
|
286
|
+
}) : (N("error"), P("Failed to process credit payment"), {
|
|
285
287
|
success: !1,
|
|
286
288
|
provider: "CREDITS",
|
|
287
289
|
subtotal: r,
|
|
@@ -290,14 +292,14 @@ function c(c = {}) {
|
|
|
290
292
|
total: r,
|
|
291
293
|
taxType: "NONE",
|
|
292
294
|
jurisdiction: "UNKNOWN",
|
|
293
|
-
currency:
|
|
295
|
+
currency: x,
|
|
294
296
|
error: "Failed to process credit payment"
|
|
295
297
|
});
|
|
296
298
|
}
|
|
297
|
-
let a =
|
|
298
|
-
billingAccountId:
|
|
299
|
+
let a = g.filter((e) => e.type === "ADDON"), o = a.length > 0 ? a.map((e) => e.metadata?.addonId || e.id) : void 0, s = a.length > 0 ? a.map((e) => e.quantity) : void 0, c = g.find((e) => e.type === "PLAN")?.metadata?.duration === "yearly", ee = t === "PLAN" && V && (H || z) || void 0, { data: l } = await K({ variables: { input: {
|
|
300
|
+
billingAccountId: v.id,
|
|
299
301
|
amount: r,
|
|
300
|
-
currency:
|
|
302
|
+
currency: x,
|
|
301
303
|
purchaseType: t,
|
|
302
304
|
provider: i,
|
|
303
305
|
orderId: n || void 0,
|
|
@@ -307,17 +309,17 @@ function c(c = {}) {
|
|
|
307
309
|
quantity: t === "ADDON" && a.length === 1 && !n ? a[0].quantity : void 0,
|
|
308
310
|
addonIds: t === "ADDON" && a.length > 1 && !n ? o : void 0,
|
|
309
311
|
quantities: t === "ADDON" && a.length > 1 && !n ? s : void 0,
|
|
310
|
-
subscriptionId: t === "ADDON" && !n ?
|
|
311
|
-
paymentMethodId:
|
|
312
|
-
saveCard:
|
|
313
|
-
upgradeFromSubscriptionId:
|
|
314
|
-
downgradeFromSubscriptionId:
|
|
315
|
-
isAnnual:
|
|
316
|
-
promoCode:
|
|
317
|
-
autoRenew: t === "PLAN" &&
|
|
318
|
-
autoRenewPaymentMethodId:
|
|
312
|
+
subscriptionId: t === "ADDON" && !n ? W : void 0,
|
|
313
|
+
paymentMethodId: z || void 0,
|
|
314
|
+
saveCard: z ? void 0 : B || V,
|
|
315
|
+
upgradeFromSubscriptionId: p || void 0,
|
|
316
|
+
downgradeFromSubscriptionId: m || void 0,
|
|
317
|
+
isAnnual: c || void 0,
|
|
318
|
+
promoCode: C || void 0,
|
|
319
|
+
autoRenew: t === "PLAN" && V ? !0 : void 0,
|
|
320
|
+
autoRenewPaymentMethodId: ee
|
|
319
321
|
} } }), u = l?.initiatePayment;
|
|
320
|
-
return u?.success ? (
|
|
322
|
+
return u?.success ? (N("success"), u) : (N("error"), P(u?.error ?? "Payment initiation failed"), {
|
|
321
323
|
success: !1,
|
|
322
324
|
provider: i,
|
|
323
325
|
subtotal: r,
|
|
@@ -326,12 +328,12 @@ function c(c = {}) {
|
|
|
326
328
|
total: r,
|
|
327
329
|
taxType: "NONE",
|
|
328
330
|
jurisdiction: "UNKNOWN",
|
|
329
|
-
currency:
|
|
331
|
+
currency: x,
|
|
330
332
|
error: u?.error ?? "Payment initiation failed"
|
|
331
333
|
});
|
|
332
334
|
} catch (e) {
|
|
333
335
|
let t = e instanceof Error ? e.message : "An error occurred";
|
|
334
|
-
return
|
|
336
|
+
return N("error"), P(t), {
|
|
335
337
|
success: !1,
|
|
336
338
|
provider: "AUTO",
|
|
337
339
|
subtotal: 0,
|
|
@@ -340,38 +342,38 @@ function c(c = {}) {
|
|
|
340
342
|
total: 0,
|
|
341
343
|
taxType: "NONE",
|
|
342
344
|
jurisdiction: "UNKNOWN",
|
|
343
|
-
currency:
|
|
345
|
+
currency: x,
|
|
344
346
|
error: t
|
|
345
347
|
};
|
|
346
348
|
}
|
|
347
349
|
}, [
|
|
348
|
-
g,
|
|
349
|
-
m,
|
|
350
350
|
v,
|
|
351
|
-
|
|
351
|
+
g,
|
|
352
|
+
x,
|
|
353
|
+
y,
|
|
352
354
|
J,
|
|
353
355
|
X,
|
|
354
|
-
|
|
355
|
-
I,
|
|
356
|
-
R,
|
|
356
|
+
C,
|
|
357
357
|
z,
|
|
358
358
|
B,
|
|
359
|
+
V,
|
|
359
360
|
H,
|
|
360
|
-
d,
|
|
361
|
-
f,
|
|
362
361
|
W,
|
|
363
|
-
|
|
362
|
+
p,
|
|
363
|
+
m,
|
|
364
|
+
K,
|
|
365
|
+
le
|
|
364
366
|
]),
|
|
365
|
-
reset:
|
|
366
|
-
|
|
367
|
+
reset: a(() => {
|
|
368
|
+
_([]), te(null), b("AUTO"), S(d), w(""), E(0), D("PERCENTAGE"), k(!1), j(0), N("idle"), P(null), I(0), L(0), R("NONE"), oe(null), se(f), ce(!1), U(null), G(h ?? null);
|
|
367
369
|
}, [
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
370
|
+
d,
|
|
371
|
+
f,
|
|
372
|
+
h
|
|
371
373
|
])
|
|
372
374
|
};
|
|
373
375
|
}
|
|
374
376
|
//#endregion
|
|
375
|
-
export {
|
|
377
|
+
export { l as useCheckout };
|
|
376
378
|
|
|
377
379
|
//# sourceMappingURL=useCheckout.js.map
|