import { ISubscriptionRepository } from '../repositories/ISubscriptionRepository.js'; import { ICustomerRepository } from '../repositories/ICustomerRepository.js'; import { IPlanRepository } from '../repositories/IPlanRepository.js'; import { IBillingCycleRepository } from '../repositories/IBillingCycleRepository.js'; import { Subscription } from '../../domain/entities/Subscription.js'; import { default as Stripe } from 'stripe'; export declare class StripeIntegrationService { private readonly subscriptionRepository; private readonly customerRepository; private readonly planRepository; private readonly billingCycleRepository; private readonly config?; constructor(subscriptionRepository: ISubscriptionRepository, customerRepository: ICustomerRepository, planRepository: IPlanRepository, billingCycleRepository: IBillingCycleRepository, config?: { stripe?: { secretKey?: string; }; } | undefined); /** * Process a verified Stripe event * NOTE: Signature verification MUST be done by implementor before calling this */ processStripeEvent(event: Stripe.Event): Promise; private handleSubscriptionCreated; private handleSubscriptionUpdated; private handleSubscriptionDeleted; private handlePaymentSucceeded; /** * Find billing cycle by Stripe price ID (stored in externalProductId) */ private findBillingCycleByStripePriceId; /** * Create Stripe subscription from Subscrio data */ createStripeSubscription(customerKey: string, planKey: string, billingCycleKey: string, _stripePriceId: string): Promise; private resolveCustomer; private getMetadataValue; private extractCustomerId; private resolvePlanFromSubscription; /** * Find the subscription item that matches the billing cycle's Stripe price ID * and extract period dates from it */ private getPeriodDatesFromStripeSubscription; private applyStripeSubscriptionFields; private mapStripeStatus; private toDateOrUndefined; private toDateOrDefault; /** * Merge Stripe schedule ID into subscription metadata * If schedule is present, adds it to metadata as 'stripeScheduleId' * If schedule is null/undefined, removes it from metadata */ private mergeScheduleIntoMetadata; private handleCustomerUpsert; private handleCustomerDeleted; /** * Find subscription by metadata (subscription key) * Verifies the subscription belongs to the specified customer */ private findSubscriptionByMetadata; /** * Get Stripe client instance * Uses provided secret key or falls back to config */ private getStripeClient; /** * Create a Stripe Checkout Session URL for subscription purchase * * This helper method: * - Ensures the customer exists in Stripe (creates if needed) * - Sets proper metadata for webhook linking * - Supports linking to existing Subscrio subscriptions * - Provides full access to Stripe Checkout options */ createCheckoutSession(params: { customerKey: string; billingCycleKey: string; subscriptionKey?: string; stripeSecretKey?: string; successUrl: string; cancelUrl: string; quantity?: number; customerEmail?: string; customerName?: string; allowPromotionCodes?: boolean; billingAddressCollection?: 'auto' | 'required'; paymentMethodTypes?: Stripe.Checkout.SessionCreateParams.PaymentMethodType[]; trialPeriodDays?: number; metadata?: Record; stripeOptions?: Partial; }): Promise<{ url: string; sessionId: string; }>; } //# sourceMappingURL=StripeIntegrationService.d.ts.map