@fonderie/react-billing 0.6.0 → 0.7.0
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/index.cjs +85 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +22 -1
- package/dist/index.d.ts +22 -1
- package/dist/index.js +82 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -20,7 +20,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
-
FonderieApiError: () =>
|
|
23
|
+
FonderieApiError: () => import_client18.FonderieApiError,
|
|
24
24
|
useBillingPortal: () => useBillingPortal,
|
|
25
25
|
useCancelSubscription: () => useCancelSubscription,
|
|
26
26
|
useCheckout: () => useCheckout,
|
|
@@ -29,6 +29,9 @@ __export(index_exports, {
|
|
|
29
29
|
usePlan: () => usePlan,
|
|
30
30
|
usePlans: () => usePlans,
|
|
31
31
|
useReactivateSubscription: () => useReactivateSubscription,
|
|
32
|
+
useRemovePaymentMethod: () => useRemovePaymentMethod,
|
|
33
|
+
useSavePaymentMethod: () => useSavePaymentMethod,
|
|
34
|
+
useSetupPaymentMethod: () => useSetupPaymentMethod,
|
|
32
35
|
useSubscription: () => useSubscription,
|
|
33
36
|
useUsage: () => useUsage,
|
|
34
37
|
useWallet: () => useWallet,
|
|
@@ -37,7 +40,7 @@ __export(index_exports, {
|
|
|
37
40
|
useWalletTransactions: () => useWalletTransactions
|
|
38
41
|
});
|
|
39
42
|
module.exports = __toCommonJS(index_exports);
|
|
40
|
-
var
|
|
43
|
+
var import_client18 = require("@fonderie/client");
|
|
41
44
|
|
|
42
45
|
// src/hooks/useBillingPortal.ts
|
|
43
46
|
var import_client = require("@fonderie/client");
|
|
@@ -556,6 +559,83 @@ function useInvoices(client) {
|
|
|
556
559
|
}, [refresh]);
|
|
557
560
|
return { invoices, isLoading, error, refresh };
|
|
558
561
|
}
|
|
562
|
+
|
|
563
|
+
// src/hooks/useSetupPaymentMethod.ts
|
|
564
|
+
var import_client15 = require("@fonderie/client");
|
|
565
|
+
var import_react29 = require("@fonderie/react");
|
|
566
|
+
var import_react30 = require("react");
|
|
567
|
+
function useSetupPaymentMethod(client) {
|
|
568
|
+
const billing = (0, import_react29.useFonderieSubClient)(client, (c) => c.billing, "useSetupPaymentMethod");
|
|
569
|
+
const [isLoading, setIsLoading] = (0, import_react30.useState)(false);
|
|
570
|
+
const [error, setError] = (0, import_react30.useState)(null);
|
|
571
|
+
const setup = (0, import_react30.useCallback)(async () => {
|
|
572
|
+
setIsLoading(true);
|
|
573
|
+
setError(null);
|
|
574
|
+
try {
|
|
575
|
+
const { result } = await billing.setupPaymentMethod();
|
|
576
|
+
return result.clientSecret;
|
|
577
|
+
} catch (err) {
|
|
578
|
+
const apiError = err instanceof import_client15.FonderieApiError ? err : new import_client15.FonderieApiError("unknown", String(err), 0);
|
|
579
|
+
setError(apiError);
|
|
580
|
+
throw apiError;
|
|
581
|
+
} finally {
|
|
582
|
+
setIsLoading(false);
|
|
583
|
+
}
|
|
584
|
+
}, [billing]);
|
|
585
|
+
return { setup, isLoading, error };
|
|
586
|
+
}
|
|
587
|
+
|
|
588
|
+
// src/hooks/useSavePaymentMethod.ts
|
|
589
|
+
var import_client16 = require("@fonderie/client");
|
|
590
|
+
var import_react31 = require("@fonderie/react");
|
|
591
|
+
var import_react32 = require("react");
|
|
592
|
+
function useSavePaymentMethod(client) {
|
|
593
|
+
const billing = (0, import_react31.useFonderieSubClient)(client, (c) => c.billing, "useSavePaymentMethod");
|
|
594
|
+
const [isLoading, setIsLoading] = (0, import_react32.useState)(false);
|
|
595
|
+
const [error, setError] = (0, import_react32.useState)(null);
|
|
596
|
+
const save = (0, import_react32.useCallback)(
|
|
597
|
+
async (paymentMethodId) => {
|
|
598
|
+
setIsLoading(true);
|
|
599
|
+
setError(null);
|
|
600
|
+
try {
|
|
601
|
+
const { result } = await billing.savePaymentMethod({ paymentMethodId });
|
|
602
|
+
return result.paymentMethod;
|
|
603
|
+
} catch (err) {
|
|
604
|
+
const apiError = err instanceof import_client16.FonderieApiError ? err : new import_client16.FonderieApiError("unknown", String(err), 0);
|
|
605
|
+
setError(apiError);
|
|
606
|
+
throw apiError;
|
|
607
|
+
} finally {
|
|
608
|
+
setIsLoading(false);
|
|
609
|
+
}
|
|
610
|
+
},
|
|
611
|
+
[billing]
|
|
612
|
+
);
|
|
613
|
+
return { save, isLoading, error };
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// src/hooks/useRemovePaymentMethod.ts
|
|
617
|
+
var import_client17 = require("@fonderie/client");
|
|
618
|
+
var import_react33 = require("@fonderie/react");
|
|
619
|
+
var import_react34 = require("react");
|
|
620
|
+
function useRemovePaymentMethod(client) {
|
|
621
|
+
const billing = (0, import_react33.useFonderieSubClient)(client, (c) => c.billing, "useRemovePaymentMethod");
|
|
622
|
+
const [isLoading, setIsLoading] = (0, import_react34.useState)(false);
|
|
623
|
+
const [error, setError] = (0, import_react34.useState)(null);
|
|
624
|
+
const remove = (0, import_react34.useCallback)(async () => {
|
|
625
|
+
setIsLoading(true);
|
|
626
|
+
setError(null);
|
|
627
|
+
try {
|
|
628
|
+
await billing.removePaymentMethod();
|
|
629
|
+
} catch (err) {
|
|
630
|
+
const apiError = err instanceof import_client17.FonderieApiError ? err : new import_client17.FonderieApiError("unknown", String(err), 0);
|
|
631
|
+
setError(apiError);
|
|
632
|
+
throw apiError;
|
|
633
|
+
} finally {
|
|
634
|
+
setIsLoading(false);
|
|
635
|
+
}
|
|
636
|
+
}, [billing]);
|
|
637
|
+
return { remove, isLoading, error };
|
|
638
|
+
}
|
|
559
639
|
// Annotate the CommonJS export names for ESM import in node:
|
|
560
640
|
0 && (module.exports = {
|
|
561
641
|
FonderieApiError,
|
|
@@ -567,6 +647,9 @@ function useInvoices(client) {
|
|
|
567
647
|
usePlan,
|
|
568
648
|
usePlans,
|
|
569
649
|
useReactivateSubscription,
|
|
650
|
+
useRemovePaymentMethod,
|
|
651
|
+
useSavePaymentMethod,
|
|
652
|
+
useSetupPaymentMethod,
|
|
570
653
|
useSubscription,
|
|
571
654
|
useUsage,
|
|
572
655
|
useWallet,
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlans.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts","../src/hooks/useWalletPreferences.ts","../src/hooks/useWallet.ts","../src/hooks/useWalletTransactions.ts","../src/hooks/useWalletCheckout.ts","../src/hooks/useCancelSubscription.ts","../src/hooks/useReactivateSubscription.ts","../src/hooks/usePaymentMethod.ts","../src/hooks/useInvoices.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIInvoiceDTO,\n\tIPaymentMethodDTO,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionChangeResult,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tIWalletCheckoutInput,\n\tIWalletDTO,\n\tIWalletTransactionDTO,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCancelSubscriptionReturn,\n\tIUseCheckoutReturn,\n\tIUseInvoicesReturn,\n\tIUsePaymentMethodReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseReactivateSubscriptionReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n\tIUseWalletCheckoutReturn,\n\tIUseWalletPreferencesReturn,\n\tIUseWalletReturn,\n\tIUseWalletTransactionsReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCancelSubscription,\n\tuseCheckout,\n\tuseInvoices,\n\tusePaymentMethod,\n\tusePlan,\n\tusePlans,\n\tuseReactivateSubscription,\n\tuseSubscription,\n\tuseUsage,\n\tuseWallet,\n\tuseWalletCheckout,\n\tuseWalletPreferences,\n\tuseWalletTransactions,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// These writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n","import { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletPreferencesReturn {\n\t// Per-subscriber toggle: when false, a debit stops at the free allowance and\n\t// never draws down purchased credits. null until the first read resolves; a\n\t// subscriber with no balance row reads the server default (true).\n\tspendPurchased: boolean | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tsetSpendPurchased: (spendPurchased: boolean) => Promise<void>;\n}\n\nexport function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletPreferences');\n\tconst [spendPurchased, setSpend] = useState<boolean | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\t// The DTO omits spendPurchased when no balance row exists; surface the\n\t\t\t\t// server default (spend_purchased DEFAULT true) rather than null.\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst setSpendPurchased = useCallback(\n\t\tasync (next: boolean) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\t// The toggle route returns the refreshed wallet, so adopt it directly.\n\t\t\t\tconst { result } = await billing.setWalletPreferences({ spendPurchased: next });\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? next);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { spendPurchased, isLoading, error, refresh, setSpendPurchased };\n}\n","import type { BillingClient, IWalletDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletReturn {\n\t// The balance snapshot. Money fields are digit strings (server bigint →\n\t// string); null until the first read resolves or after a failed read.\n\twallet: IWalletDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's stored-value wallet balance. Reads GET /billing/wallet, so\n// it reflects the periodic grant withBilling applies on every authed request.\nexport function useWallet(client?: BillingClient): IUseWalletReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWallet');\n\tconst [wallet, setWallet] = useState<IWalletDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\tsetWallet(result.wallet);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tsetWallet(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { wallet, isLoading, error, refresh };\n}\n","import type { BillingClient, IWalletTransactionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletTransactionsReturn {\n\ttransactions: IWalletTransactionDTO[];\n\t// Opaque cursor for the next page, or null when the ledger is exhausted.\n\tnextCursor: string | null;\n\thasMore: boolean;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\t// Appends the next page. No-op when there is no further page.\n\tloadMore: () => Promise<void>;\n}\n\n// The wallet ledger, newest first — every credit/debit with a running\n// balanceAfter. Cursor-paginated: `loadMore` appends the next page.\nexport function useWalletTransactions(client?: BillingClient): IUseWalletTransactionsReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletTransactions');\n\tconst [transactions, setTransactions] = useState<IWalletTransactionDTO[]>([]);\n\tconst [nextCursor, setNextCursor] = useState<string | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWalletTransactions({ bust: opts?.force });\n\t\t\t\tsetTransactions(result.transactions);\n\t\t\t\tsetNextCursor(result.nextCursor);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst loadMore = useCallback(async () => {\n\t\tif (!nextCursor) return;\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getWalletTransactions({ cursor: nextCursor });\n\t\t\tsetTransactions((prev) => [...prev, ...result.transactions]);\n\t\t\tsetNextCursor(result.nextCursor);\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t}\n\t}, [billing, nextCursor]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn {\n\t\ttransactions,\n\t\tnextCursor,\n\t\thasMore: nextCursor !== null,\n\t\tisLoading,\n\t\terror,\n\t\trefresh,\n\t\tloadMore,\n\t};\n}\n","import type { BillingClient, IWalletCheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseWalletCheckoutReturn {\n\t// Starts a one-time credit-pack purchase and resolves to the hosted checkout\n\t// URL to redirect the buyer to; the wallet is credited by the payment webhook.\n\tcheckout: (input: IWalletCheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useWalletCheckout(client?: BillingClient): IUseWalletCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: IWalletCheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createWalletCheckout(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tISubscriptionChangeResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCancelSubscriptionReturn {\n\t// First-party cancel — no billing-portal round-trip. Default keeps access\n\t// until the paid-through date; pass { atPeriodEnd: false } to end it now.\n\t// Resolves to the new lifecycle state ({ atPeriodEnd, status, currentPeriodEnd }).\n\tcancel: (input?: ICancelSubscriptionInput) => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCancelSubscription(client?: BillingClient): IUseCancelSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCancelSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst cancel = useCallback(\n\t\tasync (input?: ICancelSubscriptionInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.cancelSubscription(input);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { cancel, isLoading, error };\n}\n","import type { BillingClient, ISubscriptionChangeResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseReactivateSubscriptionReturn {\n\t// Un-cancel a subscription scheduled to cancel at period end. Resolves to the\n\t// new lifecycle state; rejects (409) if the subscription is already fully\n\t// canceled — the caller should start a fresh checkout in that case.\n\treactivate: () => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useReactivateSubscription(client?: BillingClient): IUseReactivateSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useReactivateSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst reactivate = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.reactivateSubscription();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { reactivate, isLoading, error };\n}\n","import type { BillingClient, IPaymentMethodDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePaymentMethodReturn {\n\t// The card on file (brand/last4/expiry), or null when none is stored or the\n\t// provider can't retrieve one (a normal \"no card\" state, not an error).\n\tpaymentMethod: IPaymentMethodDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's card on file, for a billing page. Reads GET\n// /billing/payment-method.\nexport function usePaymentMethod(client?: BillingClient): IUsePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePaymentMethod');\n\tconst [paymentMethod, setPaymentMethod] = useState<IPaymentMethodDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPaymentMethod({ bust: opts?.force });\n\t\t\t\tsetPaymentMethod(result.paymentMethod);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't retrieve a card — a normal \"no card on\n\t\t\t\t// file\" state for a UI, not an error banner.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetPaymentMethod(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { paymentMethod, isLoading, error, refresh };\n}\n","import type { BillingClient, IInvoiceDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseInvoicesReturn {\n\t// Invoices newest first; each links out via hostedInvoiceUrl/invoicePdf.\n\tinvoices: IInvoiceDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's invoice history, for a billing page. Reads GET\n// /billing/invoices.\nexport function useInvoices(client?: BillingClient): IUseInvoicesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useInvoices');\n\tconst [invoices, setInvoices] = useState<IInvoiceDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listInvoices({ bust: opts?.force });\n\t\t\t\tsetInvoices(result.invoices);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't list invoices — a normal \"no invoices\" state.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetInvoices([]);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { invoices, isLoading, error, refresh };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAkBA,IAAAA,kBAAiC;;;ACjBjC,oBAAiC;AACjC,mBAAqC;AACrC,IAAAC,gBAAsC;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,cAAU,mCAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB;AACjF,QAAM,CAAC,WAAW,YAAY,QAAI,wBAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,QAAI,wBAAkC,IAAI;AAEhE,QAAM,iBAAa,2BAAY,YAAY;AAC1C,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,oBAAoB;AACrD,aAAO,OAAO;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAe,iCAAmB,MAAM,IAAI,+BAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AACjB,YAAM;AAAA,IACP,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,YAAY,WAAW,MAAM;AACvC;;;AChCA,IAAAC,iBAAiC;AACjC,IAAAC,gBAAqC;AACrC,IAAAA,gBAAsC;AAQ/B,SAAS,YAAY,QAA4C;AACvE,QAAM,cAAU,oCAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa;AAC5E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AACvE,QAAM,cAAU,qCAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa;AAC5E,QAAM,CAAC,UAAU,WAAW,QAAI,yBAAwB,CAAC,CAAC;AAC1D,QAAM,CAAC,WAAW,YAAY,QAAI,yBAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,QAAI,yBAAkC,IAAI;AAEhE,QAAM,cAAU;AAAA,IACf,OAAO,SAA+B;AACrC,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,aAAa,EAAE,MAAM,MAAM,MAAM,CAAC;AACnE,oBAAY,OAAO,QAAQ;AAAA,MAC5B,SAAS,KAAK;AACb,cAAM,WACL,eAAe,mCAAmB,MAAM,IAAI,iCAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AAEvF,YAAI,SAAS,WAAW,IAAK,UAAS,QAAQ;AAC9C,oBAAY,CAAC,CAAC;AAAA,MACf,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,OAAO;AAAA,EACT;AAEA,gCAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;","names":["import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlans.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts","../src/hooks/useWalletPreferences.ts","../src/hooks/useWallet.ts","../src/hooks/useWalletTransactions.ts","../src/hooks/useWalletCheckout.ts","../src/hooks/useCancelSubscription.ts","../src/hooks/useReactivateSubscription.ts","../src/hooks/usePaymentMethod.ts","../src/hooks/useInvoices.ts","../src/hooks/useSetupPaymentMethod.ts","../src/hooks/useSavePaymentMethod.ts","../src/hooks/useRemovePaymentMethod.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIInvoiceDTO,\n\tIPaymentMethodDTO,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionChangeResult,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tIWalletCheckoutInput,\n\tIWalletDTO,\n\tIWalletTransactionDTO,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCancelSubscriptionReturn,\n\tIUseCheckoutReturn,\n\tIUseInvoicesReturn,\n\tIUsePaymentMethodReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseReactivateSubscriptionReturn,\n\tIUseRemovePaymentMethodReturn,\n\tIUseSavePaymentMethodReturn,\n\tIUseSetupPaymentMethodReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n\tIUseWalletCheckoutReturn,\n\tIUseWalletPreferencesReturn,\n\tIUseWalletReturn,\n\tIUseWalletTransactionsReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCancelSubscription,\n\tuseCheckout,\n\tuseInvoices,\n\tusePaymentMethod,\n\tusePlan,\n\tusePlans,\n\tuseReactivateSubscription,\n\tuseRemovePaymentMethod,\n\tuseSavePaymentMethod,\n\tuseSetupPaymentMethod,\n\tuseSubscription,\n\tuseUsage,\n\tuseWallet,\n\tuseWalletCheckout,\n\tuseWalletPreferences,\n\tuseWalletTransactions,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// These writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n","import { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletPreferencesReturn {\n\t// Per-subscriber toggle: when false, a debit stops at the free allowance and\n\t// never draws down purchased credits. null until the first read resolves; a\n\t// subscriber with no balance row reads the server default (true).\n\tspendPurchased: boolean | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tsetSpendPurchased: (spendPurchased: boolean) => Promise<void>;\n}\n\nexport function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletPreferences');\n\tconst [spendPurchased, setSpend] = useState<boolean | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\t// The DTO omits spendPurchased when no balance row exists; surface the\n\t\t\t\t// server default (spend_purchased DEFAULT true) rather than null.\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst setSpendPurchased = useCallback(\n\t\tasync (next: boolean) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\t// The toggle route returns the refreshed wallet, so adopt it directly.\n\t\t\t\tconst { result } = await billing.setWalletPreferences({ spendPurchased: next });\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? next);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { spendPurchased, isLoading, error, refresh, setSpendPurchased };\n}\n","import type { BillingClient, IWalletDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletReturn {\n\t// The balance snapshot. Money fields are digit strings (server bigint →\n\t// string); null until the first read resolves or after a failed read.\n\twallet: IWalletDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's stored-value wallet balance. Reads GET /billing/wallet, so\n// it reflects the periodic grant withBilling applies on every authed request.\nexport function useWallet(client?: BillingClient): IUseWalletReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWallet');\n\tconst [wallet, setWallet] = useState<IWalletDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\tsetWallet(result.wallet);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tsetWallet(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { wallet, isLoading, error, refresh };\n}\n","import type { BillingClient, IWalletTransactionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletTransactionsReturn {\n\ttransactions: IWalletTransactionDTO[];\n\t// Opaque cursor for the next page, or null when the ledger is exhausted.\n\tnextCursor: string | null;\n\thasMore: boolean;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\t// Appends the next page. No-op when there is no further page.\n\tloadMore: () => Promise<void>;\n}\n\n// The wallet ledger, newest first — every credit/debit with a running\n// balanceAfter. Cursor-paginated: `loadMore` appends the next page.\nexport function useWalletTransactions(client?: BillingClient): IUseWalletTransactionsReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletTransactions');\n\tconst [transactions, setTransactions] = useState<IWalletTransactionDTO[]>([]);\n\tconst [nextCursor, setNextCursor] = useState<string | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWalletTransactions({ bust: opts?.force });\n\t\t\t\tsetTransactions(result.transactions);\n\t\t\t\tsetNextCursor(result.nextCursor);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst loadMore = useCallback(async () => {\n\t\tif (!nextCursor) return;\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getWalletTransactions({ cursor: nextCursor });\n\t\t\tsetTransactions((prev) => [...prev, ...result.transactions]);\n\t\t\tsetNextCursor(result.nextCursor);\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t}\n\t}, [billing, nextCursor]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn {\n\t\ttransactions,\n\t\tnextCursor,\n\t\thasMore: nextCursor !== null,\n\t\tisLoading,\n\t\terror,\n\t\trefresh,\n\t\tloadMore,\n\t};\n}\n","import type { BillingClient, IWalletCheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseWalletCheckoutReturn {\n\t// Starts a one-time credit-pack purchase and resolves to the hosted checkout\n\t// URL to redirect the buyer to; the wallet is credited by the payment webhook.\n\tcheckout: (input: IWalletCheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useWalletCheckout(client?: BillingClient): IUseWalletCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: IWalletCheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createWalletCheckout(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tISubscriptionChangeResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCancelSubscriptionReturn {\n\t// First-party cancel — no billing-portal round-trip. Default keeps access\n\t// until the paid-through date; pass { atPeriodEnd: false } to end it now.\n\t// Resolves to the new lifecycle state ({ atPeriodEnd, status, currentPeriodEnd }).\n\tcancel: (input?: ICancelSubscriptionInput) => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCancelSubscription(client?: BillingClient): IUseCancelSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCancelSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst cancel = useCallback(\n\t\tasync (input?: ICancelSubscriptionInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.cancelSubscription(input);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { cancel, isLoading, error };\n}\n","import type { BillingClient, ISubscriptionChangeResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseReactivateSubscriptionReturn {\n\t// Un-cancel a subscription scheduled to cancel at period end. Resolves to the\n\t// new lifecycle state; rejects (409) if the subscription is already fully\n\t// canceled — the caller should start a fresh checkout in that case.\n\treactivate: () => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useReactivateSubscription(client?: BillingClient): IUseReactivateSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useReactivateSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst reactivate = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.reactivateSubscription();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { reactivate, isLoading, error };\n}\n","import type { BillingClient, IPaymentMethodDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePaymentMethodReturn {\n\t// The card on file (brand/last4/expiry), or null when none is stored or the\n\t// provider can't retrieve one (a normal \"no card\" state, not an error).\n\tpaymentMethod: IPaymentMethodDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's card on file, for a billing page. Reads GET\n// /billing/payment-method.\nexport function usePaymentMethod(client?: BillingClient): IUsePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePaymentMethod');\n\tconst [paymentMethod, setPaymentMethod] = useState<IPaymentMethodDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPaymentMethod({ bust: opts?.force });\n\t\t\t\tsetPaymentMethod(result.paymentMethod);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't retrieve a card — a normal \"no card on\n\t\t\t\t// file\" state for a UI, not an error banner.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetPaymentMethod(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { paymentMethod, isLoading, error, refresh };\n}\n","import type { BillingClient, IInvoiceDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseInvoicesReturn {\n\t// Invoices newest first; each links out via hostedInvoiceUrl/invoicePdf.\n\tinvoices: IInvoiceDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's invoice history, for a billing page. Reads GET\n// /billing/invoices.\nexport function useInvoices(client?: BillingClient): IUseInvoicesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useInvoices');\n\tconst [invoices, setInvoices] = useState<IInvoiceDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listInvoices({ bust: opts?.force });\n\t\t\t\tsetInvoices(result.invoices);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't list invoices — a normal \"no invoices\" state.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetInvoices([]);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { invoices, isLoading, error, refresh };\n}\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseSetupPaymentMethodReturn {\n\t// Begin in-app card entry — resolves to the provider SetupIntent client secret\n\t// the embedded card element (Stripe Payment Element) confirms. No redirect;\n\t// the user never leaves the site. 501 when the provider has no in-app support.\n\tsetup: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useSetupPaymentMethod(client?: BillingClient): IUseSetupPaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSetupPaymentMethod');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst setup = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.setupPaymentMethod();\n\t\t\treturn result.clientSecret;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { setup, isLoading, error };\n}\n","import type { BillingClient, IPaymentMethodDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseSavePaymentMethodReturn {\n\t// Save the card after the Payment Element confirms the SetupIntent: makes it\n\t// the default and records it. Resolves to the saved card for display; rejects\n\t// (422) if the card isn't attached to this customer.\n\tsave: (paymentMethodId: string) => Promise<IPaymentMethodDTO | null>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useSavePaymentMethod(client?: BillingClient): IUseSavePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSavePaymentMethod');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst save = useCallback(\n\t\tasync (paymentMethodId: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.savePaymentMethod({ paymentMethodId });\n\t\t\t\treturn result.paymentMethod;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { save, isLoading, error };\n}\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseRemovePaymentMethodReturn {\n\t// Remove the saved card (detach at the provider + clear the record).\n\tremove: () => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useRemovePaymentMethod(client?: BillingClient): IUseRemovePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useRemovePaymentMethod');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst remove = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tawait billing.removePaymentMethod();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { remove, isLoading, error };\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA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AQ,WAAW,MAAM;AACnC;","names":["import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react","import_client","import_react"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -136,4 +136,25 @@ interface IUseInvoicesReturn {
|
|
|
136
136
|
}
|
|
137
137
|
declare function useInvoices(client?: BillingClient): IUseInvoicesReturn;
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
interface IUseSetupPaymentMethodReturn {
|
|
140
|
+
setup: () => Promise<string>;
|
|
141
|
+
isLoading: boolean;
|
|
142
|
+
error: FonderieApiError | null;
|
|
143
|
+
}
|
|
144
|
+
declare function useSetupPaymentMethod(client?: BillingClient): IUseSetupPaymentMethodReturn;
|
|
145
|
+
|
|
146
|
+
interface IUseSavePaymentMethodReturn {
|
|
147
|
+
save: (paymentMethodId: string) => Promise<IPaymentMethodDTO | null>;
|
|
148
|
+
isLoading: boolean;
|
|
149
|
+
error: FonderieApiError | null;
|
|
150
|
+
}
|
|
151
|
+
declare function useSavePaymentMethod(client?: BillingClient): IUseSavePaymentMethodReturn;
|
|
152
|
+
|
|
153
|
+
interface IUseRemovePaymentMethodReturn {
|
|
154
|
+
remove: () => Promise<void>;
|
|
155
|
+
isLoading: boolean;
|
|
156
|
+
error: FonderieApiError | null;
|
|
157
|
+
}
|
|
158
|
+
declare function useRemovePaymentMethod(client?: BillingClient): IUseRemovePaymentMethodReturn;
|
|
159
|
+
|
|
160
|
+
export { type IUseBillingPortalReturn, type IUseCancelSubscriptionReturn, type IUseCheckoutReturn, type IUseInvoicesReturn, type IUsePaymentMethodReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseReactivateSubscriptionReturn, type IUseRemovePaymentMethodReturn, type IUseSavePaymentMethodReturn, type IUseSetupPaymentMethodReturn, type IUseSubscriptionReturn, type IUseUsageReturn, type IUseWalletCheckoutReturn, type IUseWalletPreferencesReturn, type IUseWalletReturn, type IUseWalletTransactionsReturn, useBillingPortal, useCancelSubscription, useCheckout, useInvoices, usePaymentMethod, usePlan, usePlans, useReactivateSubscription, useRemovePaymentMethod, useSavePaymentMethod, useSetupPaymentMethod, useSubscription, useUsage, useWallet, useWalletCheckout, useWalletPreferences, useWalletTransactions };
|
package/dist/index.d.ts
CHANGED
|
@@ -136,4 +136,25 @@ interface IUseInvoicesReturn {
|
|
|
136
136
|
}
|
|
137
137
|
declare function useInvoices(client?: BillingClient): IUseInvoicesReturn;
|
|
138
138
|
|
|
139
|
-
|
|
139
|
+
interface IUseSetupPaymentMethodReturn {
|
|
140
|
+
setup: () => Promise<string>;
|
|
141
|
+
isLoading: boolean;
|
|
142
|
+
error: FonderieApiError | null;
|
|
143
|
+
}
|
|
144
|
+
declare function useSetupPaymentMethod(client?: BillingClient): IUseSetupPaymentMethodReturn;
|
|
145
|
+
|
|
146
|
+
interface IUseSavePaymentMethodReturn {
|
|
147
|
+
save: (paymentMethodId: string) => Promise<IPaymentMethodDTO | null>;
|
|
148
|
+
isLoading: boolean;
|
|
149
|
+
error: FonderieApiError | null;
|
|
150
|
+
}
|
|
151
|
+
declare function useSavePaymentMethod(client?: BillingClient): IUseSavePaymentMethodReturn;
|
|
152
|
+
|
|
153
|
+
interface IUseRemovePaymentMethodReturn {
|
|
154
|
+
remove: () => Promise<void>;
|
|
155
|
+
isLoading: boolean;
|
|
156
|
+
error: FonderieApiError | null;
|
|
157
|
+
}
|
|
158
|
+
declare function useRemovePaymentMethod(client?: BillingClient): IUseRemovePaymentMethodReturn;
|
|
159
|
+
|
|
160
|
+
export { type IUseBillingPortalReturn, type IUseCancelSubscriptionReturn, type IUseCheckoutReturn, type IUseInvoicesReturn, type IUsePaymentMethodReturn, type IUsePlanReturn, type IUsePlansReturn, type IUseReactivateSubscriptionReturn, type IUseRemovePaymentMethodReturn, type IUseSavePaymentMethodReturn, type IUseSetupPaymentMethodReturn, type IUseSubscriptionReturn, type IUseUsageReturn, type IUseWalletCheckoutReturn, type IUseWalletPreferencesReturn, type IUseWalletReturn, type IUseWalletTransactionsReturn, useBillingPortal, useCancelSubscription, useCheckout, useInvoices, usePaymentMethod, usePlan, usePlans, useReactivateSubscription, useRemovePaymentMethod, useSavePaymentMethod, useSetupPaymentMethod, useSubscription, useUsage, useWallet, useWalletCheckout, useWalletPreferences, useWalletTransactions };
|
package/dist/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
// src/index.ts
|
|
2
|
-
import { FonderieApiError as
|
|
2
|
+
import { FonderieApiError as FonderieApiError18 } from "@fonderie/client";
|
|
3
3
|
|
|
4
4
|
// src/hooks/useBillingPortal.ts
|
|
5
5
|
import { FonderieApiError } from "@fonderie/client";
|
|
@@ -518,8 +518,85 @@ function useInvoices(client) {
|
|
|
518
518
|
}, [refresh]);
|
|
519
519
|
return { invoices, isLoading, error, refresh };
|
|
520
520
|
}
|
|
521
|
+
|
|
522
|
+
// src/hooks/useSetupPaymentMethod.ts
|
|
523
|
+
import { FonderieApiError as FonderieApiError15 } from "@fonderie/client";
|
|
524
|
+
import { useFonderieSubClient as useFonderieSubClient15 } from "@fonderie/react";
|
|
525
|
+
import { useCallback as useCallback15, useState as useState15 } from "react";
|
|
526
|
+
function useSetupPaymentMethod(client) {
|
|
527
|
+
const billing = useFonderieSubClient15(client, (c) => c.billing, "useSetupPaymentMethod");
|
|
528
|
+
const [isLoading, setIsLoading] = useState15(false);
|
|
529
|
+
const [error, setError] = useState15(null);
|
|
530
|
+
const setup = useCallback15(async () => {
|
|
531
|
+
setIsLoading(true);
|
|
532
|
+
setError(null);
|
|
533
|
+
try {
|
|
534
|
+
const { result } = await billing.setupPaymentMethod();
|
|
535
|
+
return result.clientSecret;
|
|
536
|
+
} catch (err) {
|
|
537
|
+
const apiError = err instanceof FonderieApiError15 ? err : new FonderieApiError15("unknown", String(err), 0);
|
|
538
|
+
setError(apiError);
|
|
539
|
+
throw apiError;
|
|
540
|
+
} finally {
|
|
541
|
+
setIsLoading(false);
|
|
542
|
+
}
|
|
543
|
+
}, [billing]);
|
|
544
|
+
return { setup, isLoading, error };
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
// src/hooks/useSavePaymentMethod.ts
|
|
548
|
+
import { FonderieApiError as FonderieApiError16 } from "@fonderie/client";
|
|
549
|
+
import { useFonderieSubClient as useFonderieSubClient16 } from "@fonderie/react";
|
|
550
|
+
import { useCallback as useCallback16, useState as useState16 } from "react";
|
|
551
|
+
function useSavePaymentMethod(client) {
|
|
552
|
+
const billing = useFonderieSubClient16(client, (c) => c.billing, "useSavePaymentMethod");
|
|
553
|
+
const [isLoading, setIsLoading] = useState16(false);
|
|
554
|
+
const [error, setError] = useState16(null);
|
|
555
|
+
const save = useCallback16(
|
|
556
|
+
async (paymentMethodId) => {
|
|
557
|
+
setIsLoading(true);
|
|
558
|
+
setError(null);
|
|
559
|
+
try {
|
|
560
|
+
const { result } = await billing.savePaymentMethod({ paymentMethodId });
|
|
561
|
+
return result.paymentMethod;
|
|
562
|
+
} catch (err) {
|
|
563
|
+
const apiError = err instanceof FonderieApiError16 ? err : new FonderieApiError16("unknown", String(err), 0);
|
|
564
|
+
setError(apiError);
|
|
565
|
+
throw apiError;
|
|
566
|
+
} finally {
|
|
567
|
+
setIsLoading(false);
|
|
568
|
+
}
|
|
569
|
+
},
|
|
570
|
+
[billing]
|
|
571
|
+
);
|
|
572
|
+
return { save, isLoading, error };
|
|
573
|
+
}
|
|
574
|
+
|
|
575
|
+
// src/hooks/useRemovePaymentMethod.ts
|
|
576
|
+
import { FonderieApiError as FonderieApiError17 } from "@fonderie/client";
|
|
577
|
+
import { useFonderieSubClient as useFonderieSubClient17 } from "@fonderie/react";
|
|
578
|
+
import { useCallback as useCallback17, useState as useState17 } from "react";
|
|
579
|
+
function useRemovePaymentMethod(client) {
|
|
580
|
+
const billing = useFonderieSubClient17(client, (c) => c.billing, "useRemovePaymentMethod");
|
|
581
|
+
const [isLoading, setIsLoading] = useState17(false);
|
|
582
|
+
const [error, setError] = useState17(null);
|
|
583
|
+
const remove = useCallback17(async () => {
|
|
584
|
+
setIsLoading(true);
|
|
585
|
+
setError(null);
|
|
586
|
+
try {
|
|
587
|
+
await billing.removePaymentMethod();
|
|
588
|
+
} catch (err) {
|
|
589
|
+
const apiError = err instanceof FonderieApiError17 ? err : new FonderieApiError17("unknown", String(err), 0);
|
|
590
|
+
setError(apiError);
|
|
591
|
+
throw apiError;
|
|
592
|
+
} finally {
|
|
593
|
+
setIsLoading(false);
|
|
594
|
+
}
|
|
595
|
+
}, [billing]);
|
|
596
|
+
return { remove, isLoading, error };
|
|
597
|
+
}
|
|
521
598
|
export {
|
|
522
|
-
|
|
599
|
+
FonderieApiError18 as FonderieApiError,
|
|
523
600
|
useBillingPortal,
|
|
524
601
|
useCancelSubscription,
|
|
525
602
|
useCheckout,
|
|
@@ -528,6 +605,9 @@ export {
|
|
|
528
605
|
usePlan,
|
|
529
606
|
usePlans,
|
|
530
607
|
useReactivateSubscription,
|
|
608
|
+
useRemovePaymentMethod,
|
|
609
|
+
useSavePaymentMethod,
|
|
610
|
+
useSetupPaymentMethod,
|
|
531
611
|
useSubscription,
|
|
532
612
|
useUsage,
|
|
533
613
|
useWallet,
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlans.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts","../src/hooks/useWalletPreferences.ts","../src/hooks/useWallet.ts","../src/hooks/useWalletTransactions.ts","../src/hooks/useWalletCheckout.ts","../src/hooks/useCancelSubscription.ts","../src/hooks/useReactivateSubscription.ts","../src/hooks/usePaymentMethod.ts","../src/hooks/useInvoices.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIInvoiceDTO,\n\tIPaymentMethodDTO,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionChangeResult,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tIWalletCheckoutInput,\n\tIWalletDTO,\n\tIWalletTransactionDTO,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCancelSubscriptionReturn,\n\tIUseCheckoutReturn,\n\tIUseInvoicesReturn,\n\tIUsePaymentMethodReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseReactivateSubscriptionReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n\tIUseWalletCheckoutReturn,\n\tIUseWalletPreferencesReturn,\n\tIUseWalletReturn,\n\tIUseWalletTransactionsReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCancelSubscription,\n\tuseCheckout,\n\tuseInvoices,\n\tusePaymentMethod,\n\tusePlan,\n\tusePlans,\n\tuseReactivateSubscription,\n\tuseSubscription,\n\tuseUsage,\n\tuseWallet,\n\tuseWalletCheckout,\n\tuseWalletPreferences,\n\tuseWalletTransactions,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// These writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n","import { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletPreferencesReturn {\n\t// Per-subscriber toggle: when false, a debit stops at the free allowance and\n\t// never draws down purchased credits. null until the first read resolves; a\n\t// subscriber with no balance row reads the server default (true).\n\tspendPurchased: boolean | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tsetSpendPurchased: (spendPurchased: boolean) => Promise<void>;\n}\n\nexport function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletPreferences');\n\tconst [spendPurchased, setSpend] = useState<boolean | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\t// The DTO omits spendPurchased when no balance row exists; surface the\n\t\t\t\t// server default (spend_purchased DEFAULT true) rather than null.\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst setSpendPurchased = useCallback(\n\t\tasync (next: boolean) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\t// The toggle route returns the refreshed wallet, so adopt it directly.\n\t\t\t\tconst { result } = await billing.setWalletPreferences({ spendPurchased: next });\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? next);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { spendPurchased, isLoading, error, refresh, setSpendPurchased };\n}\n","import type { BillingClient, IWalletDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletReturn {\n\t// The balance snapshot. Money fields are digit strings (server bigint →\n\t// string); null until the first read resolves or after a failed read.\n\twallet: IWalletDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's stored-value wallet balance. Reads GET /billing/wallet, so\n// it reflects the periodic grant withBilling applies on every authed request.\nexport function useWallet(client?: BillingClient): IUseWalletReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWallet');\n\tconst [wallet, setWallet] = useState<IWalletDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\tsetWallet(result.wallet);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tsetWallet(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { wallet, isLoading, error, refresh };\n}\n","import type { BillingClient, IWalletTransactionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletTransactionsReturn {\n\ttransactions: IWalletTransactionDTO[];\n\t// Opaque cursor for the next page, or null when the ledger is exhausted.\n\tnextCursor: string | null;\n\thasMore: boolean;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\t// Appends the next page. No-op when there is no further page.\n\tloadMore: () => Promise<void>;\n}\n\n// The wallet ledger, newest first — every credit/debit with a running\n// balanceAfter. Cursor-paginated: `loadMore` appends the next page.\nexport function useWalletTransactions(client?: BillingClient): IUseWalletTransactionsReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletTransactions');\n\tconst [transactions, setTransactions] = useState<IWalletTransactionDTO[]>([]);\n\tconst [nextCursor, setNextCursor] = useState<string | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWalletTransactions({ bust: opts?.force });\n\t\t\t\tsetTransactions(result.transactions);\n\t\t\t\tsetNextCursor(result.nextCursor);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst loadMore = useCallback(async () => {\n\t\tif (!nextCursor) return;\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getWalletTransactions({ cursor: nextCursor });\n\t\t\tsetTransactions((prev) => [...prev, ...result.transactions]);\n\t\t\tsetNextCursor(result.nextCursor);\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t}\n\t}, [billing, nextCursor]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn {\n\t\ttransactions,\n\t\tnextCursor,\n\t\thasMore: nextCursor !== null,\n\t\tisLoading,\n\t\terror,\n\t\trefresh,\n\t\tloadMore,\n\t};\n}\n","import type { BillingClient, IWalletCheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseWalletCheckoutReturn {\n\t// Starts a one-time credit-pack purchase and resolves to the hosted checkout\n\t// URL to redirect the buyer to; the wallet is credited by the payment webhook.\n\tcheckout: (input: IWalletCheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useWalletCheckout(client?: BillingClient): IUseWalletCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: IWalletCheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createWalletCheckout(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tISubscriptionChangeResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCancelSubscriptionReturn {\n\t// First-party cancel — no billing-portal round-trip. Default keeps access\n\t// until the paid-through date; pass { atPeriodEnd: false } to end it now.\n\t// Resolves to the new lifecycle state ({ atPeriodEnd, status, currentPeriodEnd }).\n\tcancel: (input?: ICancelSubscriptionInput) => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCancelSubscription(client?: BillingClient): IUseCancelSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCancelSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst cancel = useCallback(\n\t\tasync (input?: ICancelSubscriptionInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.cancelSubscription(input);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { cancel, isLoading, error };\n}\n","import type { BillingClient, ISubscriptionChangeResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseReactivateSubscriptionReturn {\n\t// Un-cancel a subscription scheduled to cancel at period end. Resolves to the\n\t// new lifecycle state; rejects (409) if the subscription is already fully\n\t// canceled — the caller should start a fresh checkout in that case.\n\treactivate: () => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useReactivateSubscription(client?: BillingClient): IUseReactivateSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useReactivateSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst reactivate = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.reactivateSubscription();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { reactivate, isLoading, error };\n}\n","import type { BillingClient, IPaymentMethodDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePaymentMethodReturn {\n\t// The card on file (brand/last4/expiry), or null when none is stored or the\n\t// provider can't retrieve one (a normal \"no card\" state, not an error).\n\tpaymentMethod: IPaymentMethodDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's card on file, for a billing page. Reads GET\n// /billing/payment-method.\nexport function usePaymentMethod(client?: BillingClient): IUsePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePaymentMethod');\n\tconst [paymentMethod, setPaymentMethod] = useState<IPaymentMethodDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPaymentMethod({ bust: opts?.force });\n\t\t\t\tsetPaymentMethod(result.paymentMethod);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't retrieve a card — a normal \"no card on\n\t\t\t\t// file\" state for a UI, not an error banner.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetPaymentMethod(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { paymentMethod, isLoading, error, refresh };\n}\n","import type { BillingClient, IInvoiceDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseInvoicesReturn {\n\t// Invoices newest first; each links out via hostedInvoiceUrl/invoicePdf.\n\tinvoices: IInvoiceDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's invoice history, for a billing page. Reads GET\n// /billing/invoices.\nexport function useInvoices(client?: BillingClient): IUseInvoicesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useInvoices');\n\tconst [invoices, setInvoices] = useState<IInvoiceDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listInvoices({ bust: opts?.force });\n\t\t\t\tsetInvoices(result.invoices);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't list invoices — a normal \"no invoices\" state.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetInvoices([]);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { invoices, isLoading, error, refresh };\n}\n"],"mappings":";AAkBA,SAAS,oBAAAA,0BAAwB;;;ACjBjC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,aAAa,gBAAgB;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,UAAU,qBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB;AACjF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAEhE,QAAM,aAAa,YAAY,YAAY;AAC1C,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAA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AM,CAAC,UAAU,WAAW,IAAIG,WAAwB,CAAC,CAAC;AAC1D,QAAM,CAAC,WAAW,YAAY,IAAIA,WAAS,IAAI;AAC/C,QAAM,CAAC,OAAO,QAAQ,IAAIA,WAAkC,IAAI;AAEhE,QAAM,UAAUF;AAAA,IACf,OAAO,SAA+B;AACrC,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb,UAAI;AACH,cAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,aAAa,EAAE,MAAM,MAAM,MAAM,CAAC;AACnE,oBAAY,OAAO,QAAQ;AAAA,MAC5B,SAAS,KAAK;AACb,cAAM,WACL,eAAeF,qBAAmB,MAAM,IAAIA,mBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AAEvF,YAAI,SAAS,WAAW,IAAK,UAAS,QAAQ;AAC9C,oBAAY,CAAC,CAAC;AAAA,MACf,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,OAAO;AAAA,EACT;AAEA,EAAAG,WAAU,MAAM;AACf,SAAK,QAAQ;AAAA,EACd,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,UAAU,WAAW,OAAO,QAAQ;AAC9C;","names":["FonderieApiError","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","BillingClient","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState"]}
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/hooks/useBillingPortal.ts","../src/hooks/useCheckout.ts","../src/hooks/usePlan.ts","../src/hooks/usePlans.ts","../src/hooks/useSubscription.ts","../src/hooks/useUsage.ts","../src/hooks/useWalletPreferences.ts","../src/hooks/useWallet.ts","../src/hooks/useWalletTransactions.ts","../src/hooks/useWalletCheckout.ts","../src/hooks/useCancelSubscription.ts","../src/hooks/useReactivateSubscription.ts","../src/hooks/usePaymentMethod.ts","../src/hooks/useInvoices.ts","../src/hooks/useSetupPaymentMethod.ts","../src/hooks/useSavePaymentMethod.ts","../src/hooks/useRemovePaymentMethod.ts"],"sourcesContent":["export type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tICheckoutInput,\n\tICreatePlanInput,\n\tIInvoiceDTO,\n\tIPaymentMethodDTO,\n\tIPlanDTO,\n\tIPlanFeature,\n\tIRecordUsageInput,\n\tISubscriptionChangeResult,\n\tISubscriptionDTO,\n\tIUpdatePlanInput,\n\tIWalletCheckoutInput,\n\tIWalletDTO,\n\tIWalletTransactionDTO,\n\tSubscriberType,\n} from '@fonderie/client';\nexport { FonderieApiError } from '@fonderie/client';\nexport type {\n\tIUseBillingPortalReturn,\n\tIUseCancelSubscriptionReturn,\n\tIUseCheckoutReturn,\n\tIUseInvoicesReturn,\n\tIUsePaymentMethodReturn,\n\tIUsePlanReturn,\n\tIUsePlansReturn,\n\tIUseReactivateSubscriptionReturn,\n\tIUseRemovePaymentMethodReturn,\n\tIUseSavePaymentMethodReturn,\n\tIUseSetupPaymentMethodReturn,\n\tIUseSubscriptionReturn,\n\tIUseUsageReturn,\n\tIUseWalletCheckoutReturn,\n\tIUseWalletPreferencesReturn,\n\tIUseWalletReturn,\n\tIUseWalletTransactionsReturn,\n} from './hooks';\nexport {\n\tuseBillingPortal,\n\tuseCancelSubscription,\n\tuseCheckout,\n\tuseInvoices,\n\tusePaymentMethod,\n\tusePlan,\n\tusePlans,\n\tuseReactivateSubscription,\n\tuseRemovePaymentMethod,\n\tuseSavePaymentMethod,\n\tuseSetupPaymentMethod,\n\tuseSubscription,\n\tuseUsage,\n\tuseWallet,\n\tuseWalletCheckout,\n\tuseWalletPreferences,\n\tuseWalletTransactions,\n} from './hooks';\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseBillingPortalReturn {\n\topenPortal: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useBillingPortal(client?: BillingClient): IUseBillingPortalReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useBillingPortal');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst openPortal = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.createPortalSession();\n\t\t\treturn result.url;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { openPortal, isLoading, error };\n}\n","import type { BillingClient, ICheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCheckoutReturn {\n\tcheckout: (input: ICheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCheckout(client?: BillingClient): IUseCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: ICheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createCheckoutSession(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type { IPlanDTO } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlanReturn {\n\tplan: IPlanDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function usePlan(planId: string): IUsePlanReturn;\nexport function usePlan(client: BillingClient | undefined, planId: string): IUsePlanReturn;\nexport function usePlan(\n\tclientOrPlanId: BillingClient | string | undefined,\n\tmaybePlanId?: string,\n): IUsePlanReturn {\n\tconst firstIsClient = clientOrPlanId === undefined || clientOrPlanId instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrPlanId as BillingClient | undefined) : undefined;\n\tconst planId = firstIsClient ? (maybePlanId as string) : clientOrPlanId;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'usePlan');\n\tconst [plan, setPlan] = useState<IPlanDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPlan(planId, { bust: opts?.force });\n\t\t\t\tsetPlan(result.plan);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, planId],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plan, isLoading, error, refresh };\n}\n","import type {\n\tBillingClient,\n\tICreatePlanInput,\n\tIPlanDTO,\n\tIUpdatePlanInput,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePlansReturn {\n\tplans: IPlanDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tcreatePlan: (input: ICreatePlanInput) => Promise<IPlanDTO>;\n\tupdatePlan: (planId: string, input: IUpdatePlanInput) => Promise<IPlanDTO>;\n\tdeletePlan: (planId: string) => Promise<void>;\n}\n\nexport function usePlans(client?: BillingClient): IUsePlansReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePlans');\n\tconst [plans, setPlans] = useState<IPlanDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listPlans({ bust: opts?.force });\n\t\t\t\tsetPlans(result.plans);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\t// These writes are not auth-gated by @fonderie/billing —\n\t// gate the UI that calls them behind your own admin check before shipping it.\n\tconst createPlan = useCallback(\n\t\tasync (input: ICreatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createPlan(input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst updatePlan = useCallback(\n\t\tasync (planId: string, input: IUpdatePlanInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.updatePlan(planId, input);\n\t\t\t\tawait refresh();\n\t\t\t\treturn result.plan;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tconst deletePlan = useCallback(\n\t\tasync (planId: string) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.deletePlan(planId);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { plans, isLoading, error, refresh, createPlan, updatePlan, deletePlan };\n}\n","import type { BillingClient, ISubscriptionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseSubscriptionReturn {\n\tsubscription: ISubscriptionDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\nexport function useSubscription(client?: BillingClient): IUseSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSubscription');\n\tconst [subscription, setSubscription] = useState<ISubscriptionDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getSubscription({ bust: opts?.force });\n\t\t\t\tsetSubscription(result.subscription);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// No active subscription is a normal, expected state — not an error banner.\n\t\t\t\tif (apiError.status !== 404) setError(apiError);\n\t\t\t\tsetSubscription(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { subscription, isLoading, error, refresh };\n}\n","import type { IRecordUsageInput } from '@fonderie/client';\nimport { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseUsageReturn {\n\ttotal: number | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\trecordUsage: (input: IRecordUsageInput) => Promise<void>;\n}\n\nexport function useUsage(metric: string): IUseUsageReturn;\nexport function useUsage(client: BillingClient | undefined, metric: string): IUseUsageReturn;\nexport function useUsage(\n\tclientOrMetric: BillingClient | string | undefined,\n\tmaybeMetric?: string,\n): IUseUsageReturn {\n\tconst firstIsClient = clientOrMetric === undefined || clientOrMetric instanceof BillingClient;\n\tconst explicit = firstIsClient ? (clientOrMetric as BillingClient | undefined) : undefined;\n\tconst metric = firstIsClient ? (maybeMetric as string) : clientOrMetric;\n\tconst billing = useFonderieSubClient(explicit, (c) => c.billing, 'useUsage');\n\tconst [total, setTotal] = useState<number | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getUsage(metric, { bust: opts?.force });\n\t\t\t\tsetTotal(result.total);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing, metric],\n\t);\n\n\tconst recordUsage = useCallback(\n\t\tasync (input: IRecordUsageInput) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tawait billing.recordUsage(input);\n\t\t\t\tawait refresh();\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing, refresh],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { total, isLoading, error, refresh, recordUsage };\n}\n","import { BillingClient, FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletPreferencesReturn {\n\t// Per-subscriber toggle: when false, a debit stops at the free allowance and\n\t// never draws down purchased credits. null until the first read resolves; a\n\t// subscriber with no balance row reads the server default (true).\n\tspendPurchased: boolean | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\tsetSpendPurchased: (spendPurchased: boolean) => Promise<void>;\n}\n\nexport function useWalletPreferences(client?: BillingClient): IUseWalletPreferencesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletPreferences');\n\tconst [spendPurchased, setSpend] = useState<boolean | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\t// The DTO omits spendPurchased when no balance row exists; surface the\n\t\t\t\t// server default (spend_purchased DEFAULT true) rather than null.\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? true);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst setSpendPurchased = useCallback(\n\t\tasync (next: boolean) => {\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\t// The toggle route returns the refreshed wallet, so adopt it directly.\n\t\t\t\tconst { result } = await billing.setWalletPreferences({ spendPurchased: next });\n\t\t\t\tsetSpend(result.wallet.spendPurchased ?? next);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { spendPurchased, isLoading, error, refresh, setSpendPurchased };\n}\n","import type { BillingClient, IWalletDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletReturn {\n\t// The balance snapshot. Money fields are digit strings (server bigint →\n\t// string); null until the first read resolves or after a failed read.\n\twallet: IWalletDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's stored-value wallet balance. Reads GET /billing/wallet, so\n// it reflects the periodic grant withBilling applies on every authed request.\nexport function useWallet(client?: BillingClient): IUseWalletReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWallet');\n\tconst [wallet, setWallet] = useState<IWalletDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWallet({ bust: opts?.force });\n\t\t\t\tsetWallet(result.wallet);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tsetWallet(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { wallet, isLoading, error, refresh };\n}\n","import type { BillingClient, IWalletTransactionDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseWalletTransactionsReturn {\n\ttransactions: IWalletTransactionDTO[];\n\t// Opaque cursor for the next page, or null when the ledger is exhausted.\n\tnextCursor: string | null;\n\thasMore: boolean;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n\t// Appends the next page. No-op when there is no further page.\n\tloadMore: () => Promise<void>;\n}\n\n// The wallet ledger, newest first — every credit/debit with a running\n// balanceAfter. Cursor-paginated: `loadMore` appends the next page.\nexport function useWalletTransactions(client?: BillingClient): IUseWalletTransactionsReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletTransactions');\n\tconst [transactions, setTransactions] = useState<IWalletTransactionDTO[]>([]);\n\tconst [nextCursor, setNextCursor] = useState<string | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getWalletTransactions({ bust: opts?.force });\n\t\t\t\tsetTransactions(result.transactions);\n\t\t\t\tsetNextCursor(result.nextCursor);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tconst loadMore = useCallback(async () => {\n\t\tif (!nextCursor) return;\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.getWalletTransactions({ cursor: nextCursor });\n\t\t\tsetTransactions((prev) => [...prev, ...result.transactions]);\n\t\t\tsetNextCursor(result.nextCursor);\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t}\n\t}, [billing, nextCursor]);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn {\n\t\ttransactions,\n\t\tnextCursor,\n\t\thasMore: nextCursor !== null,\n\t\tisLoading,\n\t\terror,\n\t\trefresh,\n\t\tloadMore,\n\t};\n}\n","import type { BillingClient, IWalletCheckoutInput } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseWalletCheckoutReturn {\n\t// Starts a one-time credit-pack purchase and resolves to the hosted checkout\n\t// URL to redirect the buyer to; the wallet is credited by the payment webhook.\n\tcheckout: (input: IWalletCheckoutInput) => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useWalletCheckout(client?: BillingClient): IUseWalletCheckoutReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useWalletCheckout');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst checkout = useCallback(\n\t\tasync (input: IWalletCheckoutInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.createWalletCheckout(input);\n\t\t\t\treturn result.url;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { checkout, isLoading, error };\n}\n","import type {\n\tBillingClient,\n\tICancelSubscriptionInput,\n\tISubscriptionChangeResult,\n} from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseCancelSubscriptionReturn {\n\t// First-party cancel — no billing-portal round-trip. Default keeps access\n\t// until the paid-through date; pass { atPeriodEnd: false } to end it now.\n\t// Resolves to the new lifecycle state ({ atPeriodEnd, status, currentPeriodEnd }).\n\tcancel: (input?: ICancelSubscriptionInput) => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useCancelSubscription(client?: BillingClient): IUseCancelSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useCancelSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst cancel = useCallback(\n\t\tasync (input?: ICancelSubscriptionInput) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.cancelSubscription(input);\n\t\t\t\treturn result;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { cancel, isLoading, error };\n}\n","import type { BillingClient, ISubscriptionChangeResult } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseReactivateSubscriptionReturn {\n\t// Un-cancel a subscription scheduled to cancel at period end. Resolves to the\n\t// new lifecycle state; rejects (409) if the subscription is already fully\n\t// canceled — the caller should start a fresh checkout in that case.\n\treactivate: () => Promise<ISubscriptionChangeResult>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useReactivateSubscription(client?: BillingClient): IUseReactivateSubscriptionReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useReactivateSubscription');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst reactivate = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.reactivateSubscription();\n\t\t\treturn result;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { reactivate, isLoading, error };\n}\n","import type { BillingClient, IPaymentMethodDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUsePaymentMethodReturn {\n\t// The card on file (brand/last4/expiry), or null when none is stored or the\n\t// provider can't retrieve one (a normal \"no card\" state, not an error).\n\tpaymentMethod: IPaymentMethodDTO | null;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's card on file, for a billing page. Reads GET\n// /billing/payment-method.\nexport function usePaymentMethod(client?: BillingClient): IUsePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'usePaymentMethod');\n\tconst [paymentMethod, setPaymentMethod] = useState<IPaymentMethodDTO | null>(null);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.getPaymentMethod({ bust: opts?.force });\n\t\t\t\tsetPaymentMethod(result.paymentMethod);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't retrieve a card — a normal \"no card on\n\t\t\t\t// file\" state for a UI, not an error banner.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetPaymentMethod(null);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { paymentMethod, isLoading, error, refresh };\n}\n","import type { BillingClient, IInvoiceDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useEffect, useState } from 'react';\n\nexport interface IUseInvoicesReturn {\n\t// Invoices newest first; each links out via hostedInvoiceUrl/invoicePdf.\n\tinvoices: IInvoiceDTO[];\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n\trefresh: (opts?: { force?: boolean }) => Promise<void>;\n}\n\n// The subscriber's invoice history, for a billing page. Reads GET\n// /billing/invoices.\nexport function useInvoices(client?: BillingClient): IUseInvoicesReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useInvoices');\n\tconst [invoices, setInvoices] = useState<IInvoiceDTO[]>([]);\n\tconst [isLoading, setIsLoading] = useState(true);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst refresh = useCallback(\n\t\tasync (opts?: { force?: boolean }) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.listInvoices({ bust: opts?.force });\n\t\t\t\tsetInvoices(result.invoices);\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\t// 501 = the provider can't list invoices — a normal \"no invoices\" state.\n\t\t\t\tif (apiError.status !== 501) setError(apiError);\n\t\t\t\tsetInvoices([]);\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\tuseEffect(() => {\n\t\tvoid refresh();\n\t}, [refresh]);\n\n\treturn { invoices, isLoading, error, refresh };\n}\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseSetupPaymentMethodReturn {\n\t// Begin in-app card entry — resolves to the provider SetupIntent client secret\n\t// the embedded card element (Stripe Payment Element) confirms. No redirect;\n\t// the user never leaves the site. 501 when the provider has no in-app support.\n\tsetup: () => Promise<string>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useSetupPaymentMethod(client?: BillingClient): IUseSetupPaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSetupPaymentMethod');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst setup = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tconst { result } = await billing.setupPaymentMethod();\n\t\t\treturn result.clientSecret;\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { setup, isLoading, error };\n}\n","import type { BillingClient, IPaymentMethodDTO } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseSavePaymentMethodReturn {\n\t// Save the card after the Payment Element confirms the SetupIntent: makes it\n\t// the default and records it. Resolves to the saved card for display; rejects\n\t// (422) if the card isn't attached to this customer.\n\tsave: (paymentMethodId: string) => Promise<IPaymentMethodDTO | null>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useSavePaymentMethod(client?: BillingClient): IUseSavePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useSavePaymentMethod');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst save = useCallback(\n\t\tasync (paymentMethodId: string) => {\n\t\t\tsetIsLoading(true);\n\t\t\tsetError(null);\n\t\t\ttry {\n\t\t\t\tconst { result } = await billing.savePaymentMethod({ paymentMethodId });\n\t\t\t\treturn result.paymentMethod;\n\t\t\t} catch (err) {\n\t\t\t\tconst apiError =\n\t\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\t\tsetError(apiError);\n\t\t\t\tthrow apiError;\n\t\t\t} finally {\n\t\t\t\tsetIsLoading(false);\n\t\t\t}\n\t\t},\n\t\t[billing],\n\t);\n\n\treturn { save, isLoading, error };\n}\n","import type { BillingClient } from '@fonderie/client';\nimport { FonderieApiError } from '@fonderie/client';\nimport { useFonderieSubClient } from '@fonderie/react';\nimport { useCallback, useState } from 'react';\n\nexport interface IUseRemovePaymentMethodReturn {\n\t// Remove the saved card (detach at the provider + clear the record).\n\tremove: () => Promise<void>;\n\tisLoading: boolean;\n\terror: FonderieApiError | null;\n}\n\nexport function useRemovePaymentMethod(client?: BillingClient): IUseRemovePaymentMethodReturn {\n\tconst billing = useFonderieSubClient(client, (c) => c.billing, 'useRemovePaymentMethod');\n\tconst [isLoading, setIsLoading] = useState(false);\n\tconst [error, setError] = useState<FonderieApiError | null>(null);\n\n\tconst remove = useCallback(async () => {\n\t\tsetIsLoading(true);\n\t\tsetError(null);\n\t\ttry {\n\t\t\tawait billing.removePaymentMethod();\n\t\t} catch (err) {\n\t\t\tconst apiError =\n\t\t\t\terr instanceof FonderieApiError ? err : new FonderieApiError('unknown', String(err), 0);\n\t\t\tsetError(apiError);\n\t\t\tthrow apiError;\n\t\t} finally {\n\t\t\tsetIsLoading(false);\n\t\t}\n\t}, [billing]);\n\n\treturn { remove, isLoading, error };\n}\n"],"mappings":";AAkBA,SAAS,oBAAAA,0BAAwB;;;ACjBjC,SAAS,wBAAwB;AACjC,SAAS,4BAA4B;AACrC,SAAS,aAAa,gBAAgB;AAQ/B,SAAS,iBAAiB,QAAiD;AACjF,QAAM,UAAU,qBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,kBAAkB;AACjF,QAAM,CAAC,WAAW,YAAY,IAAI,SAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAI,SAAkC,IAAI;AAEhE,QAAM,aAAa,YAAY,YAAY;AAC1C,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,EAAE,OAAO,IAAI,MAAM,QAAQ,oBAAoB;AACrD,aAAO,OAAO;AAAA,IACf,SAAS,KAAK;AACb,YAAM,WACL,eAAe,mBAAmB,MAAM,IAAI,iBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AACjB,YAAM;AAAA,IACP,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,YAAY,WAAW,MAAM;AACvC;;;AChCA,SAAS,oBAAAC,yBAAwB;AACjC,SAAS,wBAAAC,6BAA4B;AACrC,SAAS,eAAAC,cAAa,YAAAC,iBAAgB;AAQ/B,SAAS,YAAY,QAA4C;AACvE,QAAM,UAAUF,sBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,aAAa;AAC5E,QAAM,CAAC,WAAW,YAAY,IAAIE,UAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAIA,UAAkC,IAAI;AAEhE,QAAM,WAAWD;AAAA,IAChB,OAAO,UAA0B;AAChC,mBAAa,IAAI;AACjB,eAAS,IAAI;AACb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AAC;AACtE,eAAO,OAAO;AAAA,MACf,SAAS,KAAK;AACb,cAAM,WACL,eAAeF,qBAAmB,MAAM,IAAIA,mBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,iBAAS,QAAQ;AACjB,cAAM;AAAA,MACP,UAAE;AACD,qBAAa,KAAK;AAAA,MACnB;AAAA,IACD;AAAA,IACA,CAAC,OAAO;AAAA,EACT;AAEA,SAAO,EAAE,MAAM,WAAW,MAAM;AACjC;;;ACtCA,SAAS,oBAAAI,0BAAwB;AACjC,SAAS,wBAAAC,8BAA4B;AACrC,SAAS,eAAAC,eAAa,YAAAC,kBAAgB;AAS/B,SAAS,uBAAuB,QAAuD;AAC7F,QAAM,UAAUF,uBAAqB,QAAQ,CAAC,MAAM,EAAE,SAAS,wBAAwB;AACvF,QAAM,CAAC,WAAW,YAAY,IAAIE,WAAS,KAAK;AAChD,QAAM,CAAC,OAAO,QAAQ,IAAIA,WAAkC,IAAI;AAEhE,QAAM,SAASD,cAAY,YAAY;AACtC,iBAAa,IAAI;AACjB,aAAS,IAAI;AACb,QAAI;AACH,YAAM,QAAQ,oBAAoB;AAAA,IACnC,SAAS,KAAK;AACb,YAAM,WACL,eAAeF,qBAAmB,MAAM,IAAIA,mBAAiB,WAAW,OAAO,GAAG,GAAG,CAAC;AACvF,eAAS,QAAQ;AACjB,YAAM;AAAA,IACP,UAAE;AACD,mBAAa,KAAK;AAAA,IACnB;AAAA,EACD,GAAG,CAAC,OAAO,CAAC;AAEZ,SAAO,EAAE,QAAQ,WAAW,MAAM;AACnC;","names":["FonderieApiError","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","BillingClient","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useEffect","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState","FonderieApiError","useFonderieSubClient","useCallback","useState"]}
|