export { CardDetails, CreatePaymentIntentRequest, CreateRefundRequest, IyzicoConfig, Money, PaddleConfig, CreateCustomerRequest as ParsCreateCustomerRequest, CreateSubscriptionRequest as ParsCreateSubscriptionRequest, CurrencyCode as ParsCurrencyCode, PaymentIntent as ParsPaymentIntentType, PaymentMethod as ParsPaymentMethod, Price as ParsPrice, Subscription as ParsSubscription, SubscriptionStatus as ParsSubscriptionStatus, WebhookEvent as ParsWebhookEvent, WebhookEventType as ParsWebhookEventType, PaymentCustomer, PaymentIntentStatus, PaymentsConfig, PriceInterval, Refund, RefundStatus, StripeConfig, cardDetails, createCustomerRequest, createPaymentIntentRequest, createRefundRequest, createSubscriptionRequest, currencyCode, iyzicoConfig, money, paddleConfig, paymentIntent as parsPaymentIntent, price as parsPrice, subscription as parsSubscription, subscriptionStatus as parsSubscriptionStatus, paymentCustomer, paymentIntentStatus, paymentMethod, paymentsConfig, priceInterval, refund, refundStatus, stripeConfig, type, webhookEvent, webhookEventType } from '@parsrun/types'; /** * @parsrun/payments - Type Definitions * Payment types and interfaces */ /** * Payment provider type */ type PaymentProviderType = "stripe" | "paddle" | "iyzico"; /** * Currency code (ISO 4217) */ type CurrencyCode = "USD" | "EUR" | "GBP" | "TRY" | "JPY" | "CAD" | "AUD" | string; /** * Payment status */ type PaymentStatus = "pending" | "processing" | "succeeded" | "failed" | "canceled" | "refunded" | "partially_refunded"; /** * Subscription status */ type SubscriptionStatus = "active" | "past_due" | "unpaid" | "canceled" | "incomplete" | "incomplete_expired" | "trialing" | "paused"; /** * Billing interval */ type BillingInterval = "day" | "week" | "month" | "year"; /** * Customer data */ interface Customer { /** Provider customer ID */ id: string; /** Customer email */ email: string; /** Customer name */ name?: string | undefined; /** Phone number */ phone?: string | undefined; /** Billing address */ address?: Address | undefined; /** Custom metadata */ metadata?: Record | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Address */ interface Address { line1?: string | undefined; line2?: string | undefined; city?: string | undefined; state?: string | undefined; postalCode?: string | undefined; country?: string | undefined; } /** * Create customer options */ interface CreateCustomerOptions { email: string; name?: string | undefined; phone?: string | undefined; address?: Address | undefined; metadata?: Record | undefined; } /** * Product */ interface Product { /** Provider product ID */ id: string; /** Product name */ name: string; /** Description */ description?: string | undefined; /** Active status */ active: boolean; /** Custom metadata */ metadata?: Record | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Price */ interface Price { /** Provider price ID */ id: string; /** Product ID */ productId: string; /** Price in smallest currency unit (cents) */ unitAmount: number; /** Currency */ currency: CurrencyCode; /** Recurring billing details */ recurring?: { interval: BillingInterval; intervalCount: number; } | undefined; /** Active status */ active: boolean; /** Custom metadata */ metadata?: Record | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Checkout line item */ interface CheckoutLineItem { /** Price ID */ priceId: string; /** Quantity */ quantity: number; } /** * Create checkout options */ interface CreateCheckoutOptions { /** Customer ID (optional, creates new if not provided) */ customerId?: string | undefined; /** Customer email (for new customers) */ customerEmail?: string | undefined; /** Line items */ lineItems: CheckoutLineItem[]; /** Success redirect URL */ successUrl: string; /** Cancel redirect URL */ cancelUrl: string; /** Checkout mode */ mode: "payment" | "subscription" | "setup"; /** Allow promotion codes */ allowPromotionCodes?: boolean | undefined; /** Trial period days (subscription only) */ trialDays?: number | undefined; /** Custom metadata */ metadata?: Record | undefined; /** Tenant ID for multi-tenant */ tenantId?: string | undefined; } /** * Checkout session */ interface CheckoutSession { /** Provider session ID */ id: string; /** Checkout URL */ url: string; /** Customer ID */ customerId?: string | undefined; /** Payment status */ status: "open" | "complete" | "expired"; /** Mode */ mode: "payment" | "subscription" | "setup"; /** Amount total */ amountTotal?: number | undefined; /** Currency */ currency?: CurrencyCode | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Subscription */ interface Subscription { /** Provider subscription ID */ id: string; /** Customer ID */ customerId: string; /** Status */ status: SubscriptionStatus; /** Price ID */ priceId: string; /** Product ID */ productId?: string | undefined; /** Current period start */ currentPeriodStart: Date; /** Current period end */ currentPeriodEnd: Date; /** Cancel at period end */ cancelAtPeriodEnd: boolean; /** Canceled at */ canceledAt?: Date | undefined; /** Trial start */ trialStart?: Date | undefined; /** Trial end */ trialEnd?: Date | undefined; /** Custom metadata */ metadata?: Record | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Create subscription options */ interface CreateSubscriptionOptions { /** Customer ID */ customerId: string; /** Price ID */ priceId: string; /** Trial period days */ trialDays?: number | undefined; /** Custom metadata */ metadata?: Record | undefined; /** Payment behavior */ paymentBehavior?: "default_incomplete" | "error_if_incomplete" | "allow_incomplete" | undefined; } /** * Update subscription options */ interface UpdateSubscriptionOptions { /** New price ID */ priceId?: string | undefined; /** Cancel at period end */ cancelAtPeriodEnd?: boolean | undefined; /** Custom metadata */ metadata?: Record | undefined; /** Proration behavior */ prorationBehavior?: "create_prorations" | "none" | "always_invoice" | undefined; } /** * Payment intent */ interface PaymentIntent { /** Provider payment ID */ id: string; /** Amount */ amount: number; /** Currency */ currency: CurrencyCode; /** Status */ status: PaymentStatus; /** Customer ID */ customerId?: string | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Invoice */ interface Invoice { /** Provider invoice ID */ id: string; /** Customer ID */ customerId: string; /** Subscription ID */ subscriptionId?: string | undefined; /** Status */ status: "draft" | "open" | "paid" | "void" | "uncollectible"; /** Amount due */ amountDue: number; /** Amount paid */ amountPaid: number; /** Currency */ currency: CurrencyCode; /** Invoice URL */ hostedInvoiceUrl?: string | undefined; /** PDF URL */ invoicePdf?: string | undefined; /** Due date */ dueDate?: Date | undefined; /** Provider-specific data */ providerData?: unknown; } /** * Customer portal session */ interface PortalSession { /** Portal URL */ url: string; /** Return URL */ returnUrl: string; } /** * Create portal options */ interface CreatePortalOptions { /** Customer ID */ customerId: string; /** Return URL */ returnUrl: string; } /** * Webhook event types */ type WebhookEventType = "checkout.session.completed" | "checkout.session.expired" | "customer.created" | "customer.updated" | "customer.deleted" | "subscription.created" | "subscription.updated" | "subscription.deleted" | "subscription.trial_will_end" | "payment.succeeded" | "payment.failed" | "invoice.created" | "invoice.paid" | "invoice.payment_failed" | "invoice.upcoming" | "refund.created" | "refund.updated"; /** * Webhook event */ interface WebhookEvent { /** Event ID */ id: string; /** Event type */ type: WebhookEventType; /** Event data */ data: T; /** Created timestamp */ created: Date; /** Provider type */ provider: PaymentProviderType; /** Raw event data */ raw: unknown; } /** * Webhook handler */ type WebhookHandler = (event: WebhookEvent) => void | Promise; /** * Payment provider interface */ interface PaymentProvider { /** Provider type */ readonly type: PaymentProviderType; createCustomer(options: CreateCustomerOptions): Promise; getCustomer(customerId: string): Promise; updateCustomer(customerId: string, options: Partial): Promise; deleteCustomer(customerId: string): Promise; createCheckout(options: CreateCheckoutOptions): Promise; getCheckout(sessionId: string): Promise; createSubscription(options: CreateSubscriptionOptions): Promise; getSubscription(subscriptionId: string): Promise; updateSubscription(subscriptionId: string, options: UpdateSubscriptionOptions): Promise; cancelSubscription(subscriptionId: string, cancelAtPeriodEnd?: boolean): Promise; listSubscriptions(customerId: string): Promise; createPortalSession(options: CreatePortalOptions): Promise; verifyWebhook(payload: string | Uint8Array, signature: string): Promise; getProduct?(productId: string): Promise; getPrice?(priceId: string): Promise; listPrices?(productId?: string): Promise; } /** * Stripe provider config */ interface StripeProviderConfig { /** Stripe secret key */ secretKey: string; /** Webhook signing secret */ webhookSecret?: string | undefined; /** API version */ apiVersion?: string | undefined; } /** * Paddle provider config */ interface PaddleProviderConfig { /** Paddle API key */ apiKey: string; /** Paddle environment */ environment?: "sandbox" | "production" | undefined; /** Webhook secret key */ webhookSecret?: string | undefined; /** Seller ID */ sellerId?: string | undefined; } /** * Payment service config */ interface PaymentServiceConfig { /** Payment provider */ provider: PaymentProvider; /** Enable debug logging */ debug?: boolean | undefined; } /** * Payment error */ declare class PaymentError extends Error { readonly code: string; readonly cause?: unknown | undefined; constructor(message: string, code: string, cause?: unknown | undefined); } /** * Common payment error codes */ declare const PaymentErrorCodes: { readonly INVALID_CONFIG: "INVALID_CONFIG"; readonly CUSTOMER_NOT_FOUND: "CUSTOMER_NOT_FOUND"; readonly SUBSCRIPTION_NOT_FOUND: "SUBSCRIPTION_NOT_FOUND"; readonly CHECKOUT_FAILED: "CHECKOUT_FAILED"; readonly PAYMENT_FAILED: "PAYMENT_FAILED"; readonly WEBHOOK_VERIFICATION_FAILED: "WEBHOOK_VERIFICATION_FAILED"; readonly API_ERROR: "API_ERROR"; readonly RATE_LIMITED: "RATE_LIMITED"; }; export { type Address, type BillingInterval, type CheckoutLineItem, type CheckoutSession, type CreateCheckoutOptions, type CreateCustomerOptions, type CreatePortalOptions, type CreateSubscriptionOptions, type CurrencyCode, type Customer, type Invoice, type PaddleProviderConfig, PaymentError, PaymentErrorCodes, type PaymentIntent, type PaymentProvider, type PaymentProviderType, type PaymentServiceConfig, type PaymentStatus, type PortalSession, type Price, type Product, type StripeProviderConfig, type Subscription, type SubscriptionStatus, type UpdateSubscriptionOptions, type WebhookEvent, type WebhookEventType, type WebhookHandler };