import { onCharge, onCheckout, onInvoice, onPaymentIntent, onSubscription, processWebhook } from './billable/webhook'; import { stripe } from './drivers/stripe'; import type { UserModel } from '@stacksjs/orm'; import type Stripe from 'stripe'; /** * Create a one-time charge */ export declare function charge(user: UserModel, amount: number, paymentMethod: string, options?: Partial): Promise; /** * Create a payment intent (for client-side confirmation) */ export declare function createPayment(user: UserModel, amount: number, options?: Partial): Promise; /** * Refund a payment */ export declare function refund(paymentIntentId: string, amount?: number, options?: Partial): Promise; /** * Create a Stripe Checkout session */ export declare function checkout(user: UserModel, lineItems: Stripe.Checkout.SessionCreateParams.LineItem[], options?: Partial): Promise; /** * Create a subscription checkout session */ export declare function subscriptionCheckout(user: UserModel, priceId: string, options?: Partial): Promise; /** * Create a new subscription */ export declare function subscribe(user: UserModel, lookupKey: string, options?: Partial): Promise; /** * Cancel a subscription */ export declare function cancelSubscription(subscriptionId: string, immediately?: boolean): Promise; /** * Check if user has an active subscription */ export declare function hasActiveSubscription(user: UserModel, type?: string): Promise; /** * Update subscription to a new price */ export declare function changeSubscription(user: UserModel, newLookupKey: string, type?: string): Promise; /** * Get or create a Stripe customer for a user */ export declare function getOrCreateCustomer(user: UserModel, options?: Stripe.CustomerCreateParams): Promise; /** * Update customer details */ export declare function updateCustomer(user: UserModel, options: Stripe.CustomerCreateParams): Promise; /** * Delete a customer from Stripe */ export declare function deleteCustomer(user: UserModel): Promise; /** * Add a payment method to a customer */ export declare function addPaymentMethod(user: UserModel, paymentMethodId: string): Promise; /** * Set the default payment method */ export declare function setDefaultPaymentMethod(user: UserModel, paymentMethodId: string): Promise; /** * Remove a payment method. * Accepts either a numeric database ID or a Stripe payment method ID string (pm_xxx). */ export declare function removePaymentMethod(user: UserModel, paymentMethodId: string | number): Promise; /** * Create a setup intent for adding payment methods */ export declare function createSetupIntent(user: UserModel, options?: Partial): Promise; /** * Get user's invoices */ export declare function getInvoices(user: UserModel): Promise>; /** * Create an invoice */ export declare function createInvoice(customerId: string, options?: Partial): Promise; /** * Pay an invoice */ export declare function payInvoice(invoiceId: string): Promise; /** * Create a product with a price */ export declare function createProduct(name: string, price: number, options?: { currency?: string interval?: 'day' | 'week' | 'month' | 'year' description?: string metadata?: Stripe.MetadataParam }): Promise<{ product: Stripe.Product, price: Stripe.Price }>; /** * Get a price by lookup key */ export declare function getPrice(lookupKey: string): Promise; /** * List all products */ export declare function listProducts(options?: Stripe.ProductListParams): Promise>; /** * Create a discount coupon */ export declare function createCoupon(options: { percentOff?: number amountOff?: number currency?: string duration?: 'forever' | 'once' | 'repeating' durationInMonths?: number name?: string maxRedemptions?: number }): Promise; /** * Create a promotion code from a coupon */ export declare function createPromoCode(couponId: string, code: string, options?: Partial): Promise; /** * Validate a promo code */ export declare function validatePromoCode(code: string): Promise; /** * Format amount for display. * * Currency defaults to the project's configured payment currency * (`config.payment.currency` / `STRIPE_CURRENCY`), falling back to USD only * when nothing else is set. Locale follows the same pattern via * `config.app.locale` so EU merchants see €1.234,56 not $1,234.56. */ export declare function formatAmount(amount: number, currency?: string): string; /** * Convert dollars to cents */ export declare function toCents(dollars: number): number; /** * Convert cents to dollars */ export declare function toDollars(cents: number): number; // ============================================================================= // Payment Facade Object // ============================================================================= export declare const Payment: { charge: typeof charge; createPayment: typeof createPayment; refund: typeof refund; checkout: typeof checkout; subscriptionCheckout: typeof subscriptionCheckout; subscribe: typeof subscribe; cancelSubscription: typeof cancelSubscription; hasActiveSubscription: typeof hasActiveSubscription; changeSubscription: typeof changeSubscription; getOrCreateCustomer: typeof getOrCreateCustomer; updateCustomer: typeof updateCustomer; deleteCustomer: typeof deleteCustomer; addPaymentMethod: typeof addPaymentMethod; setDefaultPaymentMethod: typeof setDefaultPaymentMethod; removePaymentMethod: typeof removePaymentMethod; createSetupIntent: typeof createSetupIntent; getInvoices: typeof getInvoices; createInvoice: typeof createInvoice; payInvoice: typeof payInvoice; createProduct: typeof createProduct; getPrice: typeof getPrice; listProducts: typeof listProducts; createCoupon: typeof createCoupon; createPromoCode: typeof createPromoCode; validatePromoCode: typeof validatePromoCode; formatAmount: typeof formatAmount; toCents: typeof toCents; toDollars: typeof toDollars; webhook: unknown; onPaymentIntent: typeof onPaymentIntent; onSubscription: typeof onSubscription; onInvoice: typeof onInvoice; onCheckout: typeof onCheckout; onCharge: typeof onCharge; processWebhook: typeof processWebhook; stripe: typeof stripe; customer: unknown; subscription: unknown; invoice: unknown; paymentMethod: unknown; product: unknown; price: unknown; coupon: unknown }; export default Payment;