import { type Signal } from '@wix/services-definitions/core-services/signals'; /** * Service definition for the Pay Now service. * This defines the reactive API contract for managing custom payment checkout functionality. * * @constant */ export declare const PayNowServiceDefinition: string & { __api: { /** Function to redirect to checkout using custom checkout action */ redirectToCheckout: () => Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }; __config: {}; isServiceDefinition?: boolean; } & { /** Function to redirect to checkout using custom checkout action */ redirectToCheckout: () => Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }; /** * Configuration interface for the Pay Now service. * Contains an optional custom checkout action function. * * @interface PayNowServiceConfig */ export interface PayNowServiceConfig { /** Optional custom checkout action that returns a checkout URL or error */ customCheckoutAction?: () => Promise<{ /** The checkout URL to redirect to */ data: string | undefined; /** Any error that occurred during checkout creation */ error: unknown; }>; } /** * Implementation of the Pay Now service that manages custom payment checkout functionality. * This service provides signals for loading state and error handling, along with a method * to redirect to checkout using a custom checkout action. * * @example * ```tsx * import { PayNowServiceImplementation, PayNowServiceDefinition } from '@wix/stores/services'; * import { useService } from '@wix/services-manager-react'; * * function PayNowComponent({ payNowConfig }) { * return ( * * * * ); * } * * function PayNowButton() { * const payNowService = useService(PayNowServiceDefinition); * const isLoading = payNowService.loadingSignal.get(); * const error = payNowService.errorSignal.get(); * * const handlePayNow = async () => { * await payNowService.redirectToCheckout(); * }; * * return ( *
* {error &&
{error}
} * *
* ); * } * ``` */ export declare const PayNowServiceImplementation: import("@wix/services-definitions").ServiceFactory Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }; __config: {}; isServiceDefinition?: boolean; } & { /** Function to redirect to checkout using custom checkout action */ redirectToCheckout: () => Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }, PayNowServiceConfig>; /** * Loads pay now service initial data for SSR initialization. * This function returns an empty configuration as the Pay Now service * is typically configured with custom checkout actions at runtime. * * @returns {Promise} Promise that resolves to an empty pay now service configuration * * @example * ```tsx * --- * // Astro page example - pages/checkout.astro * import { loadPayNowServiceInitialData } from '@wix/stores/services'; * import { PayNow } from '@wix/stores/components'; * * // Load initial data (empty for PayNow) * const payNowData = await loadPayNowServiceInitialData(); * --- * * * {({ redirectToCheckout, isLoading, error }) => ( * * )} * * ``` */ export declare const loadPayNowServiceInitialData: () => Promise<{ [PayNowServiceDefinition]: {}; }>; /** * Helper function to create a pay now service binding with configuration. * This function simplifies the process of binding the pay now service with its configuration * and allows for additional configuration overrides, particularly for custom checkout actions. * * @template T * @param {T} servicesConfigs - The service configurations object from initial data loading. * @param {Partial} additionalConfig - Optional overrides for the default configuration, such as a custom checkout action. * @returns A tuple containing the service definition, implementation, and merged configuration. * * @example * ```tsx * import { payNowServiceBinding, loadPayNowServiceInitialData } from '@wix/stores/services'; * import { actions } from 'astro:actions'; * * // Load initial data * const initialData = await loadPayNowServiceInitialData(); * * // Create service binding with custom checkout action * const payNowBinding = payNowServiceBinding(initialData, { * customCheckoutAction: async () => { * try { * const result = await actions.customCheckout(); * return { data: result, error: null }; * } catch (error) { * return { data: undefined, error }; * } * } * }); * * // Use in service provider * const services = createServicesMap([payNowBinding]); * ``` */ export declare const payNowServiceBinding: >[typeof PayNowServiceDefinition]; }>(servicesConfigs: T, additionalConfig?: Partial) => readonly [string & { __api: { /** Function to redirect to checkout using custom checkout action */ redirectToCheckout: () => Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }; __config: {}; isServiceDefinition?: boolean; } & { /** Function to redirect to checkout using custom checkout action */ redirectToCheckout: () => Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }, import("@wix/services-definitions").ServiceFactory Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }; __config: {}; isServiceDefinition?: boolean; } & { /** Function to redirect to checkout using custom checkout action */ redirectToCheckout: () => Promise; /** Reactive signal indicating if a checkout redirect is in progress */ loadingSignal: Signal; /** Reactive signal containing any error message, or null if no error */ errorSignal: Signal; }, PayNowServiceConfig>, { customCheckoutAction?: () => Promise<{ /** The checkout URL to redirect to */ data: string | undefined; /** Any error that occurred during checkout creation */ error: unknown; }>; }];