import { IContractV2Response } from './contract.types'; import { BusinessEntityType, CustomerType, IBusinessEntityPartialResponse, ICustomer } from './customer.types'; import { IPlansResponseSchema } from './plans.types'; export type IProduct = { product_id: string; name: string; description: string | null; sku: string | null; unit: string | null; sub_products: any[]; features: any[]; subtotal: string | null; total: string | null; metadata: Record; }; export type IPricing = { pricing_type: string; unit_amount: string; unit: string | null; pricing_period: string | null; package_size: string | null; matrix_dimensions: any | null; }; export declare enum CheckoutSessionStatus { OPEN = "open", PROCESSING = "processing", COMPLETED = "completed", CLOSED = "closed", CANCELLED = "cancelled" } export declare enum PaymentStatus { NOT_STARTED = "not_started", PENDING = "pending", PAID = "paid", FAILED = "failed", NO_PAYMENT_REQUIRED = "no_payment_required" } export declare enum ConfirmationType { CHARGE_IMMEDIATELY = "charge_immediately", CHARGE_WHEN_DUE = "charge_when_due", NO_PAYMENT = "no_payment" } export declare enum PaymentMethodType { CARD = "card", BANK_TRANSFER = "bank_transfer", WALLET = "wallet", INVOICE = "invoice" } export declare enum CancellationReasonType { CUSTOMER_REQUESTED = "customer_requested", PAYMENT_FAILED = "payment_failed", EXPIRED = "expired", DUPLICATE = "duplicate", FRAUDULENT = "fraudulent", OTHER = "other" } export declare enum UpdateReason { CUSTOMER_REQUEST = "customer_request", ADMIN_CORRECTION = "admin_correction", PRICE_UPDATE = "price_update", CONTRACT_UPDATE = "contract_update", ERROR_CORRECTION = "error_correction", OTHER = "other" } export type Attribution = { utm_source?: string; utm_medium?: string; utm_campaign?: string; utm_term?: string; utm_content?: string; referrer_url?: string; landing_url?: string; channel?: string; source_app?: string; }; export type QuantityEntry = { [key: string]: any; }; export type InvoiceSubLineItem = { line_item_category: string; unit_amount: string; quantity: string; unit_price: string; calculation_basis: string | null; applied_to_amount: string | null; type: string | null; pricing_type: string; pricing_period: string | null; unit: string | null; tier_position: string | null; tier_range_start: string | null; tier_range_end: string | null; package_size: string | null; matrix_dimensions: any | null; feature_source: string | null; label: string; description: string | null; display_order: number; feature_hierarchy_level: string | null; custom_attributes: any | null; }; export type InvoiceLineItem = { id: string; type: string; description: string; product: IProduct; pricing: IPricing; sublineitems: InvoiceSubLineItem[]; subtotal: string; total: string; metadata: Record; }; export type EstimationInvoice = { id: string; invoice_number: string | null; status: string; customer: ICustomer; issue_date: string; due_date: string | null; line_items: InvoiceLineItem[]; features: any[]; notes: string | null; terms: string | null; subtotal: string; total: string; metadata: Record; created_at: string; updated_at: string; }; export type EstimationResponseSchema = { estimation_id: string; current_invoice: EstimationInvoice; future_invoices: EstimationInvoice[]; amount_due: string; credit_notes: any[]; }; export type CheckoutContractSchemaLineItem = { product_id?: string; pricing_id?: string; start_date?: string; end_date?: string; quantity?: QuantityEntry[]; }; export type CheckoutContractSchemaPhase = { name?: string; pricings?: CheckoutContractSchemaLineItem[]; start_date?: string; end_date?: string; }; export type CheckoutContractSchemaProductBased = { currency: string; phases?: CheckoutContractSchemaPhase[]; start_date: string; end_date?: string; is_plan_based: false; }; export type CheckoutContractSchemaPlanBased = { currency: string; plan_id?: string; start_date: string; end_date?: string; is_plan_based: true; }; export type CheckoutContract = CheckoutContractSchemaPlanBased | CheckoutContractSchemaProductBased; export type CheckoutSessionSummaryRequest = { contract: CheckoutContract; }; export type CheckoutSessionSummaryResponse = { data?: EstimationResponseSchema; }; export type CheckoutSessionConfirmRequest = { confirmation?: ConfirmationType; redirect?: boolean; preferred_payment_method?: PaymentMethodType; payment_description?: string; customer_notes?: string; }; export type CheckoutSessionConfirmResponse = { payment_status: PaymentStatus; checkout_session_status: CheckoutSessionStatus; contract?: IContractV2Response; checkout_session_redirect_url?: string; estimates?: EstimationResponseSchema; }; export type CheckoutSessionCancelRequest = { reason_type?: CancellationReasonType; reason?: string; reference_id?: string; }; export type CheckoutSessionCancelResponse = { payment_status: PaymentStatus; checkout_session_status: CheckoutSessionStatus; contract?: IContractV2Response; checkout_session_redirect_url?: string; estimates?: EstimationResponseSchema; cancelled_at?: string; cancellation_details?: Record; }; export type CheckoutSessionCreateRequest = { contract: CheckoutContract; customer_id?: CustomerType; guest_checkout?: boolean; customer?: ICustomer; business_entity_id?: BusinessEntityType; expires_at?: string; idempotency_key?: string; correlation_id?: string; currency?: string; success_url?: string; cancel_url?: string; pending_url?: string; attribution?: Attribution; custom_data?: Record; }; export type CheckoutSessionResponse = { id: string; contract_id?: string; checkout_session_status: CheckoutSessionStatus; payment_status: PaymentStatus; contract: IContractV2Response; execution_id?: string; confirmed_at?: string; paid_at?: string; payment_intent_id?: string; estimates?: EstimationResponseSchema; customer_id?: string; business_entity_id?: string; guest_checkout: boolean; customer?: ICustomer; expires_at?: string; last_activity_at?: string; completed_at?: string; idempotency_key?: string; correlation_id?: string; currency?: string; success_url?: string; cancel_url?: string; pending_url?: string; attribution?: Attribution; custom_data?: Record; }; export type CheckoutSessionUpdateRequest = { contract?: CheckoutContract; customer?: ICustomer; expires_at?: string; currency?: string; success_url?: string; cancel_url?: string; pending_url?: string; attribution?: Attribution; custom_data?: Record; update_reason?: UpdateReason; update_note?: string; }; export type PayableAmount = { amount: number; currency: string; }; export declare const CustomFieldType: { readonly STRING: "string"; readonly NUMBER: "number"; readonly DROPDOWN: "dropdown"; }; export declare const ConfirmationPageType: { readonly CONFIRMATION_PAGE: "confirmation_page"; readonly REDIRECT_URL: "redirect_url"; }; export declare const PaymentMethodCollection: { readonly IF_REQUIRED: "if_required"; readonly ALWAYS: "always"; readonly NO_PAYMENT_REQUIRED: "no_payment_required"; }; export declare const CheckoutMotionType: { readonly SLM: "SLM"; readonly PLM: "PLM"; }; export type ECustomFieldType = (typeof CustomFieldType)[keyof typeof CustomFieldType]; export type EConfirmationPageType = (typeof ConfirmationPageType)[keyof typeof ConfirmationPageType]; export type EPaymentMethodCollection = (typeof PaymentMethodCollection)[keyof typeof PaymentMethodCollection]; export type ECheckoutMotionType = (typeof CheckoutMotionType)[keyof typeof CheckoutMotionType]; export type IColorVariables = { background?: string; foreground?: string; primary?: string; primary_foreground?: string; secondary?: string; secondary_foreground?: string; muted?: string; muted_foreground?: string; card?: string; card_foreground?: string; card_shadow?: string; popover?: string; popover_foreground?: string; accent?: string; accent_foreground?: string; destructive?: string; border?: string; input?: string; ring?: string; }; export type IAppearanceConfig = { colors?: IColorVariables; font_family?: string; border_radius?: string; }; export type IBrandingConfig = { appearance?: IAppearanceConfig; }; export type IAddressCollection = { billing_address?: boolean; shipping_address?: boolean; }; export type IConsentCollection = { terms_of_service_url?: string; privacy_policy_url?: string; terms_of_service?: string; privacy_policy?: string; }; export type ICustomField = { type: ECustomFieldType; label: string; description?: string; optional: boolean; default_value?: string; max_char?: number; options?: string[]; }; export type IConfirmationPage = { type?: EConfirmationPageType; custom_message?: string; redirect_url?: string; }; export type ITaxIdCollection = { enabled: boolean; required: boolean; }; export type ICustomerInfo = { payment_collection: EPaymentMethodCollection; address_collection?: IAddressCollection; phone_required?: boolean; tax_id_collection?: ITaxIdCollection; consent_collection?: IConsentCollection; metadata?: Record; }; export type ISubscriptionItemSettings = { call_to_action?: string; currency?: string; custom_fields?: ICustomField[]; confirmation_page?: IConfirmationPage; metadata?: Record; }; export type ISubscriptionItemConfig = { id: string; is_highlight?: boolean; highlight_text?: string; name?: string; description?: string; customer_info?: ICustomerInfo | null; item_settings?: ISubscriptionItemSettings | null; order?: number; metadata?: Record; }; export type ICustomUrlConfig = { url: string; }; export type ICustomUrlItem = { subscription_item_id: string; call_to_action: string; name?: string; description?: string; custom_url_config: ICustomUrlConfig; subscription_group_id: string; is_highlight: boolean; highlight_text?: string; order?: number; metadata?: Record; }; export type ISubscriptionGroup = { id: string; name: string; order?: number; metadata?: Record; items: ISubscriptionItemConfig[]; }; export type ICheckoutConfigBaseSchema = { is_enabled: boolean; checkout_type: ECheckoutMotionType; allow_switching_subscription: boolean; show_existing_subscription: boolean; allow_quantity_changes: boolean; subscription_groups?: ISubscriptionGroup[]; customer_info_defaults?: ICustomerInfo; subscription_item_setting_defaults?: ISubscriptionItemSettings; custom_url_items?: ICustomUrlItem[]; branding?: IBrandingConfig; metadata?: Record; }; export type ICheckoutConfigRequestSchema = ICheckoutConfigBaseSchema & { business_entity_id?: string; customer_id?: string; }; export type ISubscriptionItemConfigResponse = ISubscriptionItemConfig & { item_data?: IPlansResponseSchema; }; export type ICustomUrlItemResponse = ICustomUrlItem & { subscription_item_data?: IPlansResponseSchema; }; export type ISubscriptionGroupResponse = ISubscriptionGroup & { items: ISubscriptionItemConfigResponse[]; }; export type ICheckoutConfigResponseSchema = ICheckoutConfigBaseSchema & { config_id?: string; id?: string; organisation_id?: string; business_entity_id?: string; business_entity?: IBusinessEntityPartialResponse; sub_type?: string; is_default: boolean; created_at?: string; updated_at?: string; subscription_groups?: ISubscriptionGroupResponse[]; custom_url_items?: ICustomUrlItemResponse[]; }; export type ICheckoutConfigResponseSchemaExtended = ICheckoutConfigResponseSchema & { simplified_subscription_groups?: ICheckoutSubscriptionGroup[]; }; export type ICheckoutSubscriptionGroup = Omit & { items: ICheckoutSubscriptionItem[]; }; /** * Unified type for checkout subscription items that combines both standard and custom URL items. * All fields are optional to accommodate both item types, with runtime validation handling type safety. */ export type ICheckoutSubscriptionItem = { id?: string; group_id?: string; item_type?: 'standard' | 'custom'; name?: string; description?: string; is_highlight?: boolean; highlight_text?: string; order?: number; metadata?: Record; customer_info?: ICustomerInfo | null; item_settings?: ISubscriptionItemSettings | null; call_to_action?: string; custom_url_config?: ICustomUrlConfig; item_data?: IPlansResponseSchema; };