import { PaymentProvider, StripeProviderConfig, CreateCustomerOptions, Customer, CreateCheckoutOptions, CheckoutSession, CreateSubscriptionOptions, Subscription, UpdateSubscriptionOptions, CreatePortalOptions, PortalSession, Product, Price, WebhookEvent } from '../types.js'; import '@parsrun/types'; /** * @parsrun/payments - Stripe Provider * Edge-compatible Stripe provider using fetch API */ /** * Stripe Payment Provider * Edge-compatible using fetch API * * @example * ```typescript * const stripe = new StripeProvider({ * secretKey: process.env.STRIPE_SECRET_KEY, * webhookSecret: process.env.STRIPE_WEBHOOK_SECRET, * }); * * const checkout = await stripe.createCheckout({ * lineItems: [{ priceId: 'price_xxx', quantity: 1 }], * successUrl: 'https://example.com/success', * cancelUrl: 'https://example.com/cancel', * mode: 'subscription', * }); * ``` */ declare class StripeProvider implements PaymentProvider { readonly type: "stripe"; private secretKey; private webhookSecret; private baseUrl; private apiVersion; constructor(config: StripeProviderConfig); private request; private encodeFormData; createCustomer(options: CreateCustomerOptions): Promise; getCustomer(customerId: string): Promise; updateCustomer(customerId: string, options: Partial): Promise; deleteCustomer(customerId: string): Promise; private mapCustomer; createCheckout(options: CreateCheckoutOptions): Promise; getCheckout(sessionId: string): Promise; private mapCheckoutSession; createSubscription(options: CreateSubscriptionOptions): Promise; getSubscription(subscriptionId: string): Promise; updateSubscription(subscriptionId: string, options: UpdateSubscriptionOptions): Promise; cancelSubscription(subscriptionId: string, cancelAtPeriodEnd?: boolean): Promise; listSubscriptions(customerId: string): Promise; private mapSubscription; createPortalSession(options: CreatePortalOptions): Promise; getProduct(productId: string): Promise; getPrice(priceId: string): Promise; listPrices(productId?: string): Promise; private mapProduct; private mapPrice; verifyWebhook(payload: string | Uint8Array, signature: string): Promise; private computeHmacSignature; private secureCompare; private mapEventType; /** * Report usage for metered billing * * @example * ```typescript * // Report 100 API calls for a subscription item * await stripe.reportUsage({ * subscriptionItemId: "si_xxx", * quantity: 100, * action: "increment", // or "set" to replace * }); * ``` */ reportUsage(record: { subscriptionItemId: string; quantity: number; timestamp?: Date; action?: "increment" | "set"; idempotencyKey?: string; }): Promise; /** * Report multiple usage records (batch) * Note: Stripe doesn't have a batch API, so this is sequential */ reportUsageBatch(records: Array<{ subscriptionItemId: string; quantity: number; timestamp?: Date; action?: "increment" | "set"; idempotencyKey?: string; }>): Promise; /** * Get subscription item ID for a subscription and price */ getSubscriptionItemId(subscriptionId: string, priceId: string): Promise; /** * Get usage records for a subscription item */ getUsageRecords(subscriptionItemId: string, options?: { startingAfter?: string; endingBefore?: string; limit?: number; }): Promise<{ data: Array<{ id: string; quantity: number; timestamp: Date; subscriptionItem: string; }>; hasMore: boolean; }>; /** * Get current period usage total for a subscription item */ getCurrentUsage(subscriptionItemId: string): Promise; } /** * Create a Stripe provider */ declare function createStripeProvider(config: StripeProviderConfig): StripeProvider; export { StripeProvider, createStripeProvider };