@burdenoff/microfe-billing 2026.611.1 → 2026.614.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.
@@ -1,60 +1,60 @@
1
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";
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 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(() => {
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 (O ? Math.max(0, e - A) : e) + F;
9
+ return (k ? Math.max(0, e - j) : e) + I;
10
10
  }, [
11
11
  J,
12
12
  X,
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;
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: x,
22
+ toCurrency: S,
23
23
  fromCurrency: "USD"
24
24
  } });
25
25
  }
26
26
  }, [
27
27
  Z,
28
- x,
29
- y,
28
+ S,
29
+ b,
30
30
  q,
31
- F,
31
+ I,
32
32
  J,
33
- g
34
- ]), o(() => {
35
- if (!v || J <= 0) {
36
- I(0), L(0), R("NONE");
33
+ _
34
+ ]), s(() => {
35
+ if (!y || J <= 0) {
36
+ L(0), R(0), z("NONE");
37
37
  return;
38
38
  }
39
- if (y === "CREDITS") {
40
- I(0), L(0), R("NONE");
39
+ if (b === "CREDITS") {
40
+ L(0), R(0), z("NONE");
41
41
  return;
42
42
  }
43
- if (x !== "INR") {
44
- I(0), L(0), R("NONE");
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
- I(e * t), L(t), R("GST");
48
+ L(e * t), R(t), z("GST");
49
49
  }, [
50
- v,
50
+ y,
51
51
  J,
52
52
  X,
53
- x,
54
- y
53
+ S,
54
+ b
55
55
  ]);
56
- let be = a((e) => {
57
- _((t) => e.type === "PLAN" ? t.find((e) => e.type === "PLAN") ? t.map((t) => t.type === "PLAN" ? {
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
- }, []), $ = a((e) => {
68
- _((t) => t.filter((t) => t.id !== e));
69
- }, []), xe = a((e, t) => {
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
- _((n) => n.map((n) => n.id === e ? n.type === "PLAN" ? {
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
- }, [$]), Se = a((e, t, n) => {
82
- _((r) => r.map((r) => {
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
- }, []), 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");
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
- g
105
+ _
106
106
  ]);
107
107
  return {
108
- items: g,
109
- billingAccount: v,
110
- selectedProvider: y,
111
- selectedCurrency: x,
112
- promoCode: C,
113
- promoDiscount: T,
108
+ items: _,
109
+ billingAccount: y,
110
+ selectedProvider: b,
111
+ selectedCurrency: S,
112
+ promoCode: w,
113
+ promoDiscount: E,
114
114
  promoDiscountType: ne,
115
- useCredits: O,
116
- creditsToUse: A,
117
- checkoutState: M,
115
+ useCredits: k,
116
+ creditsToUse: j,
117
+ checkoutState: N,
118
118
  error: re,
119
- selectedPaymentMethodId: z,
120
- saveCard: B,
121
- autoRenew: V,
122
- autoRenewPaymentMethodId: H,
123
- selectedSubscriptionId: W,
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: F,
127
+ taxAmount: I,
128
128
  taxRate: ie,
129
129
  taxType: ae,
130
130
  total: Z,
131
- totalInSelectedCurrency: _e,
131
+ totalInSelectedCurrency: ye,
132
132
  availableCredits: Q,
133
- hasEnoughCredits: pe,
134
- canPayWithCredits: me,
135
- isLoading: ve,
136
- isProcessing: ye,
133
+ hasEnoughCredits: he,
134
+ canPayWithCredits: ge,
135
+ isLoading: be,
136
+ isProcessing: xe,
137
137
  isCalculatingTax: !1,
138
- conversionRate: ge,
139
- convertedAmount: he,
140
- addItem: be,
138
+ conversionRate: ve,
139
+ convertedAmount: _e,
140
+ addItem: Se,
141
141
  removeItem: $,
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 {
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
- 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,
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: x
166
+ currency: S
167
167
  } } });
168
- if (t || !e?.validateCoupon) return E(0), N("idle"), {
168
+ if (t || !e?.validateCoupon) return D(0), P("idle"), {
169
169
  valid: !1,
170
- code: C,
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 E(0), N("idle"), {
176
+ if (!n.valid) return D(0), P("idle"), {
177
177
  valid: !1,
178
- code: C,
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 E(0), N("idle"), {
184
+ if (!r) return D(0), P("idle"), {
185
185
  valid: !1,
186
- code: C,
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 E(i), D(a), N("idle"), {
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 E(0), N("idle"), {
199
+ return D(0), P("idle"), {
200
200
  valid: !1,
201
- code: C,
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
- v?.id,
209
- u?.email,
210
- u?.id,
211
- C,
212
- x,
208
+ y?.id,
209
+ d?.email,
210
+ d?.id,
211
+ w,
212
+ S,
213
213
  J,
214
- fe
214
+ me
215
215
  ]),
216
- clearPromoCode: a(() => {
217
- w(""), E(0), D("PERCENTAGE");
216
+ clearPromoCode: o(() => {
217
+ T(""), D(0), O("PERCENTAGE");
218
218
  }, []),
219
- setUseCredits: k,
220
- setCreditsToUse: a((e) => {
219
+ setUseCredits: A,
220
+ setCreditsToUse: o((e) => {
221
221
  let t = Math.min(e, Q, J - X);
222
- j(Math.max(0, t));
222
+ M(Math.max(0, t));
223
223
  }, [
224
224
  Q,
225
225
  J,
226
226
  X
227
227
  ]),
228
- setSelectedPaymentMethodId: oe,
229
- setSaveCard: se,
230
- setAutoRenew: ce,
231
- setAutoRenewPaymentMethodId: U,
232
- setSelectedSubscriptionId: G,
233
- initiatePayment: a(async () => {
234
- if (!v) return {
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: x,
243
+ currency: S,
244
244
  error: "Please select a billing account"
245
245
  };
246
- if (g.length === 0) return {
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: x,
255
+ currency: S,
256
256
  error: "No items in checkout"
257
257
  };
258
258
  try {
259
- N("processing"), P(null);
260
- let e = g[0], t = e.type, n = g.find((e) => e.metadata?.billingOrderId)?.metadata?.billingOrderId;
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 r = J - X, i = y;
263
- if (i === "AUTO" && (i = x === "INR" ? "RAZORPAY" : "STRIPE"), i === "CREDITS") {
264
- let e = g.filter((e) => e.type === "ADDON"), t = g.find((e) => e.type === "PLAN"), { data: n } = await le({ variables: { input: {
265
- billingAccountId: v.id,
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: p || void 0,
273
- downgradeFromSubscriptionId: m || void 0,
274
- subscriptionId: e.length > 0 ? W : void 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
- } } }), i = n?.spendCredits;
277
- return i?.creditTransactionID ? (N("success"), {
316
+ } } }), r = n?.spendCredits;
317
+ return r?.creditTransactionID ? (P("success"), {
278
318
  success: !0,
279
319
  provider: "CREDITS",
280
- subtotal: r,
320
+ subtotal: i,
281
321
  taxAmount: 0,
282
322
  taxRate: 0,
283
- total: r,
323
+ total: i,
284
324
  taxType: "NONE",
285
325
  jurisdiction: "UNKNOWN",
286
- currency: x,
287
- orderId: i.creditTransactionID
288
- }) : (N("error"), P("Failed to process credit payment"), {
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: r,
331
+ subtotal: i,
292
332
  taxAmount: 0,
293
333
  taxRate: 0,
294
- total: r,
334
+ total: i,
295
335
  taxType: "NONE",
296
336
  jurisdiction: "UNKNOWN",
297
- currency: x,
337
+ currency: S,
298
338
  error: "Failed to process credit payment"
299
339
  });
300
340
  }
301
- 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: {
302
- billingAccountId: v.id,
303
- amount: r,
304
- currency: x,
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: i,
307
- orderId: n || void 0,
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" && a.length === 1 && !n ? a[0].metadata?.addonId || a[0].id : void 0,
311
- quantity: t === "ADDON" && a.length === 1 && !n ? a[0].quantity : void 0,
312
- addonIds: t === "ADDON" && a.length > 1 && !n ? o : void 0,
313
- quantities: t === "ADDON" && a.length > 1 && !n ? s : void 0,
314
- subscriptionId: t === "ADDON" && !n ? W : void 0,
315
- paymentMethodId: z || void 0,
316
- saveCard: z ? void 0 : B || V,
317
- upgradeFromSubscriptionId: p || void 0,
318
- downgradeFromSubscriptionId: m || void 0,
319
- isAnnual: c || void 0,
320
- promoCode: C || void 0,
321
- autoRenew: t === "PLAN" && V ? !0 : void 0,
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
- } } }), u = l?.initiatePayment;
324
- return u?.success ? (N("success"), u) : (N("error"), P(u?.error ?? "Payment initiation failed"), {
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: i,
327
- subtotal: r,
366
+ provider: a,
367
+ subtotal: i,
328
368
  taxAmount: 0,
329
369
  taxRate: 0,
330
- total: r,
370
+ total: i,
331
371
  taxType: "NONE",
332
372
  jurisdiction: "UNKNOWN",
333
- currency: x,
334
- error: u?.error ?? "Payment initiation failed"
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 N("error"), P(t), {
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: x,
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
- C,
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
- le
404
+ m,
405
+ h,
406
+ le,
407
+ ue,
408
+ de
368
409
  ]),
369
- reset: a(() => {
370
- _([]), 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);
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
- h
414
+ p,
415
+ g
375
416
  ])
376
417
  };
377
418
  }
378
419
  //#endregion
379
- export { l as useCheckout };
420
+ export { u as useCheckout };
380
421
 
381
422
  //# sourceMappingURL=useCheckout.js.map