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