/** * Payment Service Definition * Defines interfaces and service contract for payment calculation management */ import type { Signal } from '@wix/services-definitions/core-services/signals'; import type { CalculateTotalsResponse } from '@wix/auto_sdk_ecom_totals-calculator'; import type { Service } from '@wix/auto_sdk_bookings_services'; import type { SelectedPaymentOption } from '../booking/book-action/types.js'; /** * Service payment options derived from service.payment.options. * Describes which payment methods the service supports. */ export interface ServicePaymentOptions { /** Customer can pay online at booking time */ isOnline: boolean; /** Customer can pay in person (on arrival) */ isInPerson: boolean; /** A deposit is required at booking time */ isDeposit: boolean; } /** * Payment option for line items */ export type PaymentOption = 'FULL_PAYMENT_ONLINE' | 'FULL_PAYMENT_OFFLINE' | 'DEPOSIT_ONLINE'; /** * Additional computed info for a line item (not in SDK response) */ export interface LineItemAdditionalInfo { /** Line item ID to match with SDK's calculatedLineItems */ lineItemId: string; /** Custom price (for CUSTOM rate type services) */ customPrice?: string; } /** * Payment calculation result with SDK response and additional computed info */ export interface PaymentDetails { /** The raw SDK CalculateTotals response */ response: CalculateTotalsResponse; /** Additional computed information per line item */ additionalInfo: { lineItems: LineItemAdditionalInfo[]; }; } /** * Input for calculating payment for a booking service */ export interface PricingServiceSelection { service: Service; /** Optional line item ID. If not provided, one will be generated. */ lineItemId?: string; /** Local start date of the selected slot in ISO-8601 format (e.g. "2024-01-30T13:30:00"). */ localStartDate?: string; /** Local end date of the selected slot in ISO-8601 format (e.g. "2024-01-30T14:30:00"). */ localEndDate?: string; /** IANA time zone identifier for the selected slot (e.g. "America/New_York"). */ timeZone?: string; } /** * Public config for PaymentService (SSR mode only): * Pass `paymentDetails` pre-fetched via loadPaymentConfig */ export interface PaymentServiceConfig { /** Pre-calculated payment details for SSR (no API call) */ paymentDetails?: PaymentDetails; /** Service payment options for SSR (derived from service.payment.options) */ serviceOptions?: ServicePaymentOptions; } /** * Internal config used by Core component to pass lazy loading data * Not exposed publicly - Core merges this with PaymentServiceConfig */ export interface PaymentServiceInternalConfig extends PaymentServiceConfig { /** Booking services for lazy loading (internal use) */ pricingServiceSelections?: PricingServiceSelection[]; /** Number of participants for lazy loading (internal use) */ totalParticipants?: number; /** * Optional consumer-selected payment option used for lazy loading. When * set, overrides the service-config heuristic in line item `paymentOption`. */ selectedPaymentOption?: SelectedPaymentOption; } export interface PaymentServiceAPI { paymentDetailsSignal: Signal; isLoadingSignal: Signal; errorSignal: Signal; serviceOptionsSignal: Signal; } export declare const PaymentServiceDefinition: string & { __api: PaymentServiceAPI; __config: {}; isServiceDefinition?: boolean; } & PaymentServiceAPI;