import { Observable } from 'rxjs'; import { SubtrakService } from './subtrak.service'; import { Subscription, SubscriptionWithRelations, CreateSubscriptionInput, CreateSubscriptionResult, UpdateSubscriptionInput, ListSubscriptionsParams, PaginatedResponse, PriceWithEntitlements, EntitlementValue, PlanOption, PreviewUpdateResponse } from '../models'; import * as i0 from "@angular/core"; /** * Service for managing customer subscriptions * * @example * ```typescript * constructor(private subscriptions: SubscriptionsService) {} * * // Get current subscription * this.subscriptions.getCurrentSubscription('cus_123').subscribe(sub => { * console.log('Current plan:', sub.price.nickname); * }); * * // Create subscription * this.subscriptions.createSubscription({ * customerId: 'cus_123', * priceId: 'price_456', * quantity: 1 * }).subscribe(); * ``` */ export declare class SubscriptionsService { private subtrak; constructor(subtrak: SubtrakService); /** * Get the current active subscription for a customer * * @param customerId - Customer ID * @returns Observable of the active subscription */ getCurrentSubscription(customerId: string): Observable; /** * List all subscriptions with optional filtering * * @param params - Query parameters for filtering * @returns Observable of paginated subscriptions */ listSubscriptions(params?: ListSubscriptionsParams): Observable>; /** * Get a specific subscription by ID * * @param subscriptionId - Subscription ID * @returns Observable of the subscription */ getSubscription(subscriptionId: string): Observable; /** * List available plans (prices) for a country * * @param countryCode - ISO country code (e.g., 'US', 'EG') * @returns Observable of available prices with entitlements */ listAvailablePlans(countryCode?: string): Observable; /** * Get prices for a specific product (no grouping) * Uses the /products/:id/prices endpoint with automatic country fallback. * Free plans are always sorted to the beginning of the array. * * @param productId - Product ID (required) * @param countryCode - ISO country code (e.g., 'US', 'EG'). Optional. * @returns Observable of PriceWithEntitlements[] (free plans first) * * @example * ```typescript * // Get all prices for a product in Egypt * this.subscriptions.getProductPrices('prod_123', 'EG').subscribe(prices => { * console.log('First price (free plan):', prices[0]); * console.log('All prices:', prices); * }); * ``` */ getProductPrices(productId: string, countryCode?: string): Observable; /** * Get plans grouped by nickname (Plan Options) for a specific customer. * Resolves the customer's country and fetches relevant prices. * * @param customerId - Customer ID (optional) * @param productId - Product ID (optional, to filter plans by product) * @returns Observable of PlanOption[] */ getPlansForCustomer(customerId?: string | null, productId?: string, countryCode?: string): Observable; /** * Create a new subscription * * For Paymob customers, the response includes payment intent details. * The frontend should check `requiresPayment` and display the payment iframe if true. * * @param input - Subscription creation data * @returns Observable of CreateSubscriptionResult containing: * - subscription: The created subscription (status PENDING for Paymob) * - requiresPayment: true if payment iframe needed (Paymob) * - clientSecret: Paymob payment intent client_secret * - paymentUrl: Paymob iframe URL to display * - iframeId: Paymob iframe ID * - provider: Payment provider (STRIPE, PAYMOB_EGYPT, etc.) * * @example * ```typescript * // Create subscription * this.subscriptions.createSubscription({ * customerId: 'cus_123', * priceId: 'price_456' * }).subscribe(result => { * if (result.requiresPayment && result.paymentUrl) { * // Display Paymob payment iframe * window.open(result.paymentUrl, '_blank'); * } else { * // Subscription activated immediately (Stripe or free plan) * console.log('Subscription active:', result.subscription.id); * } * }); * ``` */ createSubscription(input: CreateSubscriptionInput): Observable; /** * Preview a subscription update (proration calculation) * * @param subscriptionId - Subscription ID * @param input - Update data (price, quantity, overrides) * @returns Observable of proration details */ previewUpdate(subscriptionId: string, input: Partial): Observable; /** * Update an existing subscription * * @param subscriptionId - Subscription ID * @param input - Update data * @returns Observable of the updated subscription */ updateSubscription(subscriptionId: string, input: UpdateSubscriptionInput): Observable; /** * Upgrade a subscription to a higher-tier plan * * @param subscriptionId - Subscription ID * @param newPriceId - New price ID to upgrade to * @returns Observable of the updated subscription */ upgradeSubscription(subscriptionId: string, newPriceId: string): Observable; /** * Downgrade a subscription to a lower-tier plan * * @param subscriptionId - Subscription ID * @param newPriceId - New price ID to downgrade to * @returns Observable of the updated subscription */ downgradeSubscription(subscriptionId: string, newPriceId: string): Observable; /** * Change subscription quantity * * @param subscriptionId - Subscription ID * @param quantity - New quantity * @returns Observable of the updated subscription */ changeQuantity(subscriptionId: string, quantity: number): Observable; /** * Cancel a subscription * * @param subscriptionId - Subscription ID * @param options - Cancellation options * @returns Observable of void */ cancelSubscription(subscriptionId: string, options?: { immediately?: boolean; }): Observable; /** * Reactivate a cancelled subscription * * @param subscriptionId - Subscription ID * @returns Observable of the reactivated subscription */ reactivateSubscription(subscriptionId: string): Observable; /** * Pause a subscription * * @param subscriptionId - Subscription ID * @returns Observable of the paused subscription */ pauseSubscription(subscriptionId: string): Observable; /** * Resume a paused subscription * * @param subscriptionId - Subscription ID * @returns Observable of the resumed subscription */ resumeSubscription(subscriptionId: string): Observable; /** * Get entitlements for a subscription * * @param subscriptionId - Subscription ID * @returns Observable of entitlement values */ getEntitlements(subscriptionId: string): Observable; /** * Get usage summary for a subscription * * @param subscriptionId - Subscription ID * @returns Observable of usage data */ getUsage(subscriptionId: string): Observable; static ɵfac: i0.ɵɵFactoryDeclaration; static ɵprov: i0.ɵɵInjectableDeclaration; }