@burdenoff/microfe-billing 2026.1023.2 → 2026.1026.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,40 +1,40 @@
1
- import { useBilling as e } from "../../../providers/BillingProvider.js";
2
- import { normalizeGlobalGatewayBaseUrl as t } from "../../../shared/utils/gatewayGraphql.js";
3
- import { Capacitor as n } from "../../../../node_modules/@capacitor/core/dist/index.js";
4
- import { acknowledgeNativePurchase as r, getNativeProducts as i, getNativePurchases as a, installNativeIAP as o, isNativeIAPAvailable as s, purchaseNativeProduct as c, restoreNativePurchases as l } from "../../../lib/native-purchases.js";
1
+ import { acknowledgeNativePurchase as e, getNativeProducts as t, getNativePurchases as n, installNativeIAP as r, isNativeIAPAvailable as i, purchaseNativeProduct as a, restoreNativePurchases as o } from "../../../lib/native-purchases.js";
2
+ import { useBilling as s } from "../../../providers/BillingProvider.js";
3
+ import { normalizeGlobalGatewayBaseUrl as c } from "../../../shared/utils/gatewayGraphql.js";
4
+ import { Capacitor as l } from "../../../../node_modules/@capacitor/core/dist/index.js";
5
5
  import { useCallback as u, useEffect as d, useState as f } from "react";
6
6
  //#region src/billing/modules/checkout/hooks/useNativeCheckout.ts
7
7
  function p({ billingAccountId: p, purchaseType: m, productId: h } = {}) {
8
- let { apiGatewayUrl: g, authToken: _ } = e(), [v, y] = f([]), [b, x] = f("idle"), [S, C] = f(null), [w, T] = f(!1), E = u(async (e, i, a) => {
8
+ let { apiGatewayUrl: g, authToken: _ } = s(), [v, y] = f([]), [b, x] = f("idle"), [S, C] = f(null), [w, T] = f(!1), E = u(async (t, n, r) => {
9
9
  if (!p) throw Error("No billing account selected");
10
- let o = `${t(g) ?? ""}/global/rest/billing/iap/validate`, s = n.getPlatform();
11
- if (s !== "ios" && s !== "android") throw Error("Native purchases require an iOS or Android app");
12
- let c = await fetch(o, {
10
+ let i = `${c(g) ?? ""}/global/rest/billing/iap/validate`, a = l.getPlatform();
11
+ if (a !== "ios" && a !== "android") throw Error("Native purchases require an iOS or Android app");
12
+ let o = await fetch(i, {
13
13
  method: "POST",
14
14
  headers: {
15
15
  "Content-Type": "application/json",
16
16
  ..._ ? { Authorization: `Bearer ${_}` } : {}
17
17
  },
18
18
  body: JSON.stringify({
19
- platform: s,
20
- transactionId: e.transactionId,
21
- productIdentifier: e.productIdentifier,
22
- receipt: e.receipt,
23
- jwsRepresentation: e.jwsRepresentation,
24
- purchaseToken: e.purchaseToken,
25
- appAccountToken: a ?? e.appAccountToken ?? void 0,
19
+ platform: a,
20
+ transactionId: t.transactionId,
21
+ productIdentifier: t.productIdentifier,
22
+ receipt: t.receipt,
23
+ jwsRepresentation: t.jwsRepresentation,
24
+ purchaseToken: t.purchaseToken,
25
+ appAccountToken: r ?? t.appAccountToken ?? void 0,
26
26
  billingAccountId: p,
27
27
  purchaseType: m ?? "PLAN",
28
28
  nativePurchaseType: m === "PLAN" ? "SUBS" : "INAPP",
29
- price: i?.price,
30
- currency: i?.currencyCode
29
+ price: n?.price,
30
+ currency: n?.currencyCode
31
31
  })
32
32
  });
33
- if (!c.ok) {
34
- let e = await c.json().catch(() => ({}));
35
- throw Error(e.message ?? `Validation failed (${c.status})`);
33
+ if (!o.ok) {
34
+ let e = await o.json().catch(() => ({}));
35
+ throw Error(e.message ?? `Validation failed (${o.status})`);
36
36
  }
37
- await r(e.purchaseToken ?? e.transactionId);
37
+ await e(t.purchaseToken ?? t.transactionId);
38
38
  }, [
39
39
  g,
40
40
  _,
@@ -42,17 +42,17 @@ function p({ billingAccountId: p, purchaseType: m, productId: h } = {}) {
42
42
  m
43
43
  ]);
44
44
  d(() => {
45
- !s() || !p || o((e) => {
45
+ !i() || !p || r((e) => {
46
46
  E(e).catch(() => {});
47
47
  });
48
48
  }, [p, E]);
49
49
  let D = u(async (e) => {
50
- if (!s()) return;
51
- let t = e ?? (h ? [h] : []);
52
- if (t.length !== 0) {
50
+ if (!i()) return;
51
+ let n = e ?? (h ? [h] : []);
52
+ if (n.length !== 0) {
53
53
  T(!0), C(null);
54
54
  try {
55
- y(await i(t, m === "PLAN" ? "subs" : "inapp"));
55
+ y(await t(n, m === "PLAN" ? "subs" : "inapp"));
56
56
  } catch (e) {
57
57
  C(e instanceof Error ? e.message : "Failed to load products");
58
58
  } finally {
@@ -65,7 +65,7 @@ function p({ billingAccountId: p, purchaseType: m, productId: h } = {}) {
65
65
  let t;
66
66
  try {
67
67
  let n = m === "CREDITS" || m === "ADDON", r = crypto.randomUUID();
68
- return t = await c(e.identifier, {
68
+ return t = await a(e.identifier, {
69
69
  autoAcknowledgePurchases: !1,
70
70
  isConsumable: n,
71
71
  productType: m === "PLAN" ? "subs" : "inapp",
@@ -79,8 +79,8 @@ function p({ billingAccountId: p, purchaseType: m, productId: h } = {}) {
79
79
  }, [m, E]), k = u(async () => {
80
80
  T(!0), C(null);
81
81
  try {
82
- await l();
83
- let e = await a({ productType: m === "PLAN" ? "subs" : "inapp" });
82
+ await o();
83
+ let e = await n({ productType: m === "PLAN" ? "subs" : "inapp" });
84
84
  for (let t of e) await E(t);
85
85
  return { success: !0 };
86
86
  } catch (e) {
@@ -90,7 +90,7 @@ function p({ billingAccountId: p, purchaseType: m, productId: h } = {}) {
90
90
  }
91
91
  }, [E]);
92
92
  return {
93
- isAvailable: s(),
93
+ isAvailable: i(),
94
94
  products: v,
95
95
  checkoutState: b,
96
96
  error: S,