import type { Ref } from 'vue-demi'; import type { Stripe } from '@stripe/stripe-js'; /** Names of the methods on the Stripe.js `Stripe` instance. */ export type StripeMethodName = { [K in keyof Stripe]: Stripe[K] extends (...args: never[]) => unknown ? K : never; }[keyof Stripe]; /** * What a method composable returns: the Stripe method under its own name, typed * as `Stripe[K]` (every overload kept in sync with `@stripe/stripe-js`), plus the * state of its calls. */ export type UseStripeMethodReturn = { [P in K]: Stripe[P]; } & { /** `true` while a call is in flight. */ loading: Readonly>; /** Message of the last call's Stripe `{ error }` result or thrown error; reset on each call. */ error: Readonly>; }; /** * Shared by the method composables. Injects the Stripe instance from * `` or `createVueStripe()` (throwing `VueStripeProviderError` * naming `composable` without either) and returns `{ [method], loading, error }`, where `[method](...args)` * resolves to `run(stripe, args)` untouched: an `{ error }` result also sets `error`, * and a throw is recorded in `error` and rethrown. `loading` stays true until * overlapping calls settle. */ export declare function useStripeMethodCall(composable: string, method: string, run: (stripe: Stripe, args: unknown[]) => unknown): Record & { loading: Readonly>; error: Readonly>; }; /** * Build a composable that wraps one Stripe.js method, e.g. * `createStripeMethodComposable('confirmCardPayment')` gives `useConfirmCardPayment()` * returning `{ confirmCardPayment, loading, error }`. * * The composable injects the Stripe instance from `` or * `createVueStripe()` (throwing `VueStripeProviderError` without either). The * wrapped method forwards its arguments, resolves to Stripe's result untouched (an * `{ error }` result also sets `error`), and rethrows anything Stripe throws after * recording it in `error`. * * `composableName` (default `use`) names the composable in that error, * for composables named differently from the method (`useRadarSession`). */ export declare function createStripeMethodComposable(name: K, composableName?: string): () => UseStripeMethodReturn;