import { ILogger, IMetrics, ICache } from '@digilogiclabs/platform-core'; export { AccountCapabilities, AccountLink, AccountType, Address, Balance, BalanceAmount, BankAccountDetails, BillingDetails, BusinessProfile, CapturePaymentIntentOptions, CardBrand, CardDetails, ConfirmPaymentIntentOptions, ConnectedAccount, ConnectedAccountStatus, CreateAccountLinkOptions, CreateConnectedAccountOptions, CreateCustomerOptions, CreatePaymentIntentOptions, CreatePayoutOptions, CreateRefundOptions, CreateTransferOptions, Customer, IPayment, MemoryPayment, PaymentConfig, PaymentError, PaymentErrorCode, PaymentErrorMessages, PaymentEventType, PaymentIntent, PaymentMethod, PaymentMethodType, PaymentStatus, PaymentWebhookEvent, Payout, PayoutStatus, Refund, RefundReason, RefundStatus, StripePayment, StripePaymentConfig, TosAcceptance, Transfer, TransferStatus, UpdateCustomerOptions, UpdatePaymentIntentOptions, VerifyWebhookOptions, createPaymentError, formatAmount, generatePaymentId, isPaymentError } from '@digilogiclabs/platform-core'; export { a as DonationCheckoutOptions, b as DonationCheckoutResult, D as DonationTier } from './donation-BosbuKM6.js'; /** * Platform Core Integration * * Optional integration with @digilogiclabs/platform-core for: * - Logging (payment events, webhook processing) * - Metrics (payment success/failure tracking, revenue metrics) * - Cache (subscription status caching) */ interface PlatformServices { logger?: ILogger; metrics?: IMetrics; cache?: ICache; } /** * Set the platform services for payments package to use * * @example * ```typescript * import { createPlatform } from '@digilogiclabs/platform-core'; * import { setPlatform } from '@digilogiclabs/saas-factory-payments'; * * const platform = createPlatform(); * setPlatform({ * logger: platform.logger, * metrics: platform.metrics, * cache: platform.cache, * }); * ``` */ declare function setPlatform(services: PlatformServices): void; /** * Clear platform services (useful for testing) */ declare function clearPlatform(): void; /** * Check if platform services are configured */ declare function hasPlatform(): boolean; /** * Log a payment event if logger is configured */ declare function logPaymentEvent(level: 'debug' | 'info' | 'warn' | 'error', message: string, meta?: Record): void; /** * Track a payment metric if metrics are configured */ declare function trackPaymentMetric(name: string, value?: number, tags?: Record): void; /** * Track payment revenue */ declare function trackRevenue(amount: number, currency: string, tags?: Record): void; /** * Cache subscription status */ declare function cacheSubscriptionStatus(customerId: string, status: string, ttl?: number): Promise; /** * Get cached subscription status */ declare function getCachedSubscriptionStatus(customerId: string): Promise; /** * Track webhook processing */ declare function trackWebhookEvent(eventType: string, success: boolean, duration?: number): void; /** * Track checkout session */ declare function trackCheckoutSession(success: boolean, tags?: Record): void; /** * Track subscription events */ declare function trackSubscriptionEvent(event: 'created' | 'updated' | 'canceled' | 'renewed', tags?: Record): void; declare enum SubscriptionStatus { ACTIVE = "active", CANCELED = "canceled", PAST_DUE = "past_due", UNPAID = "unpaid", INCOMPLETE = "incomplete", INCOMPLETE_EXPIRED = "incomplete_expired", TRIALING = "trialing", ENDED = "ended",// Custom status for ended subscriptions ALL = "all" } interface SubscriptionItem { id: string; priceId: string; quantity: number; metadata?: Record; } interface Subscription { id: string; customerId: string; customer_id?: string; status: SubscriptionStatus; items?: SubscriptionItem[]; price_id?: string; currentPeriodStart: Date; current_period_start?: Date; currentPeriodEnd: Date; current_period_end?: Date; cancelAtPeriodEnd: boolean; cancel_at_period_end?: boolean; trialEnd?: Date; trial_end?: Date; trialStart?: Date; trial_start?: Date; canceledAt?: Date; canceled_at?: Date; endedAt?: Date; metadata?: Record; created: Date; updated?: Date; amount?: number; currency?: string; interval?: string; interval_unit?: string; planName?: string; planId?: string; } interface SubscriptionCreateParams { customerId: string; items?: { priceId: string; quantity?: number; }[]; priceId?: string; trialPeriodDays?: number; metadata?: Record; paymentBehavior?: 'default_incomplete' | 'error_if_incomplete' | 'allow_incomplete'; customerEmail?: string; customerName?: string; successUrl?: string; cancelUrl?: string; } interface SubscriptionUpdateParams { items?: { priceId: string; quantity?: number; }[]; priceId?: string; quantity?: number; cancelAtPeriodEnd?: boolean; metadata?: Record; } type ActiveSubscriptionStatus = SubscriptionStatus.ACTIVE | SubscriptionStatus.TRIALING; type InactiveSubscriptionStatus = SubscriptionStatus.CANCELED | SubscriptionStatus.ENDED; type ProblematicSubscriptionStatus = SubscriptionStatus.PAST_DUE | SubscriptionStatus.UNPAID; type IncompleteSubscriptionStatus = SubscriptionStatus.INCOMPLETE | SubscriptionStatus.INCOMPLETE_EXPIRED; declare const ACTIVE_STATUSES: ActiveSubscriptionStatus[]; declare const INACTIVE_STATUSES: InactiveSubscriptionStatus[]; declare const PROBLEMATIC_STATUSES: ProblematicSubscriptionStatus[]; declare const INCOMPLETE_STATUSES: IncompleteSubscriptionStatus[]; declare const isActiveSubscription: (status: SubscriptionStatus) => status is ActiveSubscriptionStatus; declare const isInactiveSubscription: (status: SubscriptionStatus) => status is InactiveSubscriptionStatus; declare const isProblematicSubscription: (status: SubscriptionStatus) => status is ProblematicSubscriptionStatus; declare const isIncompleteSubscription: (status: SubscriptionStatus) => status is IncompleteSubscriptionStatus; interface Customer { id: string; email: string; name?: string | null; phone?: string | null; stripeCustomerId?: string | null; subscriptions: Subscription[]; defaultPaymentMethodId?: string | null; paymentMethods: PaymentMethod[]; metadata?: Record; created: Date; updated: Date; } interface CustomerCreateParams { email: string; name?: string; phone?: string; metadata?: Record; paymentMethod?: string; } interface CustomerUpdateParams { email?: string; name?: string; phone?: string; metadata?: Record; defaultPaymentMethod?: string; } interface PaymentMethod { id: string; type: 'card' | 'bank_account' | 'sepa_debit' | 'ideal' | 'sofort'; card?: { brand: string; last4: string; expMonth: number; expYear: number; country?: string; }; bankAccount?: { last4: string; bankName?: string; accountType?: string; }; billingDetails?: { address?: BillingAddress; email?: string; name?: string; phone?: string; }; isDefault: boolean; created: Date; } interface BillingAddress { line1?: string; line2?: string; city?: string; state?: string; postalCode?: string; country?: string; } interface StripeConfig { publishableKey: string; apiVersion?: string; } interface PricingPlan { id: string; name: string; description?: string; price: number; currency: string; interval: 'day' | 'week' | 'month' | 'year'; intervalCount?: number; stripePriceId: string; stripeProductId?: string; features: string[]; popular?: boolean; trialPeriodDays?: number; metadata?: Record; } interface CheckoutSessionParams { priceId: string; customerId?: string; customerEmail?: string; successUrl: string; cancelUrl: string; mode?: 'payment' | 'subscription' | 'setup'; allowPromotionCodes?: boolean; billingAddressCollection?: 'auto' | 'required'; metadata?: Record; trialPeriodDays?: number; } interface PaymentIntentParams { amount: number; currency: string; customerId?: string; paymentMethodTypes?: string[]; metadata?: Record; description?: string; } interface WebhookEvent { id: string; type: string; data: { object: unknown; previous_attributes?: unknown; }; created: number; livemode: boolean; pending_webhooks: number; request?: { id: string; idempotency_key?: string; }; } interface StripeError { type: 'card_error' | 'invalid_request_error' | 'api_error' | 'authentication_error' | 'rate_limit_error'; code?: string; message: string; param?: string; decline_code?: string; } interface Invoice { id: string; customerId: string; subscriptionId?: string; status: 'draft' | 'open' | 'paid' | 'uncollectible' | 'void'; amountDue: number; amountPaid: number; currency: string; dueDate?: Date; paidAt?: Date; hostedInvoiceUrl?: string; invoicePdf?: string; metadata?: Record; } interface CheckoutParams { priceId: string; mode?: 'payment' | 'subscription'; customerId?: string; customerEmail?: string; allowPromotionCodes?: boolean; successUrl?: string; cancelUrl?: string; metadata?: Record; amount?: number; currency?: string; description?: string; } interface CheckoutSession { id: string; url?: string | null; clientSecret?: string; status: 'open' | 'complete' | 'expired'; amountTotal?: number; currency?: string; customerEmail?: string; subscriptionId?: string; customer_id?: string; amount_total?: number; mode?: 'payment' | 'subscription'; payment_status?: 'paid' | 'unpaid'; expires_at?: Date; metadata?: Record; } interface PayPalConfig { clientId: string; clientSecret?: string; environment: 'sandbox' | 'production'; intent?: 'capture' | 'authorize'; currency?: string; locale?: string; enableFunding?: PayPalFundingSource[]; disableFunding?: PayPalFundingSource[]; merchantName?: string; } type PayPalFundingSource = 'paypal' | 'card' | 'credit' | 'paylater' | 'venmo' | 'applepay' | 'itau' | 'mercadopago'; interface ApplePayConfig { merchantId: string; merchantName: string; countryCode: string; currencyCode: string; supportedNetworks?: ApplePayNetwork[]; merchantCapabilities?: ApplePayMerchantCapability[]; requiredBillingContactFields?: ApplePayContactField[]; requiredShippingContactFields?: ApplePayContactField[]; shippingType?: ApplePayShippingType; environment: 'production' | 'sandbox'; } type ApplePayNetwork = 'amex' | 'chinaUnionPay' | 'discover' | 'eftpos' | 'electron' | 'elo' | 'idCredit' | 'interac' | 'jcb' | 'mada' | 'maestro' | 'masterCard' | 'privateLabel' | 'quicPay' | 'suica' | 'visa' | 'vPay'; type ApplePayMerchantCapability = 'supports3DS' | 'supportsCredit' | 'supportsDebit' | 'supportsEMV'; type ApplePayContactField = 'postalAddress' | 'phone' | 'email' | 'name' | 'phoneticName'; type ApplePayShippingType = 'shipping' | 'delivery' | 'storePickup' | 'servicePickup'; interface ApplePayPaymentRequest { countryCode: string; currencyCode: string; merchantCapabilities: ApplePayMerchantCapability[]; supportedNetworks: ApplePayNetwork[]; total: ApplePayLineItem; lineItems?: ApplePayLineItem[]; requiredBillingContactFields?: ApplePayContactField[]; requiredShippingContactFields?: ApplePayContactField[]; billingContact?: ApplePayPaymentContact; shippingContact?: ApplePayPaymentContact; applicationData?: string; supportedCountries?: string[]; shippingType?: ApplePayShippingType; shippingMethods?: ApplePayShippingMethod[]; recurringPaymentRequest?: ApplePayRecurringPaymentRequest; automaticReloadPaymentRequest?: ApplePayAutomaticReloadPaymentRequest; multiTokenContexts?: ApplePayPaymentTokenContext[]; } interface ApplePayLineItem { label: string; amount: string; type?: 'final' | 'pending'; } interface ApplePayPaymentContact { phoneNumber?: string; emailAddress?: string; givenName?: string; familyName?: string; phoneticGivenName?: string; phoneticFamilyName?: string; addressLines?: string[]; locality?: string; postalCode?: string; administrativeArea?: string; country?: string; countryCode?: string; subLocality?: string; subAdministrativeArea?: string; } interface ApplePayShippingMethod { label: string; amount: string; type?: 'final' | 'pending'; identifier?: string; detail?: string; } interface ApplePayRecurringPaymentRequest { paymentDescription: string; regularBilling: ApplePayLineItem; managementURL: string; billingAgreement?: string; trialBilling?: ApplePayLineItem; tokenNotificationURL?: string; } interface ApplePayAutomaticReloadPaymentRequest { paymentDescription: string; automaticReloadBilling: ApplePayLineItem; managementURL: string; billingAgreement?: string; tokenNotificationURL?: string; } interface ApplePayPaymentTokenContext { merchantID: string; externalIdentifier: string; merchantName: string; merchantDomain?: string; amount: string; } interface ApplePayPayment { token: ApplePayPaymentToken; billingContact?: ApplePayPaymentContact; shippingContact?: ApplePayPaymentContact; shippingMethod?: ApplePayShippingMethod; } interface ApplePayPaymentToken { paymentData: ApplePayPaymentData; paymentMethod: ApplePayPaymentMethod; transactionIdentifier: string; } interface ApplePayPaymentData { version: string; data: string; signature: string; header: ApplePayPaymentDataHeader; } interface ApplePayPaymentDataHeader { ephemeralPublicKey?: string; publicKeyHash?: string; transactionId: string; wrappedKey?: string; } interface ApplePayPaymentMethod { displayName?: string; network?: string; type: 'debit' | 'credit' | 'prepaid' | 'store'; paymentPass?: ApplePayPaymentPass; billingContact?: ApplePayPaymentContact; } interface ApplePayPaymentPass { primaryAccountIdentifier: string; primaryAccountNumberSuffix: string; deviceAccountIdentifier?: string; deviceAccountNumberSuffix?: string; activationState: 'activated' | 'requiresActivation' | 'activating' | 'suspended' | 'deactivated'; } interface ApplePayPaymentAuthorizationResult { status: ApplePayPaymentAuthorizationStatus; errors?: ApplePayError[]; } type ApplePayPaymentAuthorizationStatus = 'success' | 'failure' | 'invalidBillingPostalAddress' | 'invalidShippingPostalAddress' | 'invalidShippingContact' | 'requiresPin'; interface ApplePayError { code: ApplePayErrorCode; contactField?: ApplePayContactField; localizedDescription: string; } type ApplePayErrorCode = 'billingContactInvalid' | 'shippingContactInvalid' | 'addressUnserviceable' | 'unknown'; interface ApplePaySession { canMakePayments(): boolean; canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise; begin(): void; abort(): void; completeMerchantValidation(merchantSession: any): void; completeShippingMethodSelection(update: ApplePayShippingMethodUpdate): void; completeShippingContactSelection(update: ApplePayShippingContactUpdate): void; completePayment(result: ApplePayPaymentAuthorizationResult): void; onvalidatemerchant?: (event: ApplePayValidateMerchantEvent) => void; onpaymentmethodselected?: (event: ApplePayPaymentMethodSelectedEvent) => void; onshippingmethodselected?: (event: ApplePayShippingMethodSelectedEvent) => void; onshippingcontactselected?: (event: ApplePayShippingContactSelectedEvent) => void; onpaymentauthorized?: (event: ApplePayPaymentAuthorizedEvent) => void; oncancel?: (event: Event) => void; } interface ApplePayValidateMerchantEvent extends Event { validationURL: string; } interface ApplePayPaymentMethodSelectedEvent extends Event { paymentMethod: ApplePayPaymentMethod; } interface ApplePayShippingMethodSelectedEvent extends Event { shippingMethod: ApplePayShippingMethod; } interface ApplePayShippingContactSelectedEvent extends Event { shippingContact: ApplePayPaymentContact; } interface ApplePayPaymentAuthorizedEvent extends Event { payment: ApplePayPayment; } interface ApplePayShippingMethodUpdate { newTotal: ApplePayLineItem; newLineItems?: ApplePayLineItem[]; } interface ApplePayShippingContactUpdate { newTotal: ApplePayLineItem; newLineItems?: ApplePayLineItem[]; newShippingMethods?: ApplePayShippingMethod[]; errors?: ApplePayError[]; } interface ApplePayJS { canMakePayments(): boolean; canMakePaymentsWithActiveCard(merchantIdentifier: string): Promise; Session: { new (version: number, paymentRequest: ApplePayPaymentRequest): ApplePaySession; }; } declare global { interface Window { ApplePaySession?: ApplePayJS; } } type PaymentProviderType = 'stripe' | 'paypal' | 'applepay' | 'mock'; interface PaymentsConfig { provider: PaymentProviderType; publishableKey?: string; secretKey?: string; webhookSecret?: string; environment: 'development' | 'production'; features?: { customerPortal?: boolean; paymentMethods?: string[]; currencies?: string[]; }; stripeConfig?: StripeConfig; paypalConfig?: PayPalConfig; applePayConfig?: ApplePayConfig; } declare enum PaymentErrorType { CARD_DECLINED = "CARD_DECLINED", INSUFFICIENT_FUNDS = "INSUFFICIENT_FUNDS", CUSTOMER_NOT_FOUND = "CUSTOMER_NOT_FOUND", SUBSCRIPTION_NOT_FOUND = "SUBSCRIPTION_NOT_FOUND", NETWORK_ERROR = "NETWORK_ERROR", CONFIGURATION_ERROR = "CONFIGURATION_ERROR", WEBHOOK_ERROR = "WEBHOOK_ERROR", VALIDATION_ERROR = "VALIDATION_ERROR", PROVIDER_NOT_CONFIGURED = "PROVIDER_NOT_CONFIGURED", UNKNOWN_ERROR = "UNKNOWN_ERROR", INITIALIZATION_ERROR = "INITIALIZATION_ERROR", AUTHENTICATION_ERROR = "AUTHENTICATION_ERROR", NOT_FOUND = "NOT_FOUND", INVALID_REQUEST = "INVALID_REQUEST", API_ERROR = "API_ERROR", PERMISSION_DENIED = "PERMISSION_DENIED", WEBHOOK_VERIFICATION_FAILED = "WEBHOOK_VERIFICATION_FAILED" } interface PaymentError extends Error { type: PaymentErrorType; code?: string; details?: Record; } declare class PaymentsError extends Error implements PaymentError { type: PaymentErrorType; code?: string; details?: Record; constructor(type: PaymentErrorType, message: string, code?: string, details?: Record); } type PaymentEvent = { type: 'checkoutSuccess'; session: CheckoutSession; } | { type: 'paymentMethodAdded'; customer: Customer; } | { type: 'subscriptionCreated'; subscription: Subscription; } | { type: 'subscriptionUpdated'; subscription: Subscription; } | { type: 'subscriptionCanceled'; subscription: Subscription; } | { type: 'error'; error: PaymentError; }; interface PaymentProvider { name: string; initialize(): Promise; createCheckoutSession(params: CheckoutParams): Promise; retrieveCheckoutSession(sessionId: string): Promise; createCustomer(params: CustomerCreateParams): Promise; retrieveCustomer(customerId: string): Promise; createSubscription(params: SubscriptionCreateParams): Promise; cancelSubscription(subscriptionId: string): Promise; reactivateSubscription(subscriptionId: string): Promise; listSubscriptions(customerId: string, status?: SubscriptionStatus): Promise; retrieveSubscription(subscriptionId: string): Promise; updateSubscription(subscriptionId: string, params: SubscriptionUpdateParams): Promise; } interface PaymentsProviderState { customer: Customer | null; subscriptions: Subscription[]; activeSubscription: Subscription | null; loading: boolean; error: PaymentError | null; initialized: boolean; config: PaymentsConfig | null; isLoading: boolean; isError: boolean; } interface PaymentsProviderActions { initialize: (config?: PaymentsConfig) => Promise; createCustomer: (params: CustomerCreateParams) => Promise; retrieveCustomer: (customerId: string) => Promise; createCheckoutSession: (params: CheckoutParams) => Promise; retrieveCheckoutSession: (sessionId: string) => Promise; createSubscription: (params: SubscriptionCreateParams) => Promise; cancelSubscription: (subscriptionId: string) => Promise; reactivateSubscription: (subscriptionId: string) => Promise; listSubscriptions: (customerId: string, status?: SubscriptionStatus) => Promise; retrieveSubscription: (subscriptionId: string) => Promise; updateSubscription: (subscriptionId: string, params: SubscriptionUpdateParams) => Promise; refreshCustomer: (customerId: string) => Promise; refreshSubscriptions: (customerId: string, status?: SubscriptionStatus) => Promise; reset: () => void; } type PaymentsStore = PaymentsProviderState & PaymentsProviderActions; declare const STRIPE_API_VERSION = "2023-10-16"; declare const PAYMENT_METHODS: { readonly CARD: "card"; readonly BANK_ACCOUNT: "bank_account"; readonly SEPA_DEBIT: "sepa_debit"; readonly IDEAL: "ideal"; readonly SOFORT: "sofort"; }; declare const SUBSCRIPTION_STATUS: { readonly ACTIVE: "active"; readonly CANCELED: "canceled"; readonly PAST_DUE: "past_due"; readonly UNPAID: "unpaid"; readonly INCOMPLETE: "incomplete"; readonly INCOMPLETE_EXPIRED: "incomplete_expired"; readonly TRIALING: "trialing"; }; declare const INVOICE_STATUS: { readonly DRAFT: "draft"; readonly OPEN: "open"; readonly PAID: "paid"; readonly UNCOLLECTIBLE: "uncollectible"; readonly VOID: "void"; }; declare const CHECKOUT_MODE: { readonly PAYMENT: "payment"; readonly SUBSCRIPTION: "subscription"; readonly SETUP: "setup"; }; declare const BILLING_INTERVALS: { readonly DAY: "day"; readonly WEEK: "week"; readonly MONTH: "month"; readonly YEAR: "year"; }; declare const CURRENCY_SYMBOLS: { readonly USD: "$"; readonly EUR: "€"; readonly GBP: "£"; readonly JPY: "¥"; readonly CAD: "C$"; readonly AUD: "A$"; readonly CHF: "CHF"; readonly CNY: "¥"; readonly SEK: "kr"; readonly NZD: "NZ$"; }; declare const DEFAULT_CURRENCY = "USD"; declare const WEBHOOK_EVENTS: { readonly CUSTOMER_SUBSCRIPTION_CREATED: "customer.subscription.created"; readonly CUSTOMER_SUBSCRIPTION_UPDATED: "customer.subscription.updated"; readonly CUSTOMER_SUBSCRIPTION_DELETED: "customer.subscription.deleted"; readonly INVOICE_PAYMENT_SUCCEEDED: "invoice.payment_succeeded"; readonly INVOICE_PAYMENT_FAILED: "invoice.payment_failed"; readonly CHECKOUT_SESSION_COMPLETED: "checkout.session.completed"; readonly PAYMENT_INTENT_SUCCEEDED: "payment_intent.succeeded"; readonly PAYMENT_INTENT_PAYMENT_FAILED: "payment_intent.payment_failed"; }; declare const ERROR_MESSAGES: { readonly PROVIDER_NOT_CONFIGURED: "Payments provider is not properly configured"; readonly STRIPE_NOT_LOADED: "Stripe has not been loaded yet"; readonly INVALID_PRICE_ID: "Invalid price ID provided"; readonly INVALID_CUSTOMER_ID: "Invalid customer ID provided"; readonly CHECKOUT_FAILED: "Checkout session creation failed"; readonly PAYMENT_FAILED: "Payment processing failed"; readonly SUBSCRIPTION_NOT_FOUND: "Subscription not found"; readonly CUSTOMER_NOT_FOUND: "Customer not found"; }; declare const validateEmail: (email: string) => boolean; declare const validatePhoneNumber: (phone: string) => boolean; declare const validatePaymentsConfig: (config: PaymentsConfig) => { isValid: boolean; errors: string[]; }; declare const validatePricingPlan: (plan: PricingPlan) => { isValid: boolean; errors: string[]; }; declare const validateStripeId: (id: string, type: "customer" | "subscription" | "price" | "product" | "payment_intent") => boolean; declare const validateAmount: (amount: number, currency: string) => { isValid: boolean; error?: string; }; declare const validateCard: (cardDetails: { number: string; expMonth: number; expYear: number; cvc: string; }) => { isValid: boolean; errors: string[]; }; declare const formatCurrency: (amount: number, currency?: string, options?: { showSymbol?: boolean; showCents?: boolean; locale?: string; }) => string; declare const formatPricingPlan: (plan: PricingPlan) => string; declare const formatSubscriptionStatus: (status: SubscriptionStatus) => string; declare const formatDate: (date: Date | string | number, options?: { format?: "short" | "medium" | "long" | "full"; locale?: string; timeZone?: string; }) => string; declare const formatRelativeTime: (date: Date | string | number, options?: { locale?: string; numeric?: "always" | "auto"; }) => string; declare const formatBillingInterval: (interval: string, count?: number) => string; declare const formatTrialPeriod: (days: number) => string; declare const truncateText: (text: string, maxLength: number) => string; declare const formatCardBrand: (brand: string) => string; declare const formatPaymentMethodDisplay: (paymentMethod: { type: string; card?: { brand: string; last4: string; }; bankAccount?: { last4: string; bankName?: string; }; }) => string; declare const calculateTax: (amount: number, taxRate: number, options?: { inclusive?: boolean; roundTo?: number; }) => { subtotal: number; tax: number; total: number; }; declare const formatTaxRate: (rate: number) => string; declare const formatAmountWithTax: (amount: number, taxRate: number, currency?: string, options?: { inclusive?: boolean; showBreakdown?: boolean; locale?: string; }) => string; /** * Environment validation utilities for SaaS Factory Payments */ interface EnvironmentConfig { stripePublishableKey: string; stripeSecretKey?: string; stripeWebhookSecret?: string; environment: 'development' | 'production'; appUrl?: string; } declare const validateEnvironment: (config: Partial) => { isValid: boolean; errors: string[]; warnings: string[]; }; declare const getEnvironmentConfig: () => EnvironmentConfig; declare const validateCurrentEnvironment: () => { isValid: boolean; errors: string[]; warnings: string[]; }; declare const isDevelopment: () => boolean; declare const isProduction: () => boolean; declare const isServer: () => boolean; declare const isClient: () => boolean; declare class PaymentProviderFactory { static create(config: PaymentsConfig): PaymentProvider; static autodetect(): PaymentsConfig; static getAvailableProviders(): PaymentProviderType[]; static createMultiple(configs: PaymentsConfig[]): PaymentProvider[]; } declare abstract class BasePaymentProvider implements PaymentProvider { abstract name: string; protected config: PaymentsConfig; constructor(config: PaymentsConfig); abstract initialize(): Promise; abstract createCheckoutSession(params: CheckoutParams): Promise; abstract retrieveCheckoutSession(sessionId: string): Promise; abstract createCustomer(params: CustomerCreateParams): Promise; abstract retrieveCustomer(customerId: string): Promise; abstract createSubscription(params: SubscriptionCreateParams): Promise; abstract cancelSubscription(subscriptionId: string): Promise; abstract reactivateSubscription(subscriptionId: string): Promise; abstract listSubscriptions(customerId: string, status?: SubscriptionStatus): Promise; abstract retrieveSubscription(subscriptionId: string): Promise; abstract updateSubscription(subscriptionId: string, params: SubscriptionUpdateParams): Promise; protected handleError(error: unknown, type?: PaymentErrorType): PaymentsError; } declare class StripePaymentProvider extends BasePaymentProvider { name: string; private stripeClient; constructor(config: PaymentsConfig); initialize(): Promise; createCheckoutSession(params: CheckoutParams): Promise; createCustomer(params: CustomerCreateParams): Promise; retrieveCustomer(customerId: string): Promise; createSubscription(params: SubscriptionCreateParams): Promise; cancelSubscription(subscriptionId: string): Promise; reactivateSubscription(subscriptionId: string): Promise; retrieveCheckoutSession(sessionId: string): Promise; listSubscriptions(customerId: string, status?: SubscriptionStatus): Promise; retrieveSubscription(subscriptionId: string): Promise; updateSubscription(subscriptionId: string, params: Partial): Promise; private mapStripeSubscriptionToSubscription; } /** * A mock payment provider for testing and development purposes. * It simulates payment operations without actual API calls. */ declare class MockPaymentProvider extends BasePaymentProvider implements PaymentProvider { name: string; private customers; private subscriptions; private nextCustomerId; private nextSubscriptionId; constructor(config: Omit); initialize(): Promise; createCheckoutSession(params: CheckoutParams): Promise; retrieveCheckoutSession(id: string): Promise; createCustomer(params: CustomerCreateParams): Promise; retrieveCustomer(id: string): Promise; updateCustomer(id: string, params: CustomerCreateParams): Promise; deleteCustomer(id: string): Promise; listPaymentMethods(customerId: string): Promise; attachPaymentMethod(customerId: string, paymentMethodId: string): Promise; detachPaymentMethod(customerId: string, paymentMethodId: string): Promise; createSubscription(params: SubscriptionCreateParams): Promise; retrieveSubscription(id: string): Promise; updateSubscription(id: string, params: SubscriptionUpdateParams): Promise; cancelSubscription(id: string): Promise; reactivateSubscription(id: string): Promise; listSubscriptions(customerId: string, status?: SubscriptionStatus): Promise; } export { ACTIVE_STATUSES, type ActiveSubscriptionStatus, BILLING_INTERVALS, type BillingAddress, CHECKOUT_MODE, CURRENCY_SYMBOLS, type CheckoutParams, type CheckoutSession, type CheckoutSessionParams, type CustomerCreateParams, type CustomerUpdateParams, DEFAULT_CURRENCY, ERROR_MESSAGES, type EnvironmentConfig, INACTIVE_STATUSES, INCOMPLETE_STATUSES, INVOICE_STATUS, type InactiveSubscriptionStatus, type IncompleteSubscriptionStatus, type Invoice, MockPaymentProvider, PAYMENT_METHODS, PROBLEMATIC_STATUSES, PaymentErrorType, type PaymentEvent, type PaymentIntentParams, type PaymentProvider, PaymentProviderFactory, type PaymentProviderType, type PaymentsConfig, PaymentsError, type PaymentsProviderActions, type PaymentsProviderState, type PaymentsStore, type PricingPlan, type ProblematicSubscriptionStatus, STRIPE_API_VERSION, SUBSCRIPTION_STATUS, type StripeConfig, type StripeError, StripePaymentProvider, type Subscription, type SubscriptionCreateParams, type SubscriptionItem, SubscriptionStatus, type SubscriptionUpdateParams, WEBHOOK_EVENTS, type WebhookEvent, cacheSubscriptionStatus, calculateTax, clearPlatform, formatAmountWithTax, formatBillingInterval, formatCardBrand, formatCurrency, formatDate, formatPaymentMethodDisplay, formatPricingPlan, formatRelativeTime, formatSubscriptionStatus, formatTaxRate, formatTrialPeriod, getCachedSubscriptionStatus, getEnvironmentConfig, hasPlatform, isActiveSubscription, isClient, isDevelopment, isInactiveSubscription, isIncompleteSubscription, isProblematicSubscription, isProduction, isServer, logPaymentEvent, setPlatform, trackCheckoutSession, trackPaymentMetric, trackRevenue, trackSubscriptionEvent, trackWebhookEvent, truncateText, validateAmount, validateCard, validateCurrentEnvironment, validateEmail, validateEnvironment, validatePaymentsConfig, validatePhoneNumber, validatePricingPlan, validateStripeId };