import type { PaymentProvider, PaymentWebhookEndpointManager } from "../core/payment"; import type { PublishedStorefront, StorefrontCartLineInput } from "../core/storefront"; import type { CommerceDb } from "./queries"; export type SavePaymentInstallationInput = { config?: Record; id?: string; label: string; provider: string; secretAlias: string; webhookSecretAlias: string; }; export type PaymentInstallation = { config: Record; created_at: Date; id: string; label: string; owner_key: string; provider: string; secret_alias: string; status: string; updated_at: Date; webhook_secret_alias: string; }; export type PaymentInstallationPosture = PaymentInstallation & { platformEnabled: boolean; ready: boolean; secretAvailable: boolean; webhookSecretAvailable: boolean; }; export type PaymentWebhookReceipt = { appliedAt: Date | null; attemptCount: number; eventType: string; id: string; installationId: string; lastError: string | null; ownerKey: string; providerEventId: string; receivedAt: Date; resultStatus: string | null; status: string; updatedAt: Date; }; export type SavePaymentWebhookConnectionInput = { enabledEvents: string[]; installationId: string; maxApplyLatencyMs?: number; maxFailureRateBps?: number; url: string; }; export declare const storefrontPaymentWebhookReceiptSelection: () => { appliedAt: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").PgTimestampBuilder, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "object date"; data: Date; driverParam: string; notNull: false; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; attemptCount: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetHasDefault>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "number int32"; data: number; driverParam: string | number; notNull: true; hasDefault: true; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; eventType: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetNotNull>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; id: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetIsPrimaryKey>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string uuid"; data: string; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; installationId: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetNotNull, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string uuid"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; lastError: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").PgTextBuilder<[string, ...string[]]>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string"; data: string; driverParam: string; notNull: false; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; ownerKey: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetNotNull>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; providerEventId: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetNotNull>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; receivedAt: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetHasDefault>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "object date"; data: Date; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; resultStatus: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").PgVarcharBuilder<[string, ...string[]]>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string"; data: string; driverParam: string; notNull: false; hasDefault: false; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; status: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetHasDefault>>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "string"; data: string; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; updatedAt: import("drizzle-orm/pg-core").PgBuildColumn<"commerce_payment_webhook_receipts", import("drizzle-orm/pg-core").SetHasDefault>, { name: string; tableName: "commerce_payment_webhook_receipts"; dataType: "object date"; data: Date; driverParam: string; notNull: true; hasDefault: true; isPrimaryKey: false; isAutoincrement: false; hasRuntimeDefault: false; enumValues: undefined; identity: undefined; generated: undefined; }>; }; export declare class StorefrontPaymentError extends Error { readonly code: "checkout_identity_conflict" | "checkout_not_found" | "checkout_provider_mismatch" | "credential_unavailable" | "installation_disabled" | "installation_not_found" | "payment_amount_mismatch" | "payment_event_invalid" | "payments_disabled" | "webhook_connection_not_found" | "webhook_connection_invalid" | "webhook_canary_failed" | "webhook_inspection_disabled" | "webhook_incident_not_found" | "webhook_management_disabled" | "webhook_management_unavailable" | "webhook_reconciliation_disabled" | "webhook_repair_unavailable"; constructor(code: "checkout_identity_conflict" | "checkout_not_found" | "checkout_provider_mismatch" | "credential_unavailable" | "installation_disabled" | "installation_not_found" | "payment_amount_mismatch" | "payment_event_invalid" | "payments_disabled" | "webhook_connection_not_found" | "webhook_connection_invalid" | "webhook_canary_failed" | "webhook_inspection_disabled" | "webhook_incident_not_found" | "webhook_management_disabled" | "webhook_management_unavailable" | "webhook_reconciliation_disabled" | "webhook_repair_unavailable"); } export declare const storefrontCheckoutRequestDigest: (value: unknown) => string; export declare const createStorefrontPaymentService: (options: { credentialAvailable: (ownerKey: string, alias: string) => Promise; db: CommerceDb; enabled?: boolean; paymentFor: (installation: PaymentInstallation) => Promise; now?: () => Date; storeWebhookSigningSecret?: (ownerKey: string, alias: string, value: string) => Promise; verifyWebhookSigningSecret?: (installation: PaymentInstallation) => Promise; webhookEndpointFor?: (installation: PaymentInstallation) => Promise; webhookInspectionEnabled?: boolean; webhookManagementEnabled?: boolean; webhookReconciliationEnabled?: boolean; webhookReconciliationIntervalMs?: number; webhookReconciliationLeaseMs?: number; }) => { acknowledgeWebhookConnectionIncident: (ownerKey: string, installationId: string) => Promise<{ canary_status: string; created_at: Date; desired_events: string[]; desired_url: string; installation_id: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_error: string | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; owner_key: string; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; provider_status: string | null; status: string; updated_at: Date; }>; checkout: (input: { cancelUrl: string; idempotencyKey: string; installationId: string; lines: StorefrontCartLineInput[]; orderAccessToken: string; ownerKey: string; storefront: PublishedStorefront; successUrl: string; }) => Promise<{ checkout: import("..").CheckoutResult; checkoutIntentId: string; quote: import("..").StorefrontCartQuote; }>; installationEnabled: (ownerKey: string, installationId?: string) => Promise; listFleet: () => Promise; listOwner: (ownerKey: string) => Promise; listWebhookConnectionEvents: (ownerKey?: string, limit?: number) => Promise<{ created_at: Date; id: string; installation_id: string; kind: string; metadata: Record; owner_key: string; }[]>; inspectWebhookConnection: (ownerKey: string, installationId: string) => Promise<{ connection: { created_at: Date; status: string; owner_key: string; updated_at: Date; last_error: string | null; installation_id: string; provider_status: string | null; canary_status: string; desired_events: string[]; desired_url: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; }; drift: string[]; }>; listWebhookConnections: (ownerKey?: string) => Promise<{ deliverySlo24h: { applied: number; failed: number; failureRateBps: number; p95ApplyLatencyMs: number | null; total: number; violations: string[]; }; canary_status: string; created_at: Date; desired_events: string[]; desired_url: string; installation_id: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_error: string | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; owner_key: string; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; provider_status: string | null; status: string; updated_at: Date; }[]>; processWebhook: (input: { installationId: string; ownerKey: string; payload: string; signature: string; }) => Promise<{ duplicate: boolean; status: string; }>; listWebhookReceipts: (ownerKey?: string, limit?: number) => Promise; paymentWebhookReceiptTotals: (ownerKey?: string) => Promise & { total: number; }>; paymentInstallationPosture: (ownerKey?: string) => Promise; retryWebhookReceipt: (ownerKey: string, receiptId: string) => Promise<{ duplicate: boolean; status: string; }>; repairWebhookConnection: (ownerKey: string, installationId: string) => Promise<{ connection: { created_at: Date; status: string; owner_key: string; updated_at: Date; last_error: string | null; installation_id: string; provider_status: string | null; canary_status: string; desired_events: string[]; desired_url: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; }; drift: string[]; }>; registerWebhookConnection: (ownerKey: string, installationId: string) => Promise<{ connection: { created_at: Date; status: string; owner_key: string; updated_at: Date; last_error: string | null; installation_id: string; provider_status: string | null; canary_status: string; desired_events: string[]; desired_url: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; }; drift: string[]; }>; runWebhookSigningSecretCanary: (ownerKey: string, installationId: string) => Promise<{ canary_status: string; created_at: Date; desired_events: string[]; desired_url: string; installation_id: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_error: string | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; owner_key: string; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; provider_status: string | null; status: string; updated_at: Date; }>; runWebhookConnectionReconciliationCycle: (workerId: string, limit?: number) => Promise<{ incidents: number; reconciled: number; }>; saveWebhookConnection: (ownerKey: string, input: SavePaymentWebhookConnectionInput) => Promise<{ created_at: Date; status: string; owner_key: string; updated_at: Date; last_error: string | null; installation_id: string; provider_status: string | null; canary_status: string; desired_events: string[]; desired_url: string; incident_acknowledged_at: Date | null; incident_kind: string | null; incident_opened_at: Date | null; incident_resolved_at: Date | null; incident_status: string; last_canary_at: Date | null; last_delivery_at: Date | null; last_inspected_at: Date | null; last_reconciled_at: Date | null; last_repair_at: Date | null; last_repair_status: string | null; livemode: boolean | null; max_apply_latency_ms: number; max_failure_rate_bps: number; observed_events: string[] | null; observed_url: string | null; reconciliation_attempt_count: number; reconciliation_healthy_count: number; reconciliation_lease_expires_at: Date | null; reconciliation_worker_id: string | null; next_reconciliation_at: Date; provider_endpoint_id: string | null; } | undefined>; saveInstallation: (ownerKey: string, input: SavePaymentInstallationInput) => Promise<{ id: string; created_at: Date; status: string; label: string; config: Record; owner_key: string; updated_at: Date; provider: string; secret_alias: string; webhook_secret_alias: string; } | undefined>; setInstallationEnabled: (ownerKey: string, installationId: string, active: boolean) => Promise<{ config: Record; created_at: Date; id: string; label: string; owner_key: string; provider: string; secret_alias: string; status: string; updated_at: Date; webhook_secret_alias: string; } | undefined>; }; export type StorefrontPaymentService = ReturnType;