/** * Subscription API type definitions */ import type { BaseResponse, Locale, Currency } from './common'; // ============================================================================ // Enums and Type Aliases // ============================================================================ export type PaymentInterval = 'DAILY' | 'WEEKLY' | 'MONTHLY' | 'YEARLY'; export type PlanPaymentType = 'RECURRING'; export type SubscriptionStatus = 'ACTIVE' | 'PENDING' | 'UNPAID' | 'UPGRADED' | 'CANCELED' | 'EXPIRED'; export type SubscriptionInitialStatus = 'ACTIVE' | 'PENDING'; export type UpgradePeriod = 'NOW' | 'NEXT_PERIOD'; export type SubscriptionProductStatus = 'ACTIVE' | 'INACTIVE'; export type SubscriptionCustomerStatus = 'ACTIVE' | 'INACTIVE'; // ============================================================================ // Common Subscription Types // ============================================================================ /** * Paginated result wrapper */ export interface PaginatedResult { totalCount: number; currentPage: number; pageCount: number; items: T[]; } /** * Subscription address model (different from payment Address) */ export interface SubscriptionAddress { address: string; zipCode?: string; contactName: string; city: string; district?: string; country: string; } /** * Subscription customer model */ export interface SubscriptionCustomer { name: string; surname: string; email: string; gsmNumber: string; identityNumber: string; billingAddress: SubscriptionAddress; shippingAddress?: SubscriptionAddress; } /** * Subscription customer resource (response model) */ export interface SubscriptionCustomerResource { referenceCode: string; createdDate: number; status: SubscriptionCustomerStatus; name: string; surname: string; identityNumber: string; email: string; gsmNumber: string; contactEmail?: string; contactGsmNumber?: string; billingAddress: SubscriptionAddress; shippingAddress?: SubscriptionAddress; } /** * Subscription payment card model */ export interface SubscriptionPaymentCard { cardHolderName: string; cardNumber: string; expireMonth: string; expireYear: string; cvc: string; } /** * Pricing plan model */ export interface PricingPlan { referenceCode: string; createdDate: string | number; name: string; price: number; currencyCode: Currency; paymentInterval: PaymentInterval; paymentIntervalCount: number; trialPeriodDays?: number; productReferenceCode: string; planPaymentType: PlanPaymentType; status: string; recurrenceCount?: number; } /** * Subscription product model */ export interface SubscriptionProduct { referenceCode: string; createdDate: string; name: string; description?: string; status: SubscriptionProductStatus; pricingPlans?: PricingPlan[]; } /** * Subscription order model */ export interface SubscriptionOrder { referenceCode: string; price: number; currencyCode: Currency; startPeriod: number; endPeriod: number; orderStatus: string; } /** * Subscription resource model */ export interface SubscriptionResource { referenceCode: string; parentReferenceCode?: string; pricingPlanName?: string; pricingPlanReferenceCode: string; productName?: string; productReferenceCode?: string; customerEmail?: string; customerGsmNumber?: string; customerReferenceCode: string; subscriptionStatus: SubscriptionStatus; trialDays?: number; trialStartDate?: number; trialEndDate?: number; createdDate?: number; startDate?: number; endDate?: number; orders?: SubscriptionOrder[]; } // ============================================================================ // Product Request/Response Types // ============================================================================ /** * Create product request */ export interface ProductCreateRequest { locale?: Locale; conversationId?: string; name: string; description?: string; } /** * Create product response */ export interface ProductCreateResponse extends BaseResponse { data?: SubscriptionProduct; } /** * List products request */ export interface ProductListRequest { locale?: Locale; conversationId?: string; page?: number; count?: number; } /** * List products response */ export interface ProductListResponse extends BaseResponse { data?: PaginatedResult; } /** * Get product response */ export interface ProductGetResponse extends BaseResponse { data?: SubscriptionProduct; } /** * Update product request */ export interface ProductUpdateRequest { locale?: Locale; conversationId?: string; name: string; description?: string; } /** * Update product response */ export interface ProductUpdateResponse extends BaseResponse { data?: SubscriptionProduct; } /** * Delete product response */ export interface ProductDeleteResponse extends BaseResponse {} // ============================================================================ // Pricing Plan Request/Response Types // ============================================================================ /** * Create pricing plan request */ export interface PricingPlanCreateRequest { locale?: Locale; conversationId?: string; name: string; price: number; currencyCode: Currency; paymentInterval: PaymentInterval; paymentIntervalCount?: number; trialPeriodDays?: number; planPaymentType: PlanPaymentType; recurrenceCount?: number; } /** * Create pricing plan response */ export interface PricingPlanCreateResponse extends BaseResponse { data?: PricingPlan; } /** * List pricing plans request */ export interface PricingPlanListRequest { locale?: Locale; conversationId?: string; page?: number; count?: number; } /** * List pricing plans response */ export interface PricingPlanListResponse extends BaseResponse { data?: PaginatedResult; } /** * Get pricing plan response */ export interface PricingPlanGetResponse extends BaseResponse { data?: PricingPlan; } /** * Update pricing plan request */ export interface PricingPlanUpdateRequest { locale?: Locale; conversationId?: string; name: string; trialPeriodDays?: number; } /** * Update pricing plan response */ export interface PricingPlanUpdateResponse extends BaseResponse { data?: PricingPlan; } /** * Delete pricing plan response */ export interface PricingPlanDeleteResponse extends BaseResponse {} // ============================================================================ // Customer Request/Response Types // ============================================================================ /** * List customers request */ export interface CustomerListRequest { locale?: Locale; conversationId?: string; page?: number; count?: number; } /** * List customers response */ export interface CustomerListResponse extends BaseResponse { data?: PaginatedResult; } /** * Get customer response */ export interface CustomerGetResponse extends BaseResponse { data?: SubscriptionCustomerResource; } /** * Update customer request */ export interface CustomerUpdateRequest { locale?: Locale; conversationId?: string; name?: string; surname?: string; email?: string; gsmNumber?: string; identityNumber?: string; billingAddress?: SubscriptionAddress; shippingAddress?: SubscriptionAddress; } /** * Update customer response */ export interface CustomerUpdateResponse extends BaseResponse { data?: SubscriptionCustomerResource; } // ============================================================================ // Subscription Request/Response Types // ============================================================================ /** * Initialize subscription request (NON3D) */ export interface SubscriptionInitializeRequest { locale?: Locale; conversationId?: string; pricingPlanReferenceCode: string; subscriptionInitialStatus: SubscriptionInitialStatus; customer: SubscriptionCustomer; paymentCard: SubscriptionPaymentCard; } /** * Initialize subscription response */ export interface SubscriptionInitializeResponse extends BaseResponse { data?: { referenceCode: string; parentReferenceCode?: string; customerReferenceCode: string; pricingPlanReferenceCode?: string; subscriptionStatus?: SubscriptionStatus; trialDays?: number; trialStartDate?: number; trialEndDate?: number; createdDate?: number; startDate?: number; endDate?: number; }; } /** * Initialize subscription with existing customer request */ export interface SubscriptionInitializeWithCustomerRequest { locale?: Locale; conversationId?: string; pricingPlanReferenceCode: string; subscriptionInitialStatus: SubscriptionInitialStatus; customerReferenceCode: string; } /** * Initialize subscription checkout form request */ export interface SubscriptionCheckoutFormInitializeRequest { locale?: Locale; conversationId?: string; callbackUrl: string; pricingPlanReferenceCode: string; subscriptionInitialStatus: SubscriptionInitialStatus; customer: SubscriptionCustomer; } /** * Initialize subscription checkout form response */ export interface SubscriptionCheckoutFormInitializeResponse extends BaseResponse { token?: string; checkoutFormContent?: string; tokenExpireTime?: number; } /** * List subscriptions request */ export interface SubscriptionListRequest { locale?: Locale; conversationId?: string; subscriptionReferenceCode?: string; customerReferenceCode?: string; pricingPlanReferenceCode?: string; parentReferenceCode?: string; subscriptionStatus?: SubscriptionStatus; startDate?: number; endDate?: number; page?: number; count?: number; } /** * List subscriptions response */ export interface SubscriptionListResponse extends BaseResponse { data?: PaginatedResult; } /** * Get subscription response */ export interface SubscriptionGetResponse extends BaseResponse { data?: PaginatedResult; } /** * Cancel subscription response */ export interface SubscriptionCancelResponse extends BaseResponse {} /** * Activate subscription response */ export interface SubscriptionActivateResponse extends BaseResponse {} /** * Upgrade subscription request */ export interface SubscriptionUpgradeRequest { locale?: Locale; conversationId?: string; upgradePeriod: UpgradePeriod; newPricingPlanReferenceCode: string; useTrial?: boolean; resetRecurrenceCount?: boolean; } /** * Upgrade subscription response */ export interface SubscriptionUpgradeResponse extends BaseResponse { data?: { referenceCode: string; parentReferenceCode?: string; pricingPlanReferenceCode: string; customerReferenceCode: string; subscriptionStatus: SubscriptionStatus; trialDays?: number; createdDate?: number; startDate?: number; endDate?: number; }; } /** * Retry failed payment request */ export interface SubscriptionRetryRequest { locale?: Locale; conversationId?: string; referenceCode: string; } /** * Retry failed payment response */ export interface SubscriptionRetryResponse extends BaseResponse {} /** * Card update checkout form initialize request */ export interface CardUpdateCheckoutFormInitializeRequest { locale?: Locale; conversationId?: string; callbackUrl: string; customerReferenceCode: string; subscriptionReferenceCode?: string; } /** * Card update checkout form initialize response */ export interface CardUpdateCheckoutFormInitializeResponse extends BaseResponse { token?: string; checkoutFormContent?: string; tokenExpireTime?: number; }