import { ChargeRequest, RefundRequest, ProviderFactory } from './index.js';
import '@platform-modules/db';
import '@platform-modules/ledger';

type SumitCredentials = {
    CompanyID: number;
    APIKey: string;
};
type SumitVendorChargeItem = {
    companyId: number;
    apiKey: string;
    itemName: string;
    /** Integer minor-units (agorot). */
    amountMinor: number;
};
type SumitCreds = {
    platformCompanyId: number;
    platformApiKey: string;
    webhookSecret: string;
    baseUrl?: string;
    fetch?: typeof fetch;
};
type SumitRefundVendorItem = {
    companyId: number;
    apiKey: string;
    amountMinor: number;
    documentId: number;
};
type SumitRefundExtras = {
    customerName?: string;
    vendorItems: SumitRefundVendorItem[];
    platformDocumentId: number;
    platformAmountMinor: number;
};
type SumitRefundRequest = RefundRequest & {
    sumit?: SumitRefundExtras;
};
/**
 * Structured, charge-time-only Sumit inputs. These ride a TYPED request
 * extension — never `metadata` (which is scalar round-trip only): the
 * single-use card token, the multivendor split, and customer identity are
 * provider-shaped and never round-tripped through a webhook.
 */
type SumitChargeExtras = {
    singleUseToken: string;
    vendorItems?: SumitVendorChargeItem[];
    /** Integer minor-units; defaults to charge total minus the vendor legs. */
    platformAmountMinor?: number;
    platformItemName?: string;
    customerName?: string;
    customerEmail?: string;
    customerPhone?: string;
};
type SumitChargeRequest = ChargeRequest & {
    sumit?: SumitChargeExtras;
};
declare class SumitApiError extends Error {
    readonly path: string;
    readonly status: number;
    readonly sumitMessage: string;
    readonly raw?: unknown | undefined;
    constructor(path: string, status: number, sumitMessage: string, raw?: unknown | undefined);
}
/** One refund leg that completed before the failure (for precise resume). */
type SumitRefundLegOutcome = {
    scope: 'vendor' | 'platform';
    companyId: number;
    amountMinor: number;
    externalId: string;
    paymentId: string;
};
/**
 * A multi-leg Sumit refund failed PART-WAY. Sumit does NOT dedup negative charges
 * server-side (idempotency is the caller's DB-layer job — see the sumit-api skill),
 * so a blind FULL retry would re-issue the `completedLegs` and double-refund. This
 * structured error carries exactly which legs already succeeded so the caller resumes
 * the REMAINING legs only. `cause` is the underlying leg failure.
 */
declare class SumitRefundPartialFailureError extends Error {
    readonly chargeKey: string;
    readonly refundId: string;
    readonly completedLegs: readonly SumitRefundLegOutcome[];
    readonly cause: unknown;
    readonly name = "SumitRefundPartialFailureError";
    readonly code: "SUMIT_REFUND_PARTIAL_FAILURE";
    constructor(chargeKey: string, refundId: string, completedLegs: readonly SumitRefundLegOutcome[], cause: unknown);
}
/** Structural guard — cross-package `instanceof` is unreliable under dedup (CLAUDE.md §6). */
declare function isSumitRefundPartialFailureError(err: unknown): err is SumitRefundPartialFailureError;
/** Convert a major-unit decimal string/number to integer minor-units without float multiply. */
declare function majorDecimalToMinorUnits(value: string | number): number;
/** Convert integer minor-units to Sumit UnitPrice decimal without float division. */
declare function minorUnitsToUnitPrice(minor: number): number;
declare const sumit: ProviderFactory;

export { SumitApiError, type SumitChargeExtras, type SumitChargeRequest, type SumitCredentials, type SumitCreds, type SumitRefundExtras, type SumitRefundLegOutcome, SumitRefundPartialFailureError, type SumitRefundRequest, type SumitRefundVendorItem, type SumitVendorChargeItem, isSumitRefundPartialFailureError, majorDecimalToMinorUnits, minorUnitsToUnitPrice, sumit };
