import { Queue } from "bullmq"; import { ClsService } from "nestjs-cls"; import { AppLoggingService } from "../../../core/logging"; import { CompanyRepository } from "../../company/repositories/company.repository"; import { StripeCustomerRepository } from "../../stripe-customer/repositories/stripe-customer.repository"; import { StripeInvoiceRepository } from "../../stripe-invoice/repositories/stripe-invoice.repository"; import { UserRepository } from "../../user/repositories/user.repository"; export interface StripeWebhookPaymentFailureNotificationParams { stripeCustomerId: string; stripeInvoiceId?: string; stripePaymentIntentId?: string; errorMessage?: string; amount?: number; currency?: string; } export interface StripeWebhookPaymentSuccessNotificationParams { stripeCustomerId: string; stripeInvoiceId?: string; stripePaymentIntentId?: string; amount: number; currency: string; companyName?: string; isOneTimePurchase?: boolean; } export interface StripeWebhookTrialEndingNotificationParams { stripeCustomerId: string; stripeSubscriptionId: string; trialEndDate: Date; } export interface StripeWebhookTrialEndedNotificationParams { stripeCustomerId: string; stripeSubscriptionId: string; companyName: string; trialEndDate: Date; } /** * StripeWebhookNotificationService * * Handles sending notifications for billing events (payment failures, subscription changes, etc.) * Uses BullMQ to queue email notifications for non-blocking webhook processing. * * Key Features: * - Queue payment failure notifications via BullMQ * - Queue subscription status change notifications * - Non-blocking notification processing to prevent webhook delays * - Automatic retry logic with exponential backoff * - Enriches notifications with customer and invoice data */ export declare class StripeWebhookNotificationService { private readonly emailQueue; private readonly stripeCustomerRepository; private readonly stripeInvoiceRepository; private readonly userRepository; private readonly companyRepository; private readonly cls; private readonly logger; constructor(emailQueue: Queue, stripeCustomerRepository: StripeCustomerRepository, stripeInvoiceRepository: StripeInvoiceRepository, userRepository: UserRepository, companyRepository: CompanyRepository, cls: ClsService, logger: AppLoggingService); /** * Send payment failure notification email */ sendPaymentFailedEmail(params: StripeWebhookPaymentFailureNotificationParams): Promise; /** * Send subscription status change notification */ sendSubscriptionStatusChangeEmail(stripeCustomerId: string, status: string, subscriptionId: string): Promise; /** * Send payment success notification to company admins * Includes invoice link and thank you message */ sendPaymentSuccessToCompanyAdmins(params: StripeWebhookPaymentSuccessNotificationParams): Promise; /** * Send payment success notification to platform administrators * Minimal details: company name and amount only */ sendPaymentSuccessToPlatformAdmins(params: StripeWebhookPaymentSuccessNotificationParams): Promise; /** * Send trial ending reminder to company admins * Sent 3 days before trial expires */ sendTrialEndingReminderEmail(params: StripeWebhookTrialEndingNotificationParams): Promise; /** * Send trial ended notification to company admins * Sent when trial expires without payment, warning about 30-day data removal */ sendTrialEndedEmail(params: StripeWebhookTrialEndedNotificationParams): Promise; /** * Send deletion warning email to all company admins * Context-aware: shows different message for trial_expired vs subscription_cancelled */ sendDeletionWarningEmail(params: { companyId: string; daysRemaining: number; deletionDate: Date; reason: "trial_expired" | "subscription_cancelled"; }): Promise; /** * Send subscription cancelled email with 30-day data removal warning */ sendSubscriptionCancelledEmail(params: { companyId: string; dataRemovalDate: Date; }): Promise; } //# sourceMappingURL=stripe-webhook-notification.service.d.ts.map