/** * Versioned hosted-payment provider boundary. * * ForgeZero never accepts payment credentials. A browser is redirected to (or * embeds) the provider-hosted setup URL and only opaque provider references * return. Concrete HTTP/auth implementations are injected by the API so this * package contains no platform credential source and no vendor secret. */ import { type FailureKind, type InvokeContext, type ProviderDefinition } from './index'; export declare const PAYMENT_PROVIDER_KEYS: readonly ["stripe:v1", "paypal:v1", "razorpay:v1"]; export type PaymentProviderKey = (typeof PAYMENT_PROVIDER_KEYS)[number]; /** * Persisted operator configuration for the three supported billing providers. * Secrets are deliberately separate write-only fields; the API stores them in * the hidden operational Vault and returns only `hasSecret` to administrators. */ export declare const paymentProviderDefinitions: readonly [{ readonly id: "stripe"; readonly label: "Stripe"; readonly multiInstance: true; readonly config: { readonly type: "object"; readonly properties: { readonly providerApiVersion: { readonly type: "string"; readonly minLength: 4; readonly maxLength: 64; }; readonly mode: { readonly type: "string"; readonly enum: readonly ["test", "live"]; }; }; readonly required: readonly ["providerApiVersion", "mode"]; readonly additionalProperties: false; }; readonly credentials: { readonly type: "object"; readonly properties: { readonly secretKey: { readonly type: "string"; readonly minLength: 16; readonly maxLength: 512; readonly writeOnly: true; }; readonly webhookSecret: { readonly type: "string"; readonly minLength: 16; readonly maxLength: 512; readonly writeOnly: true; }; }; readonly required: readonly ["secretKey", "webhookSecret"]; readonly additionalProperties: false; }; readonly methods: {}; }, { readonly id: "paypal"; readonly label: "PayPal"; readonly multiInstance: true; readonly config: { readonly type: "object"; readonly properties: { readonly providerApiVersion: { readonly type: "string"; readonly minLength: 2; readonly maxLength: 64; }; readonly environment: { readonly type: "string"; readonly enum: readonly ["sandbox", "live"]; }; }; readonly required: readonly ["providerApiVersion", "environment"]; readonly additionalProperties: false; }; readonly credentials: { readonly type: "object"; readonly properties: { readonly clientId: { readonly type: "string"; readonly minLength: 10; readonly maxLength: 512; readonly writeOnly: true; }; readonly clientSecret: { readonly type: "string"; readonly minLength: 10; readonly maxLength: 512; readonly writeOnly: true; }; readonly webhookId: { readonly type: "string"; readonly minLength: 4; readonly maxLength: 256; readonly writeOnly: true; }; }; readonly required: readonly ["clientId", "clientSecret", "webhookId"]; readonly additionalProperties: false; }; readonly methods: {}; }, { readonly id: "razorpay"; readonly label: "Razorpay"; readonly multiInstance: true; readonly config: { readonly type: "object"; readonly properties: { readonly providerApiVersion: { readonly type: "string"; readonly minLength: 2; readonly maxLength: 64; }; readonly mode: { readonly type: "string"; readonly enum: readonly ["test", "live"]; }; }; readonly required: readonly ["providerApiVersion", "mode"]; readonly additionalProperties: false; }; readonly credentials: { readonly type: "object"; readonly properties: { readonly keyId: { readonly type: "string"; readonly minLength: 8; readonly maxLength: 256; readonly writeOnly: true; }; readonly keySecret: { readonly type: "string"; readonly minLength: 8; readonly maxLength: 512; readonly writeOnly: true; }; readonly webhookSecret: { readonly type: "string"; readonly minLength: 8; readonly maxLength: 512; readonly writeOnly: true; }; }; readonly required: readonly ["keyId", "keySecret", "webhookSecret"]; readonly additionalProperties: false; }; readonly methods: {}; }]; export type PaymentCurrency = 'USD'; export interface HostedSetupRequest { tenantKey: string; returnUrl: string; cancelUrl: string; idempotencyKey: string; providerCustomerReference?: string; } export interface HostedSetupResult { hostedUrl: string; setupReference: string; expiresAtTs: number; } export interface HostedSetupCompletionRequest { tenantKey: string; setupReference: string; idempotencyKey: string; } /** Only opaque references and safe display metadata cross back into ForgeZero. */ export interface HostedSetupCompletionResult { providerCustomerReference?: string; providerPaymentMethodReference: string; display: { type: 'card' | 'bank' | 'upi' | 'paypal' | 'other'; brand?: string; last4?: string; expiresMonth?: number; expiresYear?: number; label?: string; }; } export interface CustomerRequest { tenantKey: string; email: string; idempotencyKey: string; } export interface ChargeRequest { tenantKey: string; invoiceKey: string; providerCustomerReference: string; providerPaymentMethodReference: string; amountMinor: string; currency: PaymentCurrency; idempotencyKey: string; } export interface ChargeResult { providerAttemptReference: string; status: 'succeeded' | 'failed' | 'pending'; failureCode?: string; } export interface VerifiedPaymentWebhook { providerEventId: string; eventType: string; resourceReference: string; /** Normalized terminal meaning; provider-specific event names never leak into settlement logic. */ status: 'succeeded' | 'failed' | 'pending'; failureCode?: string; occurredAtTs: number; } export interface ReconciliationResult { providerAttemptReference: string; status: 'succeeded' | 'failed' | 'pending' | 'not_found'; failureCode?: string; } export interface PaymentProviderDriver { createHostedSetup(input: HostedSetupRequest): Promise; completeHostedSetup(input: HostedSetupCompletionRequest): Promise; createCustomer(input: CustomerRequest): Promise<{ providerCustomerReference: string; }>; charge(input: ChargeRequest): Promise; detachPaymentMethod(input: { tenantKey: string; providerPaymentMethodReference: string; idempotencyKey: string; }): Promise; verifyWebhook(input: { rawBody: Uint8Array; signatureHeaders: Readonly>; }): Promise; reconcile(input: { tenantKey: string; providerAttemptReference: string; }): Promise; } export declare const billingService: import("./index").ServiceDefinition<"billing", { createHostedSetup: import("./index").ServiceMethodContract; completeHostedSetup: import("./index").ServiceMethodContract; createCustomer: import("./index").ServiceMethodContract; charge: import("./index").ServiceMethodContract; detachPaymentMethod: import("./index").ServiceMethodContract<{ tenantKey: string; providerPaymentMethodReference: string; idempotencyKey: string; }, void>; verifyWebhook: import("./index").ServiceMethodContract<{ rawBody: Uint8Array; signatureHeaders: Readonly>; }, VerifiedPaymentWebhook>; reconcile: import("./index").ServiceMethodContract<{ tenantKey: string; providerAttemptReference: string; }, ReconciliationResult>; }>; export interface VersionedPaymentProvider extends PaymentProviderDriver { readonly key: PaymentProviderKey; readonly provider: 'stripe' | 'paypal' | 'razorpay'; readonly contractVersion: 'v1'; /** Provider API version selected by operator config and persisted per attempt. */ readonly providerApiVersion: string; } /** * Bind a reviewed provider/version identity to one concrete driver. Legacy API * branches remain separate configured adapters rather than conditionals hidden * inside the current implementation. */ export declare function paymentProviderAdapter(args: { key: PaymentProviderKey; providerApiVersion: string; driver: PaymentProviderDriver; }): VersionedPaymentProvider; /** * Build a registry-compatible provider with one explicit current/legacy API * branch. Vendor HTTP code stays outside the service and Vault remains injected. */ export declare function definePaymentProvider(args: { id: 'stripe' | 'paypal' | 'razorpay'; label: string; version: string; driver: { createHostedSetup(context: InvokeContext, input: HostedSetupRequest): Promise; completeHostedSetup(context: InvokeContext, input: HostedSetupCompletionRequest): Promise; createCustomer(context: InvokeContext, input: CustomerRequest): Promise<{ providerCustomerReference: string; }>; charge(context: InvokeContext, input: ChargeRequest): Promise; detachPaymentMethod(context: InvokeContext, input: { tenantKey: string; providerPaymentMethodReference: string; idempotencyKey: string; }): Promise; verifyWebhook(context: InvokeContext, input: { rawBody: Uint8Array; signatureHeaders: Readonly>; }): Promise; reconcile(context: InvokeContext, input: { tenantKey: string; providerAttemptReference: string; }): Promise; }; config: Record; credentials: Record; classify?: (error: unknown) => FailureKind; }): ProviderDefinition;