@delopay/sdk 0.104.0 → 0.105.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-S22IPUCK.js → chunk-IAZ4NPT2.js} +39 -1
- package/dist/chunk-IAZ4NPT2.js.map +1 -0
- package/dist/index.cjs +38 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +370 -1
- package/dist/index.d.ts +370 -1
- package/dist/index.js +1 -1
- package/dist/internal.cjs +73 -0
- package/dist/internal.cjs.map +1 -1
- package/dist/internal.d.cts +27 -3
- package/dist/internal.d.ts +27 -3
- package/dist/internal.js +36 -1
- package/dist/internal.js.map +1 -1
- package/package.json +1 -1
- package/dist/chunk-S22IPUCK.js.map +0 -1
package/dist/internal.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/internal.ts","../src/error.ts","../src/resources/apiKeys.ts","../src/resources/authentication.ts","../src/resources/billing.ts","../src/resources/blocklist.ts","../src/resources/connectors.ts","../src/resources/customers.ts","../src/resources/disputes.ts","../src/resources/ephemeralKeys.ts","../src/resources/events.ts","../src/resources/fees.ts","../src/resources/mandates.ts","../src/resources/merchantAccounts.ts","../src/resources/paymentLinks.ts","../src/resources/paymentMethods.ts","../src/resources/payments.ts","../src/resources/payouts.ts","../src/resources/poll.ts","../src/resources/profileAcquirers.ts","../src/resources/profiles.ts","../src/resources/projects.ts","../src/resources/refunds.ts","../src/resources/relay.ts","../src/resources/routing.ts","../src/resources/search.ts","../src/resources/shops.ts","../src/resources/stripeConnect.ts","../src/resources/threeDsRules.ts","../src/resources/users.ts","../src/resources/verification.ts","../src/resources/webhooks.ts","../src/resources/analytics.ts","../src/resources/analyticsDashboard.ts","../src/resources/cards.ts","../src/resources/export.ts","../src/resources/featureMatrix.ts","../src/resources/files.ts","../src/resources/forex.ts","../src/resources/regions.ts","../src/resources/availabilityOverrides.ts","../src/resources/subscriptions.ts","../src/resources/settlement.ts","../src/resources/operationLimits.ts","../src/resources/risk.ts","../src/client.ts","../src/feeProgram.ts","../src/branding.ts","../src/checkoutSession.ts","../src/nativePanes.ts","../src/internal/resources/admin.ts","../src/internal/resources/adminPortal.ts","../src/internal/resources/auditLogs.ts","../src/internal/resources/cache.ts","../src/internal/resources/cardIssuers.ts","../src/internal/resources/configs.ts","../src/internal/resources/connectorRestrictionRules.ts","../src/internal/resources/connectorRestrictions.ts","../src/internal/resources/gsm.ts","../src/internal/resources/platformBilling.ts","../src/internal/resources/platformFees.ts","../src/internal/client.ts"],"sourcesContent":["/**\n * Internal SDK entry. For DeloPay staff tooling only; merchants import from\n * `'@delopay/sdk'` and never touch this path.\n *\n * Re-exports the full public surface plus the admin/ops-plane resources\n * and `DelopayInternal`, a subclass of `Delopay` that wires the internal\n * resources onto the client.\n *\n * import { DelopayInternal } from '@delopay/sdk/internal';\n * const sdk = new DelopayInternal('', { baseUrl: '/api' });\n * await sdk.admin.signIn({ email, password });\n * await sdk.adminPortal.listCustomers();\n * await sdk.platformFees.list(merchantId);\n *\n * All internal type-only exports come out of this barrel too — they're not\n * exported from `'@delopay/sdk'` directly.\n */\n\nexport * from './index';\nexport { DelopayInternal } from './internal/client';\nexport { Admin } from './internal/resources/admin';\nexport { AdminPortal } from './internal/resources/adminPortal';\nexport { AuditLogs } from './internal/resources/auditLogs';\nexport { Cache } from './internal/resources/cache';\nexport { CardIssuers } from './internal/resources/cardIssuers';\nexport { Configs } from './internal/resources/configs';\nexport { ConnectorRestrictionRules } from './internal/resources/connectorRestrictionRules';\nexport { ConnectorRestrictions } from './internal/resources/connectorRestrictions';\nexport { Gsm } from './internal/resources/gsm';\nexport { PlatformBilling } from './internal/resources/platformBilling';\nexport { PlatformFees } from './internal/resources/platformFees';\nexport type * from './internal/types';\n","/**\n * Error thrown when the Delopay API returns a non-2xx response, or when a\n * timeout or network error occurs.\n *\n * @example\n * ```typescript\n * try {\n * await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * } catch (e) {\n * if (e instanceof DelopayError) {\n * console.error(e.status, e.code, e.requestId, e.message);\n * }\n * }\n * ```\n */\nexport class DelopayError extends Error {\n /** HTTP status code returned by the API, or `0` for timeout/network errors. */\n readonly status: number;\n /** Machine-readable error code returned by the API (e.g. `'HE_00'`). */\n readonly code: string;\n /** Error category (e.g. `'invalid_request'`, `'timeout_error'`). */\n readonly type: string;\n /** Value of the `x-request-id` response header, when present. Include this when contacting support. */\n readonly requestId?: string;\n /**\n * Raw response body (truncated to ~2 KB). Populated when the server returns a\n * non-JSON error body (e.g. an HTML 502 from an upstream proxy) so debugging\n * still has something to go on.\n */\n readonly rawBody?: string;\n /**\n * Structured error context the API attaches under `error.data` for select\n * codes — e.g. `{ retry_after_secs: 248 }` on rate-limit / max-attempt\n * lockouts. Schema is per-code; consult the API reference for the shape.\n */\n readonly data?: Record<string, unknown>;\n\n constructor(\n message: string,\n options: {\n status: number;\n code: string;\n type: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayError';\n this.status = options.status;\n this.code = options.code;\n this.type = options.type;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n if (options.rawBody !== undefined) this.rawBody = options.rawBody;\n if (options.data !== undefined) this.data = options.data;\n }\n}\n\n/**\n * Thrown when the API key is missing, invalid, or revoked (HTTP 401).\n *\n * @example\n * ```typescript\n * if (e instanceof DelopayAuthenticationError) {\n * // Prompt user to re-enter their API key.\n * }\n * ```\n */\nexport class DelopayAuthenticationError extends DelopayError {\n constructor(\n message = 'Invalid API key',\n options?: {\n code?: string;\n type?: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message, {\n status: 401,\n // Default to the generic \"invalid API key\" code, but let callers pass\n // through the server-reported code (e.g. `UR_05` for unverified-email\n // 401s) so they can differentiate between auth failure reasons.\n code: options?.code || 'AUTH_01',\n type: options?.type || 'authentication_error',\n requestId: options?.requestId,\n rawBody: options?.rawBody,\n data: options?.data,\n });\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayAuthenticationError';\n }\n}\n","import type {\n ApiKeyCreateRequest,\n ApiKeyCreateResponse,\n ApiKeyListConstraints,\n ApiKeyResponse,\n ApiKeyUpdateRequest,\n ApiKeyRevokeResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage API keys for a merchant account. */\nexport class ApiKeys {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new API key for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Key creation parameters (name, expiry, etc.).\n * @returns The newly created key including the plaintext secret (shown once only).\n *\n * @example\n * ```typescript\n * const { key_value } = await delopay.apiKeys.create('merch_123', { name: 'Production key' });\n * ```\n */\n async create(merchantId: string, params: ApiKeyCreateRequest): Promise<ApiKeyCreateResponse> {\n return this.request('POST', `/api-keys/${encodeURIComponent(merchantId)}`, { body: params });\n }\n\n /**\n * Retrieve metadata about an API key (does not return the plaintext secret).\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID.\n * @returns The API key metadata.\n */\n async retrieve(merchantId: string, keyId: string): Promise<ApiKeyResponse> {\n return this.request(\n 'GET',\n `/api-keys/${encodeURIComponent(merchantId)}/${encodeURIComponent(keyId)}`,\n );\n }\n\n /**\n * Update an API key's name or expiry.\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to update.\n * @param params - Fields to update.\n * @returns The updated API key metadata.\n */\n async update(\n merchantId: string,\n keyId: string,\n params: ApiKeyUpdateRequest,\n ): Promise<ApiKeyResponse> {\n return this.request(\n 'POST',\n `/api-keys/${encodeURIComponent(merchantId)}/${encodeURIComponent(keyId)}`,\n { body: params },\n );\n }\n\n /**\n * Revoke an API key, immediately invalidating it.\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to revoke.\n * @returns Revocation confirmation.\n */\n async revoke(merchantId: string, keyId: string): Promise<ApiKeyRevokeResponse> {\n return this.request(\n 'DELETE',\n `/api-keys/${encodeURIComponent(merchantId)}/${encodeURIComponent(keyId)}`,\n );\n }\n\n /**\n * List all API keys for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns Array of API key metadata objects.\n */\n async list(merchantId: string): Promise<ApiKeyResponse[]> {\n return this.request('GET', `/api-keys/${encodeURIComponent(merchantId)}/list`);\n }\n\n // --- Profile-scoped (shop-level) API keys ---------------------------------\n //\n // JWT-authenticated routes under `/account/{merchantId}/profile/api-keys`.\n // The caller's shop (business profile) comes from the JWT, never from the\n // request, so a shop-scoped user can only mint/list/manage keys pinned to\n // their own shop. Requires a backend with profile-scoped API key support.\n\n /**\n * Create a new API key pinned to the caller's shop (business profile).\n * `POST /account/{merchantId}/profile/api-keys`\n *\n * @param merchantId - The merchant account ID.\n * @param params - Key creation parameters (name, expiry, etc.).\n * @returns The newly created key including the plaintext secret (shown once\n * only) and the `profile_id` it is pinned to.\n *\n * @example\n * ```typescript\n * const { api_key } = await delopay.apiKeys.createByProfile('merch_123', {\n * name: 'Shop key',\n * expiration: 'never',\n * });\n * ```\n */\n async createByProfile(\n merchantId: string,\n params: ApiKeyCreateRequest,\n ): Promise<ApiKeyCreateResponse> {\n return this.request('POST', `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {\n body: params,\n });\n }\n\n /**\n * List API keys pinned to the caller's shop (business profile) only.\n * `GET /account/{merchantId}/profile/api-keys`\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional pagination constraints (`limit`, `skip`).\n * @returns Array of API key metadata objects belonging to the caller's shop.\n */\n async listByProfile(\n merchantId: string,\n params?: ApiKeyListConstraints,\n ): Promise<ApiKeyResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {\n query: params as Record<string, number | null | undefined>,\n });\n }\n\n /**\n * Retrieve metadata about a shop-pinned API key (does not return the\n * plaintext secret). `GET /account/{merchantId}/profile/api-keys/{keyId}`\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID.\n * @returns The API key metadata.\n */\n async retrieveByProfile(merchantId: string, keyId: string): Promise<ApiKeyResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,\n );\n }\n\n /**\n * Update a shop-pinned API key's name, description, or expiry.\n * `POST /account/{merchantId}/profile/api-keys/{keyId}`\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to update.\n * @param params - Fields to update.\n * @returns The updated API key metadata.\n */\n async updateByProfile(\n merchantId: string,\n keyId: string,\n params: ApiKeyUpdateRequest,\n ): Promise<ApiKeyResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,\n { body: params },\n );\n }\n\n /**\n * Revoke a shop-pinned API key, immediately invalidating it.\n * `DELETE /account/{merchantId}/profile/api-keys/{keyId}`\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to revoke.\n * @returns Revocation confirmation.\n */\n async revokeByProfile(merchantId: string, keyId: string): Promise<ApiKeyRevokeResponse> {\n return this.request(\n 'DELETE',\n `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,\n );\n }\n}\n","import type { AuthenticationCreateRequest, AuthenticationResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Authentication {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: AuthenticationCreateRequest): Promise<AuthenticationResponse> {\n return this.request('POST', '/authentication', { body: params });\n }\n\n async checkEligibility(authId: string): Promise<AuthenticationResponse> {\n return this.request('POST', `/authentication/${encodeURIComponent(authId)}/eligibility`);\n }\n\n async authenticate(\n authId: string,\n params: Record<string, unknown>,\n ): Promise<AuthenticationResponse> {\n return this.request('POST', `/authentication/${encodeURIComponent(authId)}/authenticate`, {\n body: params,\n });\n }\n\n /** Sync authentication status. `POST /authentication/{merchantId}/{authId}/sync` */\n async sync(\n merchantId: string,\n authId: string,\n params?: Record<string, unknown>,\n ): Promise<AuthenticationResponse> {\n return this.request(\n 'POST',\n `/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/sync`,\n { body: params },\n );\n }\n\n /** Redirect after authentication. `POST /authentication/{merchantId}/{authId}/redirect` */\n async redirect(\n merchantId: string,\n authId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request(\n 'POST',\n `/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/redirect`,\n { body: params },\n );\n }\n\n /** Enable authn methods token. `POST /authentication/{authId}/enabled-authn-methods-token` */\n async enabledAuthnMethodsToken(\n authId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request(\n 'POST',\n `/authentication/${encodeURIComponent(authId)}/enabled-authn-methods-token`,\n {\n body: params,\n },\n );\n }\n\n /** Submit eligibility check. `POST /authentication/{authId}/eligibility-check` */\n async eligibilityCheck(\n authId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/authentication/${encodeURIComponent(authId)}/eligibility-check`, {\n body: params,\n });\n }\n}\n","import type {\n BillingProfileResponse,\n BillingSetupRequest,\n BillingSetupResponse,\n BillingCompleteSetupRequest,\n TopupRequest,\n TopupResponse,\n LedgerResponse,\n LedgerListParams,\n BlockedAttemptListResponse,\n BlockedAttemptListParams,\n AutoRechargeUpdateRequest,\n AllocationTransferRequest,\n AllocationTransferResponse,\n AllocationListResponse,\n AllocationResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Manage per-shop prepaid balance allocations transferred from the host merchant treasury. */\nclass BillingAllocations {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Transfer funds from the host merchant treasury into a shop's allocation.\n *\n * @param merchantId - The host merchant account ID.\n * @param params - Transfer details (amount, target profile/shop ID).\n * @returns The allocation transfer result.\n */\n async transferIn(\n merchantId: string,\n params: AllocationTransferRequest,\n ): Promise<AllocationTransferResponse> {\n return this.request(\n 'POST',\n `/billing/${encodeURIComponent(merchantId)}/allocations/transfer-in`,\n { body: params },\n );\n }\n\n /**\n * Transfer funds from a shop's allocation back to the host merchant treasury.\n *\n * @param merchantId - The host merchant account ID.\n * @param params - Transfer details (amount, source profile/shop ID).\n * @returns The allocation transfer result.\n */\n async transferOut(\n merchantId: string,\n params: AllocationTransferRequest,\n ): Promise<AllocationTransferResponse> {\n return this.request(\n 'POST',\n `/billing/${encodeURIComponent(merchantId)}/allocations/transfer-out`,\n {\n body: params,\n },\n );\n }\n\n /**\n * List all shop balance allocations for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns List of shop allocations.\n */\n async list(merchantId: string): Promise<AllocationListResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}/allocations`);\n }\n\n /**\n * Get the balance allocation for a specific shop.\n *\n * @param merchantId - The merchant account ID.\n * @param profileId - The shop (business profile) ID.\n * @returns The shop's balance allocation.\n */\n async get(merchantId: string, profileId: string): Promise<AllocationResponse> {\n return this.request(\n 'GET',\n `/billing/${encodeURIComponent(merchantId)}/allocations/${encodeURIComponent(profileId)}`,\n );\n }\n}\n\n/**\n * Manage prepaid billing balances — top-ups, card setup, auto-recharge, and the balance ledger.\n *\n * Delopay deducts a platform fee from the merchant's prepaid balance on every successful payment.\n * Use these endpoints to fund and monitor that balance.\n */\nexport class Billing {\n /** Per-shop balance allocation management for host merchants. */\n readonly allocations: BillingAllocations;\n\n constructor(private readonly request: RequestFn) {\n this.allocations = new BillingAllocations(request);\n }\n\n /**\n * Retrieve a merchant's billing profile (balance, status, auto-recharge config).\n *\n * @param merchantId - The merchant account ID.\n * @returns The billing profile.\n *\n * @example\n * ```typescript\n * const profile = await delopay.billing.getProfile('merch_123');\n * console.log(profile.balance, profile.status);\n * ```\n */\n async getProfile(merchantId: string): Promise<BillingProfileResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Start a Stripe SetupIntent flow to collect a payment card for auto-recharge.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional setup parameters.\n * @returns The Stripe client secret needed to render the card element.\n */\n async setup(merchantId: string, params?: BillingSetupRequest): Promise<BillingSetupResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/setup`, {\n body: params,\n });\n }\n\n /**\n * Confirm card setup after the Stripe SetupIntent completes on the frontend.\n *\n * @param merchantId - The merchant account ID.\n * @param params - The Stripe SetupIntent ID to confirm.\n * @returns The updated billing profile.\n */\n async completeSetup(\n merchantId: string,\n params: BillingCompleteSetupRequest,\n ): Promise<BillingProfileResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/setup/complete`, {\n body: params,\n });\n }\n\n /**\n * Manually top up a merchant's prepaid balance by charging their saved card.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Top-up amount and currency.\n * @returns The top-up result.\n */\n async topup(merchantId: string, params: TopupRequest): Promise<TopupResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/topup`, {\n body: params,\n });\n }\n\n /**\n * List the balance ledger (credits and debits) for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional pagination parameters.\n * @returns The ledger entries.\n */\n async listLedger(merchantId: string, params?: LedgerListParams): Promise<LedgerResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}/ledger`, {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * List payment attempts that were blocked by the billing suspension gate\n * (account suspended, setup incomplete, or shop allocation suspended).\n *\n * These attempts never created a payment, so they do not appear in the\n * payments list — this is the only way to retrieve them.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional filters (profile, reason, date range) and pagination.\n * @returns The blocked-attempt entries with a total count.\n */\n async listBlockedAttempts(\n merchantId: string,\n params?: BlockedAttemptListParams,\n ): Promise<BlockedAttemptListResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}/blocked-attempts`, {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * Update auto-recharge configuration (threshold, top-up amount, enabled flag).\n *\n * @param merchantId - The merchant account ID.\n * @param params - Auto-recharge settings to update.\n * @returns The updated billing profile.\n */\n async updateAutoRecharge(\n merchantId: string,\n params: AutoRechargeUpdateRequest,\n ): Promise<BillingProfileResponse> {\n return this.request('PATCH', `/billing/${encodeURIComponent(merchantId)}/auto-recharge`, {\n body: params,\n });\n }\n}\n","import type { BlocklistAddRequest, BlocklistResponse, BlocklistDataKind } from '../types';\nimport type { RequestFn } from '../client';\n\nexport interface BlocklistListParams {\n data_kind?: BlocklistDataKind | null;\n limit?: number | null;\n offset?: number | null;\n}\n\nexport interface BlocklistToggleParams {\n status: boolean;\n}\n\nexport class Blocklist {\n constructor(private readonly request: RequestFn) {}\n\n async add(params: BlocklistAddRequest): Promise<BlocklistResponse> {\n return this.request('POST', '/blocklist', { body: params });\n }\n\n async remove(params: BlocklistAddRequest): Promise<BlocklistResponse> {\n return this.request('DELETE', '/blocklist', { body: params });\n }\n\n async list(params?: BlocklistListParams): Promise<BlocklistResponse[]> {\n return this.request('GET', '/blocklist', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n async toggle(params: BlocklistToggleParams): Promise<Record<string, unknown>> {\n return this.request('POST', '/blocklist/toggle', { body: params });\n }\n}\n","import type {\n ConnectorCloneRequest,\n EpayoutsCatalogResponse,\n VaultRoutesApplyRequest,\n VaultRoutesApplyResponse,\n VaultRoutesPreviewRequest,\n VaultRoutesPreviewResponse,\n VaultVerificationResponse,\n VaultVerifyRequest,\n ConnectorCreateRequest,\n ConnectorResponse,\n ConnectorUpdateRequest,\n ConnectorWebhookListResponse,\n ConnectorWebhookRegisterRequest,\n ConnectorWebhookRegisterResponse,\n ConnectorWebhookSyncResponse,\n StripePaymentMethodDomainsRegisterRequest,\n StripePaymentMethodDomainsRegisterResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Connectors {\n constructor(private readonly request: RequestFn) {}\n\n async create(accountId: string, params: ConnectorCreateRequest): Promise<ConnectorResponse> {\n return this.request('POST', `/account/${encodeURIComponent(accountId)}/connectors`, {\n body: params,\n });\n }\n\n /**\n * One connector account.\n *\n * The credential-bearing fields come back `null` here, whatever is stored:\n * `connector_webhook_details`, `connector_wallets_details`,\n * `pm_auth_config` and `additional_merchant_data`. They are dropped rather\n * than masked, because an editor that prefills from this response and\n * PATCHes the field back would otherwise save a mask over a live signing\n * secret. Send those fields only when the operator has typed a new value,\n * and omit them entirely otherwise — an omitted field leaves the stored one\n * alone.\n *\n * This is the retrieve path alone. `create` and `update` echo back what the\n * caller sent, and `clone` returns the *copied* secrets — see that method.\n *\n * `GET /account/{accountId}/connectors/{connectorId}`\n */\n async retrieve(accountId: string, connectorId: string): Promise<ConnectorResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`,\n );\n }\n\n /**\n * The merchant's connector accounts.\n *\n * Never wider than the caller: an API key pinned to one shop lists that\n * shop's connectors only, not every sibling shop's.\n *\n * `GET /account/{accountId}/connectors`\n */\n async list(accountId: string): Promise<ConnectorResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/connectors`);\n }\n\n /**\n * The profile-scoped connector list. The merchant-wide `list()` is\n * merchant-gated and 403s for a profile-entity (shop user) JWT; this\n * variant is scoped server-side to the caller's own profile.\n *\n * `GET /account/{accountId}/profile/connectors`\n */\n async listByProfile(accountId: string): Promise<ConnectorResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/profile/connectors`);\n }\n\n /**\n * The built-in e-Payouts reference catalog — the \"Restore defaults\" source.\n * `GET /account/{accountId}/connectors/epayouts/catalog/defaults`\n */\n async getEpayoutsCatalogDefaults(accountId: string): Promise<EpayoutsCatalogResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(accountId)}/connectors/epayouts/catalog/defaults`,\n );\n }\n\n /**\n * Sweep the merchant's own e-Payouts module and return the rails it\n * actually has enabled. Server-side this makes many upstream calls, so it\n * can take several seconds — show progress.\n *\n * `POST /account/{accountId}/connectors/{connectorId}/epayouts/catalog/sync`\n */\n async syncEpayoutsCatalog(\n accountId: string,\n connectorId: string,\n ): Promise<EpayoutsCatalogResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/epayouts/catalog/sync`,\n );\n }\n\n async update(\n accountId: string,\n connectorId: string,\n params: ConnectorUpdateRequest,\n ): Promise<ConnectorResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`,\n {\n body: params,\n },\n );\n }\n\n /**\n * Remove a connector account.\n *\n * A shop-scoped role may remove a connector of its own shop — the shop is\n * re-checked server-side — so creating processors and removing them are the\n * same rung of access rather than two.\n *\n * `DELETE /account/{accountId}/connectors/{connectorId}`\n */\n async delete(accountId: string, connectorId: string): Promise<ConnectorResponse> {\n return this.request(\n 'DELETE',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`,\n );\n }\n\n /**\n * Clone a connector into another shop (business profile) of the same\n * merchant. `POST /account/{accountId}/connectors/{connectorId}/clone`\n *\n * Credentials are copied server-side, re-encrypted under the same merchant\n * key, so the caller never has to *supply* them — `retrieve` returns `null`\n * for the credential fields, which is what makes a client-side copy\n * impossible in the first place.\n *\n * The response, however, is the unredacted connector: `connector_account_details`\n * is masked, but `connector_webhook_details`, `connector_wallets_details`,\n * `pm_auth_config` and `additional_merchant_data` come back with the copied\n * secrets in them — values this caller never sent. Do not log or echo the\n * response; read `merchant_connector_id` and discard the rest.\n */\n async clone(\n accountId: string,\n connectorId: string,\n params: ConnectorCloneRequest,\n ): Promise<ConnectorResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/clone`,\n { body: params },\n );\n }\n\n // --- Advanced operations (Task 4.8) ---\n\n /**\n * Run the configuration checks for a vault (VGS) connector account:\n * credential validity, write-only Collect scope, reachability, environment\n * coherence, route coverage. Read-only but not cheap — it decrypts the\n * vault's management credential and talks to VGS.\n *\n * `POST /account/{accountId}/connectors/{connectorId}/vault/verify`\n */\n async verifyVault(\n accountId: string,\n connectorId: string,\n params: VaultVerifyRequest,\n ): Promise<VaultVerificationResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/verify`,\n { body: params },\n );\n }\n\n /**\n * Compute the route document the vault SHOULD have and diff it against\n * what exists, without writing anything. The returned fingerprints must be\n * echoed byte for byte on {@link Connectors.applyVaultRoutes}.\n *\n * A router without these endpoints answers 404 — render that as \"this\n * build cannot configure routes\", never as \"there is nothing to change\".\n *\n * `POST /account/{accountId}/connectors/{connectorId}/vault/routes/preview`\n */\n async previewVaultRoutes(\n accountId: string,\n connectorId: string,\n params: VaultRoutesPreviewRequest,\n ): Promise<VaultRoutesPreviewResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/routes/preview`,\n { body: params },\n );\n }\n\n /**\n * Write the routes the merchant just previewed. Both fingerprints come\n * from the preview and are opaque: `expected_current_fingerprint` says the\n * vault has not moved (`null` = \"the preview found no routes\" and is sent\n * as `null`, never omitted), `expected_desired_fingerprint` says the\n * document is still the one on screen. A 409 (`DE_04`) means the vault\n * changed since the preview — nothing was written; preview again.\n *\n * `POST /account/{accountId}/connectors/{connectorId}/vault/routes/apply`\n */\n async applyVaultRoutes(\n accountId: string,\n connectorId: string,\n params: VaultRoutesApplyRequest,\n ): Promise<VaultRoutesApplyResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/routes/apply`,\n { body: params },\n );\n }\n\n /** Verify connector credentials. `POST /account/connectors/verify` */\n async verify(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/account/connectors/verify', { body: params });\n }\n\n /**\n * Register a webhook for a connector.\n * `POST /account/{merchantId}/connectors/webhooks/{connectorId}`\n *\n * @param params - Optional event scope. Defaults to `{ event_type: 'all_events' }`\n * when omitted; pass `{ event_type: { specific_event: '…' } }` to scope\n * to a single event.\n */\n async registerWebhook(\n merchantId: string,\n connectorId: string,\n params?: ConnectorWebhookRegisterRequest,\n ): Promise<ConnectorWebhookRegisterResponse> {\n const path = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;\n if (params === undefined) return this.request('POST', path);\n return this.request('POST', path, { body: params });\n }\n\n /**\n * Register checkout/shop domains as Stripe payment method domains, so Apple\n * Pay renders on those pages.\n * `POST /account/{merchantId}/connectors/{connectorId}/stripe/payment-method-domains`\n *\n * Stripe connectors only. One call registers against a single credential set\n * (`environment`, default `'live'`) — call twice to cover live and sandbox.\n * Per-URL outcomes come back in `results`; a missing sandbox credential set\n * is a request-level 400.\n */\n async registerStripePaymentMethodDomains(\n merchantId: string,\n connectorId: string,\n params: StripePaymentMethodDomainsRegisterRequest,\n ): Promise<StripePaymentMethodDomainsRegisterResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(merchantId)}/connectors/${encodeURIComponent(connectorId)}/stripe/payment-method-domains`,\n { body: params },\n );\n }\n\n /** Get registered webhooks for a connector. `GET /account/{merchantId}/connectors/webhooks/{connectorId}` */\n async getWebhook(merchantId: string, connectorId: string): Promise<ConnectorWebhookListResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`,\n );\n }\n\n /**\n * Bring an already-registered webhook's event subscription up to date with\n * the events Delopay handles.\n * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/sync-events`\n *\n * A PSP freezes an endpoint's event list at registration time, so an endpoint\n * created before an event type was added never receives it — silently, with\n * no error anywhere. {@link getWebhook} reports the gap as `missing_events`;\n * this repairs it.\n *\n * Unlike re-registering, the endpoints are updated in place: the endpoint id\n * and its signing secret are preserved, so signature verification keeps\n * working across the change. Stripe connectors only; idempotent, so it is\n * safe to call on a schedule or after every deploy.\n *\n * @example\n * ```typescript\n * const sync = await delopay.connectors.syncWebhookEvents('mer_abc', 'mca_xyz');\n * for (const endpoint of sync.endpoints) {\n * if (endpoint.error_message) console.warn(endpoint.connector_webhook_id, endpoint.error_message);\n * else if (endpoint.updated) console.log('subscribed', endpoint.added_events);\n * }\n * ```\n */\n async syncWebhookEvents(\n merchantId: string,\n connectorId: string,\n ): Promise<ConnectorWebhookSyncResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/sync-events`,\n );\n }\n\n /** List available payment methods. `GET /account/payment-methods` */\n async listPaymentMethods(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/account/payment-methods');\n }\n}\n","import type {\n CustomerCreateRequest,\n CustomerResponse,\n CustomerUpdateRequest,\n CustomerListParams,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Flatten list params for the query string.\n *\n * `profile_ids` must go out as ONE comma-separated value. The client\n * serializes arrays as repeated keys (`?profile_ids=a&profile_ids=b`), and the\n * customers endpoints cannot parse that — the whole request fails, rather than\n * the second id being ignored. So the join happens here, once, instead of at\n * four call sites.\n */\nfunction toQuery(\n params?: CustomerListParams,\n): Record<string, string | number | boolean | undefined> | undefined {\n if (!params) return undefined;\n const { profile_ids, ...rest } = params;\n const query = rest as Record<string, string | number | boolean | undefined>;\n // An empty array means \"no shop filter\", which is the absent key — sending\n // `profile_ids=` would work too, but omitting it keeps the URL honest.\n if (profile_ids && profile_ids.length > 0) {\n query.profile_ids = profile_ids.join(',');\n }\n return query;\n}\n\n/** Create and manage customer profiles. */\nexport class Customers {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new customer.\n *\n * @param params - Customer creation parameters (name, email, phone, address, etc.).\n * @returns The created customer.\n *\n * @example\n * ```typescript\n * const customer = await delopay.customers.create({\n * email: 'alice@example.com',\n * name: 'Alice Smith',\n * });\n * ```\n */\n async create(params: CustomerCreateRequest): Promise<CustomerResponse> {\n return this.request('POST', '/customers', { body: params });\n }\n\n /**\n * Retrieve a customer by their ID.\n *\n * @param customerId - The unique customer ID.\n * @returns The customer.\n *\n * @example\n * ```typescript\n * const customer = await delopay.customers.retrieve('cus_abc123');\n * ```\n */\n async retrieve(customerId: string): Promise<CustomerResponse> {\n return this.request('GET', `/customers/${encodeURIComponent(customerId)}`);\n }\n\n /**\n * Update an existing customer's details.\n *\n * @param customerId - The customer ID to update.\n * @param params - Fields to update (name, email, address, metadata, etc.).\n * @returns The updated customer.\n */\n async update(customerId: string, params: CustomerUpdateRequest): Promise<CustomerResponse> {\n return this.request('POST', `/customers/${encodeURIComponent(customerId)}`, { body: params });\n }\n\n /**\n * Delete a customer and all their saved payment methods.\n *\n * @param customerId - The customer ID to delete.\n * @returns The deleted customer object.\n */\n async delete(customerId: string): Promise<CustomerResponse> {\n return this.request('DELETE', `/customers/${encodeURIComponent(customerId)}`);\n }\n\n /**\n * List customers, optionally filtered by email, shop (`profile_id`), or\n * project (`project_id`).\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of customer objects.\n *\n * @example\n * ```typescript\n * // Customers who have transacted in a specific shop.\n * const customers = await delopay.customers.list({ profile_id: 'pro_abc123' });\n *\n * // Several shops at once (unions with profile_id / project_id).\n * const many = await delopay.customers.list({\n * profile_ids: ['pro_abc123', 'pro_def456'],\n * });\n * ```\n */\n async list(params?: CustomerListParams): Promise<CustomerResponse[]> {\n return this.request('GET', '/customers/list', {\n query: toQuery(params),\n });\n }\n\n // --- OLAP extensions (Task 4.6) ---\n\n /**\n * List customers with count. Supports the same `profile_id` / `project_id`\n * shop filters as {@link list}. `GET /customers/list-with-count`\n */\n async listWithCount(\n params?: CustomerListParams,\n ): Promise<{ count: number; total_count: number; data: CustomerResponse[] }> {\n return this.request('GET', '/customers/list-with-count', {\n query: toQuery(params),\n });\n }\n\n /**\n * List customers scoped to the authenticated dashboard user's shop\n * (business profile). The JWT auto-scopes to its own `profile`; an explicit\n * `profile_id` / `project_id` outside that scope is rejected with\n * `AccessForbidden`. `GET /customers/profile/list`\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of customer objects.\n */\n async listByProfile(params?: CustomerListParams): Promise<CustomerResponse[]> {\n return this.request('GET', '/customers/profile/list', {\n query: toQuery(params),\n });\n }\n\n /**\n * Profile-scoped variant of {@link listWithCount}.\n * `GET /customers/profile/list-with-count`\n */\n async listByProfileWithCount(\n params?: CustomerListParams,\n ): Promise<{ count: number; total_count: number; data: CustomerResponse[] }> {\n return this.request('GET', '/customers/profile/list-with-count', {\n query: toQuery(params),\n });\n }\n\n /** List mandates for a customer. `GET /customers/{customerId}/mandates` */\n async listMandates(customerId: string): Promise<Record<string, unknown>[]> {\n return this.request('GET', `/customers/${encodeURIComponent(customerId)}/mandates`);\n }\n}\n","import type {\n DisputeResponse,\n DisputeListParams,\n DisputeEvidenceRequest,\n DisputeEvidenceBlock,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** View and respond to payment disputes and chargebacks. */\nexport class Disputes {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Retrieve a dispute by its ID.\n *\n * @param disputeId - The unique dispute ID.\n * @returns The dispute.\n */\n async retrieve(disputeId: string): Promise<DisputeResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * List disputes, optionally filtered by status, stage, or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of disputes.\n */\n async list(params?: DisputeListParams): Promise<DisputeResponse[]> {\n return this.request('GET', '/disputes/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * Accept a dispute, conceding the chargeback to the customer.\n *\n * @param disputeId - The dispute ID to accept.\n * @returns The updated dispute.\n */\n async accept(disputeId: string): Promise<DisputeResponse> {\n return this.request('POST', `/disputes/accept/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * Submit evidence to challenge a dispute.\n *\n * @param params - Evidence details and the dispute ID to contest.\n * @returns The updated dispute.\n */\n async submitEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('POST', '/disputes/evidence', { body: params });\n }\n\n /**\n * Attach evidence (e.g. file upload metadata) to a dispute.\n *\n * Uses `PUT /disputes/evidence`.\n */\n async attachEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('PUT', '/disputes/evidence', { body: params });\n }\n\n /**\n * Retrieve previously stored evidence for a dispute.\n *\n * Returns an ARRAY of file-evidence blocks (this was previously mistyped\n * as the flat submit-request shape). Only file evidence is reported —\n * text evidence is not retrievable once submitted.\n *\n * @param disputeId - The dispute ID.\n * @returns The stored file-evidence blocks.\n */\n async retrieveEvidence(disputeId: string): Promise<DisputeEvidenceBlock[]> {\n return this.request('GET', `/disputes/evidence/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * Delete submitted evidence for a dispute.\n *\n * @param params - Evidence request body identifying what to delete.\n * @returns The updated dispute.\n */\n async deleteEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('DELETE', '/disputes/evidence', { body: params });\n }\n\n // --- OLAP extensions (Task 4.4) ---\n\n /** List disputes (profile-scoped). `GET /disputes/profile/list` */\n async listByProfile(params?: DisputeListParams): Promise<DisputeResponse[]> {\n return this.request('GET', '/disputes/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** Get dispute filter options. `GET /disputes/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/filter', { query: params });\n }\n\n /** Get dispute filters (profile-scoped). `GET /disputes/profile/filter` */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/profile/filter', { query: params });\n }\n\n /** Get dispute aggregates. `GET /disputes/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/aggregate', { query: params });\n }\n\n /** Get dispute aggregates (profile-scoped). `GET /disputes/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/profile/aggregate', { query: params });\n }\n\n /**\n * Fetch the latest dispute state from the connector (gateway) and persist it.\n * `GET /disputes/{disputeId}?force_sync=true`\n *\n * The path parameter is the **Delopay dispute id** (`dp_…`). Force-sync asks the\n * backend to pull the dispute from the connector (supported where the connector\n * implements the dispute-sync flow, e.g. Stripe) and update the stored record\n * before returning it.\n *\n * Note: this method previously called `GET /disputes/{id}/fetch`, which is a\n * different backend route — a bulk import keyed by **merchant connector account\n * id** with a required date range — so every call with a dispute id failed.\n */\n async fetchFromConnector(disputeId: string): Promise<DisputeResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}`, {\n query: { force_sync: 'true' },\n });\n }\n}\n","import type { EphemeralKeyCreateRequest, EphemeralKeyCreateResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Create short-lived ephemeral keys for secure client-side operations.\n *\n * Ephemeral keys grant a mobile or browser client temporary access to a\n * specific customer's data (e.g. to display saved payment methods) without\n * exposing your secret API key.\n *\n * The key is confined to the customer it was minted for, and that is\n * enforced on every customer and payment-method route: a request for another\n * customer — or for a payment method belonging to one — is refused rather\n * than served. Mint one key per customer; do not reuse a key across them.\n */\nexport class EphemeralKeys {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create an ephemeral key scoped to a specific customer.\n *\n * @param params - Customer ID and optional expiry.\n * @returns The ephemeral key with its plaintext secret and expiry timestamp.\n *\n * @example\n * ```typescript\n * const ephKey = await delopay.ephemeralKeys.create({ customer_id: 'cus_123' });\n * // Pass ephKey.secret to your mobile app.\n * ```\n */\n async create(params: EphemeralKeyCreateRequest): Promise<EphemeralKeyCreateResponse> {\n return this.request('POST', '/ephemeral-keys', { body: params });\n }\n\n /**\n * Invalidate an ephemeral key before it expires.\n *\n * @param keyId - The ephemeral key ID to delete.\n * @returns The deleted key object.\n */\n async delete(keyId: string): Promise<EphemeralKeyCreateResponse> {\n return this.request('DELETE', `/ephemeral-keys/${encodeURIComponent(keyId)}`);\n }\n}\n","import type {\n EventListParams,\n EventListResponse,\n EventDeliveryAttemptResponse,\n EventDetailResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Events {\n constructor(private readonly request: RequestFn) {}\n\n async list(merchantId: string, params?: EventListParams): Promise<EventListResponse> {\n return this.request('POST', `/events/${encodeURIComponent(merchantId)}`, { body: params });\n }\n\n async listDeliveryAttempts(\n merchantId: string,\n eventId: string,\n ): Promise<EventDeliveryAttemptResponse[]> {\n return this.request(\n 'GET',\n `/events/${encodeURIComponent(merchantId)}/${encodeURIComponent(eventId)}/attempts`,\n );\n }\n\n async retryDelivery(merchantId: string, eventId: string): Promise<EventDetailResponse> {\n return this.request(\n 'POST',\n `/events/${encodeURIComponent(merchantId)}/${encodeURIComponent(eventId)}/retry`,\n );\n }\n\n // --- Profile-scoped listing (Task 4.12) ---\n\n /** List events (profile-scoped). `POST /events/profile/list` */\n async listByProfile(params?: Record<string, unknown>): Promise<EventListResponse> {\n return this.request('POST', '/events/profile/list', { body: params });\n }\n}\n","import type {\n FeeRulePreviewRequest,\n FeeRulePreviewResponse,\n FeeScheduleCreateRequest,\n FeeScheduleResponse,\n FeeScheduleUpdateRequest,\n PlatformFeeRuleInput,\n PlatformFeeRuleRecord,\n PlatformFeeRuleRequest,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Merchant-scoped fee schedules. Each schedule optionally targets a\n * specific shop (via `shop_id`). Merchants can CRUD their own fee\n * overrides; platform-wide fee programs are administered by Delopay and\n * not exposed here.\n *\n * `fees.rules` manages the merchant-owned Euclid fee-rule program, which takes\n * precedence over the flat schedules above. A program is scoped either to one\n * shop (`profile_id`) or merchant-wide; a shop-scoped program wins for that\n * shop, otherwise the merchant-wide one applies. Build the program with the\n * `feeProgram()` helper.\n */\nexport class Fees {\n /** Merchant-owned Euclid fee-rule program (`/merchant-fees/rules`). */\n readonly rules: FeeRulesManager;\n\n constructor(private readonly request: RequestFn) {\n this.rules = new FeeRulesManager(request);\n }\n\n /**\n * Create a merchant-scoped fee schedule (optionally per-shop).\n *\n * @param params - Fee schedule parameters.\n * @param merchantId - The merchant account ID.\n */\n async create(params: FeeScheduleCreateRequest, merchantId: string): Promise<FeeScheduleResponse> {\n return this.request('POST', '/merchant-fees', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * List the merchant's own fee schedules.\n *\n * @param merchantId - The merchant account ID.\n */\n async list(merchantId: string): Promise<FeeScheduleResponse[]> {\n return this.request('GET', '/merchant-fees/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Update a merchant-scoped fee schedule.\n *\n * @param feeId - The fee schedule ID.\n * @param params - Fields to update.\n */\n async update(feeId: string, params: FeeScheduleUpdateRequest): Promise<FeeScheduleResponse> {\n return this.request('PUT', `/merchant-fees/${encodeURIComponent(feeId)}`, { body: params });\n }\n\n /**\n * Delete a merchant-scoped fee schedule.\n *\n * @param feeId - The fee schedule ID.\n */\n async delete(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('DELETE', `/merchant-fees/${encodeURIComponent(feeId)}`);\n }\n}\n\n/**\n * Manages a merchant's Euclid fee-rule programs (merchant-wide or per-shop, one\n * active program per scope). Build the `algorithm` with `feeProgram()`. The SDK\n * injects `fee_owner: 'merchant'`; set `profile_id` on the input to scope a\n * program to a shop.\n */\nexport class FeeRulesManager {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create or replace the merchant's fee-rule program (a new active version;\n * the previous version is deactivated server-side).\n *\n * @param params - The program plus optional name / shop scope / validity window.\n * @param merchantId - The merchant account ID.\n */\n async upsert(params: PlatformFeeRuleInput, merchantId: string): Promise<PlatformFeeRuleRecord> {\n const body: PlatformFeeRuleRequest = { ...params, fee_owner: 'merchant' };\n return this.request('PUT', '/merchant-fees/rules', {\n body,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve the active fee-rule program for a scope, or `null` if none.\n *\n * @param merchantId - The merchant account ID.\n * @param profileId - Optional shop (`profile_id`) scope. Omit for the\n * merchant-wide program; pass a shop id to get that shop's program.\n */\n async retrieve(merchantId: string, profileId?: string): Promise<PlatformFeeRuleRecord | null> {\n return this.request('GET', '/merchant-fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Deactivate a fee-rule program (falls back to the flat fee schedules /\n * volume tier). Idempotent.\n *\n * @param merchantId - The merchant account ID.\n * @param profileId - Optional shop (`profile_id`) scope. Omit to target the\n * merchant-wide program; pass a shop id to delete only that shop's program\n * (other shops' programs are left intact).\n */\n async delete(merchantId: string, profileId?: string): Promise<void> {\n await this.request('DELETE', '/merchant-fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Dry-run a candidate fee-rule program against a sample transaction.\n * Returns the matched rule name, whether it fell through, and the computed fee.\n * Does not persist anything.\n *\n * @param input - Candidate program + sample transaction fields.\n * @param merchantId - The merchant account ID.\n */\n async preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse> {\n return this.request('POST', '/merchant-fees/rules/preview', {\n body: input,\n query: { merchant_id: merchantId },\n });\n }\n}\n","import type { MandateResponse, MandateRevokedResponse, MandateListParams } from '../types';\nimport type { RequestFn } from '../client';\n\n/** View and revoke recurring payment mandates. */\nexport class Mandates {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Retrieve a mandate by its ID.\n *\n * @param mandateId - The unique mandate ID.\n * @returns The mandate.\n */\n async retrieve(mandateId: string): Promise<MandateResponse> {\n return this.request('GET', `/mandates/${encodeURIComponent(mandateId)}`);\n }\n\n /**\n * Revoke an active mandate, preventing future charges.\n *\n * @param mandateId - The mandate ID to revoke.\n * @returns Revocation confirmation.\n */\n async revoke(mandateId: string): Promise<MandateRevokedResponse> {\n return this.request('POST', `/mandates/revoke/${encodeURIComponent(mandateId)}`);\n }\n\n /**\n * List mandates, optionally filtered by customer or status.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of mandates.\n */\n async list(params?: MandateListParams): Promise<MandateResponse[]> {\n return this.request('GET', '/mandates/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n}\n","import type {\n MerchantAccountCreateRequest,\n MerchantAccountResponse,\n MerchantAccountUpdateRequest,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class MerchantAccounts {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: MerchantAccountCreateRequest): Promise<MerchantAccountResponse> {\n return this.request('POST', '/accounts', { body: params });\n }\n\n async retrieve(accountId: string): Promise<MerchantAccountResponse> {\n return this.request('GET', `/accounts/${encodeURIComponent(accountId)}`);\n }\n\n async update(\n accountId: string,\n params: MerchantAccountUpdateRequest,\n ): Promise<MerchantAccountResponse> {\n return this.request('POST', `/accounts/${encodeURIComponent(accountId)}`, { body: params });\n }\n\n async delete(accountId: string): Promise<MerchantAccountResponse> {\n return this.request('DELETE', `/accounts/${encodeURIComponent(accountId)}`);\n }\n\n // --- Advanced operations (Task 4.9) ---\n\n /** List all merchant accounts. `GET /accounts/list` */\n async list(): Promise<MerchantAccountResponse[]> {\n return this.request('GET', '/accounts/list');\n }\n\n /** Toggle key-value store for a merchant. `POST /accounts/{accountId}/kv` */\n async toggleKv(accountId: string): Promise<Record<string, unknown>> {\n return this.request('POST', `/accounts/${encodeURIComponent(accountId)}/kv`);\n }\n\n /** Get KV status for a merchant. `GET /accounts/{accountId}/kv` */\n async getKvStatus(accountId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/accounts/${encodeURIComponent(accountId)}/kv`);\n }\n\n /** Transfer keys between merchants. `POST /accounts/transfer` */\n async transferKeys(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/accounts/transfer', { body: params });\n }\n}\n","import type { PaymentLinkResponse, PaymentLinkListParams, PaymentLinkListResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/** Retrieve and list hosted payment links. */\nexport class PaymentLinks {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Retrieve a payment link by its ID.\n *\n * @param linkId - The unique payment link ID.\n * @returns The payment link details.\n */\n async retrieve(linkId: string): Promise<PaymentLinkResponse> {\n return this.request('GET', `/payment-link/${encodeURIComponent(linkId)}`);\n }\n\n /**\n * List payment links, optionally filtered by status or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Paginated list of payment links.\n */\n async list(params?: PaymentLinkListParams): Promise<PaymentLinkListResponse> {\n return this.request('POST', '/payment-link/list', { body: params });\n }\n\n /** Initiate (render) a payment link page. `GET /payment-link/{merchantId}/{paymentId}` */\n async initiate(merchantId: string, paymentId: string): Promise<Record<string, unknown>> {\n return this.request(\n 'GET',\n `/payment-link/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`,\n );\n }\n\n /** Get payment link status. `GET /payment-link/status/{merchantId}/{paymentId}` */\n async status(merchantId: string, paymentId: string): Promise<Record<string, unknown>> {\n return this.request(\n 'GET',\n `/payment-link/status/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`,\n );\n }\n}\n","import type {\n PaymentMethodCreateRequest,\n PaymentMethodResponse,\n PaymentMethodUpdateRequest,\n PaymentMethodListParams,\n PaymentMethodListResponse,\n PaymentMethodDeleteResponse,\n CustomerPaymentMethodsListParams,\n CustomerPaymentMethodsListResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage saved payment methods for customers. */\nexport class PaymentMethods {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Save a new payment method (card, bank account, wallet, etc.).\n *\n * @param params - Payment method data including type and card/bank details.\n * @returns The saved payment method.\n *\n * @example\n * ```typescript\n * const pm = await delopay.paymentMethods.create({\n * payment_method: 'card',\n * customer_id: 'cus_123',\n * client_secret: 'cs_...',\n * });\n * ```\n */\n async create(params: PaymentMethodCreateRequest): Promise<PaymentMethodResponse> {\n return this.request('POST', '/payment-methods', { body: params });\n }\n\n /**\n * Retrieve a saved payment method by its ID.\n *\n * @param methodId - The payment method ID.\n * @returns The payment method.\n */\n async retrieve(methodId: string): Promise<PaymentMethodResponse> {\n return this.request('GET', `/payment-methods/${encodeURIComponent(methodId)}`);\n }\n\n /**\n * Update an existing payment method (e.g. update card expiry).\n *\n * @param methodId - The payment method ID to update.\n * @param params - Fields to update (card expiry, holder name, etc.).\n * @returns The updated payment method.\n */\n async update(\n methodId: string,\n params: PaymentMethodUpdateRequest,\n ): Promise<PaymentMethodResponse> {\n return this.request('POST', `/payment-methods/${encodeURIComponent(methodId)}/update`, {\n body: params,\n });\n }\n\n /**\n * Delete a saved payment method.\n *\n * @param methodId - The payment method ID to delete.\n * @returns Deletion confirmation.\n */\n async delete(methodId: string): Promise<PaymentMethodDeleteResponse> {\n return this.request('DELETE', `/payment-methods/${encodeURIComponent(methodId)}`);\n }\n\n /**\n * List the payment methods available for a payment — the discovery endpoint a\n * custom checkout renders its tiles from.\n *\n * Callable with a publishable key plus the payment's `client_secret`, so it\n * runs from the browser. The returned set is already filtered by country,\n * order value and the merchant's availability rules, and each entry carries\n * `display` (name + icon slug) and `amount_limits` (the order values it stays\n * available for) so you do not have to maintain either alongside.\n *\n * This is *not* the customer's saved methods — see {@link listForCustomer}.\n *\n * @param params - `client_secret`, plus optional `country`, `amount` and filters.\n * @returns The methods available for the payment, grouped by payment method.\n *\n * @example\n * ```typescript\n * const { payment_methods } = await delopay.paymentMethods.list({\n * client_secret: 'pay_abc_secret_xyz',\n * country: 'DE',\n * amount: 25000,\n * });\n *\n * for (const group of payment_methods) {\n * for (const method of group.payment_method_types) {\n * // Re-check availability yourself as the cart total changes, instead of\n * // re-listing on every keystroke.\n * const limits = method.amount_limits;\n * const available =\n * !limits ||\n * ((limits.min_amount == null || cartTotal >= limits.min_amount) &&\n * (limits.max_amount == null || cartTotal <= limits.max_amount) &&\n * !limits.excluded_ranges.some(\n * (band) => cartTotal >= band.min_amount && cartTotal <= band.max_amount,\n * ));\n *\n * if (available) render(method.display?.display_name, method.display?.icon_slug);\n * }\n * }\n * ```\n */\n async list(params?: PaymentMethodListParams): Promise<PaymentMethodListResponse> {\n return this.request('GET', '/payment-methods', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * List all saved payment methods for a customer, optionally filtered.\n *\n * @param customerId - The customer ID.\n * @param params - Optional filters: `client_secret`, `accepted_countries`, `accepted_currencies`,\n * `amount`, `recurring_enabled`, `installment_payment_enabled`, `limit`, `card_networks`.\n * @returns Customer's saved payment methods.\n *\n * @example\n * ```typescript\n * const { customer_payment_methods } = await delopay.paymentMethods.listForCustomer(\n * 'cus_123',\n * { accepted_currencies: ['EUR'], amount: 5000 },\n * );\n * ```\n */\n async listForCustomer(\n customerId: string,\n params?: CustomerPaymentMethodsListParams,\n ): Promise<CustomerPaymentMethodsListResponse> {\n return this.request('GET', `/customers/${encodeURIComponent(customerId)}/payment-methods`, {\n query: params as Record<\n string,\n string | number | boolean | (string | number | boolean)[] | null | undefined\n >,\n });\n }\n\n /**\n * Set a payment method as the default for a customer.\n *\n * @param customerId - The customer ID.\n * @param methodId - The payment method ID to set as default.\n * @returns The updated payment method.\n */\n async setDefault(customerId: string, methodId: string): Promise<PaymentMethodResponse> {\n return this.request(\n 'POST',\n `/customers/${encodeURIComponent(customerId)}/payment-methods/${encodeURIComponent(methodId)}/default`,\n );\n }\n\n // --- Advanced operations (Task 3.3) ---\n\n /** Migrate a payment method. `POST /payment-methods/migrate` */\n async migrate(params: Record<string, unknown>): Promise<PaymentMethodResponse> {\n return this.request('POST', '/payment-methods/migrate', { body: params });\n }\n\n /** Batch migrate payment methods. `POST /payment-methods/migrate-batch` */\n async migrateBatch(params: Record<string, unknown>[]): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/migrate-batch', { body: params });\n }\n\n /** Batch update payment methods. `POST /payment-methods/update-batch` */\n async updateBatch(params: Record<string, unknown>[]): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/update-batch', { body: params });\n }\n\n /** Batch retrieve payment methods. `GET /payment-methods/batch` */\n async batchRetrieve(\n params?: Record<string, string | number | undefined>,\n ): Promise<PaymentMethodResponse[]> {\n return this.request('GET', '/payment-methods/batch', { query: params });\n }\n\n /** Tokenize a card. `POST /payment-methods/tokenize-card` */\n async tokenizeCard(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/tokenize-card', { body: params });\n }\n\n /** Batch tokenize cards. `POST /payment-methods/tokenize-card-batch` */\n async tokenizeCardBatch(params: Record<string, unknown>[]): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/tokenize-card-batch', { body: params });\n }\n\n /** Initiate payment method collect link flow. `POST /payment-methods/collect` */\n async collect(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/collect', { body: params });\n }\n\n /** Save a payment method. `POST /payment-methods/{methodId}/save` */\n async save(methodId: string, params?: Record<string, unknown>): Promise<PaymentMethodResponse> {\n return this.request('POST', `/payment-methods/${encodeURIComponent(methodId)}/save`, {\n body: params,\n });\n }\n\n /** Create payment method auth link token. `POST /payment-methods/auth/link` */\n async createAuthLink(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/auth/link', { body: params });\n }\n\n /** Exchange payment method auth token. `POST /payment-methods/auth/exchange` */\n async exchangeAuthToken(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/auth/exchange', { body: params });\n }\n\n /** Tokenize card using existing PM. `POST /payment-methods/{methodId}/tokenize-card` */\n async tokenizeCardForMethod(\n methodId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/payment-methods/${encodeURIComponent(methodId)}/tokenize-card`, {\n body: params,\n });\n }\n}\n","import type {\n PaymentClientContextListResponse,\n PaymentCreateRequest,\n PaymentListFilterConstraints,\n PaymentListFilteredResponse,\n PaymentListResponse,\n PaymentResponse,\n PaymentRetrieveOptions,\n PaymentUpdateRequest,\n PaymentConfirmRequest,\n PaymentCaptureRequest,\n PaymentCancelRequest,\n PaymentListParams,\n PaymentAttemptsListResponse,\n PaymentsDeletePolicyResponse,\n PaymentsDeleteResponse,\n PaymentStatusHistoryResponse,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/** Manage payment intents — create, confirm, capture, cancel, and list payments. */\nexport class Payments {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new payment intent.\n *\n * @param params - Payment creation parameters including amount and currency.\n * @param options - Optional per-call extras: extra `headers` (e.g. an\n * `Idempotency-Key` to make the create safe to retry), a `timeout` override,\n * and an `AbortSignal`.\n * @returns The created payment intent.\n *\n * @example\n * ```typescript\n * const payment = await delopay.payments.create(\n * { amount: 5000, currency: 'EUR', customer_id: 'cus_123' },\n * { headers: { 'Idempotency-Key': 'order_1001' } },\n * );\n * ```\n *\n * @example Send `test_mode` to pick the environment per payment, so a staging\n * deploy cannot charge real cards and a forgotten processor toggle cannot\n * swallow production traffic:\n * ```typescript\n * const payment = await delopay.payments.create({\n * amount: 5000,\n * currency: 'EUR',\n * test_mode: process.env.NODE_ENV !== 'production',\n * });\n * ```\n *\n * A payment that pins one connector through `routing` (the `single` form)\n * is now checked against `test_mode` here rather than at confirm: if that\n * connector has no credentials for the environment asked for, create fails\n * instead of handing back a payment whose checkout the buyer cannot\n * complete. `priority` and `volume_split` name several accounts and are\n * still resolved at confirm.\n */\n async create(params: PaymentCreateRequest, options?: RequestExtras): Promise<PaymentResponse> {\n return this.request('POST', '/payments', { body: params, ...options });\n }\n\n /**\n * Retrieve a payment by its ID.\n *\n * @param paymentId - The unique payment intent ID.\n * @param options - Optional query flags. `force_sync` reconciles the\n * intent's state with the connector before returning (useful to recover\n * a stuck intent when a webhook was lost). `all_keys_required` forces a\n * connector sync even for intents in early states like\n * `requires_payment_method` that would otherwise return the local\n * snapshot. Both flags work with JWT and API-key authentication.\n * @returns The payment intent.\n *\n * @example\n * ```typescript\n * const payment = await delopay.payments.retrieve('pay_abc123');\n * const synced = await delopay.payments.retrieve('pay_abc123', {\n * force_sync: true,\n * all_keys_required: true,\n * });\n * ```\n */\n async retrieve(paymentId: string, options?: PaymentRetrieveOptions): Promise<PaymentResponse> {\n const path = `/payments/${encodeURIComponent(paymentId)}`;\n if (options === undefined) return this.request('GET', path);\n const query: Record<string, boolean> = {};\n if (options.force_sync !== undefined) query['force_sync'] = options.force_sync;\n if (options.all_keys_required !== undefined) {\n query['all_keys_required'] = options.all_keys_required;\n }\n if (Object.keys(query).length === 0) return this.request('GET', path);\n return this.request('GET', path, { query });\n }\n\n /**\n * List every attempt made on a payment, each with its full failure detail\n * (`error_code` / `error_message`, the Delopay-unified `unified_code` and\n * `unified_message`, and structured `error_details`).\n *\n * Useful for surfacing retries across connectors — e.g. \"attempt 1 stripe →\n * insufficient_funds, attempt 2 adyen → success\".\n *\n * `GET /payments/{paymentId}/attempts`\n *\n * @param paymentId - The payment intent ID whose attempts to list.\n * @param options - Optional per-call extras: extra `headers`, a `timeout`\n * override, and an `AbortSignal`.\n * @returns The attempt list — `size` plus a `data` array of attempts.\n * @throws If the payment does not exist or belongs to another merchant (404).\n *\n * @example\n * ```typescript\n * const { size, data } = await delopay.payments.listAttempts('pay_abc123');\n * for (const attempt of data) {\n * console.log(attempt.status, attempt.unified_message ?? attempt.error_message);\n * }\n * ```\n */\n async listAttempts(\n paymentId: string,\n options?: RequestExtras,\n ): Promise<PaymentAttemptsListResponse> {\n return this.request('GET', `/payments/${encodeURIComponent(paymentId)}/attempts`, options);\n }\n\n /**\n * The status timeline of a payment: every recorded creation / status\n * transition of the intent and its attempts, refunds and disputes, oldest\n * first. `complete: false` marks timelines partially reconstructed from\n * current records (payments created before the status log existed).\n *\n * @param paymentId - The payment intent ID.\n * @returns The ordered status-history events.\n *\n * @example\n * ```typescript\n * const { events, complete } = await delopay.payments.listStatusHistory('pay_abc123');\n * for (const event of events) {\n * console.log(event.timestamp, event.entity_type, event.status);\n * }\n * ```\n */\n async listStatusHistory(\n paymentId: string,\n options?: RequestExtras,\n ): Promise<PaymentStatusHistoryResponse> {\n return this.request(\n 'GET',\n `/payments/${encodeURIComponent(paymentId)}/status-history`,\n options,\n );\n }\n\n /**\n * Update an existing payment intent before it is confirmed.\n *\n * @param paymentId - The payment intent ID to update.\n * @param params - Fields to update (amount, currency, metadata, etc.).\n * @returns The updated payment intent.\n */\n async update(paymentId: string, params: PaymentUpdateRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}`, { body: params });\n }\n\n /**\n * Confirm a payment intent, triggering authorisation with the selected gateway.\n *\n * @param paymentId - The payment intent ID to confirm.\n * @param params - Confirmation parameters (payment method data, return URL, etc.).\n * @returns The updated payment intent.\n */\n async confirm(paymentId: string, params: PaymentConfirmRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/confirm`, {\n body: params,\n });\n }\n\n /**\n * Capture a previously authorised payment.\n *\n * @param paymentId - The payment intent ID to capture.\n * @param params - Optional capture parameters (partial capture amount, etc.).\n * @returns The updated payment intent.\n */\n async capture(paymentId: string, params?: PaymentCaptureRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/capture`, {\n body: params,\n });\n }\n\n /**\n * Cancel a payment intent that has not yet been captured.\n *\n * @param paymentId - The payment intent ID to cancel.\n * @param params - Optional cancellation reason.\n * @returns The updated payment intent.\n */\n async cancel(paymentId: string, params?: PaymentCancelRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/cancel`, {\n body: params,\n });\n }\n\n /**\n * List payment intents, optionally filtered by customer or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @param options - Optional per-call extras: extra `headers`, a `timeout`\n * override, and an `AbortSignal` for cancellation.\n * @returns Paginated list of payment intents.\n *\n * @example\n * ```typescript\n * const { data } = await delopay.payments.list({ customer_id: 'cus_123', limit: 25 });\n * ```\n */\n async list(params?: PaymentListParams, options?: RequestExtras): Promise<PaymentListResponse> {\n return this.request('GET', '/payments/list', {\n query: params as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /**\n * The status timeline of client/device observations captured while the\n * buyer interacted with the payment (checkout opens, confirms, redirect\n * legs, reported client signals), oldest first.\n *\n * `GET /payments/{paymentId}/client-context`\n */\n async listClientContext(\n paymentId: string,\n options?: RequestExtras,\n ): Promise<PaymentClientContextListResponse> {\n return this.request(\n 'GET',\n `/payments/${encodeURIComponent(paymentId)}/client-context`,\n options,\n );\n }\n\n /**\n * Soft-delete a payment. Only payments whose status is in the merchant's\n * delete policy (see {@link Payments.getDeletePolicy}) can be deleted;\n * anything else fails with a precondition error.\n *\n * `DELETE /payments/{paymentId}`\n */\n async delete(paymentId: string, options?: RequestExtras): Promise<PaymentsDeleteResponse> {\n return this.request('DELETE', `/payments/${encodeURIComponent(paymentId)}`, options);\n }\n\n /**\n * The effective deletable-status set for the calling merchant — lets a\n * dashboard show the delete action only where it is allowed.\n *\n * `GET /payments/delete-policy`\n */\n async getDeletePolicy(options?: RequestExtras): Promise<PaymentsDeletePolicyResponse> {\n return this.request('GET', '/payments/delete-policy', options);\n }\n\n // --- Advanced operations (Task 3.2) ---\n\n /** Generate session tokens. `POST /payments/session-tokens` */\n async sessionTokens(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payments/session-tokens', { body: params });\n }\n\n /** Retrieve payment with gateway credentials. `POST /payments/sync` */\n async sync(params: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('POST', '/payments/sync', { body: params });\n }\n\n /** Cancel after partial capture. `POST /payments/{paymentId}/cancel-post-capture` */\n async cancelPostCapture(\n paymentId: string,\n params?: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/cancel-post-capture`, {\n body: params,\n });\n }\n\n /** Incrementally authorize more funds. `POST /payments/{paymentId}/incremental-authorization` */\n async incrementalAuthorization(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request(\n 'POST',\n `/payments/${encodeURIComponent(paymentId)}/incremental-authorization`,\n {\n body: params,\n },\n );\n }\n\n /** Extend authorization window. `POST /payments/{paymentId}/extend-authorization` */\n async extendAuthorization(\n paymentId: string,\n params?: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/extend-authorization`, {\n body: params,\n });\n }\n\n /** Complete authorization. `POST /payments/{paymentId}/complete-authorize` */\n async completeAuthorize(\n paymentId: string,\n params?: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/complete-authorize`, {\n body: params,\n });\n }\n\n /** Dynamic tax calculation. `POST /payments/{paymentId}/calculate-tax` */\n async calculateTax(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/calculate-tax`, {\n body: params,\n });\n }\n\n /** Update payment metadata. `POST /payments/{paymentId}/update-metadata` */\n async updateMetadata(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/update-metadata`, {\n body: params,\n });\n }\n\n /** Retrieve extended card info. `GET /payments/{paymentId}/extended-card-info` */\n async extendedCardInfo(paymentId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/payments/${encodeURIComponent(paymentId)}/extended-card-info`);\n }\n\n // --- OLAP extensions (Task 4.2) ---\n\n /** List payments (profile-scoped). `GET /payments/profile/list` */\n async listByProfile(params?: PaymentListParams): Promise<PaymentListResponse> {\n return this.request('GET', '/payments/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** List payments across all shops. `GET /payments/list-all-shops` */\n async listAllShops(params?: PaymentListParams): Promise<PaymentListResponse> {\n return this.request('GET', '/payments/list-all-shops', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** List payments by filter (POST body). `POST /payments/list` */\n async listByFilter(params: Record<string, unknown>): Promise<PaymentListResponse> {\n return this.request('POST', '/payments/list', { body: params });\n }\n\n /**\n * List payments by filter, scoped to the caller's profile (the shop-user\n * twin of `listByFilter`). The backend narrows to the profile from the\n * auth context, so `profile_id` / `project_id` must not be sent.\n *\n * Not to be confused with {@link Payments.listByProfile}, which is the GET\n * cursor variant and rejects this body.\n *\n * `POST /payments/profile/list`\n */\n async listByProfileFilter(\n params: PaymentListFilterConstraints,\n options?: RequestExtras,\n ): Promise<PaymentListFilteredResponse> {\n return this.request('POST', '/payments/profile/list', { body: params, ...options });\n }\n\n /** Get payment filter options. `GET /payments/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/filter', { query: params });\n }\n\n /**\n * Get payment filter options, scoped to the caller's profile.\n * `GET /payments/profile/filter`\n */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/profile/filter', { query: params });\n }\n\n /** Get payment aggregates. `GET /payments/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/aggregate', { query: params });\n }\n\n /** Get payment aggregates (profile-scoped). `GET /payments/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/profile/aggregate', { query: params });\n }\n\n /** Manually update payment status. `PUT /payments/{paymentId}/manual-update` */\n async manualUpdate(paymentId: string, params: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('PUT', `/payments/${encodeURIComponent(paymentId)}/manual-update`, {\n body: params,\n });\n }\n\n /** Approve a payment waiting for review. `POST /payments/{paymentId}/approve` */\n async approve(paymentId: string, params?: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/approve`, {\n body: params,\n });\n }\n\n /** Reject a payment waiting for review. `POST /payments/{paymentId}/reject` */\n async reject(paymentId: string, params?: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/reject`, {\n body: params,\n });\n }\n\n /** Initiate external 3DS authentication. `POST /payments/{paymentId}/3ds/authentication` */\n async threeDsAuthentication(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/3ds/authentication`, {\n body: params,\n });\n }\n}\n","import type {\n PayoutCreateRequest,\n PayoutResponse,\n PayoutUpdateRequest,\n PayoutListParams,\n PayoutListResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage payouts — fund transfers from merchant to a recipient bank account. */\nexport class Payouts {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new payout.\n *\n * @param params - Payout parameters including amount, currency, and destination.\n * @returns The created payout.\n *\n * @example\n * ```typescript\n * const payout = await delopay.payouts.create({\n * amount: 10000,\n * currency: 'EUR',\n * customer_id: 'cus_123',\n * });\n * ```\n */\n async create(params: PayoutCreateRequest): Promise<PayoutResponse> {\n return this.request('POST', '/payouts/create', { body: params });\n }\n\n /**\n * Retrieve a payout by its ID.\n *\n * @param payoutId - The unique payout ID.\n * @returns The payout.\n */\n async retrieve(payoutId: string): Promise<PayoutResponse> {\n return this.request('GET', `/payouts/${encodeURIComponent(payoutId)}`);\n }\n\n /**\n * Update a payout before it is confirmed.\n *\n * @param payoutId - The payout ID to update.\n * @param params - Fields to update.\n * @returns The updated payout.\n */\n async update(payoutId: string, params: PayoutUpdateRequest): Promise<PayoutResponse> {\n return this.request('PUT', `/payouts/${encodeURIComponent(payoutId)}`, { body: params });\n }\n\n /**\n * Confirm a payout, triggering the actual transfer.\n *\n * @param payoutId - The payout ID to confirm.\n * @param params - Optional confirmation parameters.\n * @returns The updated payout.\n */\n async confirm(payoutId: string, params?: PayoutUpdateRequest): Promise<PayoutResponse> {\n return this.request('POST', `/payouts/${encodeURIComponent(payoutId)}/confirm`, {\n body: params,\n });\n }\n\n /**\n * Cancel a payout before it is fulfilled.\n *\n * @param payoutId - The payout ID to cancel.\n * @returns The cancelled payout.\n */\n async cancel(payoutId: string): Promise<PayoutResponse> {\n return this.request('POST', `/payouts/${encodeURIComponent(payoutId)}/cancel`);\n }\n\n /**\n * Mark a payout as fulfilled (manual confirmation of successful transfer).\n *\n * @param payoutId - The payout ID to fulfil.\n * @returns The fulfilled payout.\n */\n async fulfill(payoutId: string): Promise<PayoutResponse> {\n return this.request('POST', `/payouts/${encodeURIComponent(payoutId)}/fulfill`);\n }\n\n /**\n * List payouts, optionally filtered by status or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Paginated list of payouts.\n */\n async list(params?: PayoutListParams): Promise<PayoutListResponse> {\n return this.request('GET', '/payouts/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n // --- OLAP extensions (Task 4.5) ---\n\n /** List payouts (profile-scoped). `GET /payouts/profile/list` */\n async listByProfile(params?: PayoutListParams): Promise<PayoutListResponse> {\n return this.request('GET', '/payouts/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** List payouts by filter (POST body). `POST /payouts/list` */\n async listByFilter(params: Record<string, unknown>): Promise<PayoutListResponse> {\n return this.request('POST', '/payouts/list', { body: params });\n }\n\n /** Get payout filter options. `GET /payouts/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/filter', { query: params });\n }\n\n /** Get payout filters (profile-scoped). `GET /payouts/profile/filter` */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/profile/filter', { query: params });\n }\n\n /** Get payout aggregates. `GET /payouts/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/aggregate', { query: params });\n }\n\n /** Get payout aggregates (profile-scoped). `GET /payouts/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/profile/aggregate', { query: params });\n }\n\n /** Manually update payout status. `PUT /payouts/{payoutId}/manual-update` */\n async manualUpdate(payoutId: string, params: Record<string, unknown>): Promise<PayoutResponse> {\n return this.request('PUT', `/payouts/${encodeURIComponent(payoutId)}/manual-update`, {\n body: params,\n });\n }\n}\n","import type { PollStatusResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Poll {\n constructor(private readonly request: RequestFn) {}\n\n async getStatus(pollId: string): Promise<PollStatusResponse> {\n return this.request('GET', `/poll/status/${encodeURIComponent(pollId)}`);\n }\n}\n","import type {\n ProfileAcquirerCreateRequest,\n ProfileAcquirerResponse,\n ProfileAcquirerUpdateRequest,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class ProfileAcquirers {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: ProfileAcquirerCreateRequest): Promise<ProfileAcquirerResponse> {\n return this.request('POST', '/profile-acquirer', { body: params });\n }\n\n async update(\n profileId: string,\n profileAcquirerId: string,\n params: ProfileAcquirerUpdateRequest,\n ): Promise<ProfileAcquirerResponse> {\n return this.request(\n 'POST',\n `/profile-acquirer/${encodeURIComponent(profileId)}/${encodeURIComponent(profileAcquirerId)}`,\n {\n body: params,\n },\n );\n }\n}\n","import type { ProfileCreateRequest, ProfileResponse, ProfileUpdateRequest } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Profiles {\n constructor(private readonly request: RequestFn) {}\n\n async create(accountId: string, params: ProfileCreateRequest): Promise<ProfileResponse> {\n return this.request('POST', `/account/${encodeURIComponent(accountId)}/business-profile`, {\n body: params,\n });\n }\n\n async retrieve(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}`,\n );\n }\n\n async list(accountId: string): Promise<ProfileResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/business-profile`);\n }\n\n /**\n * List the business profiles the caller can see at profile scope — the\n * `ProfileAccountRead` twin of `list()` (which needs merchant-level read).\n * A shop-scoped user gets exactly their own shop back.\n *\n * `GET /account/{accountId}/profile`\n */\n async listByProfile(accountId: string): Promise<ProfileResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/profile`);\n }\n\n async update(\n accountId: string,\n profileId: string,\n params: ProfileUpdateRequest,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}`,\n {\n body: params,\n },\n );\n }\n\n async delete(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'DELETE',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}`,\n );\n }\n\n // --- Advanced operations (Task 4.8) ---\n\n /** Toggle extended card info for a profile. `POST /account/{accountId}/business-profile/{profileId}/toggle-extended-card-info` */\n async toggleExtendedCardInfo(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}/toggle-extended-card-info`,\n );\n }\n\n /** Toggle connector agnostic MIT. `POST /account/{accountId}/business-profile/{profileId}/toggle-connector-agnostic-mit` */\n async toggleConnectorAgnosticMit(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}/toggle-connector-agnostic-mit`,\n );\n }\n}\n","import type {\n ProjectCreateRequest,\n ProjectResponse,\n ProjectUpdateRequest,\n ProjectStatsResponse,\n MerchantOverviewResponse,\n StatsPeriod,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage projects — optional grouping layers that contain one or more shops. */\nexport class Projects {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new project under a merchant account.\n *\n * @param params - Project creation parameters (name, description, etc.).\n * @param merchantId - The merchant account ID that owns this project.\n * @returns The created project.\n *\n * @example\n * ```typescript\n * const project = await delopay.projects.create({ name: 'EU Stores' }, 'merch_123');\n * ```\n */\n async create(params: ProjectCreateRequest, merchantId: string): Promise<ProjectResponse> {\n return this.request('POST', '/projects', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve a project by its ID.\n *\n * @param projectId - The unique project ID.\n * @param merchantId - Optional merchant scope. When provided, sent as\n * `?merchant_id=…` — required by dashboards that authenticate with a JWT\n * spanning multiple merchants and need to disambiguate which one this\n * call applies to. API-key callers can omit it.\n * @returns The project.\n */\n async retrieve(projectId: string, merchantId?: string): Promise<ProjectResponse> {\n const path = `/projects/${encodeURIComponent(projectId)}`;\n if (merchantId === undefined) return this.request('GET', path);\n return this.request('GET', path, { query: { merchant_id: merchantId } });\n }\n\n /**\n * Update a project's details.\n *\n * @param projectId - The project ID to update.\n * @param params - Fields to update.\n * @param merchantId - Optional merchant scope. See {@link Projects.retrieve}.\n * @returns The updated project.\n */\n async update(\n projectId: string,\n params: ProjectUpdateRequest,\n merchantId?: string,\n ): Promise<ProjectResponse> {\n const path = `/projects/${encodeURIComponent(projectId)}`;\n if (merchantId === undefined) return this.request('PUT', path, { body: params });\n return this.request('PUT', path, { body: params, query: { merchant_id: merchantId } });\n }\n\n /**\n * Delete a project.\n *\n * @param projectId - The project ID to delete.\n * @param merchantId - Optional merchant scope. See {@link Projects.retrieve}.\n * @returns The deleted project object.\n */\n async delete(projectId: string, merchantId?: string): Promise<ProjectResponse> {\n const path = `/projects/${encodeURIComponent(projectId)}`;\n if (merchantId === undefined) return this.request('DELETE', path);\n return this.request('DELETE', path, { query: { merchant_id: merchantId } });\n }\n\n /**\n * List all projects for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns Array of projects.\n */\n async list(merchantId: string): Promise<ProjectResponse[]> {\n return this.request('GET', '/projects/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Get aggregate payment statistics across all projects for a merchant.\n *\n * The response's flat `shops[]` array holds every shop, including shops that\n * belong to no project — those are absent from `projects[].shops[]`, so look\n * a single shop up in `shops[]`. Requires `MerchantAccountRead`; a\n * shop-scoped user should call {@link Shops.stats} instead.\n *\n * @param merchantId - The merchant account ID.\n * @param period - Window in days, or `'all'` for an all-time total.\n * Omitted means the server default of 30 days.\n * @returns Project statistics.\n *\n * @example\n * ```typescript\n * const stats = await delopay.projects.stats('merch_123', 'all');\n * const shop = stats.shops.find((s) => s.shop_id === 'pro_1');\n * ```\n */\n async stats(merchantId: string, period?: StatsPeriod): Promise<ProjectStatsResponse> {\n const query: Record<string, string> = { merchant_id: merchantId };\n if (period !== undefined) query['period'] = String(period);\n return this.request('GET', '/projects/stats', { query });\n }\n\n /**\n * Get a high-level overview (volume, counts, top connectors) for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns Merchant overview data.\n */\n async overview(merchantId: string): Promise<MerchantOverviewResponse> {\n return this.request('GET', '/projects/overview', {\n query: { merchant_id: merchantId },\n });\n }\n}\n","import type {\n RefundCreateRequest,\n RefundResponse,\n RefundUpdateRequest,\n RefundListParams,\n RefundListResponse,\n RefundAggregateResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage refunds for completed payments. */\nexport class Refunds {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a refund for a payment.\n *\n * Dashboard-initiated refunds are subject to the caller's operation-limit\n * rule, resolved against the role the request authenticated with. An\n * over-limit refund either fails with `DE_01` (the rule blocks) or with\n * HTTP 409 `DE_06` — the rule requires approval, and `DelopayError.data`\n * carries `PendingApprovalErrorDetails`. No refund exists in either case;\n * `DE_06` names one that a second approver can still let through, via\n * `operationLimits.approve()`.\n *\n * @param params - Refund parameters, including the required `payment_id` and optional amount.\n * @returns The created refund.\n *\n * @example\n * ```typescript\n * const refund = await delopay.refunds.create({\n * payment_id: 'pay_abc123',\n * amount: 2500, // partial refund of 25.00 EUR\n * });\n * ```\n */\n async create(params: RefundCreateRequest): Promise<RefundResponse> {\n return this.request('POST', '/refunds', { body: params });\n }\n\n /**\n * Retrieve a refund by its ID.\n *\n * @param refundId - The unique refund ID.\n * @returns The refund.\n *\n * @example\n * ```typescript\n * const refund = await delopay.refunds.retrieve('ref_abc123');\n * ```\n */\n async retrieve(refundId: string): Promise<RefundResponse> {\n return this.request('GET', `/refunds/${encodeURIComponent(refundId)}`);\n }\n\n /**\n * Update the reason or metadata on an existing refund.\n *\n * @param refundId - The refund ID to update.\n * @param params - Fields to update (reason, metadata).\n * @returns The updated refund.\n */\n async update(refundId: string, params: RefundUpdateRequest): Promise<RefundResponse> {\n return this.request('POST', `/refunds/${encodeURIComponent(refundId)}`, { body: params });\n }\n\n /**\n * List refunds, optionally filtered by payment, status, or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Paginated list of refunds.\n */\n async list(params?: RefundListParams): Promise<RefundListResponse> {\n return this.request('POST', '/refunds/list', { body: params });\n }\n\n // --- OLAP extensions (Task 4.3) ---\n\n /** List refunds (profile-scoped). `POST /refunds/profile/list` */\n async listByProfile(params?: RefundListParams): Promise<RefundListResponse> {\n return this.request('POST', '/refunds/profile/list', { body: params });\n }\n\n /** Get refund filter options. `GET /refunds/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/refunds/filter', { query: params });\n }\n\n /** Get refund aggregates. `GET /refunds/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<RefundAggregateResponse> {\n return this.request('GET', '/refunds/aggregate', { query: params });\n }\n\n /** Get refund aggregates (profile-scoped). `GET /refunds/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<RefundAggregateResponse> {\n return this.request('GET', '/refunds/profile/aggregate', { query: params });\n }\n\n /** Manually update refund status. `PUT /refunds/{refundId}/manual-update` */\n async manualUpdate(refundId: string, params: Record<string, unknown>): Promise<RefundResponse> {\n return this.request('PUT', `/refunds/${encodeURIComponent(refundId)}/manual-update`, {\n body: params,\n });\n }\n}\n","import type { RelayRequest, RelayResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Relay {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: RelayRequest): Promise<RelayResponse> {\n return this.request('POST', '/relay', { body: params });\n }\n\n async retrieve(relayId: string): Promise<RelayResponse> {\n return this.request('GET', `/relay/${encodeURIComponent(relayId)}`);\n }\n}\n","import type {\n CheckoutThemeConversionQuery,\n CheckoutThemeConversionResponse,\n CheckoutThemeProgramRequest,\n CheckoutThemeProgramResponse,\n LinkedRoutingConfigRetrieveResponse,\n MerchantRoutingAlgorithm,\n ProfileDefaultRoutingConfig,\n ProfileDeniedConnectorsResponse,\n RoutableConnectorChoice,\n RoutingActivatePayload,\n RoutingConfigCreateRequest,\n RoutingConfigHistoryResponse,\n RoutingConfigUpdateRequest,\n RoutingConnectorCaps,\n RoutingDeactivateRequest,\n RoutingDictionary,\n RoutingDictionaryRecord,\n RoutingHistoryParams,\n SurchargeRuleRequest,\n SurchargeRuleResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Create and manage payment routing algorithms.\n *\n * Routing rules determine which gateway connector handles each payment based on\n * card type, currency, amount, or custom conditions.\n */\nexport class Routing {\n readonly decision: RoutingDecisionManager;\n /** Merchant-friendly, per-payment-method surcharge rules (no Euclid DSL). */\n readonly surchargeRules: SurchargeRules;\n /** Which stored appearance variant a buyer is shown. Decides a look, never a payment. */\n readonly checkoutThemeRules: CheckoutThemeRules;\n /** Rendered-to-paid conversion per appearance variant and segment. */\n readonly checkoutThemeConversion: CheckoutThemeConversion;\n\n constructor(private readonly request: RequestFn) {\n this.decision = new RoutingDecisionManager(request);\n this.surchargeRules = new SurchargeRules(request);\n this.checkoutThemeRules = new CheckoutThemeRules(request);\n this.checkoutThemeConversion = new CheckoutThemeConversion(request);\n }\n\n /**\n * Create a new routing algorithm.\n *\n * @param params - Routing algorithm definition (rule-based, priority, or volume-based).\n * @returns Metadata record for the created routing configuration. The full\n * algorithm body is not echoed back — use `retrieve(id)` if you need it.\n *\n * @example\n * ```typescript\n * const config = await delopay.routing.create({\n * name: 'EU Priority',\n * algorithm: { type: 'priority', data: [{ connector: 'stripe' }] },\n * });\n * ```\n *\n * @example Conditional volume split (advanced): cards → 90% epayouts / 10% stripe.\n * Rules run top-down (first match wins); `defaultSelection` is the fallback.\n * Splits must sum to 100; `amount` conditions are in minor units.\n * ```typescript\n * const config = await delopay.routing.create({\n * name: 'Card split 90/10',\n * profile_id: 'pro_...',\n * algorithm: {\n * type: 'advanced',\n * data: {\n * defaultSelection: { type: 'priority', data: [{ connector: 'stripe' }] },\n * rules: [\n * {\n * name: 'cards',\n * connectorSelection: {\n * type: 'volume_split',\n * data: [\n * { connector: { connector: 'epayouts' }, split: 90 },\n * { connector: { connector: 'stripe' }, split: 10 },\n * ],\n * },\n * statements: [\n * {\n * condition: [\n * {\n * lhs: 'payment_method',\n * comparison: 'equal',\n * value: { type: 'enum_variant', value: 'card' },\n * metadata: {},\n * },\n * ],\n * },\n * ],\n * },\n * ],\n * metadata: {},\n * },\n * },\n * });\n * await delopay.routing.activate(config.id);\n * ```\n */\n async create(params: RoutingConfigCreateRequest): Promise<RoutingDictionaryRecord> {\n return this.request('POST', '/routing', { body: params });\n }\n\n /**\n * Retrieve a routing algorithm by its ID.\n *\n * @param algorithmId - The routing algorithm ID.\n * @returns The full routing configuration including the algorithm body.\n */\n async retrieve(algorithmId: string): Promise<MerchantRoutingAlgorithm> {\n return this.request('GET', `/routing/${encodeURIComponent(algorithmId)}`);\n }\n\n /**\n * Activate a routing algorithm, making it the active routing strategy.\n *\n * Always sends a JSON body (default `{}`) so the request carries the\n * `Content-Type: application/json` header that the server requires.\n *\n * @param algorithmId - The routing algorithm ID to activate.\n * @param params - Optional activation payload (e.g. `transaction_type`).\n */\n async activate(\n algorithmId: string,\n params: RoutingActivatePayload = {},\n ): Promise<RoutingDictionaryRecord> {\n return this.request('POST', `/routing/${encodeURIComponent(algorithmId)}/activate`, {\n body: params,\n });\n }\n\n /**\n * Deactivate the currently active routing algorithm (falls back to default routing).\n *\n * Always sends a JSON body (default `{}`) so the request carries the\n * `Content-Type: application/json` header that the server requires.\n *\n * @param params - Optional deactivation payload.\n */\n async deactivate(params: RoutingDeactivateRequest = {}): Promise<RoutingDictionaryRecord> {\n return this.request('POST', '/routing/deactivate', { body: params });\n }\n\n /**\n * Edit a static routing configuration.\n *\n * Partial: send only the fields to change. `name`/`description` are\n * metadata-only; `algorithm` is a wholesale rule replacement, validated\n * against the shop exactly as at create. `modified_at` is bumped either way.\n *\n * `PUT /routing/{algorithmId}`\n *\n * @param algorithmId - The routing algorithm ID to edit.\n * @param params - The fields to change (at least one required).\n * @returns The updated routing configuration including the algorithm body.\n */\n async update(\n algorithmId: string,\n params: RoutingConfigUpdateRequest,\n ): Promise<MerchantRoutingAlgorithm> {\n return this.request('PUT', `/routing/${encodeURIComponent(algorithmId)}`, { body: params });\n }\n\n /**\n * Every content window a routing configuration has had, oldest first.\n *\n * A configuration's rule can be edited in place, so this is what makes \"which\n * rule decided this payment\" answerable after the fact. Each entry is the rule\n * as it stood between `valid_from` and `valid_until`; the windows of one\n * config abut exactly, with no gap.\n *\n * Paging covers the whole timeline including the live window, so a page never\n * holds more than `limit` entries and the live one — the only entry without a\n * `valid_until` — comes back on exactly one page. Advance `offset` by `limit`;\n * a page past the end is empty, and `total_count` says where that end is\n * without probing for it.\n *\n * `GET /routing/{algorithmId}/history`\n *\n * @param algorithmId - The routing algorithm to read the history of.\n * @param params - Optional paging.\n */\n async history(\n algorithmId: string,\n params: RoutingHistoryParams = {},\n ): Promise<RoutingConfigHistoryResponse> {\n return this.request('GET', `/routing/${encodeURIComponent(algorithmId)}/history`, {\n query: params as Record<string, number | null | undefined>,\n });\n }\n\n /**\n * A shop's lifetime per-connector payment caps, each with how much of it is\n * already spent.\n *\n * `GET /routing/connector-caps/{profileId}`\n */\n async connectorCaps(profileId: string): Promise<RoutingConnectorCaps> {\n return this.request('GET', `/routing/connector-caps/${encodeURIComponent(profileId)}`);\n }\n\n /**\n * Replace a shop's per-connector payment caps.\n *\n * Whole-set replacement, not a patch: the list sent becomes the complete set\n * of capped connectors, and an empty list clears them all — which is how\n * acquirer onboarding finishes, the new account ceasing to be a special case.\n *\n * Every account named must belong to this shop; one that does not is refused.\n *\n * `PUT /routing/connector-caps/{profileId}`\n */\n async setConnectorCaps(\n profileId: string,\n params: RoutingConnectorCaps,\n ): Promise<RoutingConnectorCaps> {\n return this.request('PUT', `/routing/connector-caps/${encodeURIComponent(profileId)}`, {\n body: params,\n });\n }\n\n /**\n * List all routing algorithms for the current merchant.\n *\n * @returns The routing dictionary (records + currently active id).\n */\n async list(): Promise<RoutingDictionary> {\n return this.request('GET', '/routing');\n }\n\n /**\n * Connector names denied at routing for a shop (explicit denies plus\n * whitelist-implied exclusions). Read-only; surfaced in the routing builder.\n *\n * `GET /routing/connector-restrictions/{profileId}`\n */\n async connectorRestrictions(profileId: string): Promise<ProfileDeniedConnectorsResponse> {\n return this.request('GET', `/routing/connector-restrictions/${encodeURIComponent(profileId)}`);\n }\n\n // --- Advanced operations (Task 3.4) ---\n\n /** Get active routing config. `GET /routing/active` */\n async getActive(): Promise<LinkedRoutingConfigRetrieveResponse> {\n return this.request('GET', '/routing/active');\n }\n\n /** Update default routing config. `POST /routing/default` */\n async updateDefault(params: Record<string, unknown>): Promise<RoutableConnectorChoice[]> {\n return this.request('POST', '/routing/default', { body: params });\n }\n\n /** Retrieve default config for profiles. `GET /routing/default/profile` */\n async getDefaultProfile(): Promise<RoutableConnectorChoice[] | ProfileDefaultRoutingConfig[]> {\n return this.request('GET', '/routing/default/profile');\n }\n\n /** Update default config for a profile. `POST /routing/default/profile/{profileId}` */\n async updateDefaultProfile(\n profileId: string,\n params: Record<string, unknown>,\n ): Promise<ProfileDefaultRoutingConfig> {\n return this.request('POST', `/routing/default/profile/${encodeURIComponent(profileId)}`, {\n body: params,\n });\n }\n\n /** List routing configs for profile. `GET /routing/list/profile` */\n async listForProfile(): Promise<RoutingDictionary> {\n return this.request('GET', '/routing/list/profile');\n }\n\n /** Evaluate a routing rule. `POST /routing/rule/evaluate` */\n async evaluateRule(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/rule/evaluate', { body: params });\n }\n\n /** Migrate routing rules for profile. `POST /routing/rule/migrate` */\n async migrateRule(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/rule/migrate', { body: params });\n }\n\n /** Evaluate routing for a payment. `POST /routing/evaluate` */\n async evaluate(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/evaluate', { body: params });\n }\n\n /** Update gateway scores for dynamic routing. `POST /routing/feedback` */\n async feedback(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/feedback', { body: params });\n }\n}\n\nclass RoutingDecisionManager {\n constructor(private readonly request: RequestFn) {}\n\n /** Upsert decision manager config. `PUT /routing/decision` */\n async upsert(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', '/routing/decision', { body: params });\n }\n\n /** Retrieve decision manager config. `GET /routing/decision` */\n async retrieve(): Promise<Record<string, unknown>> {\n return this.request('GET', '/routing/decision');\n }\n\n /** Delete decision manager config. `DELETE /routing/decision` */\n async delete(): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/routing/decision');\n }\n\n /** Upsert surcharge decision config. `PUT /routing/decision/surcharge` */\n async upsertSurcharge(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', '/routing/decision/surcharge', { body: params });\n }\n\n /** Retrieve surcharge decision config. `GET /routing/decision/surcharge` */\n async retrieveSurcharge(): Promise<Record<string, unknown>> {\n return this.request('GET', '/routing/decision/surcharge');\n }\n\n /** Delete surcharge decision config. `DELETE /routing/decision/surcharge` */\n async deleteSurcharge(): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/routing/decision/surcharge');\n }\n}\n\n/**\n * Merchant-friendly surcharge rules: configure a per-payment-method surcharge\n * (fixed or %) added to the amount the buyer pays — without hand-writing the\n * Euclid DSL. Scope to a shop via `profile_id` (omit for merchant-wide).\n *\n * Distinct from the platform fee (a balance deduction): a surcharge changes what\n * the buyer is charged.\n */\nclass SurchargeRules {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create or replace the surcharge program for a scope.\n *\n * `PUT /routing/surcharge/rules`\n *\n * @example\n * ```typescript\n * await delopay.routing.surchargeRules.upsert({\n * surcharges: [\n * { payment_method: 'crypto', surcharge: { rate: { percent: 1.0 } } },\n * { payment_method: 'card', surcharge: { fixed: { amount: 35 } } },\n * ],\n * });\n * ```\n */\n async upsert(params: SurchargeRuleRequest): Promise<SurchargeRuleResponse> {\n return this.request('PUT', '/routing/surcharge/rules', { body: params });\n }\n\n /**\n * Retrieve the active surcharge program for a scope, or `null` when none is set.\n *\n * `GET /routing/surcharge/rules?profile_id={profileId}`\n *\n * @param profileId - Shop scope. Omit for the merchant-wide rule.\n */\n async retrieve(profileId?: string): Promise<SurchargeRuleResponse | null> {\n return this.request('GET', '/routing/surcharge/rules', {\n query: { profile_id: profileId },\n });\n }\n\n /**\n * Deactivate the active surcharge program for a scope.\n *\n * `DELETE /routing/surcharge/rules?profile_id={profileId}`\n *\n * @param profileId - Shop scope. Omit for the merchant-wide rule.\n */\n async delete(profileId?: string): Promise<void> {\n return this.request('DELETE', '/routing/surcharge/rules', {\n query: { profile_id: profileId },\n });\n }\n}\n\n/**\n * Checkout theme programs: which of a shop's stored appearance variants a buyer\n * is shown.\n *\n * Same engine and same wire format as the advanced routing rules above — a\n * Euclid program whose rules run top-down, first match wins, with\n * `defaultSelection` as the fallback — with the output swapped for a variant\n * name. That is deliberate: the dashboard's routing rule builder can author\n * these without learning a second condition language.\n *\n * **A theme program decides a look and nothing else.** It cannot express which\n * payment methods are offered, what is charged, which provider processes the\n * payment, or whether it succeeds. The allowed dimensions are fixed server-side\n * by the output type — see {@link CheckoutThemeDimension} — so that is a\n * property of the API rather than a convention.\n *\n * Naming a variant the shop has not defined is **not** an error: the checkout\n * falls back to the shop default, exactly as it does for an unknown `?theme=`,\n * because a buyer who cannot pay is worse than a buyer who sees the default\n * look. Such names come back in `warnings` instead, recomputed on every read.\n */\nclass CheckoutThemeRules {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create or replace the theme program for a scope.\n *\n * `PUT /routing/checkout-theme/rules`\n *\n * Supersedes rather than overwrites: the previous active version is retired\n * and a new one stored, so the record of which look was live when survives.\n * Pass `active: false` to store a revision **without** retiring the live one —\n * that is where a program drafted against a variant you have not built yet\n * belongs.\n *\n * @example A phone in Germany gets the compact look; everyone else the house style.\n * ```typescript\n * await delopay.routing.checkoutThemeRules.upsert({\n * name: 'Autumn targeting',\n * profile_id: 'pro_...',\n * algorithm: {\n * rules: [\n * {\n * name: 'German phones',\n * connectorSelection: { theme: { variant: 'compact' } },\n * statements: [\n * {\n * condition: [\n * {\n * lhs: 'device_class',\n * comparison: 'equal',\n * value: { type: 'enum_variant', value: 'phone' },\n * metadata: {},\n * },\n * {\n * lhs: 'browser_language',\n * comparison: 'equal',\n * value: { type: 'enum_variant', value: 'de' },\n * metadata: {},\n * },\n * ],\n * },\n * ],\n * },\n * ],\n * defaultSelection: { theme: { variant: 'house' } },\n * metadata: {},\n * },\n * });\n * ```\n */\n async upsert(params: CheckoutThemeProgramRequest): Promise<CheckoutThemeProgramResponse> {\n return this.request('PUT', '/routing/checkout-theme/rules', { body: params });\n }\n\n /**\n * Retrieve the active theme program for a scope, or `null` when none is set.\n *\n * `GET /routing/checkout-theme/rules?profile_id={profileId}`\n *\n * @param profileId - Shop scope. Omit for the merchant-wide program. A\n * shop-scoped caller that omits it gets its own shop's program.\n */\n async retrieve(profileId?: string): Promise<CheckoutThemeProgramResponse | null> {\n return this.request('GET', '/routing/checkout-theme/rules', {\n query: { profile_id: profileId },\n });\n }\n\n /**\n * Deactivate the active theme program for a scope. Idempotent.\n *\n * `DELETE /routing/checkout-theme/rules?profile_id={profileId}`\n *\n * Deactivation, not deletion — the stored row is what says which look was\n * live when, and that history cannot be reconstructed after the fact. Shops\n * go back to their default appearance immediately.\n *\n * @param profileId - Shop scope. Omit for the merchant-wide program.\n */\n async delete(profileId?: string): Promise<void> {\n return this.request('DELETE', '/routing/checkout-theme/rules', {\n query: { profile_id: profileId },\n });\n }\n}\n\n/**\n * Rendered-to-paid conversion, per appearance variant and segment.\n *\n * Answers the one question theme targeting exists for: *does variant B convert\n * better than the house style, on phones, in Germany?*\n *\n * **What a rate here means.** The denominator is backend-observed checkout page\n * opens, deduplicated by device within the hosted checkout's cache window, with\n * automated traffic excluded from both sides. It is narrower than \"paints\", and\n * that is deliberate - counting one buyer's refresh as a second render would\n * understate conversion. The exact basis travels with every response in\n * `denominator`, and the ways it is not the whole truth travel in `caveats`.\n *\n * **The server decides what may be concluded, not you.** Rate, Wilson interval,\n * per-cell `verdict` and the variant-vs-default `separates` test are computed\n * once, server-side, and shipped as values. Do not recompute them: the first\n * client that rounds differently tells a merchant a difference is real when the\n * server says it is not.\n */\nclass CheckoutThemeConversion {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Rendered-to-paid conversion for a shop over a window.\n *\n * `GET /routing/checkout-theme/conversion`\n *\n * Requires `CheckoutBranding` read at profile scope - the same permission\n * that governs seeing how a checkout looks.\n *\n * @param params - Window (RFC3339, `start` inclusive / `end` exclusive), the\n * shop, and the dimension to group by.\n *\n * @example Which variant wins on which device, over the last 30 days.\n * ```typescript\n * const report = await delopay.routing.checkoutThemeConversion.retrieve({\n * profile_id: 'pro_...',\n * start: '2026-07-21T00:00:00Z',\n * end: '2026-08-20T00:00:00Z',\n * segment: 'device',\n * });\n *\n * for (const c of report.comparisons) {\n * if (!c.separates) continue; // \"not shown to differ\" - say nothing\n * console.log(`${c.variant} on ${c.segment}: ${c.higher} converts better`);\n * }\n * ```\n */\n async retrieve(params: CheckoutThemeConversionQuery): Promise<CheckoutThemeConversionResponse> {\n return this.request('GET', '/routing/checkout-theme/conversion', {\n query: {\n profile_id: params.profile_id,\n start: params.start,\n end: params.end,\n segment: params.segment,\n },\n });\n }\n}\n","import type { RequestFn } from '../client';\n\n/** Index discriminator returned for each search result group. */\nexport type SearchIndex =\n | 'payment_attempts'\n | 'payment_intents'\n | 'refunds'\n | 'disputes'\n | 'payouts'\n | 'sessionizer_payment_attempts'\n | 'sessionizer_payment_intents'\n | 'sessionizer_refunds'\n | 'sessionizer_disputes'\n | 'routing_rules'\n | 'webhook_events'\n | 'audit_logs'\n | 'subscriptions';\n\nexport type SearchStatus = 'Success' | 'Failure';\n\n/** One result group (per index) in the response array. */\nexport interface SearchGroupResponse {\n count: number;\n index: SearchIndex;\n hits: Record<string, unknown>[];\n status: SearchStatus;\n}\n\n/**\n * The window a global search covers. The documented wire fields are\n * `start_time` (required) and `end_time` (optional — omit it for \"up to\n * now\"); the server also accepts the camelCase spellings as aliases, which\n * earlier SDK versions sent, so both are declared and either compiles.\n * Prefer the snake_case pair: it is what the operation documents.\n */\nexport type SearchTimeRange =\n | { start_time: string; end_time?: string | null }\n /** @deprecated Use `start_time` / `end_time` — the documented wire names. */\n | { startTime: string; endTime?: string | null };\n\nexport interface GlobalSearchRequest {\n query: string;\n filters?: Record<string, unknown>;\n /** Naive ISO 8601 bounds; `end_time` may be omitted. */\n timeRange?: SearchTimeRange;\n /** Wire alias for `timeRange` — the server reads either. */\n time_range?: SearchTimeRange;\n}\n\n/** Global cross-index search. */\nexport class Search {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Search every supported index for `query`.\n * `POST /analytics/search`\n *\n * @example\n * ```typescript\n * const groups = await delopay.search.global({ query: 'pay_abc' });\n * for (const g of groups) console.log(g.index, g.count);\n * ```\n */\n async global(\n params: GlobalSearchRequest,\n options?: { signal?: AbortSignal },\n ): Promise<SearchGroupResponse[]> {\n return this.request('POST', '/analytics/search', {\n body: params,\n ...(options?.signal ? { signal: options.signal } : {}),\n });\n }\n}\n","import type {\n CheckoutBrandingUpdate,\n ShopCreateRequest,\n ShopResponse,\n ShopUpdateRequest,\n GatewayConnectRequest,\n GatewayResponse,\n ProfileLogoUploadResponse,\n ProfileResponse,\n ShopStatsResponse,\n StatsPeriod,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/** Manage gateway connections for a specific shop. */\nclass ShopGateways {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Connect a payment gateway to a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID.\n * @param params - Gateway connector credentials and configuration.\n * @returns The created gateway connection.\n */\n async connect(\n merchantId: string,\n shopId: string,\n params: GatewayConnectRequest,\n ): Promise<GatewayResponse> {\n return this.request(\n 'POST',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/gateways`,\n { body: params },\n );\n }\n\n /**\n * List all gateway connections for a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID.\n * @returns Array of gateway connections.\n */\n async list(merchantId: string, shopId: string): Promise<GatewayResponse[]> {\n return this.request(\n 'GET',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/gateways`,\n );\n }\n\n /**\n * Disconnect a gateway from a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID.\n * @param gatewayId - The gateway connector ID to remove.\n * @returns The removed gateway connection.\n */\n async disconnect(\n merchantId: string,\n shopId: string,\n gatewayId: string,\n ): Promise<GatewayResponse> {\n return this.request(\n 'DELETE',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/gateways/${encodeURIComponent(gatewayId)}`,\n );\n }\n}\n\n/**\n * Create and manage shops (business profiles) within a merchant account.\n *\n * Each shop can have its own gateway connections, routing rules, and fee schedules.\n */\nexport class Shops {\n /** Gateway connection management for shops. */\n readonly gateways: ShopGateways;\n\n constructor(private readonly request: RequestFn) {\n this.gateways = new ShopGateways(request);\n }\n\n /**\n * Create a new shop under a merchant account.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Shop creation parameters (name, etc.).\n * @returns The created shop.\n *\n * @example\n * ```typescript\n * const shop = await delopay.shops.create('merch_123', { shop_name: 'EU Store' });\n * ```\n */\n async create(merchantId: string, params: ShopCreateRequest): Promise<ShopResponse> {\n return this.request('POST', `/shops/${encodeURIComponent(merchantId)}`, { body: params });\n }\n\n /**\n * Retrieve a shop by its ID.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID.\n * @returns The shop.\n */\n async retrieve(merchantId: string, shopId: string): Promise<ShopResponse> {\n return this.request(\n 'GET',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}`,\n );\n }\n\n /**\n * Update a shop's configuration.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID to update.\n * @param params - Fields to update.\n * @returns The updated shop.\n */\n async update(\n merchantId: string,\n shopId: string,\n params: ShopUpdateRequest,\n ): Promise<ShopResponse> {\n return this.request(\n 'PUT',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}`,\n { body: params },\n );\n }\n\n /**\n * Delete a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID to delete.\n * @returns The deleted shop object.\n */\n async delete(merchantId: string, shopId: string): Promise<ShopResponse> {\n return this.request(\n 'DELETE',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}`,\n );\n }\n\n /**\n * List all shops under a merchant account.\n *\n * @param merchantId - The merchant account ID.\n * @returns Array of shops.\n */\n async list(merchantId: string): Promise<ShopResponse[]> {\n return this.request('GET', `/shops/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Successful-order count and revenue for one shop.\n *\n * Unlike `projects.stats()` this needs only `ProfileAccountRead`, so a\n * shop-scoped user can load it for their own shop; merchant-level users can\n * load any shop of their merchant.\n *\n * Revenue comes back FX-converted as `revenue_usd` (USD major units) plus a\n * `revenue_by_currency` breakdown. The legacy `revenue` field is a raw\n * cross-currency minor-unit sum and should not be displayed.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID.\n * @param period - Window in days, or `'all'` for an all-time total.\n * Omitted means the server default of 30 days.\n * @returns The shop's stats over the requested window.\n *\n * @example\n * ```typescript\n * const stats = await delopay.shops.stats('merch_123', 'pro_1', 'all');\n * console.log(stats.orders, stats.revenue_usd);\n * ```\n */\n async stats(\n merchantId: string,\n shopId: string,\n period?: StatsPeriod,\n ): Promise<ShopStatsResponse> {\n const path = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;\n if (period === undefined) return this.request('GET', path);\n return this.request('GET', path, { query: { period: String(period) } });\n }\n\n /**\n * Upload a logo file for a shop. The file is stored in Delopay's configured\n * object store and a public HTTPS URL is returned. This method does NOT write\n * the URL into the shop's `payment_link_config.logo` — call\n * `shops.update` afterwards with the returned `logo_url` to persist the change.\n *\n * Accepts PNG, JPEG, WebP or SVG. The file must be ≤ 1 MiB.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID.\n * @param file - The logo file (Blob / File in browsers).\n * @returns The publicly-reachable URL of the uploaded logo.\n *\n * @example\n * ```typescript\n * const { logo_url } = await delopay.shops.uploadLogo('merch_1', 'pro_1', file);\n * await delopay.shops.update('merch_1', 'pro_1', {\n * payment_link_config: { logo: logo_url },\n * });\n * ```\n */\n async uploadLogo(\n merchantId: string,\n shopId: string,\n file: Blob,\n ): Promise<ProfileLogoUploadResponse> {\n const form = new FormData();\n form.append('file', file);\n return this.request(\n 'POST',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/logo`,\n { body: form },\n );\n }\n\n /**\n * Update only the checkout appearance (the `payment_link_config` blob:\n * theme, logo, colours, seller name, SDK layout/rules, DeloPay-branding\n * toggle) of a shop. Applied as a whole-object replace of\n * `payment_link_config`, mirroring the shop-update semantics.\n *\n * Gated on the dedicated `CheckoutBranding` permission, so \"may restyle\n * the checkout\" can be granted without full account/shop write.\n *\n * `POST /shops/{merchantId}/{shopId}/checkout-branding`\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID to restyle.\n * @param params - The new `payment_link_config` blob (full replacement).\n * @returns The updated business profile.\n */\n async updateCheckoutBranding(\n merchantId: string,\n shopId: string,\n params: CheckoutBrandingUpdate,\n options?: RequestExtras,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/checkout-branding`,\n { body: params, ...options },\n );\n }\n}\n","import type {\n StripeConnectAccountRequest,\n StripeConnectAccountResponse,\n StripeConnectLinkRequest,\n StripeConnectLinkResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class StripeConnect {\n constructor(private readonly request: RequestFn) {}\n\n async createAccount(params: StripeConnectAccountRequest): Promise<StripeConnectAccountResponse> {\n return this.request('POST', '/connector-onboarding/stripe/accounts', { body: params });\n }\n\n async createAccountLink(params: StripeConnectLinkRequest): Promise<StripeConnectLinkResponse> {\n return this.request('POST', '/connector-onboarding/stripe/account-links', { body: params });\n }\n\n // --- Generic connector onboarding (Task 4.11) ---\n\n /** Get onboarding action URL. `POST /connector-onboarding/action-url` */\n async getActionUrl(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/connector-onboarding/action-url', { body: params });\n }\n\n /** Sync onboarding status. `POST /connector-onboarding/sync` */\n async syncOnboarding(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/connector-onboarding/sync', { body: params });\n }\n\n /** Reset tracking ID. `POST /connector-onboarding/reset-tracking-id` */\n async resetTrackingId(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/connector-onboarding/reset-tracking-id', { body: params });\n }\n}\n","import type { ThreeDsRuleExecuteRequest, ThreeDsRuleResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class ThreeDsRules {\n constructor(private readonly request: RequestFn) {}\n\n async execute(params: ThreeDsRuleExecuteRequest): Promise<ThreeDsRuleResponse> {\n return this.request('POST', '/three-ds-decision/execute', { body: params });\n }\n}\n","import type {\n SignUpRequest,\n SignUpWithMerchantRequest,\n SignInRequest,\n AuthResponse,\n UserResponse,\n ChangePasswordRequest,\n DeleteAccountRequest,\n ForgotPasswordRequest,\n ResetPasswordRequest,\n SwitchMerchantRequest,\n SwitchProfileRequest,\n ImpersonateEmployeeRequest,\n InviteUsersRequest,\n InviteUsersResponse,\n AddUserRequest,\n AddUserResponse,\n UpdateUserRoleRequest,\n DeleteUserRoleRequest,\n TotpResponse,\n RecoveryCodesResponse,\n PhoneOtpRequest,\n PhoneOtpResponse,\n PhoneOtpVerifyRequest,\n PhoneOtpVerifyResponse,\n UpdateMetadataRequest,\n UpdateUserDetailsRequest,\n FromEmailRequest,\n TokenResponse,\n VerifyTotpRequest,\n Terminate2faQueryParams,\n ListInvitableRolesParams,\n ListUsersInLineageParams,\n UserInLineage,\n LoginHistoryParams,\n LoginHistoryResponse,\n UserSessionListResponse,\n UserSessionRevokeResponse,\n ParentGroupInfo,\n RoleConnectorGrant,\n UpdateRoleConnectorGrantParams,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Users {\n constructor(private readonly request: RequestFn) {}\n\n async signUp(params: SignUpRequest | SignUpWithMerchantRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/signup', { body: params });\n }\n\n async signIn(params: SignInRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/signin', { body: params });\n }\n\n async signOut(): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/signout');\n }\n\n /**\n * Sliding-session refresh: exchange the current (still-valid) login JWT\n * for a fresh one with the same claims and a full lifetime. The backend\n * keeps the session's identity (`jti`), slides `user_session.expires_at`\n * forward and re-sets the `login_token` cookie.\n *\n * Requires a token backed by a revocable session (a `jti` claim). Signin\n * and switch-merchant/-profile tokens have one; **session-less tokens do\n * not and are rejected with 400** — team-impersonation tokens are the\n * case in practice, and they are deliberately tab-scoped and\n * time-bounded rather than renewable. A 400 here is not a dead session:\n * the token remains valid for ordinary calls, it simply cannot slide.\n *\n * Rejected (401) for expired, blacklisted or revoked tokens — refresh can\n * only extend a session that is still alive. Rate-limited server-side\n * (429) to one mint per session per minute; treat a 429 as \"still fresh\n * enough\", not as an error.\n *\n * The returned token is NOT applied to this client automatically — pass\n * it to `setJwtToken()`, or use {@link Delopay.refreshSession} which does\n * both.\n *\n * `POST /user/token/refresh`. Requires a logged-in JWT.\n */\n async refreshToken(): Promise<TokenResponse> {\n return this.request('POST', '/user/token/refresh');\n }\n\n /**\n * Paginated login history for the authenticated user -- IP, User-Agent,\n * country / city / lat-lon (when GeoIP is enabled), success and failure\n * events with their reasons. Strictly scoped to the JWT subject; a user\n * can only see their own activity.\n *\n * `GET /user/me/login-activity`. Requires a logged-in JWT.\n *\n * Returns an empty page when a Delopay admin is impersonating a merchant,\n * so the admin's metadata is not exposed inside the merchant dashboard.\n */\n async listLoginActivity(params?: LoginHistoryParams): Promise<LoginHistoryResponse> {\n if (params === undefined) {\n return this.request('GET', '/user/me/login-activity');\n }\n return this.request('GET', '/user/me/login-activity', {\n query: params as Record<string, number | undefined>,\n });\n }\n\n /**\n * List the authenticated user's currently-active dashboard sessions\n * (one row per minted login JWT that hasn't been revoked or expired).\n *\n * The row matching the JWT making this call has `is_current: true`,\n * which is what lets the dashboard render a \"This device\" tag.\n *\n * `GET /user/me/sessions`. Requires a logged-in JWT. Returns an empty\n * list when a Delopay admin is impersonating a non-admin merchant\n * (same guard as `listLoginActivity`).\n */\n async listActiveSessions(): Promise<UserSessionListResponse> {\n return this.request('GET', '/user/me/sessions');\n }\n\n /**\n * Disconnect one of the authenticated user's sessions. The matching\n * JWT is rejected on its next request — fast-path via Redis, fall back\n * to the persistent `revoked_at` column.\n *\n * Idempotent: revoking an already-revoked or unknown id returns 404,\n * which the caller can treat as success for retry purposes. Revoking\n * a session id that belongs to a different user also returns 404 —\n * the response intentionally doesn't leak whether the id exists.\n *\n * `POST /user/me/sessions/{sessionId}/revoke`.\n */\n async revokeSession(sessionId: string): Promise<UserSessionRevokeResponse> {\n return this.request('POST', `/user/me/sessions/${encodeURIComponent(sessionId)}/revoke`);\n }\n\n async getDetails(): Promise<UserResponse> {\n return this.request('GET', '/user');\n }\n\n async update(params: UpdateUserDetailsRequest): Promise<UserResponse> {\n return this.request('POST', '/user/update', { body: params });\n }\n\n /**\n * RFC 7396 merge-patch the caller's own user-scoped metadata bucket.\n * Returns the full user details, so callers can refresh their context\n * without a second fetch.\n *\n * `PATCH /user/metadata`\n */\n async updateMetadata(params: UpdateMetadataRequest): Promise<UserResponse> {\n return this.request('PATCH', '/user/metadata', { body: params });\n }\n\n /**\n * RFC 7396 merge-patch the merchant-scoped metadata bucket shared by\n * every dashboard user of the merchant. Same response contract as\n * {@link Users.updateMetadata}.\n *\n * `PATCH /user/merchant/metadata`\n */\n async updateMerchantMetadata(params: UpdateMetadataRequest): Promise<UserResponse> {\n return this.request('PATCH', '/user/merchant/metadata', { body: params });\n }\n\n /**\n * Permanently delete the caller's account. Requires a fresh password\n * (and a current 6-digit TOTP code if the user has TOTP enrolled). On\n * success all role assignments are removed, the user record is\n * deactivated, and all in-flight sessions are invalidated. The caller\n * should clear local credentials and route to the login page.\n *\n * Returns `InvalidDeleteOperation` when the caller is the sole\n * owner-level admin of an org / merchant / profile -- they must\n * transfer ownership first.\n */\n async deleteAccount(params: DeleteAccountRequest): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/user/account', { body: params });\n }\n\n async changePassword(params: ChangePasswordRequest): Promise<UserResponse> {\n return this.request('POST', '/user/change-password', { body: params });\n }\n\n async rotatePassword(params: ResetPasswordRequest): Promise<UserResponse> {\n return this.request('POST', '/user/rotate-password', { body: params });\n }\n\n async forgotPassword(params: ForgotPasswordRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/forgot-password', { body: params });\n }\n\n /**\n * Commit a password reset.\n *\n * The caller is responsible for obtaining a `SinglePurposeToken` with\n * `purpose: reset_password` via the email-token exchange + TOTP flow\n * (see `fromEmail`, `beginTotp`, `updateTotp`/`verifyTotp`,\n * `generateRecoveryCodes`, `terminate2fa`) and setting it on the client\n * via `setJwtToken` before calling this method. `body.token` must still\n * be the original `EmailToken` from the reset-link URL — the handler\n * decodes it a second time to find the user.\n */\n async resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/reset-password', { body: params });\n }\n\n /**\n * Exchange an email-link token (`EmailToken`) for a single-purpose JWT\n * that drives the next step of the flow (TOTP, verify email, accept\n * invitation, etc.). No authentication required.\n *\n * The `token_type` in the response tells you which step to run next.\n */\n async fromEmail(params: FromEmailRequest): Promise<TokenResponse> {\n return this.request('POST', '/user/from-email', { body: params });\n }\n\n async verifyEmail(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/verify-email', { body: params });\n }\n\n async sendVerificationEmail(params: ForgotPasswordRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/verify-email-request', { body: params });\n }\n\n async createMerchant(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/create-merchant', { body: params });\n }\n\n async switchMerchant(params: SwitchMerchantRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/switch/merchant', { body: params });\n }\n\n async switchProfile(params: SwitchProfileRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/switch/profile', { body: params });\n }\n\n async listMerchants(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/list/merchant');\n }\n\n async listProfiles(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/list/profile');\n }\n\n async inviteUsers(params: InviteUsersRequest[]): Promise<InviteUsersResponse[]> {\n return this.request('POST', '/user/employees/invite', { body: params });\n }\n\n /**\n * Add a team member directly, without sending an invite email.\n * `POST /user/employees/add`\n *\n * Unlike `inviteUsers`, the account is active immediately and you hand over\n * the credentials yourself. Omit `password` to have the server generate one\n * and return it once in `password` on the response; supply your own and it is\n * not echoed back. Either way the member must change it on first sign-in.\n *\n * Same role rules as invite: you cannot grant a role above your own, and a\n * shop-scoped caller can only target their own shop.\n */\n async addUser(params: AddUserRequest): Promise<AddUserResponse> {\n return this.request('POST', '/user/employees/add', { body: params });\n }\n\n /**\n * Impersonate one of your own team members — `POST /user/employees/impersonate`.\n *\n * Mints a session token **as** the given member, so the dashboard renders\n * exactly what they see (useful for support and role verification). The\n * caller needs the *Impersonation* permission, and the member's role must\n * rank **strictly below** the caller's (`Profile < Merchant < Organization`);\n * the server rejects self-impersonation, cross-merchant targets, and\n * equal/higher roles.\n *\n * The returned token is tab-scoped by design: open it in a fresh tab (e.g.\n * `/auth/impersonate?token=…`) rather than replacing the caller's own\n * session. No auth cookie is set on the response.\n */\n async impersonateEmployee(params: ImpersonateEmployeeRequest): Promise<TokenResponse> {\n return this.request('POST', '/user/employees/impersonate', { body: params });\n }\n\n async acceptInvitation(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/employees/invite/accept', { body: params });\n }\n\n /**\n * Accept an invitation via the email-link flow.\n *\n * Caller must already hold a `SinglePurposeToken` with\n * `purpose: accept_invitation_from_email` (obtained via `fromEmail` + any\n * required TOTP step) and have set it on the client via `setJwtToken`.\n * `body.token` must still be the original `EmailToken` from the\n * invite-link URL — the handler decodes it a second time to find the\n * invitee and the entity lineage.\n */\n async acceptInviteFromEmail(params: FromEmailRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/accept-invite-from-email', { body: params });\n }\n\n /**\n * Start TOTP setup (or no-op if already set).\n *\n * Returns the QR-code payload when the user has no TOTP configured yet;\n * returns `{ secret: null }` when the user is already set up (caller\n * should then prompt for a 6-digit code and call `verifyTotp`).\n *\n * Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async beginTotp(): Promise<TotpResponse> {\n return this.request('GET', '/user/2fa/totp/begin');\n }\n\n /**\n * Verify a 6-digit TOTP code for a user whose TOTP is already set up.\n * Marks the code as used in Redis so subsequent flow steps can advance.\n *\n * Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async verifyTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/2fa/totp/verify', { body: params });\n }\n\n async resetTotp(): Promise<Record<string, unknown>> {\n return this.request('GET', '/user/2fa/totp/reset');\n }\n\n async generateRecoveryCodes(): Promise<RecoveryCodesResponse> {\n return this.request('GET', '/user/2fa/recovery-code/generate');\n }\n\n async verifyRecoveryCode(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/2fa/recovery-code/verify', { body: params });\n }\n\n async sendPhoneOtp(params: PhoneOtpRequest): Promise<PhoneOtpResponse> {\n return this.request('POST', '/user/phone/send-otp', { body: params });\n }\n\n async verifyPhoneOtp(params: PhoneOtpVerifyRequest): Promise<PhoneOtpVerifyResponse> {\n return this.request('POST', '/user/phone/verify-otp', { body: params });\n }\n\n /**\n * List all roles visible to the caller (predefined + custom).\n *\n * `GET /user/role/list`. With `groups: true` the response is the\n * parent-groups shape: `[{role_id, role_name, entity_type, role_scope,\n * parent_groups: [{name, description, scopes}]}]`; without it, the\n * deprecated flat `groups` shape.\n */\n async listRoles(params?: {\n groups?: boolean;\n entity_type?: string;\n }): Promise<Record<string, unknown>[]> {\n if (params === undefined) {\n return this.request('GET', '/user/role/list');\n }\n return this.request('GET', '/user/role/list', {\n query: { groups: params.groups, entity_type: params.entity_type },\n });\n }\n\n async listUserRoles(params?: Record<string, unknown>): Promise<Record<string, unknown>[]> {\n return this.request('POST', '/user/employees', { body: params });\n }\n\n /**\n * Change a team member's role. `POST /user/employees/update-role`\n *\n * Pass `profile_id` to name the shop when managing a shop's team as a\n * merchant-scoped admin — see {@link UpdateUserRoleRequest.profile_id}.\n */\n async updateUserRole(params: UpdateUserRoleRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/employees/update-role', { body: params });\n }\n\n /**\n * Remove a team member. `DELETE /user/employees/delete`\n *\n * Pass `profile_id` to name the shop when managing a shop's team as a\n * merchant-scoped admin — see {@link DeleteUserRoleRequest.profile_id}.\n */\n async deleteUserRole(params: DeleteUserRoleRequest): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/user/employees/delete', { body: params });\n }\n\n /** Sign in via OIDC. `POST /user/oidc` */\n async signInOidc(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/oidc', { body: params });\n }\n\n /** Transfer key. `POST /user/key/transfer` */\n async transferKey(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/key/transfer', { body: params });\n }\n\n /** List invitations. `GET /user/list/invitation` */\n async listInvitations(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/list/invitation');\n }\n\n /** Check 2FA status. `GET /user/2fa` */\n async check2faStatus(): Promise<Record<string, unknown>> {\n return this.request('GET', '/user/2fa');\n }\n\n /**\n * Finish first-time TOTP setup: commit the secret generated by `beginTotp`\n * against a 6-digit code from the user's authenticator app.\n *\n * `PUT /user/2fa/totp/verify`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async updateTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>> {\n return this.request('PUT', '/user/2fa/totp/verify', { body: params });\n }\n\n /**\n * Complete the TOTP step and advance to the next flow stage (e.g.\n * `reset_password`). Returns a fresh single-purpose token with the\n * next `token_type`.\n *\n * `GET /user/2fa/terminate`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async terminate2fa(query?: Terminate2faQueryParams): Promise<TokenResponse> {\n if (query === undefined) {\n return this.request('GET', '/user/2fa/terminate');\n }\n return this.request('GET', '/user/2fa/terminate', {\n query: query as Record<string, boolean | undefined>,\n });\n }\n\n /** Create auth method. `POST /user/auth` */\n async createAuthMethod(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/auth', { body: params });\n }\n\n /** Update auth method. `PUT /user/auth` */\n async updateAuthMethod(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', '/user/auth', { body: params });\n }\n\n /** List auth methods. `GET /user/auth/list` */\n async listAuthMethods(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/auth/list');\n }\n\n /** Get auth URL. `GET /user/auth/url` */\n async getAuthUrl(): Promise<Record<string, unknown>> {\n return this.request('GET', '/user/auth/url');\n }\n\n /** Select auth method. `POST /user/auth/select` */\n async selectAuth(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/auth/select', { body: params });\n }\n\n /**\n * List users in lineage.\n *\n * Needs the Users *view* grant now — the response carries colleagues' email\n * addresses, so a role without it is refused rather than handed a roster.\n * A shop-scoped role keeps reading its own shop's members.\n *\n * `GET /user/employees/list`\n */\n async listUsersInLineage(params?: ListUsersInLineageParams): Promise<UserInLineage[]> {\n return this.request('GET', '/user/employees/list', {\n query: params as Record<string, string | undefined> | undefined,\n });\n }\n\n /** Resend invite. `POST /user/resend-invite` */\n async resendInvite(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/resend-invite', { body: params });\n }\n\n /**\n * Get the caller's parent permission groups + scopes.\n *\n * `GET /user/role`\n */\n async getRolePermissions(): Promise<ParentGroupInfo[]> {\n return this.request('GET', '/user/role');\n }\n\n /**\n * List invitable roles. `GET /user/role/list/invite`\n *\n * @param params - Optional query. `entity_type` scopes the role list to a\n * particular entity (e.g. `'merchant'` to list only merchant-scoped roles\n * when inviting employees from the merchant dashboard).\n */\n async listInvitableRoles(params?: ListInvitableRolesParams): Promise<Record<string, unknown>[]> {\n if (params === undefined || params.entity_type === undefined) {\n return this.request('GET', '/user/role/list/invite');\n }\n return this.request('GET', '/user/role/list/invite', {\n query: { entity_type: params.entity_type },\n });\n }\n\n /** List updatable roles. `GET /user/role/list/update` */\n async listUpdatableRoles(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/role/list/update');\n }\n\n /** Get parent list. `GET /user/parent/list` */\n async getParentList(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/parent/list');\n }\n\n /** Create a role. `POST /user/role` */\n async createRole(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/role', { body: params });\n }\n\n /** Get role by ID. `GET /user/role/{roleId}` */\n async getRoleById(roleId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/user/role/${encodeURIComponent(roleId)}`);\n }\n\n /** Update role by ID. `PUT /user/role/{roleId}` */\n async updateRole(\n roleId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('PUT', `/user/role/${encodeURIComponent(roleId)}`, { body: params });\n }\n\n /**\n * Delete a custom role. Predefined roles and roles still assigned to\n * team members are rejected by the backend with a 400.\n *\n * `DELETE /user/role/{roleId}`\n */\n async deleteRole(roleId: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/user/role/${encodeURIComponent(roleId)}`);\n }\n\n /**\n * Read which individual connector accounts a role may see.\n *\n * `GET /user/role/{roleId}/connectors`\n *\n * **Check `restricted` before reading `connectors`.** An empty list is\n * ambiguous by itself, so the backend states which case it is: `false` means\n * the role holds no grant and sees whatever its entity and profile scope\n * already allowed. Rendering an empty `connectors` array as \"this role sees\n * nothing\" inverts the meaning.\n *\n * Requires the permission that *edits a role*, not a connector permission.\n */\n async getRoleConnectors(roleId: string): Promise<RoleConnectorGrant> {\n return this.request('GET', `/user/role/${encodeURIComponent(roleId)}/connectors`);\n }\n\n /**\n * Replace the set of connector accounts a role may see.\n *\n * `PUT /user/role/{roleId}/connectors`\n *\n * The call **replaces** the whole set rather than adding to it, so send the\n * complete list every time. An empty `merchant_connector_ids` clears the\n * grant and returns the role to unrestricted.\n *\n * The backend refuses an id that is not a connector account of the caller's\n * own merchant, an `Organization`-scoped role (a connector account belongs to\n * exactly one merchant, so an org-spanning role cannot hold one coherently),\n * and any predefined role (one static entry shared by every tenant).\n *\n * Editing a grant invalidates the role cache and blacklists tokens minted\n * before the edit, so **users holding this role must sign in again**. Worth\n * saying in the UI before the save, not after.\n */\n async updateRoleConnectors(\n roleId: string,\n params: UpdateRoleConnectorGrantParams,\n ): Promise<RoleConnectorGrant> {\n return this.request('PUT', `/user/role/${encodeURIComponent(roleId)}/connectors`, {\n body: params,\n });\n }\n}\n","import type {\n ApplePayVerificationRequest,\n ApplePayVerificationResponse,\n ApplePayVerifiedDomainsResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Verification {\n constructor(private readonly request: RequestFn) {}\n\n async registerApplePayDomains(\n merchantId: string,\n params: ApplePayVerificationRequest,\n ): Promise<ApplePayVerificationResponse> {\n return this.request('POST', `/verify/apple-pay/${encodeURIComponent(merchantId)}`, {\n body: params,\n });\n }\n\n async getApplePayVerifiedDomains(\n params: Record<string, string>,\n ): Promise<ApplePayVerifiedDomainsResponse> {\n return this.request('GET', '/verify/applepay-verified-domains', {\n query: params,\n });\n }\n}\n","import type {\n EventType,\n PaymentResponse,\n RefundResponse,\n DisputeResponse,\n MandateResponse,\n PayoutResponse,\n ConfirmSubscriptionResponse,\n} from '../types';\n\n/**\n * The payload of a webhook event, tagged by kind.\n *\n * Mirrors the backend's `{ \"type\": …, \"object\": … }` envelope: `type` names the\n * payload shape and `object` carries it. Narrow on `content.type` to get a\n * fully-typed `object`:\n *\n * ```typescript\n * if (event.content.type === 'payment_details') {\n * event.content.object.payment_id; // typed as PaymentResponse\n * }\n * ```\n */\nexport type WebhookContent =\n | { type: 'payment_details'; object: PaymentResponse }\n | { type: 'refund_details'; object: RefundResponse }\n | { type: 'dispute_details'; object: DisputeResponse }\n | { type: 'mandate_details'; object: MandateResponse }\n | { type: 'payout_details'; object: PayoutResponse }\n | { type: 'subscription_details'; object: ConfirmSubscriptionResponse };\n\n/**\n * A parsed and verified Delopay webhook event.\n *\n * Matches the signed wire body exactly:\n * `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`.\n *\n * - `event_type` identifies the event, e.g. `'payment_succeeded'`.\n * - `content.type` tags the payload kind, e.g. `'payment_details'`.\n * - `content.object` is the payload; narrow on `content.type` to type it.\n */\nexport interface WebhookEvent {\n /** ID of the merchant that owns this event. */\n merchant_id: string;\n /** Unique ID for this event (stable across delivery retries). */\n event_id: string;\n /** Event type identifier, e.g. `'payment_succeeded'` or `'refund_succeeded'`. */\n event_type: EventType;\n /** The event payload, tagged by kind. Narrow on `content.type` to type `object`. */\n content: WebhookContent;\n /** ISO 8601 timestamp at which the webhook was sent. */\n timestamp: string;\n}\n\nfunction hexToBytes(hex: string): Uint8Array | null {\n if (hex.length === 0 || hex.length % 2 !== 0) return null;\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n const byte = Number.parseInt(hex.slice(i, i + 2), 16);\n if (Number.isNaN(byte)) return null;\n bytes[i / 2] = byte;\n }\n return bytes;\n}\n\nexport const Webhooks = {\n /**\n * Verify the signature of an incoming Delopay webhook and return the parsed event.\n *\n * Delopay signs each outgoing webhook with HMAC-SHA512 over the raw request body,\n * using your shop's webhook secret (the *payment response hash key* configured on\n * the shop). The hex-encoded digest is delivered in the `X-Webhook-Signature-512`\n * HTTP header.\n *\n * Uses the Web Crypto API (`globalThis.crypto.subtle`), so it runs unchanged in\n * Node 18+, modern browsers, Deno, Bun, and edge runtimes (Cloudflare Workers, Vercel Edge).\n *\n * Available as a static property on the `Delopay` class\n * (`Delopay.webhooks.verify`) and does not require a client instance.\n *\n * @param rawBody - The raw request body. Pass the original bytes (`Uint8Array` /\n * `Buffer`) when possible; if you pass a string, it must be the unmodified UTF-8\n * text of the request body. Do **not** parse it before passing.\n * @param signatureHeader - The value of the `X-Webhook-Signature-512` HTTP header.\n * @param secret - Your shop's webhook signing secret.\n * @returns Promise that resolves to the parsed webhook event.\n * @throws {Error} When the signature header is malformed or does not match the body.\n *\n * @example\n * ```typescript\n * // Express example\n * app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {\n * try {\n * const event = await Delopay.webhooks.verify(\n * req.body, // Buffer from express.raw()\n * req.header('x-webhook-signature-512') ?? '',\n * process.env.DELOPAY_WEBHOOK_SECRET!,\n * );\n * console.log(event.event_type, event.content.object);\n * res.sendStatus(200);\n * } catch {\n * res.status(400).send('Invalid signature');\n * }\n * });\n * ```\n */\n async verify(\n rawBody: string | Uint8Array,\n signatureHeader: string,\n secret: string,\n ): Promise<WebhookEvent> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) {\n throw new Error(\n 'Web Crypto unavailable: Delopay.webhooks.verify requires globalThis.crypto.subtle (Node 18+, modern browsers, Workers, Deno)',\n );\n }\n\n const signatureBytes = hexToBytes(signatureHeader.trim());\n if (!signatureBytes) {\n throw new Error('Invalid webhook signature format');\n }\n\n const encoder = new TextEncoder();\n const bodyBytes = typeof rawBody === 'string' ? encoder.encode(rawBody) : rawBody;\n\n // `TextEncoder.encode` returns `Uint8Array<ArrayBufferLike>` in current lib.dom.d.ts,\n // but `crypto.subtle.*` wants `BufferSource` (backed by `ArrayBuffer`). At runtime the\n // underlying buffer is always an `ArrayBuffer` — cast to quiet the type checker.\n const asBufferSource = (bytes: Uint8Array): BufferSource => bytes as unknown as BufferSource;\n const key = await subtle.importKey(\n 'raw',\n asBufferSource(encoder.encode(secret)),\n { name: 'HMAC', hash: 'SHA-512' },\n false,\n ['verify'],\n );\n\n const valid = await subtle.verify(\n 'HMAC',\n key,\n asBufferSource(signatureBytes),\n asBufferSource(bodyBytes),\n );\n\n if (!valid) {\n throw new Error('Invalid webhook signature');\n }\n\n const bodyText =\n typeof rawBody === 'string' ? rawBody : new TextDecoder('utf-8').decode(rawBody);\n return JSON.parse(bodyText) as WebhookEvent;\n },\n};\n","import type { RequestFn } from '../client';\nimport type {\n AnalyticsScopeRequest,\n AnalyticsScopeResponse,\n ClientAnalyticsRequest,\n DevicesAnalyticsResponse,\n GeoAnalyticsResponse,\n DeviceDrillRequest,\n GeoDrillRequest,\n DrillResponse,\n} from '../types';\n\nexport class Analytics {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Scoped, drill-level analytics dashboard for the authenticated merchant\n * (the same engine as the admin portal, pinned server-side to your own\n * merchant). The server ignores `merchant_id` — it always scopes to your\n * merchant, and to your single shop for profile-scoped users — so pass only\n * `project_id` / `shop_id` to drill and the window / `sections` fields.\n * Returns one drill level: the scope's daily series + previous window,\n * processor mix and direct children. `GET /analytics/scope`\n */\n async scope(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/analytics/scope', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Device analytics over the canonical client-context observation per\n * payment (browser/platform families, device classes and models, checkout\n * channel mix, time-to-pay), pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`. Gated on the\n * client-context optimisation-use switch: when it is off the server answers\n * 200 with `enabled: false` and a caveat naming the switch.\n * `GET /analytics/devices`\n */\n async devices(params?: ClientAnalyticsRequest): Promise<DevicesAnalyticsResponse> {\n return this.request('GET', '/analytics/devices', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Geo analytics over the canonical client-context observation per payment:\n * country totals, city bubbles (IP mode), buyer languages, buyer-local\n * purchase hours and the IP-vs-billing mismatch share. `mode` selects the\n * location claim (`ip` default, `billing`); the two are never coalesced.\n * Same drill, window and gating contract as `devices`.\n * `GET /analytics/geo`\n */\n async geo(params?: ClientAnalyticsRequest): Promise<GeoAnalyticsResponse> {\n return this.request('GET', '/analytics/geo', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked geo target: a map country (in the\n * active claim mode), optionally narrowed to an IP-resolved city, or one\n * buyer-local heatmap cell (`dow` + `hour`, paid sessions only). Same\n * window/scope/filter and gating contract as `geo`; capped at 50 rows,\n * newest first, with the full match count alongside.\n * `GET /analytics/geo/transactions`\n */\n async geoTransactions(params: GeoDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/geo/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked device target: exactly one of a\n * browser family, a platform family, an identified device-model label, or\n * a device class. Family/model targets are resolved server-side with the\n * same classifiers the cards use. Same window/scope/filter and gating\n * contract as `devices`; 50 rows per page (`offset` for the next page),\n * newest first, with the full match count alongside.\n * `GET /analytics/devices/transactions`\n */\n async deviceTransactions(params: DeviceDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/devices/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /** Global search. `POST /analytics/search` */\n async search(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/search', { body: params });\n }\n\n /** Domain-specific search. `POST /analytics/search/{domain}` */\n async searchDomain(\n domain: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/analytics/search/${encodeURIComponent(domain)}`, {\n body: params,\n });\n }\n\n /** Get analytics info. `GET /analytics/{domain}/info` */\n async getInfo(domain: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/analytics/${encodeURIComponent(domain)}/info`);\n }\n\n /** Get API event logs. `GET /analytics/api-event-logs` */\n async apiEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/api-event-logs', { query: params });\n }\n\n /** Get SDK event logs. `POST /analytics/sdk-event-logs` */\n async sdkEventLogs(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/sdk-event-logs', { body: params });\n }\n\n /** Get connector event logs. `GET /analytics/connector-event-logs` */\n async connectorEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/connector-event-logs', { query: params });\n }\n\n /** Get routing event logs. `GET /analytics/routing-event-logs` */\n async routingEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/routing-event-logs', { query: params });\n }\n\n /** Get outgoing webhook event logs. `GET /analytics/outgoing-webhook-event-logs` */\n async outgoingWebhookEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/outgoing-webhook-event-logs', { query: params });\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class AnalyticsDashboard {\n constructor(private readonly request: RequestFn) {}\n\n /** Get analytics dashboard data. `GET /analytics-dashboard` */\n async retrieve(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics-dashboard', { query: params });\n }\n\n /** Generate analytics dashboard report. `POST /analytics-dashboard` */\n async generate(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics-dashboard', { body: params });\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Cards {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a card. `POST /cards/create` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/cards/create', { body: params });\n }\n\n /** Update a card. `POST /cards/update` */\n async update(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/cards/update', { body: params });\n }\n\n /** Retrieve card info by BIN. `GET /cards/{bin}` */\n async retrieve(bin: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/cards/${encodeURIComponent(bin)}`);\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Export {\n constructor(private readonly request: RequestFn) {}\n\n /** Export transactions. `POST /export/transactions` */\n async transactions(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/export/transactions', { body: params });\n }\n}\n","import type { FeatureMatrixResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * What each connector can do: payment methods, capture methods, webhook\n * flows, and whether an unverified webhook is acted on.\n */\nexport class FeatureMatrix {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve the feature matrix. `GET /feature-matrix` */\n async retrieve(): Promise<FeatureMatrixResponse> {\n return this.request('GET', '/feature-matrix');\n }\n\n /**\n * Retrieve the feature matrix scoped to a merchant. Beta connectors\n * are filtered against the merchant's allowlist so the dashboard only\n * surfaces connectors the merchant can actually attach.\n * `GET /feature-matrix/{merchantId}`\n */\n async retrieveForMerchant(merchantId: string): Promise<FeatureMatrixResponse> {\n return this.request('GET', `/feature-matrix/${encodeURIComponent(merchantId)}`);\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Files {\n constructor(private readonly request: RequestFn) {}\n\n /** Upload a file. `POST /files` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/files', { body: params });\n }\n\n /** Retrieve/download a file. `GET /files/{fileId}` */\n async retrieve(fileId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/files/${encodeURIComponent(fileId)}`);\n }\n\n /** Delete a file. `DELETE /files/{fileId}` */\n async delete(fileId: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/files/${encodeURIComponent(fileId)}`);\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Forex {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve forex rates. `GET /forex/rates` */\n async getRates(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/rates', { query: params });\n }\n\n /** Convert from minor currency. `GET /forex/convert-from-minor` */\n async convertFromMinor(\n params: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/convert-from-minor', { query: params });\n }\n}\n","import type {\n RegionCreateRequest,\n RegionUpdateRequest,\n RegionResponse,\n RegionSetCountriesRequest,\n RegionCountriesResponse,\n BuiltInRegionGroupResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Custom regions (named country groups) scoped to a shop/profile, used by the\n * geo-aware payment-method availability overrides. Every endpoint is scoped by\n * `profileId`. Admin (`sk_*`) access required.\n */\nexport class Regions {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a region. `POST /regions?profile_id=` */\n async create(profileId: string, params: RegionCreateRequest): Promise<RegionResponse> {\n return this.request('POST', '/regions', {\n body: params,\n query: { profile_id: profileId },\n });\n }\n\n /** List all regions for a profile. `GET /regions/list?profile_id=` */\n async list(profileId: string): Promise<RegionResponse[]> {\n return this.request('GET', '/regions/list', { query: { profile_id: profileId } });\n }\n\n /** List the built-in (global) region groups (EU/EEA/SEPA/LATAM/APAC). `GET /regions/groups` */\n async groups(): Promise<BuiltInRegionGroupResponse[]> {\n return this.request('GET', '/regions/groups');\n }\n\n /** Retrieve a region by id. `GET /regions/{regionId}?profile_id=` */\n async retrieve(regionId: string, profileId: string): Promise<RegionResponse> {\n return this.request('GET', `/regions/${encodeURIComponent(regionId)}`, {\n query: { profile_id: profileId },\n });\n }\n\n /** Update a region. `PUT /regions/{regionId}?profile_id=` */\n async update(\n regionId: string,\n profileId: string,\n params: RegionUpdateRequest,\n ): Promise<RegionResponse> {\n return this.request('PUT', `/regions/${encodeURIComponent(regionId)}`, {\n body: params,\n query: { profile_id: profileId },\n });\n }\n\n /** Delete a region. `DELETE /regions/{regionId}?profile_id=` */\n async delete(regionId: string, profileId: string): Promise<boolean> {\n return this.request('DELETE', `/regions/${encodeURIComponent(regionId)}`, {\n query: { profile_id: profileId },\n });\n }\n\n /** Get the countries that belong to a region. `GET /regions/{regionId}/countries?profile_id=` */\n async getCountries(regionId: string, profileId: string): Promise<RegionCountriesResponse> {\n return this.request('GET', `/regions/${encodeURIComponent(regionId)}/countries`, {\n query: { profile_id: profileId },\n });\n }\n\n /** Replace the full country membership of a region. `PUT /regions/{regionId}/countries?profile_id=` */\n async setCountries(\n regionId: string,\n profileId: string,\n params: RegionSetCountriesRequest,\n ): Promise<RegionCountriesResponse> {\n return this.request('PUT', `/regions/${encodeURIComponent(regionId)}/countries`, {\n body: params,\n query: { profile_id: profileId },\n });\n }\n}\n","import type {\n AvailabilityOverrideCreateRequest,\n AvailabilityOverrideResponse,\n AvailabilityPreviewParams,\n AvailabilityPreviewResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Merchant payment-method availability overrides. Force-show or force-hide a\n * payment method per country/region at global, project, or shop scope, on top\n * of the curated country defaults. Admin (`sk_*`) access required.\n */\nexport class AvailabilityOverrides {\n constructor(private readonly request: RequestFn) {}\n\n /** Create an availability override. `POST /availability-overrides` */\n async create(params: AvailabilityOverrideCreateRequest): Promise<AvailabilityOverrideResponse> {\n return this.request('POST', '/availability-overrides', { body: params });\n }\n\n /** List a merchant's availability overrides. `GET /availability-overrides` */\n async list(merchantId: string): Promise<AvailabilityOverrideResponse[]> {\n return this.request('GET', '/availability-overrides', {\n query: { merchant_id: merchantId },\n });\n }\n\n /** Delete an availability override by id. `DELETE /availability-overrides/{id}` */\n async delete(id: string): Promise<boolean> {\n return this.request('DELETE', `/availability-overrides/${encodeURIComponent(id)}`);\n }\n\n /**\n * Preview the methods a customer in `country` would be shown for a shop —\n * the connector ceiling narrowed by the smart country defaults and the\n * merchant overrides, without an active payment. Pass `amount` + `currency`\n * to also evaluate order-value rules.\n * `GET /availability-overrides/preview`\n */\n async preview(params: AvailabilityPreviewParams): Promise<AvailabilityPreviewResponse> {\n return this.request('GET', '/availability-overrides/preview', {\n query: {\n merchant_id: params.merchant_id,\n profile_id: params.profile_id,\n ...(params.country ? { country: params.country } : {}),\n // `0` is a legitimate order value, so test for presence, not truthiness.\n ...(params.amount !== undefined ? { amount: params.amount } : {}),\n ...(params.currency ? { currency: params.currency } : {}),\n },\n });\n }\n}\n","import type {\n CreateSubscriptionRequest,\n CreateAndConfirmSubscriptionRequest,\n ConfirmSubscriptionRequest,\n UpdateSubscriptionRequest,\n PauseSubscriptionRequest,\n ResumeSubscriptionRequest,\n CancelSubscriptionRequest,\n SubscriptionResponse,\n ConfirmSubscriptionResponse,\n PauseSubscriptionResponse,\n ResumeSubscriptionResponse,\n CancelSubscriptionResponse,\n GetSubscriptionItemsResponse,\n GetSubscriptionItemsParams,\n SubscriptionEstimateResponse,\n SubscriptionEstimateParams,\n SubscriptionListParams,\n SubscriptionPaymentLookupRequest,\n SubscriptionPaymentLookupResponse,\n SubscriptionInvoiceListParams,\n SubscriptionInvoiceListResponse,\n SubscriptionBillingProcessorResponse,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Subscription endpoints are profile-scoped: the backend requires an\n * `X-Profile-Id` header to resolve the shop / billing processor (`IR_04`\n * otherwise). Pass it through the per-call `options.headers`, e.g.\n * `subscriptions.list(params, { headers: { 'X-Profile-Id': profileId } })`.\n */\nexport class Subscriptions {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create and immediately confirm a subscription. `POST /subscriptions`\n *\n * For billing processors that require buyer approval (e.g. PayPal), the\n * response carries a `redirect_url` the customer must be sent to.\n */\n async createAndConfirm(\n params: CreateAndConfirmSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.request('POST', '/subscriptions', { body: params, ...options });\n }\n\n /** Create a subscription without confirming it. `POST /subscriptions/create` */\n async create(\n params: CreateSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse> {\n return this.request('POST', '/subscriptions/create', { body: params, ...options });\n }\n\n /** Retrieve a subscription by ID. `GET /subscriptions/{subscriptionId}` */\n async retrieve(subscriptionId: string, options?: RequestExtras): Promise<SubscriptionResponse> {\n return this.request('GET', `/subscriptions/${encodeURIComponent(subscriptionId)}`, {\n ...options,\n });\n }\n\n /**\n * Confirm a previously created subscription. `POST /subscriptions/{subscriptionId}/confirm`\n *\n * Like {@link createAndConfirm}, the response may carry a `redirect_url` for\n * processors that require buyer approval.\n */\n async confirm(\n subscriptionId: string,\n params: ConfirmSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/confirm`, {\n body: params,\n ...options,\n });\n }\n\n /** Update a subscription's plan/price. `PUT /subscriptions/{subscriptionId}/update` */\n async update(\n subscriptionId: string,\n params: UpdateSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse> {\n return this.request('PUT', `/subscriptions/${encodeURIComponent(subscriptionId)}/update`, {\n body: params,\n ...options,\n });\n }\n\n /** List subscriptions for the profile. `GET /subscriptions/list` */\n async list(\n params?: SubscriptionListParams,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse[]> {\n return this.request('GET', '/subscriptions/list', {\n query: params as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /** Estimate the cost of a subscription before creating it. `GET /subscriptions/estimate` */\n async getEstimate(\n params: SubscriptionEstimateParams,\n options?: RequestExtras,\n ): Promise<SubscriptionEstimateResponse> {\n return this.request('GET', '/subscriptions/estimate', {\n query: params as unknown as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /** List purchasable subscription items (plans/addons). `GET /subscriptions/items` */\n async getItems(\n params: GetSubscriptionItemsParams,\n options?: RequestExtras,\n ): Promise<GetSubscriptionItemsResponse[]> {\n return this.request('GET', '/subscriptions/items', {\n query: params as unknown as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /**\n * Pause a subscription. `POST /subscriptions/{subscriptionId}/pause`\n *\n * The body defaults to `{}` so the request still carries\n * `Content-Type: application/json` even when no params are passed — the\n * backend rejects the POST otherwise (\"Unsupported content type\").\n */\n async pause(\n subscriptionId: string,\n params?: PauseSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<PauseSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/pause`, {\n body: params ?? {},\n ...options,\n });\n }\n\n /** Resume a paused subscription. `POST /subscriptions/{subscriptionId}/resume` */\n async resume(\n subscriptionId: string,\n params?: ResumeSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<ResumeSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/resume`, {\n body: params ?? {},\n ...options,\n });\n }\n\n /** Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel` */\n async cancel(\n subscriptionId: string,\n params?: CancelSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<CancelSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, {\n body: params ?? {},\n ...options,\n });\n }\n\n /**\n * Resolve which of the given payments were raised by a subscription.\n * `POST /subscriptions/payments/lookup`\n *\n * The linkage exists in one direction only — an invoice points at the payment\n * it settled, and nothing is stamped on the payment — so this is the only way\n * to tell a subscription charge from a one-off one when you are holding a\n * page of payments. In particular, do not use `off_session` or the presence\n * of a mandate: an ordinary saved-card charge sets those identically.\n *\n * Ids that belong to no subscription are **absent** from `links` rather than\n * returned as an error, so match on presence:\n *\n * ```ts\n * const { links } = await subscriptions.lookupPayments(\n * { payment_ids: page.map((p) => p.payment_id) },\n * { headers: { 'X-Profile-Id': profileId } },\n * );\n * const bySubscription = new Map(links.map((l) => [l.payment_id, l]));\n * ```\n *\n * Profile-scoped like every other subscription route, and that matters more\n * here than elsewhere: a `payment_id` is merchant-supplied and only unique\n * within a merchant, so the shop is part of the question, not an\n * optimisation. Pass the profile that owns **the payments** — for a list\n * spanning several shops, group the ids by shop and call once per group.\n *\n * At most 200 ids per call.\n */\n async lookupPayments(\n params: SubscriptionPaymentLookupRequest,\n options?: RequestExtras,\n ): Promise<SubscriptionPaymentLookupResponse> {\n return this.request('POST', '/subscriptions/payments/lookup', { body: params, ...options });\n }\n\n /**\n * One subscription's billing history, newest cycle first.\n * `GET /subscriptions/{subscriptionId}/invoices`\n *\n * {@link retrieve} carries only the *latest* invoice, which is the current\n * cycle — a subscription that has renewed monthly for a year has one of those\n * and twelve of these. Use this wherever a merchant needs to see what a\n * subscription has actually billed, in particular on self-charging processors\n * (Creem, PayPal) where each renewal is charged by the processor and mirrored\n * here rather than raised as a DeloPay payment.\n *\n * Two things to render honestly, both decided rather than incidental:\n *\n * - `amount` is **gross** and `refunded_amount` sits beside it. Do not net\n * them: the difference between the two is not a smaller charge.\n * - A `refunded_amount` of `null` is \"not reported\" and must not render as\n * `0`. Likewise a processor-hosted origination records a bootstrap invoice\n * at `0` before the buyer has paid anything, so a zero amount on such a\n * subscription is a placeholder rather than a free cycle.\n *\n * Profile-scoped like every other subscription route.\n */\n async listInvoices(\n subscriptionId: string,\n params?: SubscriptionInvoiceListParams,\n options?: RequestExtras,\n ): Promise<SubscriptionInvoiceListResponse> {\n return this.request('GET', `/subscriptions/${encodeURIComponent(subscriptionId)}/invoices`, {\n query: params as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /**\n * Which billing processor this shop's subscriptions run on.\n * `GET /subscriptions/billing_processor`\n *\n * The same mapping is derivable from the connector inventory\n * (`GET /account/{merchant_id}/connectors`), but that route is gated by a\n * connector-read permission granted independently of subscriptions — so a\n * role authorised to create subscriptions could be unable to learn which\n * processor it was creating them on. This answers under the same\n * authorization as the rest of the subscription API.\n *\n * Reach for it when the client must branch on the processor *before* calling\n * — origination differs by processor, and guessing is destructive. Resolve\n * the shop's `billing_processor_id` first: a shop that runs no subscriptions\n * has none assigned, and this route has no identity to report for it.\n */\n async getBillingProcessor(\n options?: RequestExtras,\n ): Promise<SubscriptionBillingProcessorResponse> {\n return this.request('GET', '/subscriptions/billing_processor', { ...options });\n }\n}\n","import type {\n FeeStatementDetail,\n SettlementBackfillRequest,\n SettlementBackfillResponse,\n SettlementCostParams,\n SettlementCostResponse,\n SettlementCurrentParams,\n SettlementCurrentResponse,\n SettlementLineListParams,\n SettlementLineListResponse,\n SettlementOverviewParams,\n SettlementOverviewResponse,\n SettlementStatementListParams,\n SettlementStatementListResponse,\n ShopFeeConfigParams,\n ShopFeeConfigResponse,\n ShopVisibilityResponse,\n ShopVisibilityUpdateRequest,\n StatementAdjustment,\n StatementAdjustmentCreateRequest,\n StatementAdjustmentListResponse,\n StatementGenerateRequest,\n StatementPayoutUpdateRequest,\n StatementPdfParams,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Hosted-shop settlement: monthly statements, the live current-period\n * rollup, per-line detail, fee schedules and backfills.\n *\n * Every read takes an explicit `test_mode` — test and live figures must\n * never blend, so the environment lives in the signature rather than in a\n * default. `false` is transmitted, not dropped.\n *\n * Shop-owner responses are redacted server-side: absent platform-fee fields\n * are a permission boundary, not a gap — never re-derive them client-side.\n */\nexport class Settlement {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Per-shop settlement rollup for the host merchant: unpaid totals and the\n * running current period, one row per shop.\n *\n * `GET /settlement/overview`\n */\n async overview(\n params: SettlementOverviewParams,\n options?: RequestExtras,\n ): Promise<SettlementOverviewResponse> {\n return this.request('GET', '/settlement/overview', {\n query: { test_mode: params.test_mode },\n ...options,\n });\n }\n\n /**\n * Live rollup of the current (not yet statemented) period.\n *\n * `GET /settlement/current`\n */\n async current(\n params: SettlementCurrentParams,\n options?: RequestExtras,\n ): Promise<SettlementCurrentResponse> {\n return this.request('GET', '/settlement/current', {\n query: { test_mode: params.test_mode, profile_id: params.profile_id },\n ...options,\n });\n }\n\n /**\n * What a period's payments cost, and what was left over: gross, the\n * platform fee, hosting fees, what the rails took, and the margin, with a\n * per-connector breakdown.\n *\n * Send `year` and `month` together to report one UTC calendar month, or\n * neither for the running month so far.\n *\n * **Host-only.** The response is the host's cost base, which a shop owner\n * must never see, so a profile-scoped caller is refused with a 403 rather\n * than given a redacted shell. Gate the surface on the caller's scope\n * instead of calling it and handling the failure.\n *\n * Two things not to flatten when rendering the result:\n * `margin_usd` is absent — not zero — whenever `margin_quality` is\n * `'unknown'`, and `unlined_captured_attempt_count` (cost definitely\n * missing) means something different from `unlined_unresolved_attempt_count`\n * (mostly ordinary abandonment).\n *\n * `GET /settlement/cost`\n *\n * @example\n * ```typescript\n * const cost = await delopay.settlement.cost({ test_mode: false, year: 2026, month: 7 });\n * if (cost.margin_quality === 'unknown') {\n * // cost.margin_usd is absent — say so, do not render 0.00\n * }\n * ```\n */\n async cost(\n params?: SettlementCostParams,\n options?: RequestExtras,\n ): Promise<SettlementCostResponse> {\n return this.request('GET', '/settlement/cost', {\n query: {\n profile_id: params?.profile_id,\n test_mode: params?.test_mode,\n year: params?.year,\n month: params?.month,\n },\n ...options,\n });\n }\n\n /**\n * List generated settlement statements, newest first.\n *\n * `GET /settlement/statements`\n */\n async listStatements(\n params: SettlementStatementListParams,\n options?: RequestExtras,\n ): Promise<SettlementStatementListResponse> {\n return this.request('GET', '/settlement/statements', {\n query: {\n test_mode: params.test_mode,\n profile_id: params.profile_id,\n limit: params.limit,\n offset: params.offset,\n },\n ...options,\n });\n }\n\n /**\n * One statement with its per-connector/currency breakdown.\n *\n * `GET /settlement/statements/{statementId}`\n */\n async retrieveStatement(\n statementId: string,\n options?: RequestExtras,\n ): Promise<FeeStatementDetail> {\n return this.request(\n 'GET',\n `/settlement/statements/${encodeURIComponent(statementId)}`,\n options,\n );\n }\n\n /**\n * Generate (or regenerate) the statement for one shop and calendar month.\n *\n * `POST /settlement/statements/generate`\n */\n async generateStatement(\n params: StatementGenerateRequest,\n options?: RequestExtras,\n ): Promise<FeeStatementDetail> {\n return this.request('POST', '/settlement/statements/generate', {\n body: params,\n ...options,\n });\n }\n\n /**\n * Record payout progress on a statement (`unpaid` / `partial` / `paid`).\n *\n * Subject to the caller's `settlement_payout` operation limit, which can\n * only be a per-operation ceiling: an over-limit call fails with `DE_01`\n * and nothing is recorded. There is no approval route out of it — four-eyes\n * needs an executor that can run the operation once somebody says yes, and\n * only refunds have one, so a settlement rule can only block.\n *\n * `POST /settlement/statements/{statementId}/payout`\n */\n async updateStatementPayout(\n statementId: string,\n params: StatementPayoutUpdateRequest,\n options?: RequestExtras,\n ): Promise<FeeStatementDetail> {\n return this.request(\n 'POST',\n `/settlement/statements/${encodeURIComponent(statementId)}/payout`,\n { body: params, ...options },\n );\n }\n\n /**\n * Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with\n * the same auth, retries and error handling as every other call — persist\n * or object-URL it caller-side.\n *\n * `GET /settlement/statements/{statementId}/pdf`\n *\n * @example\n * ```typescript\n * const pdf = await delopay.settlement.downloadStatementPdf('stmt_1', {\n * currency: 'EUR',\n * include_transactions: true,\n * });\n * const url = URL.createObjectURL(pdf);\n * ```\n */\n async downloadStatementPdf(\n statementId: string,\n params?: StatementPdfParams,\n options?: RequestExtras,\n ): Promise<Blob> {\n return this.request('GET', `/settlement/statements/${encodeURIComponent(statementId)}/pdf`, {\n query: {\n currency: params?.currency,\n include_transactions: params?.include_transactions,\n },\n responseType: 'blob',\n ...options,\n });\n }\n\n /**\n * The individual settled attempts of one shop's calendar month.\n *\n * `GET /settlement/lines`\n */\n async listLines(\n params: SettlementLineListParams,\n options?: RequestExtras,\n ): Promise<SettlementLineListResponse> {\n return this.request('GET', '/settlement/lines', {\n query: {\n profile_id: params.profile_id,\n year: params.year,\n month: params.month,\n test_mode: params.test_mode,\n limit: params.limit,\n offset: params.offset,\n },\n ...options,\n });\n }\n\n /**\n * The fee schedules that currently apply to a shop.\n *\n * `GET /settlement/fee-config`\n */\n async feeConfig(\n params: ShopFeeConfigParams,\n options?: RequestExtras,\n ): Promise<ShopFeeConfigResponse> {\n return this.request('GET', '/settlement/fee-config', {\n query: { profile_id: params.profile_id },\n ...options,\n });\n }\n\n /**\n * Enqueue a settlement-line backfill over historical attempts. Attempts\n * already covered by a line are always skipped.\n *\n * `POST /settlement/backfill`\n */\n async backfill(\n params?: SettlementBackfillRequest,\n options?: RequestExtras,\n ): Promise<SettlementBackfillResponse> {\n return this.request('POST', '/settlement/backfill', { body: params, ...options });\n }\n\n /**\n * Toggle whether a shop's owner can see their own settlement figures.\n *\n * `POST /settlement/shops/visibility`\n */\n async setShopVisibility(\n params: ShopVisibilityUpdateRequest,\n options?: RequestExtras,\n ): Promise<ShopVisibilityResponse> {\n return this.request('POST', '/settlement/shops/visibility', {\n body: params,\n ...options,\n });\n }\n\n /**\n * Manual adjustments recorded on a statement.\n *\n * `GET /settlement/statements/{statementId}/adjustments`\n */\n async listStatementAdjustments(\n statementId: string,\n options?: RequestExtras,\n ): Promise<StatementAdjustmentListResponse> {\n return this.request(\n 'GET',\n `/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,\n options,\n );\n }\n\n /**\n * Add a manual adjustment to a statement. Positive `amount_usd` charges\n * the shop (reducing their payout); negative credits them.\n *\n * Subject to the caller's `settlement_adjustment` operation limit (amount\n * dimensions only): an over-limit call fails with `DE_01` and no adjustment\n * is added. A settlement rule can only block — approval is refund-only, for\n * the reason given on `updateStatementPayout()`.\n *\n * `POST /settlement/statements/{statementId}/adjustments`\n */\n async createStatementAdjustment(\n statementId: string,\n params: StatementAdjustmentCreateRequest,\n options?: RequestExtras,\n ): Promise<StatementAdjustment> {\n return this.request(\n 'POST',\n `/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,\n { body: params, ...options },\n );\n }\n\n /**\n * Remove a manual adjustment from a statement.\n *\n * `DELETE /settlement/statements/{statementId}/adjustments/{adjustmentId}`\n */\n async deleteStatementAdjustment(\n statementId: string,\n adjustmentId: string,\n options?: RequestExtras,\n ): Promise<void> {\n return this.request(\n 'DELETE',\n `/settlement/statements/${encodeURIComponent(statementId)}/adjustments/${encodeURIComponent(adjustmentId)}`,\n options,\n );\n }\n}\n","import type {\n DecidePendingOperationRequest,\n OperationLimitRule,\n OperationLimitRuleDeleteResponse,\n OperationLimitRuleListParams,\n OperationLimitSettings,\n PendingOperation,\n PendingOperationListParams,\n PendingOperationListResponse,\n UpdateOperationLimitSettingsRequest,\n UpsertOperationLimitRuleRequest,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Per-operation spending limits: rules scoped to the merchant, a role or a\n * user, the merchant-level enforcement settings, and the approvals inbox.\n * Enforcement resolves the most specific rule: user > role > merchant.\n *\n * A rule set to `require_approval` does not refuse an over-limit operation —\n * it parks it. The original call fails with HTTP 409 `DE_06` carrying\n * `PendingApprovalErrorDetails`, and the operation runs only once a second\n * person approves the request through this inbox.\n *\n * **Refunds only.** Approval needs an executor that can run the operation\n * after the decision, and only refunds have one; the settlement operations\n * take `block` alone, which the request type enforces. So every request in\n * this inbox is a refund, and `DE_06` never comes back from a settlement\n * call — an over-limit settlement adjustment or payout fails with `DE_01`.\n */\nexport class OperationLimits {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * List the merchant's limit rules, optionally for one operation.\n *\n * `GET /operation-limits/rules`\n */\n async listRules(\n params?: OperationLimitRuleListParams,\n options?: RequestExtras,\n ): Promise<OperationLimitRule[]> {\n return this.request('GET', '/operation-limits/rules', {\n query: { operation: params?.operation },\n ...options,\n });\n }\n\n /**\n * Create or replace the limit rule for one target. Full-replace upsert:\n * absent limit fields clear that dimension.\n *\n * `PUT /operation-limits/rules`\n */\n async upsertRule(\n params: UpsertOperationLimitRuleRequest,\n options?: RequestExtras,\n ): Promise<OperationLimitRule> {\n return this.request('PUT', '/operation-limits/rules', { body: params, ...options });\n }\n\n /**\n * Delete a limit rule.\n *\n * `DELETE /operation-limits/rules/{ruleId}`\n */\n async deleteRule(\n ruleId: string,\n options?: RequestExtras,\n ): Promise<OperationLimitRuleDeleteResponse> {\n return this.request('DELETE', `/operation-limits/rules/${encodeURIComponent(ruleId)}`, options);\n }\n\n /**\n * The merchant-level enforcement settings. An untouched merchant gets the\n * defaults: rolling window, admins not exempt.\n *\n * `GET /operation-limits/settings`\n */\n async retrieveSettings(options?: RequestExtras): Promise<OperationLimitSettings> {\n return this.request('GET', '/operation-limits/settings', options);\n }\n\n /**\n * Update the enforcement settings. Only provided fields change.\n *\n * `PUT /operation-limits/settings`\n */\n async updateSettings(\n params: UpdateOperationLimitSettingsRequest,\n options?: RequestExtras,\n ): Promise<OperationLimitSettings> {\n return this.request('PUT', '/operation-limits/settings', { body: params, ...options });\n }\n\n /**\n * The approvals inbox: over-limit operations waiting on a second person.\n *\n * Both filters default rather than widen. With no `status` the list holds\n * **pending requests only** — approved, rejected and expired ones are\n * reachable only by asking for that status, so a history view must pass one\n * per status. With no `operation` it lists **refunds only**; the list is one\n * operation at a time. `limit` defaults to 100 and is clamped to 1–500.\n *\n * Requests past their `expires_at` are expired before the list is read, so\n * nothing here is shown as actionable when it is not.\n *\n * `GET /operation-limits/approvals`\n */\n async listApprovals(\n params?: PendingOperationListParams,\n options?: RequestExtras,\n ): Promise<PendingOperationListResponse> {\n return this.request('GET', '/operation-limits/approvals', {\n query: {\n operation: params?.operation,\n status: params?.status,\n limit: params?.limit,\n },\n ...options,\n });\n }\n\n /**\n * Approve a parked operation and execute it.\n *\n * Refused for the user who requested it, and for an approver whose own\n * limit would not have covered the operation — the permission is necessary\n * and not sufficient.\n *\n * Approval and execution are two facts. A request that was approved but\n * whose operation then failed comes back `approved` with `execution_error`\n * set and no `result_entity_id`; that is a real outcome, not a partial read.\n *\n * `POST /operation-limits/approvals/{id}/approve`\n */\n async approve(\n id: string,\n params: DecidePendingOperationRequest = {},\n options?: RequestExtras,\n ): Promise<PendingOperation> {\n return this.request('POST', `/operation-limits/approvals/${encodeURIComponent(id)}/approve`, {\n body: params,\n ...options,\n });\n }\n\n /**\n * Reject a parked operation. Nothing is executed and the request is closed.\n *\n * `POST /operation-limits/approvals/{id}/reject`\n */\n async reject(\n id: string,\n params: DecidePendingOperationRequest = {},\n options?: RequestExtras,\n ): Promise<PendingOperation> {\n return this.request('POST', `/operation-limits/approvals/${encodeURIComponent(id)}/reject`, {\n body: params,\n ...options,\n });\n }\n}\n","import type { MerchantRisk, ShopRisk } from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Stored shop risk indexes, per connector.\n *\n * Both reads return snapshots and never score on demand, so `computed_at` is\n * the age of the answer rather than the time of the call.\n *\n * The caller's own scope is what bounds the answer, and it is enforced\n * server-side: a profile-scoped role, or an API key pinned to one shop, gets\n * that shop from both endpoints and cannot read or enumerate a sibling's.\n */\nexport class Risk {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Every shop's stored risk for the caller's merchant, with the worst band\n * across them.\n *\n * `GET /risk`\n */\n async retrieve(options?: RequestExtras): Promise<MerchantRisk> {\n return this.request('GET', '/risk', options);\n }\n\n /**\n * One shop's stored risk index per connector.\n *\n * `GET /risk/shops/{profileId}`\n */\n async retrieveShop(profileId: string, options?: RequestExtras): Promise<ShopRisk> {\n return this.request('GET', `/risk/shops/${encodeURIComponent(profileId)}`, options);\n }\n}\n","import { DelopayError, DelopayAuthenticationError } from './error';\nimport { ApiKeys } from './resources/apiKeys';\nimport { Authentication } from './resources/authentication';\nimport { Billing } from './resources/billing';\nimport { Blocklist } from './resources/blocklist';\nimport { Connectors } from './resources/connectors';\nimport { Customers } from './resources/customers';\nimport { Disputes } from './resources/disputes';\nimport { EphemeralKeys } from './resources/ephemeralKeys';\nimport { Events } from './resources/events';\nimport { Fees } from './resources/fees';\nimport { Mandates } from './resources/mandates';\nimport { MerchantAccounts } from './resources/merchantAccounts';\nimport { PaymentLinks } from './resources/paymentLinks';\nimport { PaymentMethods } from './resources/paymentMethods';\nimport { Payments } from './resources/payments';\nimport { Payouts } from './resources/payouts';\nimport { Poll } from './resources/poll';\nimport { ProfileAcquirers } from './resources/profileAcquirers';\nimport { Profiles } from './resources/profiles';\nimport { Projects } from './resources/projects';\nimport { Refunds } from './resources/refunds';\nimport { Relay } from './resources/relay';\nimport { Routing } from './resources/routing';\nimport { Search } from './resources/search';\nimport { Shops } from './resources/shops';\nimport { StripeConnect } from './resources/stripeConnect';\nimport { ThreeDsRules } from './resources/threeDsRules';\nimport { Users } from './resources/users';\nimport { Verification } from './resources/verification';\nimport { Webhooks } from './resources/webhooks';\nimport type { TokenResponse } from './types';\nimport { Analytics } from './resources/analytics';\nimport { AnalyticsDashboard } from './resources/analyticsDashboard';\nimport { Cards } from './resources/cards';\nimport { Export } from './resources/export';\nimport { FeatureMatrix } from './resources/featureMatrix';\nimport { Files } from './resources/files';\nimport { Forex } from './resources/forex';\nimport { Regions } from './resources/regions';\nimport { AvailabilityOverrides } from './resources/availabilityOverrides';\nimport { Subscriptions } from './resources/subscriptions';\nimport { Settlement } from './resources/settlement';\nimport { OperationLimits } from './resources/operationLimits';\nimport { Risk } from './resources/risk';\n\nconst PRODUCTION_URL = 'https://api.delopay.net';\nconst SANDBOX_URL = 'https://sandbox.delopay.net';\n\nconst MAX_RAW_BODY_BYTES = 2048;\nconst MAX_RETRY_AFTER_MS = 30_000;\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const trimmed = header.trim();\n const seconds = Number(trimmed);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);\n }\n const date = Date.parse(trimmed);\n if (Number.isFinite(date)) {\n const delta = date - Date.now();\n return delta > 0 ? Math.min(delta, MAX_RETRY_AFTER_MS) : 0;\n }\n return null;\n}\n\nfunction truncateRawBody(raw: string): string | undefined {\n if (!raw) return undefined;\n return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + '…' : raw;\n}\n\nfunction findIdempotencyKey(headers: Record<string, string>): string | undefined {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === 'idempotency-key') return v;\n }\n return undefined;\n}\n\ninterface CombinedSignal {\n signal: AbortSignal;\n dispose: () => void;\n}\n\nfunction noop(): void {\n // Intentionally empty: no listeners registered, nothing to clean up.\n}\n\nfunction combineSignals(signals: AbortSignal[]): CombinedSignal {\n const controller = new AbortController();\n const listeners: { signal: AbortSignal; handler: () => void }[] = [];\n const dispose = () => {\n for (const { signal, handler } of listeners) {\n signal.removeEventListener('abort', handler);\n }\n listeners.length = 0;\n };\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n dispose();\n return { signal: controller.signal, dispose: noop };\n }\n const handler = () => {\n controller.abort(signal.reason);\n dispose();\n };\n signal.addEventListener('abort', handler, { once: true });\n listeners.push({ signal, handler });\n }\n return { signal: controller.signal, dispose };\n}\n\n/**\n * Events emitted by the debug logger.\n * - `request` — about to send a request (`method`, `url`, `path`)\n * - `response` — response received (`status`, `method`, `path`, `requestId?`)\n * - `retry` — about to retry after a transient failure (`attempt`, `maxRetries`, `method`, `path`)\n */\nexport type DelopayLogger = (\n event: 'request' | 'response' | 'retry',\n data: Record<string, unknown>,\n) => void;\n\n/**\n * Configuration options for the Delopay client.\n */\nexport interface DelopayOptions {\n /** Use the sandbox environment (`https://sandbox.delopay.net`). Defaults to `false` (production). */\n sandbox?: boolean;\n /** Override the base URL entirely. Takes precedence over `sandbox`. */\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to `30000` (30 seconds). */\n timeout?: number;\n /**\n * Maximum number of automatic retries for transient failures (5xx, timeout, network errors).\n * Retries use exponential backoff. Set to `0` to disable. Defaults to `2`.\n * Only idempotent-safe requests (GET, DELETE, and requests with an `Idempotency-Key` header) are retried.\n */\n maxRetries?: number;\n /** Enable debug logging of requests and responses. Defaults to `false`. */\n debug?: boolean;\n /**\n * Custom logger for debug events (`request`, `response`, `retry`). When omitted,\n * debug output is written to `console.log`. Has no effect unless `debug` is `true`.\n * Useful for routing SDK logs through pino, winston, or similar structured loggers.\n */\n logger?: DelopayLogger;\n}\n\nconst SENSITIVE_QUERY_KEYS = new Set([\n 'client_secret',\n 'ephemeral_key',\n 'api_key',\n 'publishable_key',\n]);\n\n/**\n * Return a copy of `url` with the values of known-sensitive query parameters\n * replaced by `REDACTED`, leaving the rest of the query string intact.\n * Used only to sanitize URLs before they hit debug logs.\n */\nfunction redactUrlForLogging(url: string): string {\n const qIdx = url.indexOf('?');\n if (qIdx === -1) return url;\n const base = url.slice(0, qIdx);\n const query = url.slice(qIdx + 1);\n const parts = query.split('&').map((pair) => {\n const eqIdx = pair.indexOf('=');\n if (eqIdx === -1) return pair;\n const key = pair.slice(0, eqIdx);\n if (SENSITIVE_QUERY_KEYS.has(decodeURIComponent(key).toLowerCase())) {\n return `${key}=REDACTED`;\n }\n return pair;\n });\n return `${base}?${parts.join('&')}`;\n}\n\n/**\n * Low-level options forwarded to a single HTTP request.\n */\nexport interface RequestOptions {\n /** Request body, serialised as JSON. */\n body?: unknown;\n /**\n * Query-string parameters. `undefined` and `null` values are omitted.\n * Array values are emitted as repeated keys (`?tag=a&tag=b`) — not comma-joined.\n */\n query?: Record<\n string,\n string | number | boolean | null | undefined | (string | number | boolean)[]\n >;\n /** Additional HTTP headers merged with the default `api-key` header. */\n headers?: Record<string, string>;\n /** Override the client-level timeout for this request, in milliseconds. */\n timeout?: number;\n /**\n * Caller-provided `AbortSignal`. Aborting it cancels the in-flight request and rejects\n * with a `DelopayError` carrying code `'ABORTED'`. Combined with the per-request timeout.\n */\n signal?: AbortSignal;\n /**\n * How to decode a 2xx response body. `'json'` (the default) parses JSON;\n * `'blob'` / `'arraybuffer'` return the raw bytes for binary endpoints\n * such as PDF exports. Error responses are always decoded as JSON and\n * thrown as `DelopayError` regardless of this setting.\n */\n responseType?: 'json' | 'blob' | 'arraybuffer';\n /**\n * Pass `keepalive: true` to let the request outlive its page — e.g.\n * telemetry sent while the document is navigating away. Browsers cap\n * keepalive request bodies at ~64 KiB and reject larger ones.\n */\n keepalive?: boolean;\n}\n\nexport type RequestFn = <T>(method: string, path: string, options?: RequestOptions) => Promise<T>;\n\n/**\n * Per-call options that resource methods accept as an optional final argument:\n * extra HTTP headers (e.g. `Idempotency-Key`), a per-request timeout override,\n * and an `AbortSignal` for cancellation.\n */\nexport type RequestExtras = Pick<RequestOptions, 'headers' | 'timeout' | 'signal'>;\n\n/**\n * Delopay API client.\n *\n * Instantiate once with your API key and reuse across your application.\n * All resource sub-clients (payments, refunds, customers, …) are exposed\n * as properties on the instance.\n *\n * @example\n * ```typescript\n * const delopay = new Delopay('prd_...', { sandbox: false });\n * const payment = await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * ```\n */\nexport class Delopay {\n /** Utility for verifying incoming webhook signatures (static, no instance needed). */\n static webhooks = Webhooks;\n\n /** The resolved base URL used for all API requests. */\n readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly debug: boolean;\n private readonly logger?: DelopayLogger;\n private jwtToken?: string;\n\n // Merchant-facing\n readonly payments: Payments;\n readonly refunds: Refunds;\n readonly customers: Customers;\n readonly paymentMethods: PaymentMethods;\n readonly paymentLinks: PaymentLinks;\n readonly mandates: Mandates;\n readonly disputes: Disputes;\n readonly payouts: Payouts;\n readonly ephemeralKeys: EphemeralKeys;\n readonly events: Events;\n readonly poll: Poll;\n\n // Connector / routing\n readonly connectors: Connectors;\n readonly routing: Routing;\n readonly profiles: Profiles;\n readonly shops: Shops;\n readonly profileAcquirers: ProfileAcquirers;\n\n // Authentication & verification\n readonly authentication: Authentication;\n readonly verification: Verification;\n\n // Dashboard / internal\n readonly users: Users;\n readonly apiKeys: ApiKeys;\n readonly billing: Billing;\n readonly blocklist: Blocklist;\n readonly fees: Fees;\n readonly merchantAccounts: MerchantAccounts;\n readonly projects: Projects;\n readonly relay: Relay;\n readonly stripeConnect: StripeConnect;\n readonly threeDsRules: ThreeDsRules;\n readonly settlement: Settlement;\n readonly operationLimits: OperationLimits;\n readonly risk: Risk;\n\n // New resources (Phases 3-4)\n readonly subscriptions: Subscriptions;\n readonly files: Files;\n readonly export: Export;\n readonly forex: Forex;\n readonly regions: Regions;\n readonly availabilityOverrides: AvailabilityOverrides;\n readonly analytics: Analytics;\n readonly analyticsDashboard: AnalyticsDashboard;\n readonly featureMatrix: FeatureMatrix;\n readonly cards: Cards;\n readonly search: Search;\n\n /**\n * Create a new Delopay client.\n *\n * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).\n * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).\n * @param options - Optional configuration (sandbox mode, base URL override, timeout).\n */\n constructor(apiKey?: string, options?: DelopayOptions) {\n this.apiKey = apiKey ?? '';\n this.timeout = options?.timeout ?? 30_000;\n this.maxRetries = options?.maxRetries ?? 2;\n this.debug = options?.debug ?? false;\n if (options?.logger !== undefined) this.logger = options.logger;\n\n if (options?.baseUrl !== undefined) {\n this.baseUrl = options.baseUrl;\n } else if (options?.sandbox) {\n this.baseUrl = SANDBOX_URL;\n } else {\n this.baseUrl = PRODUCTION_URL;\n }\n\n const request = this.request.bind(this) as RequestFn;\n\n // JWT auth methods are defined below (setJwtToken / clearJwtToken)\n\n // Merchant-facing\n this.payments = new Payments(request);\n this.refunds = new Refunds(request);\n this.customers = new Customers(request);\n this.paymentMethods = new PaymentMethods(request);\n this.paymentLinks = new PaymentLinks(request);\n this.mandates = new Mandates(request);\n this.disputes = new Disputes(request);\n this.payouts = new Payouts(request);\n this.ephemeralKeys = new EphemeralKeys(request);\n this.events = new Events(request);\n this.poll = new Poll(request);\n\n // Connector / routing\n this.connectors = new Connectors(request);\n this.routing = new Routing(request);\n this.profiles = new Profiles(request);\n this.shops = new Shops(request);\n this.profileAcquirers = new ProfileAcquirers(request);\n\n // Authentication & verification\n this.authentication = new Authentication(request);\n this.verification = new Verification(request);\n\n // Dashboard / internal\n this.users = new Users(request);\n this.apiKeys = new ApiKeys(request);\n this.billing = new Billing(request);\n this.blocklist = new Blocklist(request);\n this.fees = new Fees(request);\n this.merchantAccounts = new MerchantAccounts(request);\n this.projects = new Projects(request);\n this.relay = new Relay(request);\n this.stripeConnect = new StripeConnect(request);\n this.threeDsRules = new ThreeDsRules(request);\n this.settlement = new Settlement(request);\n this.operationLimits = new OperationLimits(request);\n this.risk = new Risk(request);\n\n // New resources (Phases 3-4)\n this.subscriptions = new Subscriptions(request);\n this.files = new Files(request);\n this.export = new Export(request);\n this.forex = new Forex(request);\n this.regions = new Regions(request);\n this.availabilityOverrides = new AvailabilityOverrides(request);\n this.analytics = new Analytics(request);\n this.analyticsDashboard = new AnalyticsDashboard(request);\n this.featureMatrix = new FeatureMatrix(request);\n this.cards = new Cards(request);\n this.search = new Search(request);\n }\n\n /**\n * Set a JWT token for subsequent requests.\n * When set, requests use `Authorization: Bearer <token>` instead of `api-key`.\n * Useful after `users.signIn()` returns a JWT for dashboard operations.\n */\n setJwtToken(token: string): void {\n this.jwtToken = token;\n }\n\n /**\n * Clear the JWT token, reverting to API key authentication.\n */\n clearJwtToken(): void {\n this.jwtToken = undefined;\n }\n\n /**\n * Refresh the current login JWT (see {@link Users.refreshToken}) and\n * apply the fresh token to this client, so subsequent requests use it.\n * Returns the fresh token for the caller to persist (e.g. session\n * storage) — the backend has already re-set the `login_token` cookie.\n *\n * If the client's auth state changes while the refresh is pending —\n * `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another\n * session — the stale completion is discarded and this rejects with a\n * `session_changed` `DelopayError` (status 0), so the explicit change\n * wins and the caller never persists a token for a session that is gone.\n *\n * Otherwise throws like any other request; in particular a 401 means the\n * session is dead (expired/blacklisted/revoked), a 429 means a refresh\n * was already minted for this session within the last minute, and a 400\n * means this token has no revocable session to slide (no `jti` — team\n * impersonation is the case in practice) and can never be refreshed,\n * though it stays valid for ordinary calls.\n */\n async refreshSession(): Promise<TokenResponse> {\n const originatingToken = this.jwtToken;\n const response = await this.users.refreshToken();\n if (this.jwtToken !== originatingToken) {\n throw new DelopayError(\n 'Auth state changed while the refresh was pending; refreshed token discarded',\n {\n status: 0,\n code: 'session_changed',\n type: 'session_changed',\n },\n );\n }\n this.setJwtToken(response.token);\n return response;\n }\n\n /**\n * Make a raw HTTP request to the Delopay API.\n *\n * You rarely need to call this directly — prefer the typed resource methods.\n * Use it only for endpoints not yet covered by a resource class.\n *\n * @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).\n * @param path - API path starting with `/` (e.g. `/payments`).\n * @param options - Optional body, query parameters, and headers.\n * @returns Parsed JSON response body typed as `T`.\n * @throws {DelopayAuthenticationError} On 401 responses.\n * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.\n */\n async request<T>(method: string, path: string, options?: RequestOptions): Promise<T> {\n let url = `${this.baseUrl}${path}`;\n\n if (options?.query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(options.query)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else {\n params.set(key, String(value));\n }\n }\n const qs = params.toString();\n if (qs) {\n url += `?${qs}`;\n }\n }\n\n const headers: Record<string, string> = {\n ...(this.jwtToken\n ? { Authorization: `Bearer ${this.jwtToken}` }\n : this.apiKey\n ? { 'api-key': this.apiKey }\n : {}),\n ...options?.headers,\n };\n\n // FormData / Blob / ArrayBuffer / URLSearchParams pass through unchanged so callers\n // can send multipart uploads. The runtime (browser or Node 18+ fetch) sets the\n // appropriate Content-Type including the multipart boundary, so we don't touch it.\n const isRawBody =\n options?.body !== undefined &&\n options?.body !== null &&\n (options.body instanceof FormData ||\n options.body instanceof Blob ||\n options.body instanceof ArrayBuffer ||\n options.body instanceof URLSearchParams);\n\n if (options?.body && !isRawBody) {\n headers['Content-Type'] = 'application/json';\n }\n\n const idempotencyKey = findIdempotencyKey(headers)?.trim();\n const isRetryable =\n method === 'GET' ||\n method === 'DELETE' ||\n (idempotencyKey !== undefined && idempotencyKey !== '');\n\n // Serialize body once so circular-reference errors surface immediately and big payloads\n // aren't re-stringified on every retry attempt. Raw bodies pass through untouched.\n let serializedBody: BodyInit | undefined;\n if (isRawBody) {\n serializedBody = options?.body as BodyInit;\n } else if (options?.body) {\n serializedBody = JSON.stringify(options.body);\n }\n\n const callerSignal = options?.signal;\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n\n const timeoutMs = options?.timeout ?? this.timeout;\n\n let lastError: unknown;\n let retryAfterOverrideMs: number | null = null;\n\n const safeUrl = () => redactUrlForLogging(url);\n const emit = (event: 'request' | 'response' | 'retry', data: Record<string, unknown>) => {\n if (!this.debug) return;\n if (this.logger) {\n this.logger(event, data);\n return;\n }\n if (event === 'request')\n console.log(`[delopay] ${data.method as string} ${data.url as string}`);\n else if (event === 'response')\n console.log(\n `[delopay] ${data.status as number} ${data.method as string} ${data.path as string}`,\n );\n else\n console.log(\n `[delopay] retry ${data.attempt as number}/${data.maxRetries as number} ${data.method as string} ${data.path as string}`,\n );\n };\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const base = Math.min(500 * 2 ** (attempt - 1), 5000);\n // Full jitter: pick uniformly in [0, base) to avoid synchronized retry storms.\n const jittered = Math.random() * base;\n const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);\n retryAfterOverrideMs = null;\n await new Promise((resolve) => setTimeout(resolve, delay));\n emit('retry', { attempt, maxRetries: this.maxRetries, method, path });\n }\n\n const timeoutCtrl = new AbortController();\n const timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n const combined = combineSignals(\n callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal],\n );\n\n try {\n emit('request', { method, url: safeUrl(), path });\n\n const response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: combined.signal,\n ...(options?.keepalive !== undefined ? { keepalive: options.keepalive } : {}),\n });\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n\n emit('response', { status: response.status, method, path, requestId });\n\n if (!response.ok) {\n const rawBody = await response.text().catch(() => '');\n let parsed: Record<string, unknown> = {};\n if (rawBody) {\n try {\n parsed = JSON.parse(rawBody) as Record<string, unknown>;\n } catch {\n // non-JSON error body (HTML from a proxy, truncated stream, etc.) — keep raw\n }\n }\n // API wraps errors as { error: { message, code, type, data? } } — unwrap if present\n const err = (parsed.error as Record<string, unknown>) ?? parsed;\n const message =\n (err.message as string) ?? `Request failed with status ${response.status}`;\n const code = (err.code as string) ?? '';\n const type = (err.error_type as string) ?? (err.type as string) ?? '';\n const data =\n err.data && typeof err.data === 'object' && !Array.isArray(err.data)\n ? (err.data as Record<string, unknown>)\n : undefined;\n const truncatedRaw = truncateRawBody(rawBody);\n\n // A 401 usually means OUR credential (API key / JWT) was rejected —\n // but connector-passthrough errors (`CE_*` / type \"connector\", e.g.\n // a PSP rejecting the merchant's stored Stripe key) propagate the\n // upstream status and are NOT a Delopay authentication failure, so\n // they stay a plain DelopayError instead of triggering the\n // \"re-authenticate\" handling dashboards attach to auth errors.\n const isConnectorPassthrough = type === 'connector' || code.startsWith('CE_');\n if (response.status === 401 && !isConnectorPassthrough) {\n throw new DelopayAuthenticationError(message, {\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n }\n\n const error = new DelopayError(message, {\n status: response.status,\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n\n // Retry on 5xx and 429 (rate limit). 4xx other than 429 are not transient.\n const isTransientStatus = response.status >= 500 || response.status === 429;\n if (isTransientStatus && isRetryable && attempt < this.maxRetries) {\n if (response.status === 429) {\n retryAfterOverrideMs = parseRetryAfter(response.headers?.get('retry-after') ?? null);\n }\n lastError = error;\n continue;\n }\n\n throw error;\n }\n\n if (options?.responseType === 'blob') {\n return (await response.blob()) as T;\n }\n if (options?.responseType === 'arraybuffer') {\n return (await response.arrayBuffer()) as T;\n }\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n } catch (err) {\n if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {\n throw err;\n }\n if (err instanceof Error && err.name === 'AbortError') {\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n lastError = new DelopayError('Request timed out', {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof TypeError) {\n lastError = new DelopayError(`Network error: ${err.message}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n combined.dispose();\n }\n }\n\n throw lastError;\n }\n\n /**\n * Auto-paginate a list endpoint. Yields items one by one, fetching\n * the next page automatically when the current one is exhausted.\n *\n * Delopay list endpoints use one of two pagination styles, so this helper\n * supports both:\n * - **Offset** (default) — for endpoints like `customers.list` that accept\n * `offset`/`limit`. Each page advances `offset` by the number of items returned.\n * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page\n * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor\n * that returns the id of an item; the next page is requested with\n * `starting_after` set to the last item's id.\n *\n * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.\n * @param params - Additional parameters to pass to every page request.\n * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.\n * Provide `cursor` to switch to cursor pagination.\n *\n * @example\n * ```typescript\n * // Offset endpoint (customers):\n * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {\n * console.log(c.customer_id);\n * }\n *\n * // Cursor endpoint (payments): extract the id used as the next cursor.\n * for await (const payment of delopay.paginate(\n * (p) => delopay.payments.list(p),\n * undefined,\n * { cursor: (p) => p.payment_id },\n * )) {\n * console.log(payment.payment_id);\n * }\n * ```\n */\n async *paginate<T, P extends Record<string, unknown>>(\n listFn: (\n params: P & { limit: number; offset?: number; starting_after?: string },\n ) => Promise<{ data: T[] } | T[]>,\n params?: P,\n options?: number | { pageSize?: number; cursor?: (item: T) => string | undefined },\n ): AsyncGenerator<T> {\n const pageSize = typeof options === 'number' ? options : (options?.pageSize ?? 50);\n const cursorOf = typeof options === 'object' ? options.cursor : undefined;\n let offset = 0;\n let after: string | undefined;\n while (true) {\n const page = { ...((params ?? {}) as P), limit: pageSize } as P & {\n limit: number;\n offset?: number;\n starting_after?: string;\n };\n if (cursorOf) {\n if (after !== undefined) page.starting_after = after;\n } else {\n page.offset = offset;\n }\n const result = await listFn(page);\n const items = Array.isArray(result) ? result : result.data;\n if (items.length === 0) break;\n for (const item of items) {\n yield item;\n }\n if (items.length < pageSize) break;\n if (cursorOf) {\n const last = items[items.length - 1];\n if (last === undefined) break;\n after = cursorOf(last);\n if (after === undefined) break;\n } else {\n offset += items.length;\n }\n }\n }\n}\n","import type {\n Connector,\n Currency,\n EuclidComparison,\n EuclidComparisonType,\n EuclidIfStatement,\n EuclidValue,\n PaymentMethod,\n PlatformFeeKind,\n PlatformFeeOutput,\n PlatformFeeProgram,\n PlatformFeeRule,\n} from './types';\n\n/** A single condition leaf in the builder's condition tree. */\nexport interface LeafNode {\n kind: 'leaf';\n lhs: string;\n comparison: EuclidComparisonType;\n value: EuclidValue;\n}\n\n/** An AND (`all`) or OR (`any`) group of condition nodes. */\nexport interface GroupNode {\n kind: 'all' | 'any';\n children: ConditionNode[];\n}\n\nexport type ConditionNode = LeafNode | GroupNode;\n\n/**\n * A condition leaf. Numeric values (amount, merchant_volume) tag as `number`;\n * string values (payment_method, connector, currency, card_network) tag as\n * `enum_variant`.\n */\nexport function leaf(\n lhs: string,\n comparison: EuclidComparisonType,\n value: string | number,\n): LeafNode {\n const tagged: EuclidValue =\n typeof value === 'number' ? { type: 'number', value } : { type: 'enum_variant', value };\n return { kind: 'leaf', lhs, comparison, value: tagged };\n}\n\n/** AND group — all children must match. */\nexport function allOf(...children: ConditionNode[]): GroupNode {\n return { kind: 'all', children };\n}\n\n/** OR group — any child matching is enough. */\nexport function anyOf(...children: ConditionNode[]): GroupNode {\n return { kind: 'any', children };\n}\n\n/**\n * How a rule (or the default) prices a transaction. `fee_type` is inferred:\n * percentage-only → `percentage`, flat-only → `flat`, both → `combined`.\n */\nexport interface FeeSpecInput {\n /** Percentage fee, e.g. `2.5` means 2.5%. */\n percentage?: number;\n /** Flat fee in minor units. */\n flat?: number;\n /** ISO 4217 currency for the flat fee. */\n flatCurrency?: string;\n /** Clamp floor in minor units. */\n min?: number;\n /** Clamp ceiling in minor units. */\n max?: number;\n}\n\n/**\n * Friendly conditions for a rule. Every provided key becomes one condition and\n * they are ANDed together. For dimensions not covered here (payment-method-type\n * keys like `crypto`/`wallet`, metadata, value arrays) use `rawConditions`.\n */\nexport interface FeeRuleConditions {\n paymentMethod?: PaymentMethod;\n connector?: Connector;\n currency?: Currency;\n cardNetwork?: string;\n /**\n * Customer billing-address country. Must be the exact backend `Country` enum\n * variant (PascalCase full name, e.g. `Germany`/`UnitedStatesOfAmerica`), not\n * an ISO code — the engine lowers `billing_country` via case-sensitive\n * `from_str`.\n */\n billingCountry?: string;\n /** `amount == n` (minor units). */\n amountEquals?: number;\n /** `amount > n` (minor units). */\n amountGreaterThan?: number;\n /** `amount < n` (minor units). */\n amountLessThan?: number;\n /**\n * `merchant_volume == n` — the merchant's previous-month volume snapshot\n * (USD minor units). Combine with any other condition, e.g.\n * `{ paymentMethod: 'crypto', merchantVolumeGreaterThan: 1_000_000 }`.\n */\n merchantVolumeEquals?: number;\n /** `merchant_volume > n` (USD minor units). */\n merchantVolumeGreaterThan?: number;\n /** `merchant_volume < n` (USD minor units). */\n merchantVolumeLessThan?: number;\n}\n\nexport interface FeeRuleInput {\n name: string;\n /** Friendly conditions (ANDed). Omit for an always-matching rule (prefer `otherwise`). */\n when?: FeeRuleConditions;\n /** Extra raw conditions ANDed in, for dimensions `when` does not cover. */\n rawConditions?: EuclidComparison[];\n /** Nested AND/OR condition tree. Mutually exclusive with `when`/`rawConditions`. */\n match?: ConditionNode;\n fee: FeeSpecInput;\n}\n\nfunction toFeeOutput(spec: FeeSpecInput): PlatformFeeOutput {\n const hasPct = spec.percentage != null;\n const hasFlat = spec.flat != null;\n const feeType: PlatformFeeKind = hasPct && hasFlat ? 'combined' : hasFlat ? 'flat' : 'percentage';\n return {\n fee_type: feeType,\n percentage_fee: spec.percentage ?? null,\n flat_fee_amount: spec.flat ?? null,\n flat_fee_currency: spec.flatCurrency ?? null,\n min_fee_amount: spec.min ?? null,\n max_fee_amount: spec.max ?? null,\n };\n}\n\nfunction enumCondition(lhs: string, value: string): EuclidComparison {\n return { lhs, comparison: 'equal', value: { type: 'enum_variant', value }, metadata: {} };\n}\n\nfunction numberCondition(\n lhs: string,\n comparison: EuclidComparisonType,\n value: number,\n): EuclidComparison {\n return { lhs, comparison, value: { type: 'number', value }, metadata: {} };\n}\n\nfunction buildConditions(\n when: FeeRuleConditions = {},\n raw: EuclidComparison[] = [],\n): EuclidComparison[] {\n const out: EuclidComparison[] = [];\n if (when.paymentMethod != null) out.push(enumCondition('payment_method', when.paymentMethod));\n if (when.connector != null) out.push(enumCondition('connector', when.connector));\n if (when.currency != null) out.push(enumCondition('currency', when.currency));\n if (when.cardNetwork != null) out.push(enumCondition('card_network', when.cardNetwork));\n if (when.billingCountry != null) out.push(enumCondition('billing_country', when.billingCountry));\n if (when.amountEquals != null) out.push(numberCondition('amount', 'equal', when.amountEquals));\n if (when.amountGreaterThan != null) {\n out.push(numberCondition('amount', 'greater_than', when.amountGreaterThan));\n }\n if (when.amountLessThan != null) {\n out.push(numberCondition('amount', 'less_than', when.amountLessThan));\n }\n if (when.merchantVolumeEquals != null) {\n out.push(numberCondition('merchant_volume', 'equal', when.merchantVolumeEquals));\n }\n if (when.merchantVolumeGreaterThan != null) {\n out.push(numberCondition('merchant_volume', 'greater_than', when.merchantVolumeGreaterThan));\n }\n if (when.merchantVolumeLessThan != null) {\n out.push(numberCondition('merchant_volume', 'less_than', when.merchantVolumeLessThan));\n }\n out.push(...raw);\n return out;\n}\n\nfunction leafToComparison(node: LeafNode): EuclidComparison {\n return { lhs: node.lhs, comparison: node.comparison, value: node.value, metadata: {} };\n}\n\n/**\n * Flatten associativity (nested all-in-all / any-in-any) and collapse\n * single-child groups, so every group child of an `all` is an `any`.\n * @internal\n */\nexport function normalizeNode(node: ConditionNode): ConditionNode {\n if (node.kind === 'leaf') return node;\n const children = node.children.map(normalizeNode);\n const flat: ConditionNode[] = [];\n for (const c of children) {\n if (c.kind === node.kind) flat.push(...c.children);\n else flat.push(c);\n }\n if (flat.length === 1) return flat[0];\n return { kind: node.kind, children: flat };\n}\n\nfunction toStatement(node: ConditionNode): EuclidIfStatement {\n if (node.kind === 'leaf') return { condition: [leafToComparison(node)], nested: null };\n // Unreachable via current callers (encodeStatements strips top-level any); kept for totality.\n if (node.kind === 'any') {\n return { condition: [], nested: node.children.map(toStatement) };\n }\n // 'all': after normalize, group children are all 'any'.\n const leaves = node.children.filter((c): c is LeafNode => c.kind === 'leaf');\n const groups = node.children.filter((c): c is GroupNode => c.kind !== 'leaf');\n const condition = leaves.map(leafToComparison);\n if (groups.length === 0) return { condition, nested: null };\n const [first, ...rest] = groups;\n // `first` is an OR; AND each of its branches with the remaining OR groups.\n const nested = first.children.map((branch) => toStatement(normalizeNode(allOf(branch, ...rest))));\n return { condition, nested };\n}\n\nfunction assertNoEmptyAnyOf(node: ConditionNode): void {\n if (node.kind === 'leaf') return;\n if (node.kind === 'any' && node.children.length === 0) {\n throw new Error('feeProgram: an anyOf() group must have at least one condition');\n }\n node.children.forEach(assertNoEmptyAnyOf);\n}\n\n/**\n * Encode a rule's match (a condition tree) into the engine's `statements[]`.\n * A top-level OR spreads across statements; anything else is a single statement.\n * @internal\n */\nexport function encodeStatements(match: ConditionNode): EuclidIfStatement[] {\n const m = normalizeNode(match);\n if (m.kind === 'any') return m.children.map(toStatement);\n return [toStatement(m)];\n}\n\nfunction comparisonToLeaf(c: EuclidComparison): LeafNode {\n return { kind: 'leaf', lhs: c.lhs, comparison: c.comparison, value: c.value };\n}\n\nfunction statementToNode(stmt: EuclidIfStatement): ConditionNode {\n const leaves = stmt.condition.map(comparisonToLeaf);\n if (stmt.nested && stmt.nested.length > 0) {\n const orNode = anyOf(...stmt.nested.map(statementToNode));\n if (leaves.length === 0) return orNode;\n return allOf(...leaves, orNode);\n }\n return leaves.length === 1 ? leaves[0] : allOf(...leaves);\n}\n\n/**\n * Decode a rule's `statements[]` back into a condition tree.\n *\n * Returns a tree that is **logically equivalent** to the source. It is\n * deep-equal to `normalizeNode(input)` only when no `all` group contains two\n * or more `any` groups; where the encoder distributed AND over OR, the decoded\n * shape differs (still equivalent).\n */\nexport function ruleMatchToTree(statements: EuclidIfStatement[]): ConditionNode {\n if (statements.length === 1) return normalizeNode(statementToNode(statements[0]));\n return normalizeNode(anyOf(...statements.map(statementToNode)));\n}\n\n/**\n * Decode a stored program into the builder's editable model.\n *\n * Returns a tree that is **logically equivalent** to the source. It is\n * deep-equal to `normalizeNode(input)` only when no `all` group contains two\n * or more `any` groups; where the encoder distributed AND over OR, the decoded\n * shape differs (still equivalent).\n */\nexport function programToTree(program: PlatformFeeProgram): {\n rules: { name: string; match: ConditionNode; fee: PlatformFeeOutput | null }[];\n otherwise: PlatformFeeOutput | null;\n} {\n return {\n rules: program.rules.map((r) => ({\n name: r.name,\n match: ruleMatchToTree(r.statements),\n fee: r.connectorSelection.fee ?? null,\n })),\n otherwise: program.defaultSelection.fee ?? null,\n };\n}\n\n/**\n * Fluent builder for a platform fee-rule program. Emits the exact Euclid wire\n * shape (camelCase tree, tagged values, `metadata: {}` everywhere) so callers\n * never hand-write the AST. Rules are evaluated in order; the first match wins,\n * else `otherwise` (the default selection).\n *\n * @example\n * ```ts\n * const algorithm = feeProgram()\n * .rule({ name: 'crypto', when: { paymentMethod: 'crypto' }, fee: { percentage: 1.0 } })\n * .rule({\n * name: 'card_on_cryptomus',\n * when: { paymentMethod: 'card', connector: 'cryptomus' },\n * fee: { percentage: 2.0 },\n * })\n * .otherwise({ percentage: 3.0 })\n * .build();\n *\n * await delopay.fees.rules.upsert({ algorithm }, merchantId);\n * ```\n */\nexport class FeeProgramBuilder {\n private readonly rules: PlatformFeeRule[] = [];\n private defaultFee: PlatformFeeOutput | null = null;\n\n /** Append a rule. Provided `when`/`rawConditions` are ANDed. */\n rule(input: FeeRuleInput): this {\n if (input.match) assertNoEmptyAnyOf(input.match);\n const statements: PlatformFeeRule['statements'] = input.match\n ? encodeStatements(input.match)\n : [{ condition: buildConditions(input.when, input.rawConditions) }];\n this.rules.push({\n name: input.name,\n connectorSelection: { fee: toFeeOutput(input.fee) },\n statements,\n });\n return this;\n }\n\n /** Set the default selection (applied when no rule matches). */\n otherwise(fee: FeeSpecInput): this {\n this.defaultFee = toFeeOutput(fee);\n return this;\n }\n\n /** Produce the wire-ready program. */\n build(): PlatformFeeProgram {\n return {\n defaultSelection: { fee: this.defaultFee },\n rules: this.rules,\n metadata: {},\n };\n }\n}\n\n/** Start building a platform fee-rule program. See {@link FeeProgramBuilder}. */\nexport function feeProgram(): FeeProgramBuilder {\n return new FeeProgramBuilder();\n}\n","// Checkout branding — typed shape, design tokens, palettes, persistence\n// codec, CSS sanitizer, and DOM helpers for `--dp-*` CSS variables.\n//\n// Both delopay-checkout and delopay-control-center consume this module.\n//\n// Persistence: top-level fields own the \"loud\" tokens (logo, theme,\n// payment_button_*, background_colour, etc.). Everything else lives in\n// `sdk_ui_rules.branding` as a nested string-keyed map — booleans and\n// numbers round-trip as strings, the trust-badge list is JSON-stringified.\n\n// --- Types --------------------------------------------------------------\n\nexport type CornerRadius = 'square' | 'small' | 'medium' | 'large' | 'pill';\n\n// Surfaces and inputs never make sense pill-shaped (a pill input ends up with\n// half-circle ends crammed against text). The form picker only exposes these\n// four; if a stale 'pill' value lands here from older saved data, decode\n// drops it back to 'medium'. Buttons and badges still allow 'pill'.\nexport type NonPillRadius = Exclude<CornerRadius, 'pill'>;\n\n// Spacing scales — split apart so the merchant can independently tune\n// surface padding, vertical rhythm, input height and pay-button height. Used\n// to live as a single `density` enum but that conflated four dimensions.\nexport type SpacingScale = 'compact' | 'comfortable' | 'spacious';\nexport type SizeScale = 'sm' | 'md' | 'lg';\nexport type SurfaceStyle = 'flat' | 'outlined' | 'elevated';\n\nexport type FontFamily =\n | 'inter'\n | 'system'\n | 'serif'\n | 'mono'\n | 'roboto'\n | 'poppins'\n | 'manrope'\n | 'dm-sans'\n | 'space-grotesk'\n | 'plex-sans'\n | 'work-sans'\n | 'open-sans'\n | 'lora'\n | 'playfair'\n | 'plex-mono'\n | 'jetbrains-mono';\n\nexport type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';\nexport type LayoutStyle = 'compact' | 'split';\nexport type SummaryPosition = 'left' | 'right';\n\n// Stripe Elements only supports two label modes (\"above\" or hidden via the\n// .Label-collapse hack); a \"floating\" label is not a Stripe concept and\n// would only render in our own mock — preview was lying about it. Persisted\n// `'floating'` is silently decoded to `'above'` for back-compat.\nexport type LabelStyle = 'above' | 'hidden';\n\n// Stripe Elements layout. Honored inside the StripeCardPane only — other\n// connector panes stack vertically regardless of this setting.\nexport type PaymentLayout = 'tabs' | 'accordion' | 'spaced_accordion';\n\nexport type LogoShape = 'square' | 'rounded' | 'circle';\nexport type LogoSize = 'sm' | 'md' | 'lg';\n\nexport interface TrustBadge {\n id: string;\n label: string;\n textColor: string;\n backgroundColor: string;\n borderColor: string | null;\n}\n\n// Merchant-defined checkout inputs. Rendered by the buyer-facing checkout\n// above the payment surface; submitted values land in the payment's\n// `metadata` under each field's `key`. Persisted JSON-stringified under\n// `sdk_ui_rules.branding.customFields` (same transport as trustBadges).\n// `checkbox` is a single opt-in box (terms acceptance, marketing consent),\n// not a multi-select. Its submitted value is always the string `'true'` or\n// `'false'` — never absent — so a merchant can tell \"declined\" from \"never\n// asked\" in the payment's metadata, which is what makes it usable as a\n// consent record. See `CHECKBOX_CHECKED` / `isCheckboxChecked`.\nexport type CustomFieldType = 'text' | 'textarea' | 'password' | 'email' | 'select' | 'checkbox';\n\n// Per-locale overrides ('de', 'en', …). Missing locale falls back to the\n// default-language string on the field itself — see `customFieldText`.\nexport type CustomFieldTranslations = Record<string, string>;\n\nexport interface CustomFieldOption {\n value: string;\n label: string;\n labelTranslations: CustomFieldTranslations;\n}\n\n// --- Conditional visibility ---------------------------------------------\n//\n// A field can be gated on facts the payment already carries when the\n// checkout renders: the intent's `metadata` (which a shop integration fills\n// per product/category — see the WordPress plugin's product metadata), its\n// `currency`, or its `amount`. This is what lets one profile serve a\n// \"Windows key\" order (no fields) and a \"Spotify account\" order (login\n// fields) without two shops.\n//\n// Evaluation is authoritative on the **backend**: `form_payment_link_data`\n// drops non-matching fields from the payload the buyer's browser receives,\n// so merchant metadata never leaves the server and the rules can't be\n// tampered with client-side. The implementation here is the shared\n// specification (and drives the control-center's builder); the Rust mirror\n// in `crates/router/src/core/payment_link/custom_fields.rs` must stay\n// behaviorally identical.\nexport type CustomFieldConditionSource = 'metadata' | 'currency' | 'amount';\n\n// String operators apply to metadata + currency; numeric ones (`gt`…`lte`)\n// apply to amount and to metadata values that parse as numbers.\nexport type CustomFieldOperator =\n | 'equals'\n | 'not_equals'\n | 'contains'\n | 'not_contains'\n | 'starts_with'\n | 'ends_with'\n | 'in'\n | 'not_in'\n | 'exists'\n | 'not_exists'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte';\n\nexport interface CustomFieldCondition {\n // Stable identity for editor list operations (reorder/remove). Not part\n // of the semantics.\n id: string;\n source: CustomFieldConditionSource;\n // Metadata key to read. Ignored (and persisted empty) for currency/amount.\n key: string;\n operator: CustomFieldOperator;\n // Right-hand operand. `in`/`not_in` read it as a comma-separated list;\n // `exists`/`not_exists` ignore it; amount comparisons parse it as an\n // integer in the currency's minor unit (1000 = 10.00).\n value: string;\n}\n\nexport interface CustomFieldVisibility {\n // `always` — unconditional (the default, and what every pre-feature field\n // decodes to). `match` — evaluate `conditions`.\n mode: 'always' | 'match';\n // How to combine multiple conditions.\n match: 'all' | 'any';\n conditions: CustomFieldCondition[];\n}\n\nexport interface CheckoutCustomField {\n // Stable identity for editor list operations (reorder/remove).\n id: string;\n // Metadata key the submitted value is stored under. Must be unique per\n // profile; the editor enforces `CUSTOM_FIELD_KEY_PATTERN`.\n key: string;\n type: CustomFieldType;\n // Default-language copy; `*Translations` maps override per locale.\n label: string;\n labelTranslations: CustomFieldTranslations;\n placeholder: string;\n placeholderTranslations: CustomFieldTranslations;\n helpText: string;\n helpTextTranslations: CustomFieldTranslations;\n required: boolean;\n // Disabled fields stay configured but are neither rendered nor submitted.\n enabled: boolean;\n // Length bounds apply to text/textarea/password/email; null = unbounded.\n minLength: number | null;\n maxLength: number | null;\n // Prefill for text-like fields; for selects, the option `value` selected\n // initially (empty = placeholder \"choose\" state).\n defaultValue: string;\n // Select choices; ignored for other types.\n options: CustomFieldOption[];\n // Conditional display. Always populated by the decoder — fields without a\n // persisted rule decode to `{ mode: 'always', … }`.\n visibility: CustomFieldVisibility;\n}\n\nexport interface CheckoutBranding {\n // Brand identity\n displayName: string;\n logoUrl: string;\n tagline: string;\n showLogo: boolean;\n logoShape: LogoShape;\n logoSize: LogoSize;\n\n // Color tokens\n primary: string;\n background: string;\n surface: string;\n text: string;\n heading: string;\n muted: string;\n border: string;\n accentText: string;\n buttonBackground: string;\n buttonText: string;\n\n // Typography\n fontFamily: FontFamily;\n headingWeight: FontWeight;\n\n // Shape — granular per-element. Surfaces & inputs use a narrower union\n // (no pill) because pill cards/inputs are always wrong; button and badge\n // keep the full `CornerRadius` since pill is a legitimate look there.\n radiusSurface: NonPillRadius;\n radiusInput: NonPillRadius;\n radiusButton: CornerRadius;\n radiusBadge: CornerRadius;\n surfaceStyle: SurfaceStyle;\n\n // Spacing — four independent dimensions.\n surfacePadding: SpacingScale;\n verticalGap: SpacingScale;\n inputSize: SizeScale;\n buttonSize: SizeScale;\n\n // Layout\n layout: LayoutStyle;\n summaryPosition: SummaryPosition;\n showOrderSummary: boolean;\n summaryGradient: boolean;\n showTotal: boolean;\n totalLabel: string;\n showCurrencyCode: boolean;\n showOrderItems: boolean;\n\n // Trust badges (fully customizable; empty = hide row).\n trustBadges: TrustBadge[];\n\n // Merchant-defined checkout inputs (empty = no custom fields section).\n customFields: CheckoutCustomField[];\n\n // Copy. All of these are optional in the persisted form: empty string\n // means \"unset\" and consumers should fall back (e.g. payButtonLabel falls\n // back to a localized \"Pay $X\" string).\n headerText: string;\n payButtonLabel: string;\n cardTermsMessage: string;\n footerText: string;\n supportEmail: string;\n\n // Stripe Elements behavior. `paymentLayout` only affects what's painted\n // inside Stripe's iframe; non-Stripe connector panes stack vertically\n // regardless. `labelStyle` is also Stripe-iframe scope.\n paymentLayout: PaymentLayout;\n labelStyle: LabelStyle;\n\n // Footer\n showPoweredBy: boolean;\n\n // Advanced — raw CSS appended after brand-token CSS variables are\n // applied, so its declarations win cascade order. Sanitized at render\n // time (see `sanitizeCustomCss`); persisted as-typed under\n // `sdk_ui_rules.branding.customCss`.\n customCss: string;\n}\n\n// --- Token maps ---------------------------------------------------------\n\n// Self-hostable font stacks. The buyer-facing checkout bundles these via\n// @fontsource* packages; the variable-font names ('Inter Variable', …) are\n// listed first so the smaller variable file is preferred when bundled.\nconst FONT_STACKS: Record<FontFamily, string> = {\n inter: \"'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif\",\n system:\n \"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif\",\n serif: \"Georgia, 'Times New Roman', serif\",\n mono: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',\n roboto: \"'Roboto', system-ui, sans-serif\",\n poppins: \"'Poppins', system-ui, sans-serif\",\n manrope: \"'Manrope Variable', 'Manrope', system-ui, sans-serif\",\n 'dm-sans': \"'DM Sans Variable', 'DM Sans', system-ui, sans-serif\",\n 'space-grotesk': \"'Space Grotesk Variable', 'Space Grotesk', system-ui, sans-serif\",\n 'plex-sans': \"'IBM Plex Sans', system-ui, sans-serif\",\n 'work-sans': \"'Work Sans Variable', 'Work Sans', system-ui, sans-serif\",\n 'open-sans': \"'Open Sans Variable', 'Open Sans', system-ui, sans-serif\",\n lora: \"'Lora Variable', 'Lora', Georgia, serif\",\n playfair: \"'Playfair Display Variable', 'Playfair Display', Georgia, serif\",\n 'plex-mono': \"'IBM Plex Mono', ui-monospace, monospace\",\n 'jetbrains-mono': \"'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, monospace\",\n};\n\nconst RADIUS_PX: Record<CornerRadius, string> = {\n square: '0px',\n small: '6px',\n medium: '12px',\n large: '20px',\n pill: '999px',\n};\n\nconst FONT_WEIGHT_NUMERIC: Record<FontWeight, string> = {\n regular: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n};\n\nconst SURFACE_PAD: Record<SpacingScale, string> = {\n compact: '1rem',\n comfortable: '1.5rem',\n spacious: '2rem',\n};\n\nconst VERTICAL_GAP: Record<SpacingScale, string> = {\n compact: '0.75rem',\n comfortable: '1rem',\n spacious: '1.5rem',\n};\n\nconst INPUT_PAD: Record<SizeScale, string> = {\n sm: '0.5rem 0.75rem',\n md: '0.625rem 0.75rem',\n lg: '0.875rem 0.875rem',\n};\n\nconst BUTTON_PAD: Record<SizeScale, string> = {\n sm: '0.625rem 1rem',\n md: '0.875rem 1.25rem',\n lg: '1.125rem 1.5rem',\n};\n\nexport function fontStack(family: FontFamily): string {\n return FONT_STACKS[family] ?? FONT_STACKS.inter;\n}\n\nexport function radiusValue(radius: CornerRadius): string {\n return RADIUS_PX[radius] ?? RADIUS_PX.medium;\n}\n\nexport function fontWeightValue(weight: FontWeight): string {\n return FONT_WEIGHT_NUMERIC[weight] ?? '600';\n}\n\nexport function surfacePadValue(scale: SpacingScale): string {\n return SURFACE_PAD[scale] ?? SURFACE_PAD.comfortable;\n}\n\nexport function verticalGapValue(scale: SpacingScale): string {\n return VERTICAL_GAP[scale] ?? VERTICAL_GAP.comfortable;\n}\n\nexport function inputPadValue(size: SizeScale): string {\n return INPUT_PAD[size] ?? INPUT_PAD.md;\n}\n\nexport function buttonPadValue(size: SizeScale): string {\n return BUTTON_PAD[size] ?? BUTTON_PAD.md;\n}\n\nexport function logoDimensions(size: LogoSize): { px: number; radius: number } {\n switch (size) {\n case 'sm':\n return { px: 36, radius: 8 };\n case 'lg':\n return { px: 64, radius: 16 };\n case 'md':\n default:\n return { px: 48, radius: 12 };\n }\n}\n\nconst HEX_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;\n\nexport function isHexColor(value: string): boolean {\n return HEX_RE.test(value.trim());\n}\n\n// Crude perceived-luminance check — picks the right Stripe Elements preset\n// (`'night'` vs `'stripe'`) when the merchant has a dark surface. Inputs we\n// don't recognize as a 6-/3-digit hex fall through to \"light\" since that's\n// the safer assumption for the default palette.\nexport function isDarkSurface(color: string): boolean {\n const m = color.replace('#', '').trim();\n if (m.length !== 3 && m.length !== 6) return false;\n const full =\n m.length === 3\n ? m\n .split('')\n .map((c) => c + c)\n .join('')\n : m;\n const r = parseInt(full.slice(0, 2), 16);\n const g = parseInt(full.slice(2, 4), 16);\n const b = parseInt(full.slice(4, 6), 16);\n if ([r, g, b].some(Number.isNaN)) return false;\n const luma = (r * 299 + g * 587 + b * 114) / 1000;\n return luma < 128;\n}\n\n// --- Defaults -----------------------------------------------------------\n\n// Light-mode DeloPay-branded baseline. Hex values come straight from\n// `design-guidelines/colors.md`:\n// - #1E4FEB is `--color-dp-blue`, the wordmark/icon brand blue\n// - #0A1130 is `--color-dp-blue-dark`, the wordmark navy\n// - the rest are slate-50 / slate-200 / slate-500 / slate-800 from the\n// design system's neutral ramp.\n// Picked for: high contrast, neutral surroundings, brand-blue accents,\n// confident navy CTA. Reads \"fintech\" without feeling cold.\nconst LIGHT_PALETTE = {\n primary: '#1E4FEB',\n background: '#f8fafc',\n surface: '#ffffff',\n text: '#1e293b',\n heading: '#0A1130',\n muted: '#64748b',\n border: '#e2e8f0',\n accentText: '#1E4FEB',\n buttonBackground: '#0A1130',\n buttonText: '#ffffff',\n} as const;\n\nexport const DEFAULT_BADGES: TrustBadge[] = [\n {\n id: 'secure',\n label: 'Secure',\n textColor: '#047857',\n backgroundColor: '#ecfdf5',\n borderColor: '#a7f3d0',\n },\n {\n id: 'ssl',\n label: '256-bit SSL',\n textColor: '#1E4FEB',\n backgroundColor: '#eff6ff',\n borderColor: '#bfdbfe',\n },\n];\n\n// Dark-mode equivalents of DEFAULT_BADGES. Dark trust chips need solid hex\n// (the form's color picker only accepts hex), so we pick the design system's\n// success-900 / info-900 backdrops paired with their *-400 foreground tokens.\nexport const DEFAULT_BADGES_DARK: TrustBadge[] = [\n {\n id: 'secure',\n label: 'Secure',\n textColor: '#34d399',\n backgroundColor: '#064e3b',\n borderColor: '#065f46',\n },\n {\n id: 'ssl',\n label: '256-bit SSL',\n textColor: '#60a5fa',\n backgroundColor: '#172554',\n borderColor: '#1e40af',\n },\n];\n\nconst DEFAULT_BRANDING_BASE: Omit<\n CheckoutBranding,\n keyof typeof LIGHT_PALETTE | 'trustBadges' | 'customFields'\n> = {\n displayName: '',\n logoUrl: '',\n tagline: '',\n // Logo + summary gradient OFF by default — an unconfigured DeloPay\n // checkout reads cleaner without a placeholder logo block, and the\n // gradient implies a primary tint the merchant hasn't yet picked.\n showLogo: false,\n logoShape: 'rounded',\n logoSize: 'md',\n\n fontFamily: 'inter',\n headingWeight: 'semibold',\n\n radiusSurface: 'medium',\n radiusInput: 'medium',\n radiusButton: 'medium',\n radiusBadge: 'pill',\n surfaceStyle: 'elevated',\n surfacePadding: 'comfortable',\n verticalGap: 'comfortable',\n inputSize: 'md',\n buttonSize: 'md',\n\n layout: 'split',\n summaryPosition: 'left',\n showOrderSummary: true,\n summaryGradient: false,\n showTotal: true,\n totalLabel: 'Total',\n showCurrencyCode: false,\n showOrderItems: true,\n\n headerText: '',\n payButtonLabel: '',\n cardTermsMessage: '',\n footerText: '',\n supportEmail: '',\n\n paymentLayout: 'tabs',\n labelStyle: 'above',\n showPoweredBy: true,\n\n customCss: '',\n};\n\nexport const DEFAULT_BRANDING: CheckoutBranding = {\n ...DEFAULT_BRANDING_BASE,\n ...LIGHT_PALETTE,\n trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),\n customFields: [],\n};\n\n// Dark counterpart to DEFAULT_BRANDING. Same form-only fields stay empty\n// (logo / display name / tagline / copy) — only visual tokens diverge.\n// Palette mirrors the design-guidelines dark ramp:\n// - background = slate-950, surface = slate-900 → soft contrast.\n// - text = slate-200, heading = slate-50 → AA+ contrast on the surface.\n// - muted = slate-400, border = slate-800 → chrome that fades into the bg.\n// - accentText = primary-400, button bg = brand blue → brand pops on dark\n// where the light theme's near-black navy CTA would disappear.\n// - surfaceStyle = 'flat' because soft drop-shadows don't read on dark\n// surfaces; the existing 'elevated' shadow tokens are tuned for light.\nexport const DEFAULT_BRANDING_DARK: CheckoutBranding = {\n ...DEFAULT_BRANDING_BASE,\n primary: '#1E4FEB',\n background: '#020617',\n surface: '#0f172a',\n text: '#e2e8f0',\n heading: '#f8fafc',\n muted: '#94a3b8',\n border: '#1e293b',\n accentText: '#60a5fa',\n buttonBackground: '#1E4FEB',\n buttonText: '#ffffff',\n surfaceStyle: 'flat',\n trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),\n customFields: [],\n};\n\n// Back-compat alias. Prefer `DEFAULT_BRANDING` directly.\nexport function defaultBranding(): CheckoutBranding {\n return cloneBranding(DEFAULT_BRANDING);\n}\n\n// Deep-ish clone — needed because the form mutates state reactively and we\n// don't want shared TrustBadge / CheckoutCustomField object refs across the\n// loaded/edit/default snapshots. Spread is shallow; array elements would\n// otherwise be shared between snapshots, breaking reset.\nexport function cloneBranding(b: CheckoutBranding): CheckoutBranding {\n return {\n ...b,\n trustBadges: b.trustBadges.map((badge) => ({ ...badge })),\n customFields: b.customFields.map(cloneCustomField),\n };\n}\n\nexport function cloneCustomField(f: CheckoutCustomField): CheckoutCustomField {\n return {\n ...f,\n labelTranslations: { ...f.labelTranslations },\n placeholderTranslations: { ...f.placeholderTranslations },\n helpTextTranslations: { ...f.helpTextTranslations },\n options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } })),\n visibility: {\n ...f.visibility,\n conditions: f.visibility.conditions.map((c) => ({ ...c })),\n },\n };\n}\n\n// --- Sanitizer ----------------------------------------------------------\n\n// Hard cap on the persisted custom CSS payload. Mirrors the editor's\n// validation; oversized input is dropped to null rather than truncated,\n// since a half-truncated rule is worse than no rule.\nexport const CUSTOM_CSS_MAX_LENGTH = 50_000;\n\n// Strip CSS tokens that turn a stylesheet into a delivery vector before\n// handing the merchant's input to the renderer. The list isn't exhaustive\n// — it's the everyday surface area:\n//\n// - `</style` would let injected text break out of the <style> block and\n// parse as HTML/JS. Replaced with a benign token (not removed) so\n// `</styled-tag` (unlikely but possible inside a content: string)\n// doesn't silently merge into surrounding text.\n// - `@import` would let the merchant pull in a remote stylesheet on\n// every buyer page-load (analytics by side-channel; possible buyer-IP\n// leak).\n// - `expression(…)` was a legacy IE construct that ran JS from CSS.\n// - `behavior:` and `-moz-binding:` ditto for IE/old-Gecko.\n// - `javascript:` URLs in url(...) execute on resource load in some\n// browsers/contexts.\n//\n// Anything else passes through. The merchant can still write whatever\n// declarations they like (background images, gradients, transforms,\n// keyframes, container queries, …).\nexport function sanitizeCustomCss(raw: string | null | undefined): string | null {\n if (typeof raw !== 'string') return null;\n const trimmed = raw.trim();\n if (trimmed.length === 0) return null;\n if (trimmed.length > CUSTOM_CSS_MAX_LENGTH) return null;\n\n let out = trimmed;\n out = out.replace(/<\\/style/gi, '<\\\\/style');\n out = out.replace(/@import\\b[^;]*;?/gi, '');\n out = out.replace(/expression\\s*\\(/gi, '/* expression( */');\n out = out.replace(/(^|[^a-z-])behavior\\s*:/gi, '$1/* behavior: */');\n out = out.replace(/-moz-binding\\s*:/gi, '/* -moz-binding: */');\n out = out.replace(/url\\s*\\(\\s*[\"']?\\s*javascript:/gi, 'url(invalid:');\n return out;\n}\n\n// --- Codec --------------------------------------------------------------\n\n// Structural shape the decoder reads. Both `CheckoutDetails` (public buyer\n// payload) and `BusinessPaymentLinkConfig` (merchant config request shape)\n// satisfy this via duck typing — they each fill some of these and leave the\n// rest undefined. `merchant_*` and `seller_*`/`logo` are aliases for the\n// same API field, surfaced under different names by the two payloads.\nexport interface BrandingSource {\n // Identity (one or the other, depending on payload shape)\n merchant_name?: string | null;\n seller_name?: string | null;\n merchant_logo?: string | null;\n logo?: string | null;\n merchant_description?: string | null;\n\n // Visual\n theme?: string | null;\n background_colour?: string | null;\n payment_button_colour?: string | null;\n payment_button_text_colour?: string | null;\n\n // Copy\n payment_form_header_text?: string | null;\n payment_button_text?: string | null;\n custom_message_for_card_terms?: string | null;\n\n // Footer\n branding_visibility?: boolean | null;\n\n // Stripe\n sdk_layout?: string | null;\n payment_form_label_type?: string | null;\n\n // The bag for everything else\n sdk_ui_rules?: Record<string, Record<string, string> | null | undefined> | null;\n}\n\nconst BRANDING_GROUP_KEY = 'branding';\n\nconst ALL_FONT_FAMILIES: readonly FontFamily[] = [\n 'inter',\n 'system',\n 'serif',\n 'mono',\n 'roboto',\n 'poppins',\n 'manrope',\n 'dm-sans',\n 'space-grotesk',\n 'plex-sans',\n 'work-sans',\n 'open-sans',\n 'lora',\n 'playfair',\n 'plex-mono',\n 'jetbrains-mono',\n];\n\nconst ALL_RADII: readonly CornerRadius[] = ['square', 'small', 'medium', 'large', 'pill'];\nconst NON_PILL_RADII: readonly NonPillRadius[] = ['square', 'small', 'medium', 'large'];\n\nfunction pickEnum<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T {\n if (typeof value !== 'string') return fallback;\n return (allowed as readonly string[]).includes(value) ? (value as T) : fallback;\n}\n\nfunction parseBool(value: unknown, fallback: boolean): boolean {\n if (typeof value === 'boolean') return value;\n if (value === 'true') return true;\n if (value === 'false') return false;\n return fallback;\n}\n\nfunction s(value: string | null | undefined): string {\n return typeof value === 'string' ? value : '';\n}\n\n// Decode the JSON-encoded trust badges stored under\n// `sdk_ui_rules.branding.trustBadges`. Tolerant: a malformed payload,\n// missing fields, or wrong types fall through to null so the caller can\n// substitute the default badge set. An explicit empty array means \"no\n// badges\" (we honor it — merchants who hide the row need a way to express\n// that).\nexport function decodeBadges(raw: string | undefined): TrustBadge[] | null {\n if (raw === undefined) return null;\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) return null;\n return parsed\n .filter((b): b is Record<string, unknown> => !!b && typeof b === 'object')\n .map((b, i) => ({\n id: typeof b['id'] === 'string' && b['id'] ? (b['id'] as string) : `badge-${i}`,\n label: typeof b['label'] === 'string' ? (b['label'] as string) : '',\n textColor: typeof b['textColor'] === 'string' ? (b['textColor'] as string) : '#0f172a',\n backgroundColor:\n typeof b['backgroundColor'] === 'string' ? (b['backgroundColor'] as string) : '#f1f5f9',\n borderColor:\n typeof b['borderColor'] === 'string' && b['borderColor']\n ? (b['borderColor'] as string)\n : null,\n }))\n .filter((b) => b.label.length > 0);\n } catch {\n return null;\n }\n}\n\nexport function encodeBadges(badges: TrustBadge[]): string {\n return JSON.stringify(\n badges.map((b) => ({\n id: b.id,\n label: b.label,\n textColor: b.textColor,\n backgroundColor: b.backgroundColor,\n ...(b.borderColor ? { borderColor: b.borderColor } : {}),\n })),\n );\n}\n\n// --- Custom checkout fields codec ---------------------------------------\n\nexport const CUSTOM_FIELDS_MAX = 20;\n// Metadata keys: start with a letter, then letters/digits/underscore/dash.\n// Keeps keys safe for every downstream metadata consumer (dashboards,\n// exports, PSP forwarding).\nexport const CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;\n\nexport const ALL_CUSTOM_FIELD_TYPES: readonly CustomFieldType[] = [\n 'text',\n 'textarea',\n 'password',\n 'email',\n 'select',\n 'checkbox',\n];\n\n// The two values a checkbox field ever submits. Kept as strings because the\n// whole metadata bag is `Record<string, string>` on the wire.\nexport const CHECKBOX_CHECKED = 'true';\nexport const CHECKBOX_UNCHECKED = 'false';\n\n/** Whether a stored/submitted checkbox value counts as ticked. Tolerant of\n * case and padding so a value round-tripped through a shop integration\n * ('True', ' true ') still reads correctly. */\nexport function isCheckboxChecked(value: string | null | undefined): boolean {\n return typeof value === 'string' && value.trim().toLowerCase() === CHECKBOX_CHECKED;\n}\n\n/** Types whose value is free text, so length bounds and a placeholder apply.\n * `select` and `checkbox` are choice controls and have neither. */\nexport function customFieldIsTextLike(type: CustomFieldType): boolean {\n return type !== 'select' && type !== 'checkbox';\n}\n\n// Rule-builder vocabulary. Kept next to the codec so the editor, the\n// evaluator and the Rust mirror all read from one list.\nexport const CUSTOM_FIELD_CONDITIONS_MAX = 10;\n\nexport const ALL_CUSTOM_FIELD_CONDITION_SOURCES: readonly CustomFieldConditionSource[] = [\n 'metadata',\n 'currency',\n 'amount',\n];\n\nexport const ALL_CUSTOM_FIELD_OPERATORS: readonly CustomFieldOperator[] = [\n 'equals',\n 'not_equals',\n 'contains',\n 'not_contains',\n 'starts_with',\n 'ends_with',\n 'in',\n 'not_in',\n 'exists',\n 'not_exists',\n 'gt',\n 'gte',\n 'lt',\n 'lte',\n];\n\n// Which operators make sense per source. Currency is a closed 3-letter set,\n// so substring/numeric operators would only ever confuse; amount is numeric,\n// so string operators don't apply. Metadata is free-form and gets all of them.\nexport const CUSTOM_FIELD_OPERATORS_BY_SOURCE: Record<\n CustomFieldConditionSource,\n readonly CustomFieldOperator[]\n> = {\n metadata: ALL_CUSTOM_FIELD_OPERATORS,\n currency: ['equals', 'not_equals', 'in', 'not_in'],\n amount: ['equals', 'not_equals', 'gt', 'gte', 'lt', 'lte'],\n};\n\n// Operators that ignore the right-hand operand — the editor hides the value\n// input for these, and validation must not demand a value.\nexport const CUSTOM_FIELD_VALUELESS_OPERATORS: readonly CustomFieldOperator[] = [\n 'exists',\n 'not_exists',\n];\n\nexport function customFieldOperatorTakesValue(operator: CustomFieldOperator): boolean {\n return !CUSTOM_FIELD_VALUELESS_OPERATORS.includes(operator);\n}\n\n// The operator a condition falls back to when its source changes and the\n// current operator isn't valid for the new source.\nexport function defaultOperatorForSource(source: CustomFieldConditionSource): CustomFieldOperator {\n return CUSTOM_FIELD_OPERATORS_BY_SOURCE[source][0] ?? 'equals';\n}\n\nexport function defaultCustomFieldVisibility(): CustomFieldVisibility {\n return { mode: 'always', match: 'all', conditions: [] };\n}\n\nfunction parseTranslations(raw: unknown): CustomFieldTranslations {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};\n const out: CustomFieldTranslations = {};\n for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {\n if (typeof v === 'string' && v.length > 0) out[k] = v;\n }\n return out;\n}\n\n// Normalize one persisted condition. Total: an unusable source/operator\n// falls back rather than dropping the row, so a rule authored by a newer\n// control-center never silently becomes \"always visible\" on an older\n// decoder — it becomes a stricter, still-evaluable rule.\nfunction normalizeCondition(raw: unknown, index: number): CustomFieldCondition | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;\n const c = raw as Record<string, unknown>;\n const source = pickEnum<CustomFieldConditionSource>(\n c['source'],\n ALL_CUSTOM_FIELD_CONDITION_SOURCES,\n 'metadata',\n );\n const allowed = CUSTOM_FIELD_OPERATORS_BY_SOURCE[source];\n const operator = pickEnum<CustomFieldOperator>(\n c['operator'],\n allowed,\n defaultOperatorForSource(source),\n );\n const rawValue = c['value'];\n return {\n id: typeof c['id'] === 'string' && c['id'] ? (c['id'] as string) : `cond-${index}`,\n source,\n // Only metadata conditions carry a key; drop anything else so the\n // encoded form stays canonical.\n key: source === 'metadata' && typeof c['key'] === 'string' ? c['key'].trim() : '',\n operator,\n value:\n typeof rawValue === 'string'\n ? rawValue\n : typeof rawValue === 'number' || typeof rawValue === 'boolean'\n ? String(rawValue)\n : '',\n };\n}\n\nfunction normalizeVisibility(raw: unknown): CustomFieldVisibility {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return defaultCustomFieldVisibility();\n const v = raw as Record<string, unknown>;\n const conditions: CustomFieldCondition[] = Array.isArray(v['conditions'])\n ? (v['conditions'] as unknown[])\n .slice(0, CUSTOM_FIELD_CONDITIONS_MAX)\n .map(normalizeCondition)\n .filter((c): c is CustomFieldCondition => c !== null)\n : [];\n return {\n mode: pickEnum<'always' | 'match'>(v['mode'], ['always', 'match'], 'always'),\n match: pickEnum<'all' | 'any'>(v['match'], ['all', 'any'], 'all'),\n conditions,\n };\n}\n\nfunction parseBoundedInt(raw: unknown): number | null {\n const n = typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : NaN;\n if (!Number.isInteger(n) || n < 0) return null;\n return Math.min(n, 5000);\n}\n\n// Normalize one persisted/imported field object. Total: anything malformed\n// falls back per-property; returns null only when there is no usable key.\nfunction normalizeCustomField(raw: unknown, index: number): CheckoutCustomField | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;\n const f = raw as Record<string, unknown>;\n const key = typeof f['key'] === 'string' ? f['key'].trim() : '';\n if (!CUSTOM_FIELD_KEY_PATTERN.test(key)) return null;\n\n const type = pickEnum<CustomFieldType>(f['type'], ALL_CUSTOM_FIELD_TYPES, 'text');\n\n const options: CustomFieldOption[] =\n type === 'select' && Array.isArray(f['options'])\n ? (f['options'] as unknown[])\n .filter((o): o is Record<string, unknown> => !!o && typeof o === 'object')\n .map((o) => {\n const value = typeof o['value'] === 'string' ? o['value'] : '';\n return {\n value,\n label: typeof o['label'] === 'string' && o['label'] ? (o['label'] as string) : value,\n labelTranslations: parseTranslations(o['labelTranslations']),\n };\n })\n .filter((o) => o.value.length > 0)\n : [];\n\n // Length bounds are meaningless for choice controls; drop them at decode\n // so a field switched to checkbox/select can't carry stale bounds that\n // would then be validated against 'true'/'false'.\n const textLike = customFieldIsTextLike(type);\n const minLength = textLike ? parseBoundedInt(f['minLength']) : null;\n const maxLength = textLike ? parseBoundedInt(f['maxLength']) : null;\n\n // A checkbox default is a tick state, not free text: anything that isn't\n // truthy normalizes to unchecked, so the control can never start in a\n // third state.\n const rawDefault = typeof f['defaultValue'] === 'string' ? f['defaultValue'] : '';\n const defaultValue =\n type === 'checkbox'\n ? isCheckboxChecked(rawDefault)\n ? CHECKBOX_CHECKED\n : CHECKBOX_UNCHECKED\n : rawDefault;\n\n return {\n id: typeof f['id'] === 'string' && f['id'] ? (f['id'] as string) : `field-${index}`,\n key,\n type,\n label: typeof f['label'] === 'string' && f['label'] ? (f['label'] as string) : key,\n labelTranslations: parseTranslations(f['labelTranslations']),\n placeholder: typeof f['placeholder'] === 'string' ? (f['placeholder'] as string) : '',\n placeholderTranslations: parseTranslations(f['placeholderTranslations']),\n helpText: typeof f['helpText'] === 'string' ? (f['helpText'] as string) : '',\n helpTextTranslations: parseTranslations(f['helpTextTranslations']),\n required: parseBool(f['required'], false),\n enabled: parseBool(f['enabled'], true),\n minLength,\n // Guard inverted bounds at decode so consumers never see min > max.\n maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,\n defaultValue,\n options,\n visibility: normalizeVisibility(f['visibility']),\n };\n}\n\n// Parse an array of field objects (already JSON-parsed). Null when the\n// input isn't an array — callers fall back to \"no custom fields\". Duplicate\n// keys keep the first occurrence; the list is capped at CUSTOM_FIELDS_MAX.\nexport function parseCustomFieldsLoose(raw: unknown): CheckoutCustomField[] | null {\n if (!Array.isArray(raw)) return null;\n const seen = new Set<string>();\n const out: CheckoutCustomField[] = [];\n for (let i = 0; i < raw.length && out.length < CUSTOM_FIELDS_MAX; i++) {\n const field = normalizeCustomField(raw[i], i);\n if (!field || seen.has(field.key)) continue;\n seen.add(field.key);\n out.push(field);\n }\n return out;\n}\n\n// Decode the JSON-encoded custom fields stored under\n// `sdk_ui_rules.branding.customFields`. Tolerant like `decodeBadges`:\n// malformed payloads fall through to null.\nexport function decodeCustomFields(raw: string | undefined): CheckoutCustomField[] | null {\n if (raw === undefined) return null;\n try {\n return parseCustomFieldsLoose(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\nexport function encodeCustomFields(fields: CheckoutCustomField[]): string {\n const nonEmpty = (m: CustomFieldTranslations): CustomFieldTranslations | undefined => {\n const entries = Object.entries(m).filter(([, v]) => v.trim().length > 0);\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n };\n return JSON.stringify(\n fields.map((f) => ({\n id: f.id,\n key: f.key,\n type: f.type,\n label: f.label,\n ...(nonEmpty(f.labelTranslations)\n ? { labelTranslations: nonEmpty(f.labelTranslations) }\n : {}),\n ...(f.placeholder ? { placeholder: f.placeholder } : {}),\n ...(nonEmpty(f.placeholderTranslations)\n ? { placeholderTranslations: nonEmpty(f.placeholderTranslations) }\n : {}),\n ...(f.helpText ? { helpText: f.helpText } : {}),\n ...(nonEmpty(f.helpTextTranslations)\n ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) }\n : {}),\n ...(f.required ? { required: true } : {}),\n ...(f.enabled ? {} : { enabled: false }),\n // Length bounds only exist for free-text types; a choice control that\n // still carries them is stale state the decoder would drop anyway.\n ...(customFieldIsTextLike(f.type) && f.minLength !== null ? { minLength: f.minLength } : {}),\n ...(customFieldIsTextLike(f.type) && f.maxLength !== null ? { maxLength: f.maxLength } : {}),\n // A checkbox persists only \"starts ticked\"; unticked is the decoder's\n // default, so writing 'false' would be noise on every such field.\n ...(f.type === 'checkbox'\n ? isCheckboxChecked(f.defaultValue)\n ? { defaultValue: CHECKBOX_CHECKED }\n : {}\n : f.defaultValue\n ? { defaultValue: f.defaultValue }\n : {}),\n ...(f.type === 'select' ? { options: f.options } : {}),\n // Omitted for unconditional fields so the stored blob (and every\n // pre-feature payload) stays byte-identical to what it was.\n ...(f.visibility.mode === 'match' ? { visibility: encodeVisibility(f.visibility) } : {}),\n })),\n );\n}\n\nfunction encodeVisibility(v: CustomFieldVisibility): Record<string, unknown> {\n return {\n mode: v.mode,\n match: v.match,\n conditions: v.conditions.map((c) => ({\n id: c.id,\n source: c.source,\n ...(c.source === 'metadata' && c.key ? { key: c.key } : {}),\n operator: c.operator,\n ...(customFieldOperatorTakesValue(c.operator) && c.value ? { value: c.value } : {}),\n })),\n };\n}\n\n// --- Conditional-visibility evaluator -----------------------------------\n\n/** Facts a rule can read. `amount` is in the currency's minor unit (what\n * the payment intent stores); `metadata` values are already flattened to\n * strings by `customFieldContextFromMetadata`. */\nexport interface CustomFieldContext {\n amount: number;\n currency: string;\n metadata: Record<string, string>;\n}\n\n/** Flatten a payment's raw `metadata` object into the string map a rule\n * compares against. Arrays join on `,` so a list-shaped value stays usable\n * with `contains` / `in`; objects fall back to JSON. Mirrors the Rust\n * side's `flatten_metadata`. */\nexport function customFieldContextFromMetadata(raw: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return out;\n for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {\n const flat = flattenMetadataValue(value);\n if (flat !== null) out[key] = flat;\n }\n return out;\n}\n\nfunction flattenMetadataValue(value: unknown): string | null {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n if (value === null || value === undefined) return null;\n if (Array.isArray(value)) {\n return value\n .map((v) => flattenMetadataValue(v))\n .filter((v): v is string => v !== null)\n .join(',');\n }\n try {\n return JSON.stringify(value);\n } catch {\n return null;\n }\n}\n\n// Case- and whitespace-insensitive: merchants type `Windows` in the builder\n// and the shop sends `windows`. Exact-case matching would be a support\n// ticket generator.\nfunction norm(value: string): string {\n return value.trim().toLowerCase();\n}\n\n// Decimal-float grammar, deliberately narrower than `Number()`.\n//\n// `Number()` accepts radix-prefixed literals — `Number('0x10') === 16` — while\n// the router's Rust mirror uses `f64::from_str`, which rejects them. Left\n// unconstrained, a metadata value of `0x10` would satisfy `gte 5` in the\n// control-center's builder and fail it on the backend: the merchant sees one\n// rule, buyers get another. This regex is `f64::from_str`'s number grammar\n// (sign, digits with optional point, optional exponent); `inf`/`nan` are\n// excluded here rather than by the finiteness check below, which matches\n// Rust filtering them out too.\nconst DECIMAL_NUMBER_PATTERN = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\n\n// Both implementations compare as f64, so they round identically. Payment\n// amounts in minor units are far below 2^53, where that is lossless.\nfunction numeric(value: string): number | null {\n const trimmed = value.trim();\n if (!DECIMAL_NUMBER_PATTERN.test(trimmed)) return null;\n const n = Number(trimmed);\n return Number.isFinite(n) ? n : null;\n}\n\nfunction splitList(value: string): string[] {\n return value\n .split(',')\n .map((part) => norm(part))\n .filter((part) => part.length > 0);\n}\n\n/** Resolve the left-hand operand. `undefined` means \"the metadata key is\n * absent\" — which only `exists`/`not_exists` distinguish from empty. */\nfunction operandFor(condition: CustomFieldCondition, ctx: CustomFieldContext): string | undefined {\n switch (condition.source) {\n case 'currency':\n return ctx.currency;\n case 'amount':\n return String(ctx.amount);\n case 'metadata':\n return Object.prototype.hasOwnProperty.call(ctx.metadata, condition.key)\n ? ctx.metadata[condition.key]\n : undefined;\n }\n}\n\nexport function evaluateCustomFieldCondition(\n condition: CustomFieldCondition,\n ctx: CustomFieldContext,\n): boolean {\n const raw = operandFor(condition, ctx);\n const actual = raw ?? '';\n const expected = condition.value;\n\n switch (condition.operator) {\n case 'exists':\n return raw !== undefined && raw.trim().length > 0;\n case 'not_exists':\n return raw === undefined || raw.trim().length === 0;\n case 'equals':\n return norm(actual) === norm(expected);\n case 'not_equals':\n return norm(actual) !== norm(expected);\n case 'contains':\n return norm(actual).includes(norm(expected));\n case 'not_contains':\n return !norm(actual).includes(norm(expected));\n case 'starts_with':\n return norm(actual).startsWith(norm(expected));\n case 'ends_with':\n return norm(actual).endsWith(norm(expected));\n case 'in':\n return splitList(expected).includes(norm(actual));\n case 'not_in':\n return !splitList(expected).includes(norm(actual));\n case 'gt':\n case 'gte':\n case 'lt':\n case 'lte': {\n // Both sides must be numbers. A non-numeric metadata value never\n // matches a numeric comparison (rather than coercing to 0).\n const a = numeric(actual);\n const b = numeric(expected);\n if (a === null || b === null) return false;\n if (condition.operator === 'gt') return a > b;\n if (condition.operator === 'gte') return a >= b;\n if (condition.operator === 'lt') return a < b;\n return a <= b;\n }\n }\n}\n\n/**\n * Whether a field's rule matches the payment.\n *\n * Fail-open in two spots, deliberately: `mode: 'always'` and a `match` rule\n * with no conditions both resolve to visible. A half-authored rule should\n * never silently swallow a field the merchant needs collected — the\n * control-center flags the empty rule as a validation issue instead.\n */\nexport function evaluateCustomFieldVisibility(\n field: CheckoutCustomField,\n ctx: CustomFieldContext,\n): boolean {\n const { mode, match, conditions } = field.visibility;\n if (mode !== 'match' || conditions.length === 0) return true;\n return match === 'any'\n ? conditions.some((c) => evaluateCustomFieldCondition(c, ctx))\n : conditions.every((c) => evaluateCustomFieldCondition(c, ctx));\n}\n\n/** Filter a field list to what the buyer should see for this payment.\n * Disabled fields are dropped here too — the two reasons a field doesn't\n * render are the same to every consumer. */\nexport function visibleCustomFields(\n fields: CheckoutCustomField[],\n ctx: CustomFieldContext,\n): CheckoutCustomField[] {\n return fields.filter((f) => f.enabled && evaluateCustomFieldVisibility(f, ctx));\n}\n\n// Exact-locale-then-base-language lookup. Own-property + string checks so\n// a hostile or odd locale string ('constructor', '__proto__') can never\n// surface a prototype-chain member as a \"translation\".\nfunction translationFor(map: CustomFieldTranslations, locale?: string): string | null {\n if (!locale) return null;\n const own = (k: string): string | null => {\n const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : undefined;\n return typeof v === 'string' && v.length > 0 ? v : null;\n };\n const exact = own(locale);\n if (exact) return exact;\n const base = locale.split('-')[0];\n return base && base !== locale ? own(base) : null;\n}\n\n// Resolve the display string for a field part in a buyer locale.\n// Exact locale wins ('de-AT'), then its base language ('de'), then the\n// field's default-language string; labels finally fall back to the key so\n// a field is never rendered nameless.\nexport function customFieldText(\n field: CheckoutCustomField,\n part: 'label' | 'placeholder' | 'helpText',\n locale?: string,\n): string {\n const map =\n part === 'label'\n ? field.labelTranslations\n : part === 'placeholder'\n ? field.placeholderTranslations\n : field.helpTextTranslations;\n const translated = translationFor(map, locale);\n if (translated) return translated;\n const fallback = field[part];\n if (fallback) return fallback;\n return part === 'label' ? field.key : '';\n}\n\nexport function customFieldOptionLabel(option: CustomFieldOption, locale?: string): string {\n return translationFor(option.labelTranslations, locale) ?? (option.label || option.value);\n}\n\n// Read a branding source into a fully-resolved CheckoutBranding.\n// Flat fields are authoritative when set; the bag fills in everything not\n// reachable via flat columns. Persisted `labelStyle: 'floating'` (legacy\n// \"floating\" mock) decodes to `'above'`.\nexport function decodeBranding(source: BrandingSource | null | undefined): CheckoutBranding {\n if (!source) return cloneBranding(DEFAULT_BRANDING);\n\n const extras: Record<string, string> = (source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ??\n {}) as Record<string, string>;\n\n const decodedBadges = decodeBadges(extras['trustBadges']);\n const decodedCustomFields = decodeCustomFields(extras['customFields']);\n\n // Identity name: public payloads call it `merchant_name`, request payloads\n // call it `seller_name`. Same API field; pick whichever is present.\n const displayName = s(source.merchant_name) || s(source.seller_name);\n const logoUrl = s(source.merchant_logo) || s(source.logo);\n\n // Tagline lives in the bag, but `merchant_description` is its public\n // surface. Either may fill it; bag wins if both are set.\n const tagline = s(extras['tagline']) || s(source.merchant_description);\n\n // Stripe label style: the bag's `labelStyle` is the new source of truth;\n // the legacy flat `payment_form_label_type` is consulted only when the\n // bag is empty. `'floating'` (a legacy preview-only value that Stripe\n // Elements never honored) decodes to `'above'`. `'never'` (legacy API\n // wording) decodes to `'hidden'`.\n const labelStyle: LabelStyle = (() => {\n const fromBag = extras['labelStyle'];\n if (fromBag === 'above' || fromBag === 'hidden') return fromBag;\n if (fromBag === 'floating') return 'above';\n const legacy = source.payment_form_label_type;\n if (legacy === 'above' || legacy === 'floating') return 'above';\n if (legacy === 'hidden' || legacy === 'never') return 'hidden';\n return DEFAULT_BRANDING.labelStyle;\n })();\n\n return {\n displayName,\n logoUrl,\n tagline,\n showLogo: parseBool(extras['showLogo'], DEFAULT_BRANDING.showLogo),\n logoShape: pickEnum<LogoShape>(\n extras['logoShape'],\n ['square', 'rounded', 'circle'],\n DEFAULT_BRANDING.logoShape,\n ),\n logoSize: pickEnum<LogoSize>(extras['logoSize'], ['sm', 'md', 'lg'], DEFAULT_BRANDING.logoSize),\n\n primary: s(source.theme) || DEFAULT_BRANDING.primary,\n background: s(source.background_colour) || DEFAULT_BRANDING.background,\n surface: s(extras['surface']) || DEFAULT_BRANDING.surface,\n text: s(extras['text']) || DEFAULT_BRANDING.text,\n heading: s(extras['heading']) || s(extras['text']) || DEFAULT_BRANDING.heading,\n muted: s(extras['muted']) || DEFAULT_BRANDING.muted,\n border: s(extras['border']) || DEFAULT_BRANDING.border,\n accentText: s(extras['accentText']) || s(source.theme) || DEFAULT_BRANDING.accentText,\n buttonBackground:\n s(source.payment_button_colour) || s(source.theme) || DEFAULT_BRANDING.buttonBackground,\n buttonText: s(source.payment_button_text_colour) || DEFAULT_BRANDING.buttonText,\n\n fontFamily: pickEnum<FontFamily>(\n extras['fontFamily'],\n ALL_FONT_FAMILIES,\n DEFAULT_BRANDING.fontFamily,\n ),\n headingWeight: pickEnum<FontWeight>(\n extras['headingWeight'],\n ['regular', 'medium', 'semibold', 'bold'],\n DEFAULT_BRANDING.headingWeight,\n ),\n\n radiusSurface: pickEnum<NonPillRadius>(\n extras['radiusSurface'],\n NON_PILL_RADII,\n DEFAULT_BRANDING.radiusSurface,\n ),\n radiusInput: pickEnum<NonPillRadius>(\n extras['radiusInput'],\n NON_PILL_RADII,\n DEFAULT_BRANDING.radiusInput,\n ),\n radiusButton: pickEnum<CornerRadius>(\n extras['radiusButton'],\n ALL_RADII,\n DEFAULT_BRANDING.radiusButton,\n ),\n radiusBadge: pickEnum<CornerRadius>(\n extras['radiusBadge'],\n ALL_RADII,\n DEFAULT_BRANDING.radiusBadge,\n ),\n surfaceStyle: pickEnum<SurfaceStyle>(\n extras['surfaceStyle'],\n ['flat', 'outlined', 'elevated'],\n DEFAULT_BRANDING.surfaceStyle,\n ),\n surfacePadding: pickEnum<SpacingScale>(\n extras['surfacePadding'],\n ['compact', 'comfortable', 'spacious'],\n DEFAULT_BRANDING.surfacePadding,\n ),\n verticalGap: pickEnum<SpacingScale>(\n extras['verticalGap'],\n ['compact', 'comfortable', 'spacious'],\n DEFAULT_BRANDING.verticalGap,\n ),\n inputSize: pickEnum<SizeScale>(\n extras['inputSize'],\n ['sm', 'md', 'lg'],\n DEFAULT_BRANDING.inputSize,\n ),\n buttonSize: pickEnum<SizeScale>(\n extras['buttonSize'],\n ['sm', 'md', 'lg'],\n DEFAULT_BRANDING.buttonSize,\n ),\n\n layout: pickEnum<LayoutStyle>(extras['layout'], ['compact', 'split'], DEFAULT_BRANDING.layout),\n summaryPosition: pickEnum<SummaryPosition>(\n extras['summaryPosition'],\n ['left', 'right'],\n DEFAULT_BRANDING.summaryPosition,\n ),\n showOrderSummary: parseBool(extras['showOrderSummary'], DEFAULT_BRANDING.showOrderSummary),\n summaryGradient: parseBool(extras['summaryGradient'], DEFAULT_BRANDING.summaryGradient),\n showTotal: parseBool(extras['showTotal'], DEFAULT_BRANDING.showTotal),\n totalLabel: s(extras['totalLabel']) || DEFAULT_BRANDING.totalLabel,\n showCurrencyCode: parseBool(extras['showCurrencyCode'], DEFAULT_BRANDING.showCurrencyCode),\n showOrderItems: parseBool(extras['showOrderItems'], DEFAULT_BRANDING.showOrderItems),\n\n trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),\n customFields: decodedCustomFields ?? [],\n\n headerText: s(source.payment_form_header_text),\n payButtonLabel: s(source.payment_button_text),\n cardTermsMessage: s(source.custom_message_for_card_terms),\n footerText: s(extras['footerText']),\n supportEmail: s(extras['supportEmail']),\n\n paymentLayout: pickEnum<PaymentLayout>(\n source.sdk_layout,\n ['tabs', 'accordion', 'spaced_accordion'],\n DEFAULT_BRANDING.paymentLayout,\n ),\n labelStyle,\n showPoweredBy: source.branding_visibility !== false,\n\n customCss: s(extras['customCss']),\n };\n}\n\n// Encoded request shape — the union of fields the encoder fills. Compatible\n// with `BusinessPaymentLinkConfig` / `PaymentLinkConfigRequest` via\n// structural typing on the consumer side.\nexport interface EncodedBranding {\n theme: string;\n logo: string | null;\n seller_name: string | null;\n sdk_layout: PaymentLayout;\n payment_button_text: string | null;\n payment_button_colour: string;\n payment_button_text_colour: string;\n background_colour: string;\n payment_form_header_text: string | null;\n payment_form_label_type: 'above' | 'never';\n custom_message_for_card_terms: string | null;\n sdk_ui_rules: Record<string, Record<string, string>>;\n branding_visibility: boolean;\n}\n\n// Encode a CheckoutBranding into the API request shape. `base` is the\n// existing config (if any) -- preserves bag entries the form doesn't surface\n// (other sdk_ui_rules groups, business_specific_configs, etc.) by spreading\n// it through.\n//\n// `TBase` is constrained to `object | null | undefined` (not\n// `Record<string, unknown>`) so consumers can pass interface-typed values\n// directly. TS interfaces don't get an implicit string index signature, so\n// they don't structurally satisfy `Record<string, unknown>` even when their\n// property values would all unify to `unknown` — `object` admits them\n// without forcing a cast at every call site. We only spread the value, so\n// no index-signature semantics are needed at runtime.\nexport function encodeBranding<TBase extends object | null | undefined>(\n branding: CheckoutBranding,\n base?: TBase,\n): EncodedBranding & (TBase extends object ? TBase : Record<string, never>) {\n const trim = (v: string): string | null => {\n const t = v.trim();\n return t.length > 0 ? t : null;\n };\n\n // We only read one property off `base` and structural typing on `object`\n // doesn't permit index access, so go through `unknown` here.\n const existingRules = ((base as unknown as Record<string, unknown> | undefined)?.[\n 'sdk_ui_rules'\n ] ?? {}) as Record<string, Record<string, string>>;\n const extras: Record<string, string> = {\n surface: branding.surface,\n text: branding.text,\n heading: branding.heading,\n muted: branding.muted,\n border: branding.border,\n accentText: branding.accentText,\n fontFamily: branding.fontFamily,\n headingWeight: branding.headingWeight,\n radiusSurface: branding.radiusSurface,\n radiusInput: branding.radiusInput,\n radiusButton: branding.radiusButton,\n radiusBadge: branding.radiusBadge,\n surfaceStyle: branding.surfaceStyle,\n surfacePadding: branding.surfacePadding,\n verticalGap: branding.verticalGap,\n inputSize: branding.inputSize,\n buttonSize: branding.buttonSize,\n layout: branding.layout,\n summaryPosition: branding.summaryPosition,\n showOrderSummary: String(branding.showOrderSummary),\n summaryGradient: String(branding.summaryGradient),\n showTotal: String(branding.showTotal),\n totalLabel: branding.totalLabel,\n showCurrencyCode: String(branding.showCurrencyCode),\n showOrderItems: String(branding.showOrderItems),\n showLogo: String(branding.showLogo),\n logoShape: branding.logoShape,\n logoSize: branding.logoSize,\n labelStyle: branding.labelStyle,\n trustBadges: encodeBadges(branding.trustBadges),\n };\n // Omit the key entirely when there are no fields — decode treats a\n // missing entry the same as an empty list, and the bag stays clean for\n // merchants who never touch the feature.\n if (branding.customFields.length > 0) {\n extras['customFields'] = encodeCustomFields(branding.customFields);\n }\n const tagline = trim(branding.tagline);\n if (tagline) extras['tagline'] = tagline;\n const footer = trim(branding.footerText);\n if (footer) extras['footerText'] = footer;\n const support = trim(branding.supportEmail);\n if (support) extras['supportEmail'] = support;\n // Persist raw — sanitization runs at render time so we keep the merchant's\n // input as-typed (preserves comments, whitespace) and let the checkout\n // strip dangerous tokens consistently across all readers.\n const css = trim(branding.customCss);\n if (css) extras['customCss'] = css;\n\n const nextRules: Record<string, Record<string, string>> = {\n ...existingRules,\n [BRANDING_GROUP_KEY]: extras,\n };\n\n // Map `hidden` back to the legacy `never` token the API's label type\n // enum understands. `floating` no longer exists.\n const legacyLabel: 'above' | 'never' = branding.labelStyle === 'hidden' ? 'never' : 'above';\n\n const flatFields: EncodedBranding = {\n theme: branding.primary,\n logo: trim(branding.logoUrl),\n seller_name: trim(branding.displayName),\n sdk_layout: branding.paymentLayout,\n payment_button_text: trim(branding.payButtonLabel),\n payment_button_colour: branding.buttonBackground,\n payment_button_text_colour: branding.buttonText,\n background_colour: branding.background,\n payment_form_header_text: trim(branding.headerText),\n payment_form_label_type: legacyLabel,\n custom_message_for_card_terms: trim(branding.cardTermsMessage),\n sdk_ui_rules: nextRules,\n branding_visibility: branding.showPoweredBy,\n };\n\n // Spread `base` first to preserve fields the encoder doesn't surface\n // (show_card_terms, show_card_form_by_default, hide_card_nickname_field,\n // enable_button_only_on_form_ready, skip_status_screen,\n // transaction_details, background_image, details_layout,\n // custom_message_for_payment_method_types, payment_link_ui_rules,\n // color_icon_card_cvc_error, is_setup_mandate_flow,\n // enabled_saved_payment_method, display_sdk_only,\n // business_specific_configs, domain_name, allowed_domains).\n return {\n ...base,\n ...flatFields,\n } as EncodedBranding & (TBase extends object ? TBase : Record<string, never>);\n}\n\n// --- Import / Export envelope ------------------------------------------\n\n// Versioned envelope used by the merchant control-center's \"Import /\n// Export\" buttons. Bumping `version` is informational; the importer is\n// graceful and accepts any version (or no envelope at all).\nexport const BRANDING_EXPORT_FORMAT = 'delopay-checkout-branding';\nexport const BRANDING_EXPORT_VERSION = 1;\n\nexport interface BrandingExport {\n format: typeof BRANDING_EXPORT_FORMAT;\n version: number;\n exported_at: string;\n branding: CheckoutBranding;\n}\n\nexport function buildBrandingExport(branding: CheckoutBranding): BrandingExport {\n return {\n format: BRANDING_EXPORT_FORMAT,\n version: BRANDING_EXPORT_VERSION,\n exported_at: new Date().toISOString(),\n branding: cloneBranding(branding),\n };\n}\n\n// Resolve arbitrary JSON into a fully-typed CheckoutBranding. Designed to\n// never throw — every field is independently validated against its type\n// and silently falls back to the light-mode default if missing or\n// malformed:\n// - extra fields the form doesn't know about are ignored,\n// - missing fields inherit defaults,\n// - hex colors that fail the regex stay at the default,\n// - enums outside the allowed set fall back,\n// - a payload with no recognizable shape produces DEFAULT_BRANDING.\n//\n// Accepts either a bare CheckoutBranding object or an envelope produced by\n// `buildBrandingExport()`. The caller (the import handler) only needs to\n// catch JSON.parse errors; everything past that point is total.\nexport function parseImportedBranding(raw: unknown): CheckoutBranding {\n // Unwrap the envelope if present. Don't gate on version — bumping it is\n // informational; this function is the migration layer.\n const root: Record<string, unknown> | null =\n isObject(raw) && isObject(raw['branding'])\n ? (raw['branding'] as Record<string, unknown>)\n : isObject(raw)\n ? raw\n : null;\n\n if (!root) return cloneBranding(DEFAULT_BRANDING);\n\n const dflt = DEFAULT_BRANDING;\n const sStr = (v: unknown, fallback: string): string => (typeof v === 'string' ? v : fallback);\n const sHex = (v: unknown, fallback: string): string =>\n typeof v === 'string' && isHexColor(v) ? v : fallback;\n\n const trustBadges =\n parseTrustBadgesLoose(root['trustBadges']) ?? dflt.trustBadges.map((b) => ({ ...b }));\n const customFields = parseCustomFieldsLoose(root['customFields']) ?? [];\n\n // `floating` from older exports normalizes to `above`; see decodeBranding.\n const labelStyle: LabelStyle = (() => {\n const v = root['labelStyle'];\n if (v === 'above' || v === 'hidden') return v;\n return dflt.labelStyle;\n })();\n\n return {\n displayName: sStr(root['displayName'], dflt.displayName),\n logoUrl: sStr(root['logoUrl'], dflt.logoUrl),\n tagline: sStr(root['tagline'], dflt.tagline),\n showLogo: parseBool(root['showLogo'], dflt.showLogo),\n logoShape: pickEnum<LogoShape>(\n root['logoShape'],\n ['square', 'rounded', 'circle'],\n dflt.logoShape,\n ),\n logoSize: pickEnum<LogoSize>(root['logoSize'], ['sm', 'md', 'lg'], dflt.logoSize),\n\n primary: sHex(root['primary'], dflt.primary),\n background: sHex(root['background'], dflt.background),\n surface: sHex(root['surface'], dflt.surface),\n text: sHex(root['text'], dflt.text),\n heading: sHex(root['heading'], dflt.heading),\n muted: sHex(root['muted'], dflt.muted),\n border: sHex(root['border'], dflt.border),\n accentText: sHex(root['accentText'], dflt.accentText),\n buttonBackground: sHex(root['buttonBackground'], dflt.buttonBackground),\n buttonText: sHex(root['buttonText'], dflt.buttonText),\n\n fontFamily: pickEnum<FontFamily>(root['fontFamily'], ALL_FONT_FAMILIES, dflt.fontFamily),\n headingWeight: pickEnum<FontWeight>(\n root['headingWeight'],\n ['regular', 'medium', 'semibold', 'bold'],\n dflt.headingWeight,\n ),\n\n radiusSurface: pickEnum<NonPillRadius>(\n root['radiusSurface'],\n NON_PILL_RADII,\n dflt.radiusSurface,\n ),\n radiusInput: pickEnum<NonPillRadius>(root['radiusInput'], NON_PILL_RADII, dflt.radiusInput),\n radiusButton: pickEnum<CornerRadius>(root['radiusButton'], ALL_RADII, dflt.radiusButton),\n radiusBadge: pickEnum<CornerRadius>(root['radiusBadge'], ALL_RADII, dflt.radiusBadge),\n surfaceStyle: pickEnum<SurfaceStyle>(\n root['surfaceStyle'],\n ['flat', 'outlined', 'elevated'],\n dflt.surfaceStyle,\n ),\n surfacePadding: pickEnum<SpacingScale>(\n root['surfacePadding'],\n ['compact', 'comfortable', 'spacious'],\n dflt.surfacePadding,\n ),\n verticalGap: pickEnum<SpacingScale>(\n root['verticalGap'],\n ['compact', 'comfortable', 'spacious'],\n dflt.verticalGap,\n ),\n inputSize: pickEnum<SizeScale>(root['inputSize'], ['sm', 'md', 'lg'], dflt.inputSize),\n buttonSize: pickEnum<SizeScale>(root['buttonSize'], ['sm', 'md', 'lg'], dflt.buttonSize),\n\n layout: pickEnum<LayoutStyle>(root['layout'], ['compact', 'split'], dflt.layout),\n summaryPosition: pickEnum<SummaryPosition>(\n root['summaryPosition'],\n ['left', 'right'],\n dflt.summaryPosition,\n ),\n showOrderSummary: parseBool(root['showOrderSummary'], dflt.showOrderSummary),\n summaryGradient: parseBool(root['summaryGradient'], dflt.summaryGradient),\n showTotal: parseBool(root['showTotal'], dflt.showTotal),\n totalLabel: sStr(root['totalLabel'], dflt.totalLabel),\n showCurrencyCode: parseBool(root['showCurrencyCode'], dflt.showCurrencyCode),\n showOrderItems: parseBool(root['showOrderItems'], dflt.showOrderItems),\n\n trustBadges,\n customFields,\n\n headerText: sStr(root['headerText'], dflt.headerText),\n payButtonLabel: sStr(root['payButtonLabel'], dflt.payButtonLabel),\n cardTermsMessage: sStr(root['cardTermsMessage'], dflt.cardTermsMessage),\n footerText: sStr(root['footerText'], dflt.footerText),\n supportEmail: sStr(root['supportEmail'], dflt.supportEmail),\n\n paymentLayout: pickEnum<PaymentLayout>(\n root['paymentLayout'],\n ['tabs', 'accordion', 'spaced_accordion'],\n dflt.paymentLayout,\n ),\n labelStyle,\n showPoweredBy: parseBool(root['showPoweredBy'], dflt.showPoweredBy),\n\n customCss: sStr(root['customCss'], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH),\n };\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n// Loose trust-badge parser used by the importer. Unlike `decodeBadges`\n// (which reads the JSON-stringified API bag), this accepts an array of\n// objects directly. Returns null when the input isn't an array — the\n// caller falls back to the default badge set; an explicit empty array is\n// honored.\nfunction parseTrustBadgesLoose(raw: unknown): TrustBadge[] | null {\n if (!Array.isArray(raw)) return null;\n return raw\n .filter(isObject)\n .map((b, i) => ({\n id: typeof b['id'] === 'string' && b['id'] ? (b['id'] as string) : `badge-${i}`,\n label: typeof b['label'] === 'string' ? (b['label'] as string) : '',\n textColor:\n typeof b['textColor'] === 'string' && isHexColor(b['textColor'] as string)\n ? (b['textColor'] as string)\n : '#0f172a',\n backgroundColor:\n typeof b['backgroundColor'] === 'string' && isHexColor(b['backgroundColor'] as string)\n ? (b['backgroundColor'] as string)\n : '#f1f5f9',\n borderColor:\n typeof b['borderColor'] === 'string' && isHexColor(b['borderColor'] as string)\n ? (b['borderColor'] as string)\n : null,\n }))\n .filter((b) => b.label.length > 0);\n}\n\n// --- DOM helpers --------------------------------------------------------\n\n// Write branding tokens onto a target element as CSS custom properties.\n// The buyer-facing checkout sets these on `<html>` so every component sees\n// the same set, including Stripe Elements (indirectly via\n// appearance.variables). The merchant control-center's preview component\n// uses an analogous `--p-*` set with `var(--dp-*, fallback)` indirection so\n// a custom-CSS rule like `:root{--dp-primary:red}` overrides the preview\n// without re-typing the whole brand.\nexport function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void {\n const set = (k: string, v: string) => {\n el.style.setProperty(k, v);\n };\n\n set('--dp-primary', b.primary);\n set('--dp-bg', b.background);\n set('--dp-surface', b.surface);\n set('--dp-text', b.text);\n set('--dp-heading', b.heading);\n set('--dp-muted', b.muted);\n set('--dp-border', b.border);\n set('--dp-accent-text', b.accentText);\n set('--dp-btn-bg', b.buttonBackground);\n set('--dp-btn-fg', b.buttonText);\n\n set('--dp-radius-surface', radiusValue(b.radiusSurface));\n set('--dp-radius-input', radiusValue(b.radiusInput));\n set('--dp-radius-button', radiusValue(b.radiusButton));\n set('--dp-radius-badge', radiusValue(b.radiusBadge));\n\n set('--dp-font', fontStack(b.fontFamily));\n set('--dp-heading-weight', fontWeightValue(b.headingWeight));\n\n set('--dp-pad-surface', SURFACE_PAD[b.surfacePadding]);\n set('--dp-gap-vertical', VERTICAL_GAP[b.verticalGap]);\n set('--dp-input-pad', INPUT_PAD[b.inputSize]);\n set('--dp-button-pad', BUTTON_PAD[b.buttonSize]);\n\n set('--dp-shadow', shadowFor(b.surfaceStyle));\n set(\n '--dp-surface-border',\n b.surfaceStyle === 'outlined' ? `1px solid ${b.border}` : '1px solid transparent',\n );\n}\n\nexport function shadowFor(style: SurfaceStyle): string {\n switch (style) {\n case 'elevated':\n return '0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 32px -12px rgba(15, 23, 42, 0.08)';\n case 'outlined':\n case 'flat':\n default:\n return 'none';\n }\n}\n","import { Delopay } from './client';\nimport type { DelopayLogger, RequestExtras } from './client';\nimport { DelopayError } from './error';\nimport type {\n ConfirmSubscriptionRequest,\n ConfirmSubscriptionResponse,\n EpayoutsMethodsResponse,\n PaymentConfirmRequest,\n PaymentMethodListResponse,\n PaymentResponse,\n PaymentUpdateRequest,\n PayseproMethodsResponse,\n RecordCheckoutEventRequest,\n RecordCheckoutEventResponse,\n VaultCollectSessionResponse,\n VaultPaymentMethodRequest,\n VaultPaymentMethodResponse,\n} from './types';\n\n/**\n * A publishable (browser-safe) API key. The template type rejects secret\n * keys (`prd_…` / `snd_…`) at compile time, so a checkout cannot be handed\n * a credential that would reach secret-key routes.\n */\nexport type PublishableKey = `pk_${string}`;\n\n/**\n * Drop any caller-supplied credential headers (case-insensitively), so a\n * route can only ever carry the one credential its family requires — the\n * class's isolation guarantee must hold against per-call `headers` too.\n * Non-credential extras (`Idempotency-Key`, `X-Dp-*`, …) pass through.\n */\nfunction withoutCredentialHeaders(extra?: Record<string, string>): Record<string, string> {\n if (!extra) return {};\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(extra)) {\n const lower = key.toLowerCase();\n if (lower === 'api-key' || lower === 'authorization') continue;\n out[key] = value;\n }\n return out;\n}\n\n/** Drop one header (case-insensitively) from a caller-supplied extras map. */\nfunction withoutHeader(headers: Record<string, string>, name: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) continue;\n out[key] = value;\n }\n return out;\n}\n\n/** Configuration for a {@link CheckoutSession}. */\nexport interface CheckoutSessionOptions {\n /** The merchant the payment belongs to. */\n merchantId: string;\n /** The payment this session is about. */\n paymentId: string;\n /**\n * The merchant's publishable key (`pk_prd_…` / `pk_snd_…`), from the\n * checkout payload's `pub_key`. Required for the `/payments/*` and\n * `/payment-methods` calls.\n */\n publishableKey?: PublishableKey;\n /**\n * The payment's client secret, from the checkout payload. Required for\n * every `/payment-link/*` call, and rides along on the payment calls.\n */\n clientSecret?: string;\n /** Override the API base URL (e.g. `/api` behind a same-origin proxy). */\n baseUrl?: string;\n /** Use the sandbox environment. Ignored when `baseUrl` is set. */\n sandbox?: boolean;\n /** Per-request timeout in milliseconds. */\n timeout?: number;\n /** Maximum automatic retries for retryable requests. */\n maxRetries?: number;\n debug?: boolean;\n logger?: DelopayLogger;\n}\n\n/**\n * Buyer-side client for a single hosted-checkout payment.\n *\n * Binds the two browser-safe credentials once — the merchant's publishable\n * key and the payment's client secret — and sends each request with exactly\n * the credential its route expects:\n *\n * - `/payment-link/*` side-channel routes authenticate with\n * `Authorization: Bearer <client_secret>`.\n * - `/payments/*` and `/payment-methods` authenticate with the publishable\n * key in the `api-key` header, with the client secret as query parameter\n * or body field.\n *\n * Neither credential can reach a secret-key route: the publishable key is\n * typed to the `pk_` prefix and the client secret only ever leaves as a\n * bearer token / parameter, never as an `api-key`.\n *\n * @example\n * ```typescript\n * const session = new CheckoutSession({\n * merchantId: checkout.merchant_id,\n * paymentId: checkout.payment_id,\n * publishableKey: checkout.pub_key,\n * clientSecret: checkout.client_secret,\n * });\n * const catalog = await session.payseproMethods('de');\n * ```\n */\nexport class CheckoutSession {\n private readonly client: Delopay;\n private readonly merchantId: string;\n private readonly paymentId: string;\n private readonly publishableKey?: PublishableKey;\n private readonly clientSecret?: string;\n\n constructor(options: CheckoutSessionOptions) {\n this.merchantId = options.merchantId;\n this.paymentId = options.paymentId;\n this.publishableKey = options.publishableKey;\n this.clientSecret = options.clientSecret;\n // Constructed WITHOUT a key: every call attaches its own credential\n // explicitly, so a bearer-authenticated route never carries an api-key\n // header and vice versa.\n this.client = new Delopay('', {\n baseUrl: options.baseUrl,\n sandbox: options.sandbox,\n timeout: options.timeout,\n maxRetries: options.maxRetries,\n debug: options.debug,\n logger: options.logger,\n });\n }\n\n private get linkBase(): string {\n return `/payment-link/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`;\n }\n\n /** Headers for the client-secret bearer routes (`/payment-link/*`). */\n private bearerHeaders(extra?: Record<string, string>): Record<string, string> {\n return {\n ...withoutCredentialHeaders(extra),\n Authorization: `Bearer ${this.requireClientSecret()}`,\n };\n }\n\n /** Headers for the publishable-key routes (`/payments/*`, `/payment-methods`). */\n private pkHeaders(extra?: Record<string, string>): Record<string, string> {\n if (!this.publishableKey) {\n throw new DelopayError('This call requires the publishable key', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return { ...withoutCredentialHeaders(extra), 'api-key': this.publishableKey };\n }\n\n private requireClientSecret(): string {\n if (!this.clientSecret) {\n throw new DelopayError('This call requires the payment client secret', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return this.clientSecret;\n }\n\n /**\n * The hosted checkout's bootstrap payload for a one-time payment —\n * `CheckoutDetails` while payable, a status view once settled.\n *\n * Deliberately unauthenticated: a `pay_` link bootstraps before any\n * credential exists, so no credential header is ever attached (caller\n * extras are still stripped of credentials). The response is a large\n * discriminated union owned by the consuming checkout, which keeps its\n * own types and runtime gates — hence the loose return type.\n *\n * `theme` is the route's one declared query parameter (a named checkout\n * variant). `locale` travels as `Accept-Language` — the only\n * channel the backend's locale resolution reads; a `?locale=` query is\n * silently ignored by this route.\n *\n * `GET /payment-link/data/{merchantId}/{paymentId}`\n */\n async fetchCheckoutData(\n params?: { locale?: string; theme?: string },\n options?: RequestExtras,\n ): Promise<Record<string, unknown>> {\n return this.client.request(\n 'GET',\n `/payment-link/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n query: { theme: params?.theme },\n ...options,\n headers: {\n ...(params?.locale\n ? {\n ...withoutHeader(withoutCredentialHeaders(options?.headers), 'accept-language'),\n 'Accept-Language': params.locale,\n }\n : withoutCredentialHeaders(options?.headers)),\n },\n },\n );\n }\n\n /**\n * The subscription twin of {@link CheckoutSession.fetchCheckoutData}: the\n * bootstrap payload for a `sub_` checkout. Authenticated with the\n * subscription's client secret (construct the session with the `sub_…` id\n * in the `paymentId` slot). `locale` travels as `Accept-Language`, same\n * as {@link CheckoutSession.fetchCheckoutData}.\n *\n * `GET /subscriptions/data/{merchantId}/{subscriptionId}`\n */\n async fetchSubscriptionData(\n params?: { locale?: string },\n options?: RequestExtras,\n ): Promise<Record<string, unknown>> {\n return this.client.request(\n 'GET',\n `/subscriptions/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n ...options,\n headers: {\n ...(params?.locale\n ? {\n ...withoutHeader(this.bearerHeaders(options?.headers), 'accept-language'),\n 'Accept-Language': params.locale,\n }\n : this.bearerHeaders(options?.headers)),\n },\n },\n );\n }\n\n /**\n * Report buyer/device signals for rails that never reach\n * `/payments/{id}/confirm` (the Stripe SAQ-A rail: raw cards, Apple Pay,\n * Google Pay). Same telemetry contract as\n * {@link CheckoutSession.recordEvent}: sent with `keepalive: true`, and\n * failures resolve instead of rejecting — signals must never block or\n * break a checkout. Unauthenticated by design.\n *\n * `POST /payment-link/client-signals/{merchantId}/{paymentId}`\n */\n async reportClientSignals(\n params: {\n browser_info?: Record<string, unknown>;\n signals: Record<string, unknown>;\n },\n options?: RequestExtras,\n ): Promise<void> {\n try {\n await this.client.request(\n 'POST',\n `/payment-link/client-signals/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n body: params,\n keepalive: true,\n ...options,\n headers: withoutCredentialHeaders(options?.headers),\n },\n );\n } catch {\n // Telemetry: swallowing is the contract, not an oversight.\n }\n }\n\n /**\n * Confirm a subscription (PayPal approval rail). The client secret is\n * attached automatically; the shop's profile id travels as the\n * `X-Profile-Id` header the subscription routes require.\n *\n * `POST /subscriptions/{subscriptionId}/confirm` (publishable key)\n */\n async confirmSubscription(\n subscriptionId: string,\n profileId: string,\n params: Omit<ConfirmSubscriptionRequest, 'client_secret'>,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.client.request(\n 'POST',\n `/subscriptions/${encodeURIComponent(subscriptionId)}/confirm`,\n {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n // Strip any caller-supplied x-profile-id first (case-insensitively):\n // Fetch folds duplicate headers into `caller, pro_x`, and the\n // subscription routes must see exactly one profile scope.\n headers: {\n ...withoutHeader(this.pkHeaders(options?.headers), 'x-profile-id'),\n 'X-Profile-Id': profileId,\n },\n },\n );\n }\n\n /**\n * The Paysepro rail catalog for the buyer's country.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/paysepro/methods`\n *\n * @param country - Lowercase ISO 3166-1 alpha-2 country code.\n */\n async payseproMethods(\n country: string,\n options?: RequestExtras,\n ): Promise<PayseproMethodsResponse> {\n return this.client.request('GET', `${this.linkBase}/paysepro/methods`, {\n query: { cc: country },\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The e-Payouts rail catalog for the buyer's country, plus the set of\n * countries that have at least one vendor.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/epayouts/methods`\n *\n * @param country - Lowercase ISO 3166-1 alpha-2 country code.\n */\n async epayoutsMethods(\n country: string,\n options?: RequestExtras,\n ): Promise<EpayoutsMethodsResponse> {\n return this.client.request('GET', `${this.linkBase}/epayouts/methods`, {\n query: { cc: country },\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Record a buyer-side checkout event on the payment's status timeline.\n *\n * Telemetry semantics, built in so callers can genuinely fire-and-forget:\n * the request is sent with `keepalive: true` (it survives the document\n * navigating away, e.g. right before a `window.open`), and transport or\n * server failures resolve to `undefined` instead of rejecting — telemetry\n * must never break a checkout or surface an unhandled rejection. Do not\n * `await` this in a click handler that must stay synchronous.\n *\n * A missing client secret still throws `MISSING_CREDENTIAL`: that is a\n * wiring bug, not a telemetry failure.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/checkout-events`\n */\n async recordEvent(\n params: RecordCheckoutEventRequest,\n options?: RequestExtras,\n ): Promise<RecordCheckoutEventResponse | undefined> {\n const headers = this.bearerHeaders(options?.headers);\n try {\n return await this.client.request('POST', `${this.linkBase}/checkout-events`, {\n body: params,\n keepalive: true,\n ...options,\n headers,\n });\n } catch {\n return undefined;\n }\n }\n\n /**\n * A short-lived VGS Collect session for browser-side card capture.\n *\n * **Exactly one refusal means \"this shop has no vault\": a 400 carrying\n * `IR_19`.** Every other refusal means a vault exists and could not be used,\n * and answering it by falling back to the processor's own card pane sends an\n * unprotected card number to the very processor the shop pays to hide it\n * from — the bug this endpoint's error contract exists to prevent.\n *\n * A **404 is not benign.** The router answers it when the shop's vault\n * account cannot be found — the state a shop is left in when its vault\n * connector is deleted while the profile keeps naming the id: it still\n * reports the vault as enabled and still expects its cards cloaked. The same\n * status also covers a payment that does not exist.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`\n */\n async vaultCollectSession(options?: RequestExtras): Promise<VaultCollectSessionResponse> {\n return this.client.request('GET', `${this.linkBase}/vault/collect-session`, {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Register the aliased card as a payment method and mint the one-shot\n * `payment_token` the confirm call spends.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/vault/payment-method`\n */\n async registerVaultPaymentMethod(\n params: VaultPaymentMethodRequest,\n options?: RequestExtras,\n ): Promise<VaultPaymentMethodResponse> {\n return this.client.request('POST', `${this.linkBase}/vault/payment-method`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The payment's current state — status polling for redirect/popup rails.\n *\n * `GET /payments/{paymentId}` (publishable key + client secret)\n */\n async retrievePayment(options?: RequestExtras): Promise<PaymentResponse> {\n return this.client.request('GET', `/payments/${encodeURIComponent(this.paymentId)}`, {\n query: { client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Update the payment before confirmation (e.g. persist custom-field\n * answers as `metadata` on rails that never hit `/confirm`). The client\n * secret is attached automatically.\n *\n * `POST /payments/{paymentId}` (publishable key)\n */\n async updatePayment(\n params: PaymentUpdateRequest,\n options?: RequestExtras,\n ): Promise<PaymentResponse> {\n return this.client.request('POST', `/payments/${encodeURIComponent(this.paymentId)}`, {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Confirm the payment. The client secret is attached automatically; pass\n * an `Idempotency-Key` header via `options` to make retries safe.\n *\n * `POST /payments/{paymentId}/confirm` (publishable key)\n */\n async confirmPayment(\n params: PaymentConfirmRequest,\n options?: RequestExtras,\n ): Promise<PaymentResponse> {\n return this.client.request('POST', `/payments/${encodeURIComponent(this.paymentId)}/confirm`, {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Payment methods available for this payment.\n *\n * `GET /payment-methods` (publishable key + client secret)\n *\n * @param params - Optional filters; `country` is the highest-precedence\n * geo hint, ahead of billing address and IP geolocation.\n */\n async listPaymentMethods(\n params?: { country?: string },\n options?: RequestExtras,\n ): Promise<PaymentMethodListResponse> {\n return this.client.request('GET', '/payment-methods', {\n query: { client_secret: this.requireClientSecret(), country: params?.country },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n}\n","// Stripe **native panes** — merchant-configured payment methods that render as\n// DeloPay-drawn tiles in the embedded checkout instead of inside Stripe's\n// Payment Element.\n//\n// Why they exist: Stripe only offers Apple Pay / Google Pay / Link when the\n// *top-level* document's domain is registered as a payment method domain on the\n// merchant's Stripe account. In an embedded iframe that domain is the\n// merchant's shop, not the DeloPay checkout — so the wallet silently\n// disappears. A native pane replaces it with our own tile that opens the DeloPay\n// hosted checkout at the top level, in a focused single-method view.\n//\n// Nothing here is Apple-Pay-specific: the feature is \"which Stripe payment\n// methods render as a native pane, and how they look\".\n//\n// This module serves SDK consumers: merchants configuring\n// `metadata.native_panes` on a Stripe connector account programmatically\n// (codec), reading the resolved `native_panes` off a checkout payload\n// (`NativePaneView`), or building the focused single-method link that goes\n// behind their own button (`focusedCheckoutUrl()`).\n//\n// It is a **mirror**, not the source of truth. The catalog and wire shapes are\n// owned by the router (delopay-backend\n// `crates/router/src/core/payment_link/native_panes.rs`). Four independent\n// copies exist, none importing another — change the router and all four in the\n// same change, or a merchant configures a pane the router silently drops:\n//\n// 1. this module\n// 2. delopay-control-center `src/app/core/services/native-panes.model.ts`\n// (the connector-page editor)\n// 3. delopay-java `src/main/java/net/delopay/sdk/nativepanes/NativePanes.java`\n// 4. delopay-rust-sdk `src/core/native_panes.rs`\n//\n// delopay-checkout (`src/lib/types.ts`) holds the resolved wire type only, not\n// the catalog, but its field names move with the router too.\n\n// --- Wire types ---------------------------------------------------------\n\n/**\n * How the focused external checkout charges a paned method. Decided\n * server-side; the browser never picks.\n *\n * - `wallet` — the method rides inside Stripe's `card` rail (Apple Pay, Google\n * Pay, Link). The focused view charges the **same** PaymentIntent the\n * embedded checkout already holds, so no second intent is ever created.\n * - `redirect` — the method has its own `payment_method_types[]` entry. The\n * focused view confirms through the standard `/payments/{id}/confirm` rail\n * and follows `next_action.redirect_to_url`.\n */\nexport type NativePaneRail = 'wallet' | 'redirect';\n\n/**\n * Where a pane's tile is offered. Wallet rail only — a redirect pane is\n * suppressed server-side, before any render knows whether it is framed, so\n * `embedded_only` there would leave the method unpayable at top level and the\n * router forces it back to `always`.\n */\nexport type NativePaneVisibility = 'always' | 'embedded_only';\n\n/**\n * How the embedded checkout opens a pane's focused view: a new browser tab\n * (`tab`, the historical behaviour) or a centred popup window (`popup`).\n * Only meaningful when the checkout renders inside an iframe — a top-level\n * render always navigates in place. Browsers that refuse popup windows fall\n * back to a tab on their own.\n */\nexport type NativePaneOpenTarget = 'tab' | 'popup';\n\n/**\n * One native pane exactly as the merchant configures it. Persisted (JSON) under\n * `metadata.native_panes` on the Stripe merchant connector account.\n *\n * Field names are the wire contract — renaming one is a migration. The router\n * decodes strictly row by row: a row that fails strict decoding (e.g. a\n * wrong-typed field like `display_order: \"3\"`) is dropped whole with a server\n * log, and the remaining rows still render. This SDK's\n * {@link decodeNativePanes} is additionally per-property tolerant — including\n * clamping `display_order` into the router's `i32` range — so a decode→encode\n * round-trip through the SDK repairs a blob the router would partially drop.\n */\nexport interface StripeNativePane {\n /** Catalog key of the promoted method — see {@link STRIPE_NATIVE_PANE_METHODS}. */\n method: string;\n /** Disabled rows keep their tuning but never reach a buyer. */\n enabled: boolean;\n /** Default-language tile label. Empty falls back to the catalog name. */\n label: string;\n /** Per-locale overrides of `label`, keyed by checkout locale (`de`, `de-AT`). */\n labelTranslations: Record<string, string>;\n /**\n * Secondary line under the label. `null` means \"use the catalog default\";\n * an empty string means the merchant deliberately hid the line. That\n * distinction is the whole reason this is nullable and `label` is not.\n */\n sublabel: string | null;\n /** Per-locale overrides of `sublabel`. */\n sublabelTranslations: Record<string, string>;\n /** Section the tile groups under. Empty falls back to the catalog category. */\n category: string;\n /** Built-in icon key — see {@link NATIVE_PANE_ICON_KEYS}. */\n icon: string;\n /** Custom inline SVG. Sanitized server-side before it reaches a buyer; a\n * rejected payload falls back to the built-in `icon`. */\n iconSvg: string;\n /** Lower renders first; ties break on catalog order. */\n displayOrder: number;\n /** `embedded_only` keeps the wallet inside Stripe's form at top level. */\n visibility: NativePaneVisibility;\n /** How the embedded checkout opens the focused view — see {@link NativePaneOpenTarget}. */\n openIn: NativePaneOpenTarget;\n}\n\n/**\n * One resolved native pane as the buyer-facing checkout receives it on the\n * payment-link payload (`native_panes`). Labels are already localized for the\n * render's locale and icons already sanitized — snake_case because this is the\n * API wire shape, not the editor's.\n */\nexport interface NativePaneView {\n method: string;\n rail: NativePaneRail;\n label: string;\n sublabel: string;\n category: string;\n icon?: string | null;\n icon_svg?: string | null;\n display_order: number;\n /** Redirect rail only — echo verbatim on confirm, never derive. */\n payment_method?: string | null;\n /** Redirect rail only — echo verbatim on confirm, never derive. */\n payment_method_type?: string | null;\n /** Redirect rail only — echo verbatim on confirm, never derive. */\n payment_method_data?: Record<string, unknown> | null;\n /**\n * The confirm body needs the buyer's country: merged into\n * `billing.address.country` and echoed into the single `payment_method_data`\n * variant's `billing_country`.\n */\n requires_billing_country?: boolean;\n /** `true` when the tile is only offered inside an iframe. Wallet rail only. */\n embedded_only?: boolean;\n /**\n * How the embedded checkout opens this tile's focused view. Absent on\n * payloads from older backends — treat as `tab`.\n */\n open_in?: NativePaneOpenTarget;\n}\n\n// --- Catalog ------------------------------------------------------------\n\n/**\n * Methods that may be promoted to a native pane.\n *\n * **The router owns this list** — `core::payment_link::native_panes::CATALOG` in\n * delopay-backend. This is a mirror so SDK consumers can validate or offer the\n * promotable methods without a round-trip; keep it in sync when the router's\n * catalog changes (the control-center keeps its own copy in\n * `native-panes.model.ts`). Drift is safe in one direction only: the backend\n * silently drops a key it does not know, so a stale entry here produces a row\n * that never renders rather than a broken checkout.\n */\nexport interface NativePaneMethodInfo {\n key: string;\n rail: NativePaneRail;\n /** Catalog default label, shown as the editor's placeholder. */\n defaultLabel: string;\n /** Catalog default sub-text. */\n defaultSublabel: string;\n /** Catalog default section. */\n defaultCategory: string;\n /** Catalog default icon key. */\n defaultIcon: string;\n}\n\nexport const STRIPE_NATIVE_PANE_METHODS: readonly NativePaneMethodInfo[] = [\n {\n key: 'apple_pay',\n rail: 'wallet',\n defaultLabel: 'Apple Pay',\n defaultSublabel: 'Pay with Apple Pay',\n defaultCategory: 'wallet',\n defaultIcon: 'apple',\n },\n {\n key: 'google_pay',\n rail: 'wallet',\n defaultLabel: 'Google Pay',\n defaultSublabel: 'Pay with Google Pay',\n defaultCategory: 'wallet',\n defaultIcon: 'google',\n },\n {\n key: 'link',\n rail: 'wallet',\n defaultLabel: 'Link',\n defaultSublabel: 'Pay with saved details',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n {\n key: 'klarna',\n rail: 'redirect',\n defaultLabel: 'Klarna',\n defaultSublabel: 'Pay later or in instalments',\n defaultCategory: 'bnpl',\n defaultIcon: 'bnpl',\n },\n {\n key: 'affirm',\n rail: 'redirect',\n defaultLabel: 'Affirm',\n defaultSublabel: 'Pay over time',\n defaultCategory: 'bnpl',\n defaultIcon: 'bnpl',\n },\n {\n key: 'ideal',\n rail: 'redirect',\n defaultLabel: 'iDEAL',\n defaultSublabel: 'Pay from your bank',\n defaultCategory: 'bank_redirect',\n defaultIcon: 'bank',\n },\n // eps / p24 / bancontact were removed from the router catalog: Stripe\n // hard-requires billing fields the focused checkout never collects (full\n // name for EPS/Bancontact, email for Przelewy24), so their tiles could\n // never succeed. They may return behind billing-aware gating.\n {\n key: 'alipay',\n rail: 'redirect',\n defaultLabel: 'Alipay',\n defaultSublabel: 'Pay with Alipay',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n {\n key: 'revolut_pay',\n rail: 'redirect',\n defaultLabel: 'Revolut Pay',\n defaultSublabel: 'Pay with Revolut',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n {\n key: 'amazon_pay',\n rail: 'redirect',\n defaultLabel: 'Amazon Pay',\n defaultSublabel: 'Pay with Amazon',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n];\n\n/** Built-in tile icon keys the buyer-facing checkout ships a glyph for. */\nexport const NATIVE_PANE_ICON_KEYS: readonly string[] = [\n 'wallet',\n 'card',\n 'bank',\n 'apple',\n 'google',\n 'bnpl',\n 'cash',\n];\n\n/** Section keys the checkout knows a translated header for. */\nexport const NATIVE_PANE_CATEGORY_KEYS: readonly string[] = [\n 'wallet',\n 'card',\n 'bnpl',\n 'bank_redirect',\n 'bank_transfer',\n 'cash',\n];\n\n/**\n * Mirror of the router's per-connector cap. Counted differently on each side:\n * {@link decodeNativePanes} stops after 12 *decoded* rows (entries with a\n * usable, non-duplicate `method` — junk and duplicate entries don't consume a\n * slot), while the router caps *accepted* panes (enabled, known,\n * deduplicated) at 12 — so an oversized hand-written blob may render a pane\n * this decoder drops. Blobs the SDK itself encodes never exceed the cap.\n */\nexport const NATIVE_PANES_MAX = 12;\n\nexport function nativePaneMethodInfo(method: string): NativePaneMethodInfo | undefined {\n return STRIPE_NATIVE_PANE_METHODS.find((m) => m.key === method);\n}\n\n// --- Codec --------------------------------------------------------------\n\nexport function defaultNativePane(method: string): StripeNativePane {\n const info = nativePaneMethodInfo(method);\n return {\n method,\n enabled: true,\n label: '',\n labelTranslations: {},\n sublabel: null,\n sublabelTranslations: {},\n category: '',\n icon: info?.defaultIcon ?? '',\n iconSvg: '',\n displayOrder: 0,\n visibility: 'always',\n openIn: 'tab',\n };\n}\n\nexport function cloneNativePane(pane: StripeNativePane): StripeNativePane {\n return {\n ...pane,\n labelTranslations: { ...pane.labelTranslations },\n sublabelTranslations: { ...pane.sublabelTranslations },\n };\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction parseTranslations(raw: unknown): Record<string, string> {\n if (!isObject(raw)) return {};\n const out: Record<string, string> = {};\n for (const [locale, value] of Object.entries(raw)) {\n if (typeof value === 'string' && value.length > 0) out[locale] = value;\n }\n return out;\n}\n\nfunction str(raw: unknown): string {\n return typeof raw === 'string' ? raw : '';\n}\n\n// The router's wire type is an `i32` (`api_models` `display_order`), and a\n// fractional or out-of-range value fails its strict row decode — dropping the\n// whole row server-side while an SDK round-trip would keep the blob looking\n// healthy. Clamped on BOTH decode and encode so this codec never emits a\n// value the router rejects, regardless of where the number came from.\nconst DISPLAY_ORDER_MIN = -2147483648;\nconst DISPLAY_ORDER_MAX = 2147483647;\n\nfunction clampDisplayOrder(raw: number): number {\n if (!Number.isFinite(raw)) return 0;\n return Math.min(DISPLAY_ORDER_MAX, Math.max(DISPLAY_ORDER_MIN, Math.trunc(raw)));\n}\n\n/**\n * Decode the stored `metadata.native_panes` blob into editor rows.\n *\n * Tolerant like the branding codecs: anything malformed falls back per\n * property, rows without a usable `method` are dropped, duplicates keep the\n * first occurrence — except that an enabled row wins over an earlier disabled\n * one for the same method, because that is the row the router renders — and\n * decoding stops after {@link NATIVE_PANES_MAX} decoded\n * rows (dropped junk/duplicate entries don't consume a slot). That is more\n * forgiving than the router, which drops a strict-decode-failing row whole\n * (keeping the rest) and caps accepted panes rather than decoded rows — see\n * {@link StripeNativePane} and {@link NATIVE_PANES_MAX}. Returns `null` when\n * the input is not an array so the caller can distinguish \"never configured\"\n * from \"cleared\".\n */\nexport function decodeNativePanes(raw: unknown): StripeNativePane[] | null {\n if (!Array.isArray(raw)) return null;\n const decodeRow = (entry: Record<string, unknown>, method: string): StripeNativePane => ({\n method,\n enabled: entry['enabled'] !== false,\n label: str(entry['label']),\n labelTranslations: parseTranslations(entry['label_translations']),\n sublabel: typeof entry['sublabel'] === 'string' ? entry['sublabel'] : null,\n sublabelTranslations: parseTranslations(entry['sublabel_translations']),\n category: str(entry['category']),\n icon: str(entry['icon']),\n iconSvg: str(entry['icon_svg']),\n displayOrder: clampDisplayOrder(Number(entry['display_order'])),\n // Anything unrecognised degrades to `always` rather than dropping the row.\n visibility: entry['visibility'] === 'embedded_only' ? 'embedded_only' : 'always',\n // Same tolerance: an unknown value degrades to the default `tab`.\n openIn: entry['open_in'] === 'popup' ? 'popup' : 'tab',\n });\n\n const indexByMethod = new Map<string, number>();\n const out: StripeNativePane[] = [];\n for (const entry of raw) {\n if (out.length >= NATIVE_PANES_MAX) break;\n if (!isObject(entry)) continue;\n const method = str(entry['method']).trim();\n if (!method) continue;\n const kept = indexByMethod.get(method);\n if (kept !== undefined) {\n // Duplicate method. Keep the row the ROUTER would render: it skips\n // disabled rows BEFORE deduping (`native_panes.rs`), so where a blob\n // holds both a disabled and an enabled row for one method, buyers see\n // the enabled one. Keeping the disabled row here would show the merchant\n // a pane that is off while it is live, and persist that on the next save.\n const enabled = entry['enabled'] !== false;\n const existing = out[kept];\n if (enabled && existing && !existing.enabled) out[kept] = decodeRow(entry, method);\n continue;\n }\n indexByMethod.set(method, out.length);\n out.push(decodeRow(entry, method));\n }\n return out;\n}\n\n/**\n * Encode editor rows back into the snake_case blob the connector account\n * stores. Empty optional strings are omitted so the metadata stays small and a\n * merchant who typed nothing round-trips as \"use the catalog default\" rather\n * than as an explicit empty override.\n *\n * `sublabel` is the exception: an explicitly-empty value is preserved (as `\"\"`)\n * because that is how a merchant hides the second line.\n */\nexport function encodeNativePanes(panes: StripeNativePane[]): Record<string, unknown>[] {\n const nonEmpty = (map: Record<string, string>): Record<string, string> | undefined => {\n const entries = Object.entries(map).filter(([, v]) => v.trim().length > 0);\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n };\n return panes.slice(0, NATIVE_PANES_MAX).map((pane) => {\n const labelTranslations = nonEmpty(pane.labelTranslations);\n const sublabelTranslations = nonEmpty(pane.sublabelTranslations);\n return {\n method: pane.method,\n enabled: pane.enabled,\n ...(pane.label.trim() ? { label: pane.label.trim() } : {}),\n ...(labelTranslations ? { label_translations: labelTranslations } : {}),\n // `null` omits the key entirely (catalog default wins); `''` is sent\n // as-is because that is how the merchant hides the second line.\n ...(pane.sublabel !== null ? { sublabel: pane.sublabel } : {}),\n ...(sublabelTranslations ? { sublabel_translations: sublabelTranslations } : {}),\n ...(pane.category.trim() ? { category: pane.category.trim() } : {}),\n ...(pane.icon.trim() ? { icon: pane.icon.trim() } : {}),\n ...(pane.iconSvg.trim() ? { icon_svg: pane.iconSvg.trim() } : {}),\n // Clamped on encode too, not only decode: the router's strict i32 row\n // decode drops a row whole for a fractional or out-of-range value, so\n // writing e.g. 3.5 or Date.now() verbatim would silently delete the\n // pane at render while every read surface shows it healthy.\n display_order: clampDisplayOrder(pane.displayOrder),\n visibility: pane.visibility,\n open_in: pane.openIn,\n };\n });\n}\n\n// --- Focused checkout URL ----------------------------------------------\n\nexport interface FocusedCheckoutUrlParams {\n /** Base URL of the DeloPay hosted checkout, e.g. `https://checkout.delopay.net`. */\n checkoutBaseUrl: string;\n merchantId: string;\n paymentId: string;\n /** Native-pane method key to focus on (`apple_pay`, `klarna`, …). */\n method: string;\n /** Optional buyer locale, forwarded as `?locale=`. */\n locale?: string;\n /**\n * Set when the merchant's checkout-custom-field answers are already\n * persisted on the payment — forwarded as `cf=1` so the focused view skips\n * asking a second time. Purely a UI hint: the values live on the intent\n * either way, and the backend only accepts the merchant's configured field\n * keys from a client, so a wrongly-set flag can at worst skip an\n * informational prompt. This is the same hint the embedded pane sets when\n * it opens the focused view.\n */\n customFieldsCollected?: boolean;\n}\n\n/**\n * Build the link to the **focused single-method checkout**: the DeloPay hosted\n * checkout rendered with one payment method, one button, no picker.\n *\n * Two callers:\n * - the embedded checkout, which opens this in a new tab when a buyer clicks\n * a native pane tile, and\n * - a merchant running their own checkout, who puts it behind their own\n * button — the same mechanism without an iframe.\n *\n * `method` is not limited to configured native panes. A configured Stripe\n * native pane gets the focused one-button view; `card`, `paypal`,\n * `crypto_currency` and the local-methods catalogs (by method key or vendor\n * code) open the checkout pinned to that method. Methods that exist only as a\n * tab inside Stripe's Payment Element — iDEAL, Bancontact, P24 and the like,\n * unless promoted to a native pane — cannot be isolated, because Stripe owns\n * that surface. An unknown or unavailable method is never a dead end: the\n * checkout shows a notice with a visible \"show all payment methods\" action.\n *\n * Open it **at the top level** (a new tab or a full-page navigation). The whole\n * point is that the top-level domain is the registered payment method domain;\n * rendering it in an iframe puts you back where you started.\n *\n * If you open it with `window.open`, call that **synchronously inside the click\n * handler** or the popup blocker will eat it, and make sure any iframe you\n * render DeloPay in permits popups (`allow-popups`, plus\n * `allow-popups-to-escape-sandbox` under a restrictive `sandbox`).\n */\nexport function focusedCheckoutUrl(params: FocusedCheckoutUrlParams): string {\n const base = params.checkoutBaseUrl.replace(/\\/+$/, '');\n const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(\n params.paymentId,\n )}`;\n const query = new URLSearchParams({ pane: params.method });\n if (params.locale) query.set('locale', params.locale);\n if (params.customFieldsCollected) query.set('cf', '1');\n return `${path}?${query.toString()}`;\n}\n\n// --- Buyer-side checkout events ----------------------------------------\n\n/**\n * The closed vocabulary of buyer-side checkout events recorded on the payment's\n * status timeline. Written through\n * `POST /payment-link/{merchant_id}/{payment_id}/checkout-events`, authorized\n * with the payment's `client_secret` as a bearer token.\n */\nexport const CHECKOUT_EVENT_KINDS = [\n 'native_pane_selected',\n 'native_pane_tab_opened',\n 'native_pane_tab_blocked',\n 'native_pane_abandoned',\n 'native_pane_returned',\n] as const;\n\nexport type CheckoutEventKind = (typeof CHECKOUT_EVENT_KINDS)[number];\n","import type { AuthResponse, SignUpWithMerchantIdRequest } from '../../types';\nimport type {\n AdminSignInRequest,\n AuthorizeResponse,\n CreateInternalUserRequest,\n CreateTenantUserRequest,\n OnboardMerchantRequest,\n OnboardMerchantResponse,\n SignupToggleRequest,\n SignupToggleResponse,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class Admin {\n constructor(private readonly request: RequestFn) {}\n\n async signIn(params: AdminSignInRequest): Promise<AuthResponse> {\n return this.request('POST', '/admin/signin', { body: params });\n }\n\n async createInternalUser(params: CreateInternalUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/internal-signup', { body: params });\n }\n\n async createTenant(params: CreateTenantUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/tenant-signup', { body: params });\n }\n\n /**\n * Create a new merchant admin user and merchant account atomically.\n *\n * This is the correct endpoint for bootstrapping the first admin user in a\n * fresh deployment — `internal-signup`/`tenant-signup` both require\n * pre-existing merchant records that don't exist on a clean database.\n *\n * `POST /admin/signup-with-merchant-id`\n */\n async signupWithMerchantId(params: SignUpWithMerchantIdRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/signup-with-merchant-id', { body: params });\n }\n\n /** Toggle public signup on/off. `POST /admin/settings/signup` */\n async setSignupSettings(params: SignupToggleRequest): Promise<SignupToggleResponse> {\n return this.request('POST', '/admin/settings/signup', { body: params });\n }\n\n /** Read current public-signup status. `GET /admin/settings/signup` */\n async getSignupSettings(): Promise<SignupToggleResponse> {\n return this.request('GET', '/admin/settings/signup');\n }\n\n /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard-merchant` */\n async onboardMerchant(params: OnboardMerchantRequest): Promise<OnboardMerchantResponse> {\n return this.request('POST', '/admin/onboard-merchant', { body: params });\n }\n}\n","import type {\n FeeStatementDetail,\n MerchantAccountResponse,\n MerchantAccountUpdateRequest,\n PaymentAttemptsListResponse,\n PaymentClientContextListResponse,\n PaymentResponse,\n PaymentsDeleteResponse,\n PaymentStatusHistoryResponse,\n ProfileResponse,\n RefundListResponse,\n SettlementCurrentParams,\n SettlementCurrentResponse,\n SettlementOverviewParams,\n SettlementOverviewResponse,\n SettlementStatementListParams,\n SettlementStatementListResponse,\n StatementPdfParams,\n} from '../../types';\nimport type {\n AdminAttachVaultRequest,\n AdminAttachVaultResponse,\n AdminVaultStateResponse,\n AdminCustomerListParams,\n AdminCustomerListResponse,\n AdminCustomerDetail,\n AdminTransactionListParams,\n AdminTransactionListResponse,\n AdminAnalyticsRequest,\n PlatformAnalyticsResponse,\n OverviewStatsResponse,\n PaymentAnalyticsRequest,\n PaymentAnalyticsResponse,\n AnalyticsScopeRequest,\n ClientAnalyticsRequest,\n DeviceDrillRequest,\n GeoDrillRequest,\n DrillResponse,\n DevicesAnalyticsResponse,\n GeoAnalyticsResponse,\n AnalyticsScopeResponse,\n AdminLedgerAnalyticsRequest,\n AdminLedgerAnalyticsResponse,\n AdminCreateUserForMerchantRequest,\n AdminUpdateUserRequest,\n AdminUserResponse,\n PaymentAutoCloseConfigResponse,\n PaymentAutoCloseOverrideResponse,\n PromoConfigResponse,\n TransactionDeleteConfigResponse,\n TransactionDeleteOverrideResponse,\n UpdatePaymentAutoCloseConfigRequest,\n UpdatePaymentAutoCloseOverrideRequest,\n UpdatePromoConfigRequest,\n UpdateTransactionDeleteConfigRequest,\n UpdateTransactionDeleteOverrideRequest,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class AdminPortal {\n constructor(private readonly request: RequestFn) {}\n\n async listCustomers(params?: AdminCustomerListParams): Promise<AdminCustomerListResponse> {\n return this.request('GET', '/admin-portal/customers', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n async getCustomer(customerId: string): Promise<AdminCustomerDetail> {\n return this.request('GET', `/admin-portal/customers/${encodeURIComponent(customerId)}`);\n }\n\n async listTransactions(\n params?: AdminTransactionListParams,\n ): Promise<AdminTransactionListResponse> {\n return this.request('GET', '/admin-portal/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Full detail for a single transaction of ANY merchant — the same\n * `PaymentResponse` the merchant `payments.retrieve` returns. Admin-scoped:\n * the JWT (or admin API key) does not need to belong to the payment's\n * merchant; the backend resolves the owning merchant and reads it read-only\n * (no connector sync).\n */\n async getTransaction(paymentId: string): Promise<PaymentResponse> {\n return this.request('GET', `/admin-portal/transactions/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * Per-attempt history (retries across connectors, decline reasons) for a\n * single transaction of ANY merchant.\n */\n async getTransactionAttempts(paymentId: string): Promise<PaymentAttemptsListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/attempts`,\n );\n }\n\n /**\n * Status timeline (intent / attempt / refund / dispute transitions) for a\n * single transaction of ANY merchant. `complete: false` marks timelines\n * partially reconstructed from current records.\n */\n async getTransactionStatusHistory(paymentId: string): Promise<PaymentStatusHistoryResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/status-history`,\n );\n }\n\n /**\n * Refunds for a single transaction of ANY merchant.\n */\n async getTransactionRefunds(paymentId: string): Promise<RefundListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/refunds`,\n );\n }\n\n async analytics(params: AdminAnalyticsRequest): Promise<PlatformAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n async overviewStats(): Promise<OverviewStatsResponse> {\n return this.request('GET', '/admin-portal/overview-stats');\n }\n\n async paymentAnalytics(params: PaymentAnalyticsRequest): Promise<PaymentAnalyticsResponse> {\n return this.request('GET', '/admin-portal/payment-analytics', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * One drill level of the analytics dashboard: the scope's daily series +\n * processor mix and its direct children's series. Range / metric / donut\n * toggles apply client-side; only a drill (passing merchant_id / project_id\n * / shop_id) fetches the next level.\n */\n async analyticsScope(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/admin-portal/analytics/scope', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Device analytics over the canonical client-context observation per\n * payment, rooted at all merchants and drillable via `merchant_id` /\n * `project_id` / `shop_id` like `analyticsScope`. Answers 200 with\n * `enabled: false` when the client-context optimisation-use switch is off.\n */\n async analyticsDevices(params?: ClientAnalyticsRequest): Promise<DevicesAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics/devices', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Geo analytics over the canonical client-context observation per payment,\n * rooted at all merchants. `mode` selects the location claim (`ip` default,\n * `billing`).\n */\n async analyticsGeo(params?: ClientAnalyticsRequest): Promise<GeoAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics/geo', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked geo target (map country/city or\n * local-hours heatmap cell), rooted at all merchants. Capped at 50 rows,\n * newest first, with the full match count alongside.\n */\n async analyticsGeoTransactions(params: GeoDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/admin-portal/analytics/geo/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked device target (browser/platform\n * family, device-model label or device class), rooted at all merchants.\n * 50 rows per page (`offset` for the next page), newest first.\n */\n async analyticsDeviceTransactions(params: DeviceDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/admin-portal/analytics/devices/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Platform billing dashboard: total balance across all ledger accounts (+\n * the net change), top-ups, fees collected, and the day-by-day ledger flow.\n * All amounts are in USD minor units.\n */\n async ledgerAnalytics(\n params?: AdminLedgerAnalyticsRequest,\n ): Promise<AdminLedgerAnalyticsResponse> {\n return this.request('GET', '/admin-portal/ledger-analytics', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Retrieve a merchant account via the admin portal. Unlike\n * `merchantAccounts.retrieve`, this route accepts an admin JWT (or admin API\n * key) and does not require the JWT to be scoped to the target merchant.\n */\n async retrieveAccount(merchantId: string): Promise<MerchantAccountResponse> {\n return this.request('GET', `/admin-portal/accounts/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Update a merchant account via the admin portal. Authenticated via admin JWT\n * or admin API key.\n */\n async updateAccount(\n merchantId: string,\n params: MerchantAccountUpdateRequest,\n ): Promise<MerchantAccountResponse> {\n return this.request('POST', `/admin-portal/accounts/${encodeURIComponent(merchantId)}`, {\n body: params,\n });\n }\n\n /**\n * Delete a merchant account via the admin portal. Authenticated via admin JWT\n * or admin API key.\n */\n async deleteAccount(merchantId: string): Promise<MerchantAccountResponse> {\n return this.request('DELETE', `/admin-portal/accounts/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Create a brand-new user attached to the given merchant. The user is\n * marked `is_verified = true` so the admin can hand off credentials\n * immediately — no email round-trip is sent.\n */\n async createUserForMerchant(\n customerId: string,\n body: AdminCreateUserForMerchantRequest,\n ): Promise<AdminUserResponse> {\n return this.request('POST', `/admin-portal/customers/${encodeURIComponent(customerId)}/users`, {\n body,\n });\n }\n\n /**\n * Edit a user record. Any subset of fields may be supplied. `role_id`\n * requires `merchant_id`. `password` triggers a password reset (validated\n * against signup policy + JWT blacklist). `reset_2fa` clears TOTP state\n * so the user re-enrolls on next login. `is_active` supports both\n * directions: false soft-disables, true reactivates a soft-disabled user.\n */\n async updateUser(userId: string, body: AdminUpdateUserRequest): Promise<AdminUserResponse> {\n return this.request('PATCH', `/admin-portal/users/${encodeURIComponent(userId)}`, { body });\n }\n\n /**\n * Soft-delete a user globally: deactivates the row, blacklists existing\n * JWTs, and wipes credentials. Distinct from `deleteUserRole`, which\n * removes a single role binding while leaving the user signed-in elsewhere.\n */\n async deleteUser(userId: string): Promise<void> {\n return this.request('DELETE', `/admin-portal/users/${encodeURIComponent(userId)}`);\n }\n\n /**\n * Set a target merchant's shop iframe-allowed origins. Internal-admin\n * route — accepts an admin JWT or admin API key without requiring the\n * caller to be scoped to the target merchant. Pass `null` (or an empty\n * array) to clear the allowlist back to same-origin only.\n *\n * Server validates each origin: full origin (scheme + host[:port]),\n * no path/query/fragment, no wildcards.\n */\n async updateShopIframeOrigins(\n merchantId: string,\n profileId: string,\n origins: string[] | null,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/business_profile/${encodeURIComponent(profileId)}/iframe-origins`,\n { body: { iframe_allowed_origins: origins } },\n );\n }\n\n /**\n * Set (or clear) a target merchant shop's home country — the geo\n * dashboard's cross-border baseline. Internal-admin route. Pass `null` to\n * clear back to \"international / no home country\" (the default).\n *\n * `POST /admin-portal/accounts/{merchantId}/business-profile/{profileId}/home-country`\n */\n async updateShopHomeCountry(\n merchantId: string,\n profileId: string,\n homeCountry: string | null,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/business-profile/${encodeURIComponent(profileId)}/home-country`,\n { body: { home_country: homeCountry } },\n );\n }\n\n /**\n * Soft-delete a transaction of ANY merchant. Only payments whose status\n * is in the admin delete policy can be deleted; the action is audited.\n *\n * `DELETE /admin-portal/transactions/{paymentId}`\n */\n async deleteTransaction(paymentId: string): Promise<PaymentsDeleteResponse> {\n return this.request('DELETE', `/admin-portal/transactions/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * Recover (undelete) a soft-deleted transaction. Audited.\n *\n * `POST /admin-portal/transactions/{paymentId}/recover`\n */\n async recoverTransaction(paymentId: string): Promise<PaymentsDeleteResponse> {\n return this.request(\n 'POST',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/recover`,\n );\n }\n\n /**\n * Client/device observations captured while the buyer interacted with a\n * transaction of ANY merchant, oldest first.\n *\n * `GET /admin-portal/transactions/{paymentId}/client-context`\n */\n async getTransactionClientContext(paymentId: string): Promise<PaymentClientContextListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/client-context`,\n );\n }\n\n /**\n * The global payment auto-close policy.\n * `GET /admin-portal/auto-close-config`\n */\n async getAutoCloseConfig(): Promise<PaymentAutoCloseConfigResponse> {\n return this.request('GET', '/admin-portal/auto-close-config');\n }\n\n /**\n * Update the global payment auto-close policy. PATCH semantics — omitted\n * fields are left unchanged.\n *\n * `PUT /admin-portal/auto-close-config`\n */\n async updateAutoCloseConfig(\n params: UpdatePaymentAutoCloseConfigRequest,\n ): Promise<PaymentAutoCloseConfigResponse> {\n return this.request('PUT', '/admin-portal/auto-close-config', { body: params });\n }\n\n /**\n * One merchant's auto-close override plus the effective values.\n * `GET /admin-portal/accounts/{merchantId}/auto-close-config`\n */\n async getMerchantAutoCloseConfig(merchantId: string): Promise<PaymentAutoCloseOverrideResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/auto-close-config`,\n );\n }\n\n /**\n * Replace one merchant's auto-close override. REPLACE semantics — sending\n * both fields as `null` removes the override entirely.\n *\n * `PUT /admin-portal/accounts/{merchantId}/auto-close-config`\n */\n async updateMerchantAutoCloseConfig(\n merchantId: string,\n params: UpdatePaymentAutoCloseOverrideRequest,\n ): Promise<PaymentAutoCloseOverrideResponse> {\n return this.request(\n 'PUT',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/auto-close-config`,\n { body: params },\n );\n }\n\n /**\n * The global transaction soft-delete policy (statuses admins may delete,\n * plus the deploy-time env ceiling).\n *\n * `GET /admin-portal/transaction-delete-config`\n */\n async getTransactionDeleteConfig(): Promise<TransactionDeleteConfigResponse> {\n return this.request('GET', '/admin-portal/transaction-delete-config');\n }\n\n /**\n * Replace the global deletable-status set. Must be a subset of the env\n * ceiling.\n *\n * `PUT /admin-portal/transaction-delete-config`\n */\n async updateTransactionDeleteConfig(\n params: UpdateTransactionDeleteConfigRequest,\n ): Promise<TransactionDeleteConfigResponse> {\n return this.request('PUT', '/admin-portal/transaction-delete-config', { body: params });\n }\n\n /**\n * One merchant's deletable-status override plus the effective set.\n * `GET /admin-portal/accounts/{merchantId}/transaction-delete-config`\n */\n async getMerchantTransactionDeleteConfig(\n merchantId: string,\n ): Promise<TransactionDeleteOverrideResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/transaction-delete-config`,\n );\n }\n\n /**\n * Replace one merchant's deletable-status override. `statuses: null`\n * removes the override; an empty list forbids deletion entirely.\n *\n * `PUT /admin-portal/accounts/{merchantId}/transaction-delete-config`\n */\n async updateMerchantTransactionDeleteConfig(\n merchantId: string,\n params: UpdateTransactionDeleteOverrideRequest,\n ): Promise<TransactionDeleteOverrideResponse> {\n return this.request(\n 'PUT',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/transaction-delete-config`,\n { body: params },\n );\n }\n\n /**\n * A merchant's settlement statements. Same shapes as the merchant-facing\n * `settlement` resource, admin-authenticated.\n *\n * `GET /admin-portal/accounts/{merchantId}/settlement/statements`\n */\n async listSettlementStatements(\n merchantId: string,\n params: SettlementStatementListParams,\n ): Promise<SettlementStatementListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/statements`,\n {\n query: {\n test_mode: params.test_mode,\n profile_id: params.profile_id,\n limit: params.limit,\n offset: params.offset,\n },\n },\n );\n }\n\n /**\n * One settlement statement with its breakdown.\n * `GET /admin-portal/accounts/{merchantId}/settlement/statements/{statementId}`\n */\n async getSettlementStatement(\n merchantId: string,\n statementId: string,\n ): Promise<FeeStatementDetail> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/statements/${encodeURIComponent(statementId)}`,\n );\n }\n\n /**\n * Export a settlement statement as PDF. Returns the raw bytes as a `Blob`\n * with the same auth and error handling as every other call.\n *\n * `GET /admin-portal/accounts/{merchantId}/settlement/statements/{statementId}/pdf`\n */\n async downloadSettlementStatementPdf(\n merchantId: string,\n statementId: string,\n params?: StatementPdfParams,\n ): Promise<Blob> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/statements/${encodeURIComponent(statementId)}/pdf`,\n {\n query: {\n currency: params?.currency,\n include_transactions: params?.include_transactions,\n },\n responseType: 'blob',\n },\n );\n }\n\n /**\n * A merchant's per-shop settlement overview.\n * `GET /admin-portal/accounts/{merchantId}/settlement/overview`\n */\n async settlementOverview(\n merchantId: string,\n params: SettlementOverviewParams,\n ): Promise<SettlementOverviewResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/overview`,\n { query: { test_mode: params.test_mode } },\n );\n }\n\n /**\n * A merchant's live current-period settlement rollup.\n * `GET /admin-portal/accounts/{merchantId}/settlement/current`\n */\n async settlementCurrent(\n merchantId: string,\n params: SettlementCurrentParams,\n ): Promise<SettlementCurrentResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/current`,\n { query: { test_mode: params.test_mode, profile_id: params.profile_id } },\n );\n }\n\n /**\n * A merchant's vault state: the attach entitlement, and the vault\n * configuration of every shop.\n *\n * `GET /admin-portal/accounts/{merchantId}/vault`\n */\n async getVaultState(merchantId: string): Promise<AdminVaultStateResponse> {\n return this.request('GET', `/admin-portal/accounts/${encodeURIComponent(merchantId)}/vault`);\n }\n\n /**\n * Attach a vault to one of a merchant's shops — creates the vault\n * connector account and points the profile at it in one request. The\n * Collect credentials are verified write-only before anything is stored.\n *\n * `POST /admin-portal/accounts/{merchantId}/vault/attach`\n */\n async attachVault(\n merchantId: string,\n params: AdminAttachVaultRequest,\n ): Promise<AdminAttachVaultResponse> {\n return this.request(\n 'POST',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/vault/attach`,\n { body: params },\n );\n }\n\n /**\n * Fetch the global welcome promotional-credit config (amount + message)\n * granted to newly created billing profiles. Internal-admin route.\n */\n async getPromoConfig(): Promise<PromoConfigResponse> {\n return this.request('GET', '/admin-portal/promo-config');\n }\n\n /**\n * Update the global welcome promotional-credit config. Any subset of\n * `amount` (minor units) / `message` may be supplied; omitted fields are\n * left unchanged. Returns the resulting config. Internal-admin route.\n */\n async updatePromoConfig(params: UpdatePromoConfigRequest): Promise<PromoConfigResponse> {\n return this.request('PUT', '/admin-portal/promo-config', { body: params });\n }\n}\n","import type { AuditLogListParams, AuditLogListResponse, AuditLogResponse } from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class AuditLogs {\n constructor(private readonly request: RequestFn) {}\n\n async list(params?: AuditLogListParams): Promise<AuditLogListResponse> {\n return this.request('GET', '/admin-portal/audit', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n async retrieve(logId: string): Promise<AuditLogResponse> {\n return this.request('GET', `/admin-portal/audit/${encodeURIComponent(logId)}`);\n }\n}\n","import type { RequestFn } from '../../client';\n\nexport class Cache {\n constructor(private readonly request: RequestFn) {}\n\n /** Invalidate a cache entry by key. `POST /cache/invalidate/{key}` */\n async invalidate(key: string): Promise<Record<string, unknown>> {\n return this.request('POST', `/cache/invalidate/${encodeURIComponent(key)}`);\n }\n}\n","import type {\n CardIssuerCreateRequest,\n CardIssuerResponse,\n CardIssuerUpdateRequest,\n CardIssuerListResponse,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class CardIssuers {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: CardIssuerCreateRequest): Promise<CardIssuerResponse> {\n return this.request('POST', '/card-issuers', { body: params });\n }\n\n async update(issuerId: string, params: CardIssuerUpdateRequest): Promise<CardIssuerResponse> {\n return this.request('PUT', `/card-issuers/${encodeURIComponent(issuerId)}`, { body: params });\n }\n\n async list(): Promise<CardIssuerListResponse> {\n return this.request('GET', '/card-issuers');\n }\n}\n","import type { RequestFn } from '../../client';\n\nexport class Configs {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a config. `POST /configs` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/configs', { body: params });\n }\n\n /** Retrieve a config by key. `GET /configs/{key}` */\n async retrieve(key: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/configs/${encodeURIComponent(key)}`);\n }\n\n /** Update a config. `PUT /configs/{key}` */\n async update(key: string, params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', `/configs/${encodeURIComponent(key)}`, { body: params });\n }\n\n /** Delete a config. `DELETE /configs/{key}` */\n async delete(key: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/configs/${encodeURIComponent(key)}`);\n }\n}\n","import type {\n ConnectorRestrictionRuleResponse,\n CreateConnectorRestrictionRuleRequest,\n ListConnectorRestrictionRulesQuery,\n UpdateConnectorRestrictionRuleRequest,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nconst BASE = '/admin/connector-restriction-rules';\n\n/**\n * Per-shop / per-project connector restriction rules.\n *\n * Distinct from `connectorRestrictions` (the merchant-tier attach gate):\n * these rules allow/deny a connector for one shop (`scope: 'profile'`) or\n * project (`scope: 'project'`) at routing time. A `deny` is never routed even\n * when the connector is attached and enabled; once a scope has any `allow` it\n * becomes a whitelist, and the project scope takes precedence over the shop\n * scope. Admin-only, under `/admin/connector-restriction-rules`; exposed only\n * via `'@delopay/sdk/internal'`.\n */\nexport class ConnectorRestrictionRules {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create one allow/deny rule. A duplicate\n * `(merchant_id, scope, scope_id, connector)` is rejected — update or delete\n * the existing rule instead.\n */\n async create(\n body: CreateConnectorRestrictionRuleRequest,\n ): Promise<ConnectorRestrictionRuleResponse> {\n return this.request('POST', BASE, { body });\n }\n\n /**\n * List rules for one scope (`scope` + `scope_id`) or a whole merchant\n * (`merchant_id`). Pass exactly one selector.\n */\n async list(\n query: ListConnectorRestrictionRulesQuery,\n ): Promise<ConnectorRestrictionRuleResponse[]> {\n // Spread into a fresh object literal so the typed query satisfies the\n // request layer's `Record<string, …>` index signature. `undefined` values\n // are dropped by `request()`.\n return this.request('GET', BASE, { query: { ...query } });\n }\n\n /** Retrieve a single rule by ID. */\n async retrieve(id: string): Promise<ConnectorRestrictionRuleResponse> {\n return this.request('GET', `${BASE}/${encodeURIComponent(id)}`);\n }\n\n /** Update a rule's action and/or reason. */\n async update(\n id: string,\n body: UpdateConnectorRestrictionRuleRequest,\n ): Promise<ConnectorRestrictionRuleResponse> {\n return this.request('PATCH', `${BASE}/${encodeURIComponent(id)}`, { body });\n }\n\n /** Delete a rule by ID. */\n async delete(id: string): Promise<{ id: string; deleted: boolean }> {\n return this.request('DELETE', `${BASE}/${encodeURIComponent(id)}`);\n }\n}\n","import type { ConnectorRestrictionResponse, UpsertConnectorRestrictionRequest } from '../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Admin-only allowlist for phased connector rollouts.\n *\n * Default-open semantics: a connector with no restriction row is\n * usable by every merchant (current behavior). A connector with a\n * row is gated — only merchants in `allowed_merchant_ids` can attach\n * a connector account. Enforced server-side at MCA-create time.\n */\nexport class ConnectorRestrictions {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Idempotent upsert. If a row exists for `connector_name`, its\n * allowlist + reason are replaced. To open the connector to\n * everyone again, call `delete()`.\n */\n async upsert(body: UpsertConnectorRestrictionRequest): Promise<ConnectorRestrictionResponse> {\n return this.request('POST', '/admin/connector-restrictions', { body });\n }\n\n async list(): Promise<ConnectorRestrictionResponse[]> {\n return this.request('GET', '/admin/connector-restrictions');\n }\n\n async retrieve(connectorName: string): Promise<ConnectorRestrictionResponse> {\n return this.request(\n 'GET',\n `/admin/connector-restrictions/${encodeURIComponent(connectorName)}`,\n );\n }\n\n /** Removing the row makes the connector public again. */\n async delete(connectorName: string): Promise<{ connector_name: string; deleted: boolean }> {\n return this.request(\n 'DELETE',\n `/admin/connector-restrictions/${encodeURIComponent(connectorName)}`,\n );\n }\n}\n","import type { GsmRuleCreateRequest, GsmRuleResponse, GsmRuleUpdateRequest } from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class Gsm {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: GsmRuleCreateRequest): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm', { body: params });\n }\n\n async retrieve(params: Record<string, unknown>): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm/get', { body: params });\n }\n\n async update(params: GsmRuleUpdateRequest): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm/update', { body: params });\n }\n\n async delete(params: Record<string, unknown>): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm/delete', { body: params });\n }\n}\n","import type {\n AdminAdjustmentRequest,\n AdminAdjustmentResponse,\n AdminSuspendRequest,\n AdminUnsuspendRequest,\n AdminSetTrustedRequest,\n UpdateLedgerEntryRequest,\n} from '../types';\nimport type { BillingProfileResponse } from '../../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Platform-level ledger adjustments on a merchant's balance. Admin-only\n * routes under `/billing/{merchantId}/admin/credit|debit`. Exposed only\n * via `'@delopay/sdk/internal'` so the public merchant SDK doesn't\n * advertise the admin adjustment path in autocomplete.\n */\nexport class PlatformBilling {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Manually credit a merchant's balance (e.g. promotional credit,\n * dispute reversal, manual correction).\n *\n * @param merchantId - The merchant account ID.\n * @param params - Credit amount and reason.\n */\n async credit(\n merchantId: string,\n params: AdminAdjustmentRequest,\n ): Promise<AdminAdjustmentResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/credit`, {\n body: params,\n });\n }\n\n /**\n * Manually debit a merchant's balance.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Debit amount and reason.\n */\n async debit(\n merchantId: string,\n params: AdminAdjustmentRequest,\n ): Promise<AdminAdjustmentResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/debit`, {\n body: params,\n });\n }\n\n /**\n * Edit a single ledger entry (amount and/or description), keeping the\n * merchant balance consistent: when `amount` changes, the balance is\n * atomically adjusted by the difference. Returns the entry id and new\n * balance.\n *\n * @param merchantId - The merchant account ID.\n * @param ledgerId - The ledger entry id to edit.\n * @param params - New amount / description (either optional).\n */\n async editLedgerEntry(\n merchantId: string,\n ledgerId: string,\n params: UpdateLedgerEntryRequest,\n ): Promise<AdminAdjustmentResponse> {\n return this.request(\n 'PATCH',\n `/billing/${encodeURIComponent(merchantId)}/admin/ledger/${encodeURIComponent(ledgerId)}`,\n { body: params },\n );\n }\n\n /**\n * Delete a single ledger entry, reversing its amount from the merchant\n * balance. Returns the deleted entry id and the new balance.\n *\n * @param merchantId - The merchant account ID.\n * @param ledgerId - The ledger entry id to delete.\n */\n async deleteLedgerEntry(merchantId: string, ledgerId: string): Promise<AdminAdjustmentResponse> {\n return this.request(\n 'DELETE',\n `/billing/${encodeURIComponent(merchantId)}/admin/ledger/${encodeURIComponent(ledgerId)}`,\n );\n }\n\n /**\n * Manually suspend a merchant (e.g. confirmed fraud or ToS violation),\n * independent of balance. A `reason` is required for audit. Throws 412 if\n * the merchant is trusted (clear the flag first) or already suspended.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Suspension reason.\n * @returns The updated billing profile.\n */\n async suspend(merchantId: string, params: AdminSuspendRequest): Promise<BillingProfileResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/suspend`, {\n body: params,\n });\n }\n\n /**\n * Lift a suspension. Restores the merchant to `active` (or `delinquent` if\n * the balance is at/below the hard floor) and resets the recharge-failure\n * counter. Throws 412 if the merchant is not suspended.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional audit note.\n * @returns The updated billing profile.\n */\n async unsuspend(\n merchantId: string,\n params: AdminUnsuspendRequest = {},\n ): Promise<BillingProfileResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/unsuspend`, {\n body: params,\n });\n }\n\n /**\n * Set or clear the trusted (suspension-exempt) flag. Trusted merchants\n * cannot be suspended automatically or manually. Does not lift an existing\n * suspension — use {@link PlatformBilling.unsuspend} for that.\n *\n * @param merchantId - The merchant account ID.\n * @param params - The desired trusted state.\n * @returns The updated billing profile.\n */\n async setTrusted(\n merchantId: string,\n params: AdminSetTrustedRequest,\n ): Promise<BillingProfileResponse> {\n return this.request('PATCH', `/billing/${encodeURIComponent(merchantId)}/admin/trusted`, {\n body: params,\n });\n }\n}\n","import type {\n FeeRulePreviewRequest,\n FeeRulePreviewResponse,\n FeeScheduleCreateRequest,\n FeeScheduleResponse,\n FeeScheduleUpdateRequest,\n PlatformFeeRuleInput,\n PlatformFeeRuleRecord,\n PlatformFeeRuleRequest,\n} from '../../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Platform-wide fee schedule management. Admin-only routes under\n * `/admin/fees/*`. Exposed only via `'@delopay/sdk/internal'`.\n *\n * `platformFees.rules` manages the platform-owned Euclid fee-rule program per\n * merchant, which takes precedence over the flat platform schedules. Build the\n * program with `feeProgram()`.\n */\nexport class PlatformFees {\n /** Platform-owned Euclid fee-rule program (`/admin/fees/rules`). */\n readonly rules: PlatformFeeRulesManager;\n\n constructor(private readonly request: RequestFn) {\n this.rules = new PlatformFeeRulesManager(request);\n }\n\n /** Create a platform fee schedule for a specific merchant. */\n async create(params: FeeScheduleCreateRequest, merchantId: string): Promise<FeeScheduleResponse> {\n return this.request('POST', '/admin/fees', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /** List every platform fee schedule assigned to a merchant. */\n async list(merchantId: string): Promise<FeeScheduleResponse[]> {\n return this.request('GET', '/admin/fees/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /** Retrieve a single platform fee schedule by ID. */\n async retrieve(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('GET', `/admin/fees/${encodeURIComponent(feeId)}`);\n }\n\n /** Update a platform fee schedule. */\n async update(feeId: string, params: FeeScheduleUpdateRequest): Promise<FeeScheduleResponse> {\n return this.request('PUT', `/admin/fees/${encodeURIComponent(feeId)}`, { body: params });\n }\n\n /** Delete a platform fee schedule. */\n async delete(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('DELETE', `/admin/fees/${encodeURIComponent(feeId)}`);\n }\n}\n\n/**\n * Manages a merchant's platform-owned Euclid fee-rule programs (admin surface),\n * merchant-wide or per-shop (one active program per scope; a shop-scoped\n * program wins for its shop, else the merchant-wide one applies). Build the\n * `algorithm` with `feeProgram()`. The SDK injects `fee_owner: 'platform'`; set\n * `profile_id` on the input to scope a program to a shop.\n */\nexport class PlatformFeeRulesManager {\n constructor(private readonly request: RequestFn) {}\n\n /** Create or replace the platform fee-rule program for a merchant. */\n async upsert(params: PlatformFeeRuleInput, merchantId: string): Promise<PlatformFeeRuleRecord> {\n const body: PlatformFeeRuleRequest = { ...params, fee_owner: 'platform' };\n return this.request('PUT', '/admin/fees/rules', {\n body,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve the active platform fee-rule program for a scope, or `null`.\n * `profileId` omitted = merchant-wide program; set = that shop's program.\n */\n async retrieve(merchantId: string, profileId?: string): Promise<PlatformFeeRuleRecord | null> {\n return this.request('GET', '/admin/fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Deactivate a platform fee-rule program. Idempotent. `profileId` omitted\n * targets the merchant-wide program; set targets only that shop's program.\n */\n async delete(merchantId: string, profileId?: string): Promise<void> {\n await this.request('DELETE', '/admin/fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Dry-run a candidate fee-rule program against a sample transaction.\n * Returns the matched rule name, whether it fell through, and the computed fee.\n * Does not persist anything.\n */\n async preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse> {\n return this.request('POST', '/admin/fees/rules/preview', {\n body: input,\n query: { merchant_id: merchantId },\n });\n }\n}\n","import type { RequestFn } from '../client';\nimport { Delopay } from '../client';\nimport { Admin } from './resources/admin';\nimport { AdminPortal } from './resources/adminPortal';\nimport { AuditLogs } from './resources/auditLogs';\nimport { Cache } from './resources/cache';\nimport { CardIssuers } from './resources/cardIssuers';\nimport { Configs } from './resources/configs';\nimport { ConnectorRestrictionRules } from './resources/connectorRestrictionRules';\nimport { ConnectorRestrictions } from './resources/connectorRestrictions';\nimport { Gsm } from './resources/gsm';\nimport { PlatformBilling } from './resources/platformBilling';\nimport { PlatformFees } from './resources/platformFees';\n\n/**\n * Internal-only Delopay client for DeloPay staff tooling (the admin\n * control-center, audit UIs, etc.). Extends the public `Delopay` surface\n * with admin-plane resources that must **not** be discoverable from the\n * merchant-facing package entry.\n *\n * Import path: `import { DelopayInternal } from '@delopay/sdk/internal'`.\n * The merchant-facing `import { Delopay } from '@delopay/sdk'` never\n * surfaces these.\n */\nexport class DelopayInternal extends Delopay {\n /** Bootstrap admin endpoints — signup, signin, onboarding. */\n readonly admin: Admin;\n /** Platform-wide customer, transaction, analytics, merchant-account ops. */\n readonly adminPortal: AdminPortal;\n /** Audit log reads. */\n readonly auditLogs: AuditLogs;\n /** Backend cache invalidation. */\n readonly cache: Cache;\n /** Platform card-issuer program management. */\n readonly cardIssuers: CardIssuers;\n /** Generic platform config store. */\n readonly configs: Configs;\n /** Per-merchant connector allowlist for phased rollouts. */\n readonly connectorRestrictions: ConnectorRestrictions;\n /** Per-shop / per-project connector allow-deny rules (routing-time). */\n readonly connectorRestrictionRules: ConnectorRestrictionRules;\n /** GSM (Gateway Status Mapping) routing rules. */\n readonly gsm: Gsm;\n /** Admin-only ledger credits/debits against a merchant's balance. */\n readonly platformBilling: PlatformBilling;\n /** Platform-wide fee schedules assigned to merchants. */\n readonly platformFees: PlatformFees;\n\n constructor(...args: ConstructorParameters<typeof Delopay>) {\n super(...args);\n const request = this.request.bind(this) as RequestFn;\n this.admin = new Admin(request);\n this.adminPortal = new AdminPortal(request);\n this.auditLogs = new AuditLogs(request);\n this.cache = new Cache(request);\n this.cardIssuers = new CardIssuers(request);\n this.configs = new Configs(request);\n this.connectorRestrictions = new ConnectorRestrictions(request);\n this.connectorRestrictionRules = new ConnectorRestrictionRules(request);\n this.gsm = new Gsm(request);\n this.platformBilling = new PlatformBilling(request);\n this.platformFees = new PlatformFees(request);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAsBtC,YACE,SACA,SAQA;AACA,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,WAAW,SAAS;AAChD,SAAK,OAAO;AACZ,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,QAAQ;AACpB,SAAK,OAAO,QAAQ;AACpB,QAAI,QAAQ,cAAc,OAAW,MAAK,YAAY,QAAQ;AA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resources/authentication.ts","../src/resources/billing.ts","../src/resources/blocklist.ts","../src/resources/connectors.ts","../src/resources/customers.ts","../src/resources/disputes.ts","../src/resources/ephemeralKeys.ts","../src/resources/events.ts","../src/resources/fees.ts","../src/resources/mandates.ts","../src/resources/merchantAccounts.ts","../src/resources/paymentLinks.ts","../src/resources/paymentMethods.ts","../src/resources/payments.ts","../src/resources/payouts.ts","../src/resources/poll.ts","../src/resources/profileAcquirers.ts","../src/resources/profiles.ts","../src/resources/projects.ts","../src/resources/refunds.ts","../src/resources/relay.ts","../src/resources/routing.ts","../src/resources/search.ts","../src/resources/shops.ts","../src/resources/stripeConnect.ts","../src/resources/threeDsRules.ts","../src/resources/users.ts","../src/resources/verification.ts","../src/resources/webhooks.ts","../src/resources/analytics.ts","../src/resources/analyticsDashboard.ts","../src/resources/cards.ts","../src/resources/export.ts","../src/resources/featureMatrix.ts","../src/resources/files.ts","../src/resources/forex.ts","../src/resources/regions.ts","../src/resources/availabilityOverrides.ts","../src/resources/subscriptions.ts","../src/resources/settlement.ts","../src/resources/operationLimits.ts","../src/resources/risk.ts","../src/client.ts","../src/feeProgram.ts","../src/branding.ts","../src/checkoutSession.ts","../src/nativePanes.ts","../src/internal/resources/admin.ts","../src/internal/resources/adminPortal.ts","../src/internal/resources/auditLogs.ts","../src/internal/resources/cache.ts","../src/internal/resources/cardIssuers.ts","../src/internal/resources/configs.ts","../src/internal/resources/connectorRestrictionRules.ts","../src/internal/resources/connectorRestrictions.ts","../src/internal/resources/gsm.ts","../src/internal/resources/platformBilling.ts","../src/internal/resources/platformFees.ts","../src/internal/client.ts"],"sourcesContent":["/**\n * Internal SDK entry. For DeloPay staff tooling only; merchants import from\n * `'@delopay/sdk'` and never touch this path.\n *\n * Re-exports the full public surface plus the admin/ops-plane resources\n * and `DelopayInternal`, a subclass of `Delopay` that wires the internal\n * resources onto the client.\n *\n * import { DelopayInternal } from '@delopay/sdk/internal';\n * const sdk = new DelopayInternal('', { baseUrl: '/api' });\n * await sdk.admin.signIn({ email, password });\n * await sdk.adminPortal.listCustomers();\n * await sdk.platformFees.list(merchantId);\n *\n * All internal type-only exports come out of this barrel too — they're not\n * exported from `'@delopay/sdk'` directly.\n */\n\nexport * from './index';\nexport { DelopayInternal } from './internal/client';\nexport { Admin } from './internal/resources/admin';\nexport { AdminPortal } from './internal/resources/adminPortal';\nexport { AuditLogs } from './internal/resources/auditLogs';\nexport { Cache } from './internal/resources/cache';\nexport { CardIssuers } from './internal/resources/cardIssuers';\nexport { Configs } from './internal/resources/configs';\nexport { ConnectorRestrictionRules } from './internal/resources/connectorRestrictionRules';\nexport { ConnectorRestrictions } from './internal/resources/connectorRestrictions';\nexport { Gsm } from './internal/resources/gsm';\nexport { PlatformBilling } from './internal/resources/platformBilling';\nexport { PlatformFees } from './internal/resources/platformFees';\nexport type * from './internal/types';\n","/**\n * Error thrown when the Delopay API returns a non-2xx response, or when a\n * timeout or network error occurs.\n *\n * @example\n * ```typescript\n * try {\n * await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * } catch (e) {\n * if (e instanceof DelopayError) {\n * console.error(e.status, e.code, e.requestId, e.message);\n * }\n * }\n * ```\n */\nexport class DelopayError extends Error {\n /** HTTP status code returned by the API, or `0` for timeout/network errors. */\n readonly status: number;\n /** Machine-readable error code returned by the API (e.g. `'HE_00'`). */\n readonly code: string;\n /** Error category (e.g. `'invalid_request'`, `'timeout_error'`). */\n readonly type: string;\n /** Value of the `x-request-id` response header, when present. Include this when contacting support. */\n readonly requestId?: string;\n /**\n * Raw response body (truncated to ~2 KB). Populated when the server returns a\n * non-JSON error body (e.g. an HTML 502 from an upstream proxy) so debugging\n * still has something to go on.\n */\n readonly rawBody?: string;\n /**\n * Structured error context the API attaches under `error.data` for select\n * codes — e.g. `{ retry_after_secs: 248 }` on rate-limit / max-attempt\n * lockouts. Schema is per-code; consult the API reference for the shape.\n */\n readonly data?: Record<string, unknown>;\n\n constructor(\n message: string,\n options: {\n status: number;\n code: string;\n type: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message);\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayError';\n this.status = options.status;\n this.code = options.code;\n this.type = options.type;\n if (options.requestId !== undefined) this.requestId = options.requestId;\n if (options.rawBody !== undefined) this.rawBody = options.rawBody;\n if (options.data !== undefined) this.data = options.data;\n }\n}\n\n/**\n * Thrown when the API key is missing, invalid, or revoked (HTTP 401).\n *\n * @example\n * ```typescript\n * if (e instanceof DelopayAuthenticationError) {\n * // Prompt user to re-enter their API key.\n * }\n * ```\n */\nexport class DelopayAuthenticationError extends DelopayError {\n constructor(\n message = 'Invalid API key',\n options?: {\n code?: string;\n type?: string;\n requestId?: string;\n rawBody?: string;\n data?: Record<string, unknown>;\n },\n ) {\n super(message, {\n status: 401,\n // Default to the generic \"invalid API key\" code, but let callers pass\n // through the server-reported code (e.g. `UR_05` for unverified-email\n // 401s) so they can differentiate between auth failure reasons.\n code: options?.code || 'AUTH_01',\n type: options?.type || 'authentication_error',\n requestId: options?.requestId,\n rawBody: options?.rawBody,\n data: options?.data,\n });\n Object.setPrototypeOf(this, new.target.prototype);\n this.name = 'DelopayAuthenticationError';\n }\n}\n","import type {\n ApiKeyCreateRequest,\n ApiKeyCreateResponse,\n ApiKeyListConstraints,\n ApiKeyResponse,\n ApiKeyUpdateRequest,\n ApiKeyRevokeResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage API keys for a merchant account. */\nexport class ApiKeys {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new API key for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Key creation parameters (name, expiry, etc.).\n * @returns The newly created key including the plaintext secret (shown once only).\n *\n * @example\n * ```typescript\n * const { key_value } = await delopay.apiKeys.create('merch_123', { name: 'Production key' });\n * ```\n */\n async create(merchantId: string, params: ApiKeyCreateRequest): Promise<ApiKeyCreateResponse> {\n return this.request('POST', `/api-keys/${encodeURIComponent(merchantId)}`, { body: params });\n }\n\n /**\n * Retrieve metadata about an API key (does not return the plaintext secret).\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID.\n * @returns The API key metadata.\n */\n async retrieve(merchantId: string, keyId: string): Promise<ApiKeyResponse> {\n return this.request(\n 'GET',\n `/api-keys/${encodeURIComponent(merchantId)}/${encodeURIComponent(keyId)}`,\n );\n }\n\n /**\n * Update an API key's name or expiry.\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to update.\n * @param params - Fields to update.\n * @returns The updated API key metadata.\n */\n async update(\n merchantId: string,\n keyId: string,\n params: ApiKeyUpdateRequest,\n ): Promise<ApiKeyResponse> {\n return this.request(\n 'POST',\n `/api-keys/${encodeURIComponent(merchantId)}/${encodeURIComponent(keyId)}`,\n { body: params },\n );\n }\n\n /**\n * Revoke an API key, immediately invalidating it.\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to revoke.\n * @returns Revocation confirmation.\n */\n async revoke(merchantId: string, keyId: string): Promise<ApiKeyRevokeResponse> {\n return this.request(\n 'DELETE',\n `/api-keys/${encodeURIComponent(merchantId)}/${encodeURIComponent(keyId)}`,\n );\n }\n\n /**\n * List all API keys for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns Array of API key metadata objects.\n */\n async list(merchantId: string): Promise<ApiKeyResponse[]> {\n return this.request('GET', `/api-keys/${encodeURIComponent(merchantId)}/list`);\n }\n\n // --- Profile-scoped (shop-level) API keys ---------------------------------\n //\n // JWT-authenticated routes under `/account/{merchantId}/profile/api-keys`.\n // The caller's shop (business profile) comes from the JWT, never from the\n // request, so a shop-scoped user can only mint/list/manage keys pinned to\n // their own shop. Requires a backend with profile-scoped API key support.\n\n /**\n * Create a new API key pinned to the caller's shop (business profile).\n * `POST /account/{merchantId}/profile/api-keys`\n *\n * @param merchantId - The merchant account ID.\n * @param params - Key creation parameters (name, expiry, etc.).\n * @returns The newly created key including the plaintext secret (shown once\n * only) and the `profile_id` it is pinned to.\n *\n * @example\n * ```typescript\n * const { api_key } = await delopay.apiKeys.createByProfile('merch_123', {\n * name: 'Shop key',\n * expiration: 'never',\n * });\n * ```\n */\n async createByProfile(\n merchantId: string,\n params: ApiKeyCreateRequest,\n ): Promise<ApiKeyCreateResponse> {\n return this.request('POST', `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {\n body: params,\n });\n }\n\n /**\n * List API keys pinned to the caller's shop (business profile) only.\n * `GET /account/{merchantId}/profile/api-keys`\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional pagination constraints (`limit`, `skip`).\n * @returns Array of API key metadata objects belonging to the caller's shop.\n */\n async listByProfile(\n merchantId: string,\n params?: ApiKeyListConstraints,\n ): Promise<ApiKeyResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(merchantId)}/profile/api-keys`, {\n query: params as Record<string, number | null | undefined>,\n });\n }\n\n /**\n * Retrieve metadata about a shop-pinned API key (does not return the\n * plaintext secret). `GET /account/{merchantId}/profile/api-keys/{keyId}`\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID.\n * @returns The API key metadata.\n */\n async retrieveByProfile(merchantId: string, keyId: string): Promise<ApiKeyResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,\n );\n }\n\n /**\n * Update a shop-pinned API key's name, description, or expiry.\n * `POST /account/{merchantId}/profile/api-keys/{keyId}`\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to update.\n * @param params - Fields to update.\n * @returns The updated API key metadata.\n */\n async updateByProfile(\n merchantId: string,\n keyId: string,\n params: ApiKeyUpdateRequest,\n ): Promise<ApiKeyResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,\n { body: params },\n );\n }\n\n /**\n * Revoke a shop-pinned API key, immediately invalidating it.\n * `DELETE /account/{merchantId}/profile/api-keys/{keyId}`\n *\n * @param merchantId - The merchant account ID.\n * @param keyId - The API key ID to revoke.\n * @returns Revocation confirmation.\n */\n async revokeByProfile(merchantId: string, keyId: string): Promise<ApiKeyRevokeResponse> {\n return this.request(\n 'DELETE',\n `/account/${encodeURIComponent(merchantId)}/profile/api-keys/${encodeURIComponent(keyId)}`,\n );\n }\n}\n","import type { AuthenticationCreateRequest, AuthenticationResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Authentication {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: AuthenticationCreateRequest): Promise<AuthenticationResponse> {\n return this.request('POST', '/authentication', { body: params });\n }\n\n async checkEligibility(authId: string): Promise<AuthenticationResponse> {\n return this.request('POST', `/authentication/${encodeURIComponent(authId)}/eligibility`);\n }\n\n async authenticate(\n authId: string,\n params: Record<string, unknown>,\n ): Promise<AuthenticationResponse> {\n return this.request('POST', `/authentication/${encodeURIComponent(authId)}/authenticate`, {\n body: params,\n });\n }\n\n /** Sync authentication status. `POST /authentication/{merchantId}/{authId}/sync` */\n async sync(\n merchantId: string,\n authId: string,\n params?: Record<string, unknown>,\n ): Promise<AuthenticationResponse> {\n return this.request(\n 'POST',\n `/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/sync`,\n { body: params },\n );\n }\n\n /** Redirect after authentication. `POST /authentication/{merchantId}/{authId}/redirect` */\n async redirect(\n merchantId: string,\n authId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request(\n 'POST',\n `/authentication/${encodeURIComponent(merchantId)}/${encodeURIComponent(authId)}/redirect`,\n { body: params },\n );\n }\n\n /** Enable authn methods token. `POST /authentication/{authId}/enabled-authn-methods-token` */\n async enabledAuthnMethodsToken(\n authId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request(\n 'POST',\n `/authentication/${encodeURIComponent(authId)}/enabled-authn-methods-token`,\n {\n body: params,\n },\n );\n }\n\n /** Submit eligibility check. `POST /authentication/{authId}/eligibility-check` */\n async eligibilityCheck(\n authId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/authentication/${encodeURIComponent(authId)}/eligibility-check`, {\n body: params,\n });\n }\n}\n","import type {\n BillingProfileResponse,\n BillingSetupRequest,\n BillingSetupResponse,\n BillingCompleteSetupRequest,\n TopupRequest,\n TopupResponse,\n LedgerResponse,\n LedgerListParams,\n BlockedAttemptListResponse,\n BlockedAttemptListParams,\n AutoRechargeUpdateRequest,\n AllocationTransferRequest,\n AllocationTransferResponse,\n AllocationListResponse,\n AllocationResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Manage per-shop prepaid balance allocations transferred from the host merchant treasury. */\nclass BillingAllocations {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Transfer funds from the host merchant treasury into a shop's allocation.\n *\n * @param merchantId - The host merchant account ID.\n * @param params - Transfer details (amount, target profile/shop ID).\n * @returns The allocation transfer result.\n */\n async transferIn(\n merchantId: string,\n params: AllocationTransferRequest,\n ): Promise<AllocationTransferResponse> {\n return this.request(\n 'POST',\n `/billing/${encodeURIComponent(merchantId)}/allocations/transfer-in`,\n { body: params },\n );\n }\n\n /**\n * Transfer funds from a shop's allocation back to the host merchant treasury.\n *\n * @param merchantId - The host merchant account ID.\n * @param params - Transfer details (amount, source profile/shop ID).\n * @returns The allocation transfer result.\n */\n async transferOut(\n merchantId: string,\n params: AllocationTransferRequest,\n ): Promise<AllocationTransferResponse> {\n return this.request(\n 'POST',\n `/billing/${encodeURIComponent(merchantId)}/allocations/transfer-out`,\n {\n body: params,\n },\n );\n }\n\n /**\n * List all shop balance allocations for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns List of shop allocations.\n */\n async list(merchantId: string): Promise<AllocationListResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}/allocations`);\n }\n\n /**\n * Get the balance allocation for a specific shop.\n *\n * @param merchantId - The merchant account ID.\n * @param profileId - The shop (business profile) ID.\n * @returns The shop's balance allocation.\n */\n async get(merchantId: string, profileId: string): Promise<AllocationResponse> {\n return this.request(\n 'GET',\n `/billing/${encodeURIComponent(merchantId)}/allocations/${encodeURIComponent(profileId)}`,\n );\n }\n}\n\n/**\n * Manage prepaid billing balances — top-ups, card setup, auto-recharge, and the balance ledger.\n *\n * Delopay deducts a platform fee from the merchant's prepaid balance on every successful payment.\n * Use these endpoints to fund and monitor that balance.\n */\nexport class Billing {\n /** Per-shop balance allocation management for host merchants. */\n readonly allocations: BillingAllocations;\n\n constructor(private readonly request: RequestFn) {\n this.allocations = new BillingAllocations(request);\n }\n\n /**\n * Retrieve a merchant's billing profile (balance, status, auto-recharge config).\n *\n * @param merchantId - The merchant account ID.\n * @returns The billing profile.\n *\n * @example\n * ```typescript\n * const profile = await delopay.billing.getProfile('merch_123');\n * console.log(profile.balance, profile.status);\n * ```\n */\n async getProfile(merchantId: string): Promise<BillingProfileResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Start a Stripe SetupIntent flow to collect a payment card for auto-recharge.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional setup parameters.\n * @returns The Stripe client secret needed to render the card element.\n */\n async setup(merchantId: string, params?: BillingSetupRequest): Promise<BillingSetupResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/setup`, {\n body: params,\n });\n }\n\n /**\n * Confirm card setup after the Stripe SetupIntent completes on the frontend.\n *\n * @param merchantId - The merchant account ID.\n * @param params - The Stripe SetupIntent ID to confirm.\n * @returns The updated billing profile.\n */\n async completeSetup(\n merchantId: string,\n params: BillingCompleteSetupRequest,\n ): Promise<BillingProfileResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/setup/complete`, {\n body: params,\n });\n }\n\n /**\n * Manually top up a merchant's prepaid balance by charging their saved card.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Top-up amount and currency.\n * @returns The top-up result.\n */\n async topup(merchantId: string, params: TopupRequest): Promise<TopupResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/topup`, {\n body: params,\n });\n }\n\n /**\n * List the balance ledger (credits and debits) for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional pagination parameters.\n * @returns The ledger entries.\n */\n async listLedger(merchantId: string, params?: LedgerListParams): Promise<LedgerResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}/ledger`, {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * List payment attempts that were blocked by the billing suspension gate\n * (account suspended, setup incomplete, or shop allocation suspended).\n *\n * These attempts never created a payment, so they do not appear in the\n * payments list — this is the only way to retrieve them.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional filters (profile, reason, date range) and pagination.\n * @returns The blocked-attempt entries with a total count.\n */\n async listBlockedAttempts(\n merchantId: string,\n params?: BlockedAttemptListParams,\n ): Promise<BlockedAttemptListResponse> {\n return this.request('GET', `/billing/${encodeURIComponent(merchantId)}/blocked-attempts`, {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * Update auto-recharge configuration (threshold, top-up amount, enabled flag).\n *\n * @param merchantId - The merchant account ID.\n * @param params - Auto-recharge settings to update.\n * @returns The updated billing profile.\n */\n async updateAutoRecharge(\n merchantId: string,\n params: AutoRechargeUpdateRequest,\n ): Promise<BillingProfileResponse> {\n return this.request('PATCH', `/billing/${encodeURIComponent(merchantId)}/auto-recharge`, {\n body: params,\n });\n }\n}\n","import type { BlocklistAddRequest, BlocklistResponse, BlocklistDataKind } from '../types';\nimport type { RequestFn } from '../client';\n\nexport interface BlocklistListParams {\n data_kind?: BlocklistDataKind | null;\n limit?: number | null;\n offset?: number | null;\n}\n\nexport interface BlocklistToggleParams {\n status: boolean;\n}\n\nexport class Blocklist {\n constructor(private readonly request: RequestFn) {}\n\n async add(params: BlocklistAddRequest): Promise<BlocklistResponse> {\n return this.request('POST', '/blocklist', { body: params });\n }\n\n async remove(params: BlocklistAddRequest): Promise<BlocklistResponse> {\n return this.request('DELETE', '/blocklist', { body: params });\n }\n\n async list(params?: BlocklistListParams): Promise<BlocklistResponse[]> {\n return this.request('GET', '/blocklist', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n async toggle(params: BlocklistToggleParams): Promise<Record<string, unknown>> {\n return this.request('POST', '/blocklist/toggle', { body: params });\n }\n}\n","import type {\n ConnectorCloneRequest,\n EpayoutsCatalogResponse,\n VaultRoutesApplyRequest,\n VaultRoutesApplyResponse,\n VaultRoutesPreviewRequest,\n VaultRoutesPreviewResponse,\n VaultVerificationResponse,\n VaultVerifyRequest,\n ConnectorCreateRequest,\n ConnectorResponse,\n ConnectorUpdateRequest,\n ConnectorWebhookListResponse,\n ConnectorWebhookRegisterRequest,\n ConnectorWebhookRegisterResponse,\n ConnectorWebhookSyncResponse,\n StripePaymentMethodDomainsRegisterRequest,\n StripePaymentMethodDomainsRegisterResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Connectors {\n constructor(private readonly request: RequestFn) {}\n\n async create(accountId: string, params: ConnectorCreateRequest): Promise<ConnectorResponse> {\n return this.request('POST', `/account/${encodeURIComponent(accountId)}/connectors`, {\n body: params,\n });\n }\n\n /**\n * One connector account.\n *\n * The credential-bearing fields come back `null` here, whatever is stored:\n * `connector_webhook_details`, `connector_wallets_details`,\n * `pm_auth_config` and `additional_merchant_data`. They are dropped rather\n * than masked, because an editor that prefills from this response and\n * PATCHes the field back would otherwise save a mask over a live signing\n * secret. Send those fields only when the operator has typed a new value,\n * and omit them entirely otherwise — an omitted field leaves the stored one\n * alone.\n *\n * This is the retrieve path alone. `create` and `update` echo back what the\n * caller sent, and `clone` returns the *copied* secrets — see that method.\n *\n * `GET /account/{accountId}/connectors/{connectorId}`\n */\n async retrieve(accountId: string, connectorId: string): Promise<ConnectorResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`,\n );\n }\n\n /**\n * The merchant's connector accounts.\n *\n * Never wider than the caller: an API key pinned to one shop lists that\n * shop's connectors only, not every sibling shop's.\n *\n * `GET /account/{accountId}/connectors`\n */\n async list(accountId: string): Promise<ConnectorResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/connectors`);\n }\n\n /**\n * The profile-scoped connector list. The merchant-wide `list()` is\n * merchant-gated and 403s for a profile-entity (shop user) JWT; this\n * variant is scoped server-side to the caller's own profile.\n *\n * `GET /account/{accountId}/profile/connectors`\n */\n async listByProfile(accountId: string): Promise<ConnectorResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/profile/connectors`);\n }\n\n /**\n * The built-in e-Payouts reference catalog — the \"Restore defaults\" source.\n * `GET /account/{accountId}/connectors/epayouts/catalog/defaults`\n */\n async getEpayoutsCatalogDefaults(accountId: string): Promise<EpayoutsCatalogResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(accountId)}/connectors/epayouts/catalog/defaults`,\n );\n }\n\n /**\n * Sweep the merchant's own e-Payouts module and return the rails it\n * actually has enabled. Server-side this makes many upstream calls, so it\n * can take several seconds — show progress.\n *\n * `POST /account/{accountId}/connectors/{connectorId}/epayouts/catalog/sync`\n */\n async syncEpayoutsCatalog(\n accountId: string,\n connectorId: string,\n ): Promise<EpayoutsCatalogResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/epayouts/catalog/sync`,\n );\n }\n\n async update(\n accountId: string,\n connectorId: string,\n params: ConnectorUpdateRequest,\n ): Promise<ConnectorResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`,\n {\n body: params,\n },\n );\n }\n\n /**\n * Remove a connector account.\n *\n * A shop-scoped role may remove a connector of its own shop — the shop is\n * re-checked server-side — so creating processors and removing them are the\n * same rung of access rather than two.\n *\n * `DELETE /account/{accountId}/connectors/{connectorId}`\n */\n async delete(accountId: string, connectorId: string): Promise<ConnectorResponse> {\n return this.request(\n 'DELETE',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}`,\n );\n }\n\n /**\n * Clone a connector into another shop (business profile) of the same\n * merchant. `POST /account/{accountId}/connectors/{connectorId}/clone`\n *\n * Credentials are copied server-side, re-encrypted under the same merchant\n * key, so the caller never has to *supply* them — `retrieve` returns `null`\n * for the credential fields, which is what makes a client-side copy\n * impossible in the first place.\n *\n * The response, however, is the unredacted connector: `connector_account_details`\n * is masked, but `connector_webhook_details`, `connector_wallets_details`,\n * `pm_auth_config` and `additional_merchant_data` come back with the copied\n * secrets in them — values this caller never sent. Do not log or echo the\n * response; read `merchant_connector_id` and discard the rest.\n */\n async clone(\n accountId: string,\n connectorId: string,\n params: ConnectorCloneRequest,\n ): Promise<ConnectorResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/clone`,\n { body: params },\n );\n }\n\n // --- Advanced operations (Task 4.8) ---\n\n /**\n * Run the configuration checks for a vault (VGS) connector account:\n * credential validity, write-only Collect scope, reachability, environment\n * coherence, route coverage. Read-only but not cheap — it decrypts the\n * vault's management credential and talks to VGS.\n *\n * `POST /account/{accountId}/connectors/{connectorId}/vault/verify`\n */\n async verifyVault(\n accountId: string,\n connectorId: string,\n params: VaultVerifyRequest,\n ): Promise<VaultVerificationResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/verify`,\n { body: params },\n );\n }\n\n /**\n * Compute the route document the vault SHOULD have and diff it against\n * what exists, without writing anything. The returned fingerprints must be\n * echoed byte for byte on {@link Connectors.applyVaultRoutes}.\n *\n * A router without these endpoints answers 404 — render that as \"this\n * build cannot configure routes\", never as \"there is nothing to change\".\n *\n * `POST /account/{accountId}/connectors/{connectorId}/vault/routes/preview`\n */\n async previewVaultRoutes(\n accountId: string,\n connectorId: string,\n params: VaultRoutesPreviewRequest,\n ): Promise<VaultRoutesPreviewResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/routes/preview`,\n { body: params },\n );\n }\n\n /**\n * Write the routes the merchant just previewed. Both fingerprints come\n * from the preview and are opaque: `expected_current_fingerprint` says the\n * vault has not moved (`null` = \"the preview found no routes\" and is sent\n * as `null`, never omitted), `expected_desired_fingerprint` says the\n * document is still the one on screen. A 409 (`DE_04`) means the vault\n * changed since the preview — nothing was written; preview again.\n *\n * `POST /account/{accountId}/connectors/{connectorId}/vault/routes/apply`\n */\n async applyVaultRoutes(\n accountId: string,\n connectorId: string,\n params: VaultRoutesApplyRequest,\n ): Promise<VaultRoutesApplyResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/connectors/${encodeURIComponent(connectorId)}/vault/routes/apply`,\n { body: params },\n );\n }\n\n /** Verify connector credentials. `POST /account/connectors/verify` */\n async verify(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/account/connectors/verify', { body: params });\n }\n\n /**\n * Register a webhook for a connector.\n * `POST /account/{merchantId}/connectors/webhooks/{connectorId}`\n *\n * @param params - Optional event scope. Defaults to `{ event_type: 'all_events' }`\n * when omitted; pass `{ event_type: { specific_event: '…' } }` to scope\n * to a single event.\n */\n async registerWebhook(\n merchantId: string,\n connectorId: string,\n params?: ConnectorWebhookRegisterRequest,\n ): Promise<ConnectorWebhookRegisterResponse> {\n const path = `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`;\n if (params === undefined) return this.request('POST', path);\n return this.request('POST', path, { body: params });\n }\n\n /**\n * Register checkout/shop domains as Stripe payment method domains, so Apple\n * Pay renders on those pages.\n * `POST /account/{merchantId}/connectors/{connectorId}/stripe/payment-method-domains`\n *\n * Stripe connectors only. One call registers against a single credential set\n * (`environment`, default `'live'`) — call twice to cover live and sandbox.\n * Per-URL outcomes come back in `results`; a missing sandbox credential set\n * is a request-level 400.\n */\n async registerStripePaymentMethodDomains(\n merchantId: string,\n connectorId: string,\n params: StripePaymentMethodDomainsRegisterRequest,\n ): Promise<StripePaymentMethodDomainsRegisterResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(merchantId)}/connectors/${encodeURIComponent(connectorId)}/stripe/payment-method-domains`,\n { body: params },\n );\n }\n\n /** Get registered webhooks for a connector. `GET /account/{merchantId}/connectors/webhooks/{connectorId}` */\n async getWebhook(merchantId: string, connectorId: string): Promise<ConnectorWebhookListResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}`,\n );\n }\n\n /**\n * Bring an already-registered webhook's event subscription up to date with\n * the events Delopay handles.\n * `POST /account/{merchantId}/connectors/webhooks/{connectorId}/sync-events`\n *\n * A PSP freezes an endpoint's event list at registration time, so an endpoint\n * created before an event type was added never receives it — silently, with\n * no error anywhere. {@link getWebhook} reports the gap as `missing_events`;\n * this repairs it.\n *\n * Unlike re-registering, the endpoints are updated in place: the endpoint id\n * and its signing secret are preserved, so signature verification keeps\n * working across the change. Stripe connectors only; idempotent, so it is\n * safe to call on a schedule or after every deploy.\n *\n * @example\n * ```typescript\n * const sync = await delopay.connectors.syncWebhookEvents('mer_abc', 'mca_xyz');\n * for (const endpoint of sync.endpoints) {\n * if (endpoint.error_message) console.warn(endpoint.connector_webhook_id, endpoint.error_message);\n * else if (endpoint.updated) console.log('subscribed', endpoint.added_events);\n * }\n * ```\n */\n async syncWebhookEvents(\n merchantId: string,\n connectorId: string,\n ): Promise<ConnectorWebhookSyncResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(merchantId)}/connectors/webhooks/${encodeURIComponent(connectorId)}/sync-events`,\n );\n }\n\n /** List available payment methods. `GET /account/payment-methods` */\n async listPaymentMethods(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/account/payment-methods');\n }\n}\n","import type {\n CustomerCreateRequest,\n CustomerResponse,\n CustomerUpdateRequest,\n CustomerListParams,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Flatten list params for the query string.\n *\n * `profile_ids` must go out as ONE comma-separated value. The client\n * serializes arrays as repeated keys (`?profile_ids=a&profile_ids=b`), and the\n * customers endpoints cannot parse that — the whole request fails, rather than\n * the second id being ignored. So the join happens here, once, instead of at\n * four call sites.\n */\nfunction toQuery(\n params?: CustomerListParams,\n): Record<string, string | number | boolean | undefined> | undefined {\n if (!params) return undefined;\n const { profile_ids, ...rest } = params;\n const query = rest as Record<string, string | number | boolean | undefined>;\n // An empty array means \"no shop filter\", which is the absent key — sending\n // `profile_ids=` would work too, but omitting it keeps the URL honest.\n if (profile_ids && profile_ids.length > 0) {\n query.profile_ids = profile_ids.join(',');\n }\n return query;\n}\n\n/** Create and manage customer profiles. */\nexport class Customers {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new customer.\n *\n * @param params - Customer creation parameters (name, email, phone, address, etc.).\n * @returns The created customer.\n *\n * @example\n * ```typescript\n * const customer = await delopay.customers.create({\n * email: 'alice@example.com',\n * name: 'Alice Smith',\n * });\n * ```\n */\n async create(params: CustomerCreateRequest): Promise<CustomerResponse> {\n return this.request('POST', '/customers', { body: params });\n }\n\n /**\n * Retrieve a customer by their ID.\n *\n * @param customerId - The unique customer ID.\n * @returns The customer.\n *\n * @example\n * ```typescript\n * const customer = await delopay.customers.retrieve('cus_abc123');\n * ```\n */\n async retrieve(customerId: string): Promise<CustomerResponse> {\n return this.request('GET', `/customers/${encodeURIComponent(customerId)}`);\n }\n\n /**\n * Update an existing customer's details.\n *\n * @param customerId - The customer ID to update.\n * @param params - Fields to update (name, email, address, metadata, etc.).\n * @returns The updated customer.\n */\n async update(customerId: string, params: CustomerUpdateRequest): Promise<CustomerResponse> {\n return this.request('POST', `/customers/${encodeURIComponent(customerId)}`, { body: params });\n }\n\n /**\n * Delete a customer and all their saved payment methods.\n *\n * @param customerId - The customer ID to delete.\n * @returns The deleted customer object.\n */\n async delete(customerId: string): Promise<CustomerResponse> {\n return this.request('DELETE', `/customers/${encodeURIComponent(customerId)}`);\n }\n\n /**\n * List customers, optionally filtered by email, shop (`profile_id`), or\n * project (`project_id`).\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of customer objects.\n *\n * @example\n * ```typescript\n * // Customers who have transacted in a specific shop.\n * const customers = await delopay.customers.list({ profile_id: 'pro_abc123' });\n *\n * // Several shops at once (unions with profile_id / project_id).\n * const many = await delopay.customers.list({\n * profile_ids: ['pro_abc123', 'pro_def456'],\n * });\n * ```\n */\n async list(params?: CustomerListParams): Promise<CustomerResponse[]> {\n return this.request('GET', '/customers/list', {\n query: toQuery(params),\n });\n }\n\n // --- OLAP extensions (Task 4.6) ---\n\n /**\n * List customers with count. Supports the same `profile_id` / `project_id`\n * shop filters as {@link list}. `GET /customers/list-with-count`\n */\n async listWithCount(\n params?: CustomerListParams,\n ): Promise<{ count: number; total_count: number; data: CustomerResponse[] }> {\n return this.request('GET', '/customers/list-with-count', {\n query: toQuery(params),\n });\n }\n\n /**\n * List customers scoped to the authenticated dashboard user's shop\n * (business profile). The JWT auto-scopes to its own `profile`; an explicit\n * `profile_id` / `project_id` outside that scope is rejected with\n * `AccessForbidden`. `GET /customers/profile/list`\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of customer objects.\n */\n async listByProfile(params?: CustomerListParams): Promise<CustomerResponse[]> {\n return this.request('GET', '/customers/profile/list', {\n query: toQuery(params),\n });\n }\n\n /**\n * Profile-scoped variant of {@link listWithCount}.\n * `GET /customers/profile/list-with-count`\n */\n async listByProfileWithCount(\n params?: CustomerListParams,\n ): Promise<{ count: number; total_count: number; data: CustomerResponse[] }> {\n return this.request('GET', '/customers/profile/list-with-count', {\n query: toQuery(params),\n });\n }\n\n /** List mandates for a customer. `GET /customers/{customerId}/mandates` */\n async listMandates(customerId: string): Promise<Record<string, unknown>[]> {\n return this.request('GET', `/customers/${encodeURIComponent(customerId)}/mandates`);\n }\n}\n","import type {\n DisputeResponse,\n DisputeListParams,\n DisputeEvidenceRequest,\n DisputeEvidenceBlock,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** View and respond to payment disputes and chargebacks. */\nexport class Disputes {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Retrieve a dispute by its ID.\n *\n * @param disputeId - The unique dispute ID.\n * @returns The dispute.\n */\n async retrieve(disputeId: string): Promise<DisputeResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * List disputes, optionally filtered by status, stage, or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of disputes.\n */\n async list(params?: DisputeListParams): Promise<DisputeResponse[]> {\n return this.request('GET', '/disputes/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * Accept a dispute, conceding the chargeback to the customer.\n *\n * @param disputeId - The dispute ID to accept.\n * @returns The updated dispute.\n */\n async accept(disputeId: string): Promise<DisputeResponse> {\n return this.request('POST', `/disputes/accept/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * Submit evidence to challenge a dispute.\n *\n * @param params - Evidence details and the dispute ID to contest.\n * @returns The updated dispute.\n */\n async submitEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('POST', '/disputes/evidence', { body: params });\n }\n\n /**\n * Attach evidence (e.g. file upload metadata) to a dispute.\n *\n * Uses `PUT /disputes/evidence`.\n */\n async attachEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('PUT', '/disputes/evidence', { body: params });\n }\n\n /**\n * Retrieve previously stored evidence for a dispute.\n *\n * Returns an ARRAY of file-evidence blocks (this was previously mistyped\n * as the flat submit-request shape). Only file evidence is reported —\n * text evidence is not retrievable once submitted.\n *\n * @param disputeId - The dispute ID.\n * @returns The stored file-evidence blocks.\n */\n async retrieveEvidence(disputeId: string): Promise<DisputeEvidenceBlock[]> {\n return this.request('GET', `/disputes/evidence/${encodeURIComponent(disputeId)}`);\n }\n\n /**\n * Delete submitted evidence for a dispute.\n *\n * @param params - Evidence request body identifying what to delete.\n * @returns The updated dispute.\n */\n async deleteEvidence(params: DisputeEvidenceRequest): Promise<DisputeResponse> {\n return this.request('DELETE', '/disputes/evidence', { body: params });\n }\n\n // --- OLAP extensions (Task 4.4) ---\n\n /** List disputes (profile-scoped). `GET /disputes/profile/list` */\n async listByProfile(params?: DisputeListParams): Promise<DisputeResponse[]> {\n return this.request('GET', '/disputes/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** Get dispute filter options. `GET /disputes/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/filter', { query: params });\n }\n\n /** Get dispute filters (profile-scoped). `GET /disputes/profile/filter` */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/profile/filter', { query: params });\n }\n\n /** Get dispute aggregates. `GET /disputes/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/aggregate', { query: params });\n }\n\n /** Get dispute aggregates (profile-scoped). `GET /disputes/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/disputes/profile/aggregate', { query: params });\n }\n\n /**\n * Fetch the latest dispute state from the connector (gateway) and persist it.\n * `GET /disputes/{disputeId}?force_sync=true`\n *\n * The path parameter is the **Delopay dispute id** (`dp_…`). Force-sync asks the\n * backend to pull the dispute from the connector (supported where the connector\n * implements the dispute-sync flow, e.g. Stripe) and update the stored record\n * before returning it.\n *\n * Note: this method previously called `GET /disputes/{id}/fetch`, which is a\n * different backend route — a bulk import keyed by **merchant connector account\n * id** with a required date range — so every call with a dispute id failed.\n */\n async fetchFromConnector(disputeId: string): Promise<DisputeResponse> {\n return this.request('GET', `/disputes/${encodeURIComponent(disputeId)}`, {\n query: { force_sync: 'true' },\n });\n }\n}\n","import type { EphemeralKeyCreateRequest, EphemeralKeyCreateResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Create short-lived ephemeral keys for secure client-side operations.\n *\n * Ephemeral keys grant a mobile or browser client temporary access to a\n * specific customer's data (e.g. to display saved payment methods) without\n * exposing your secret API key.\n *\n * The key is confined to the customer it was minted for, and that is\n * enforced on every customer and payment-method route: a request for another\n * customer — or for a payment method belonging to one — is refused rather\n * than served. Mint one key per customer; do not reuse a key across them.\n */\nexport class EphemeralKeys {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create an ephemeral key scoped to a specific customer.\n *\n * @param params - Customer ID and optional expiry.\n * @returns The ephemeral key with its plaintext secret and expiry timestamp.\n *\n * @example\n * ```typescript\n * const ephKey = await delopay.ephemeralKeys.create({ customer_id: 'cus_123' });\n * // Pass ephKey.secret to your mobile app.\n * ```\n */\n async create(params: EphemeralKeyCreateRequest): Promise<EphemeralKeyCreateResponse> {\n return this.request('POST', '/ephemeral-keys', { body: params });\n }\n\n /**\n * Invalidate an ephemeral key before it expires.\n *\n * @param keyId - The ephemeral key ID to delete.\n * @returns The deleted key object.\n */\n async delete(keyId: string): Promise<EphemeralKeyCreateResponse> {\n return this.request('DELETE', `/ephemeral-keys/${encodeURIComponent(keyId)}`);\n }\n}\n","import type {\n EventListParams,\n EventListResponse,\n EventDeliveryAttemptResponse,\n EventDetailResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Events {\n constructor(private readonly request: RequestFn) {}\n\n async list(merchantId: string, params?: EventListParams): Promise<EventListResponse> {\n return this.request('POST', `/events/${encodeURIComponent(merchantId)}`, { body: params });\n }\n\n async listDeliveryAttempts(\n merchantId: string,\n eventId: string,\n ): Promise<EventDeliveryAttemptResponse[]> {\n return this.request(\n 'GET',\n `/events/${encodeURIComponent(merchantId)}/${encodeURIComponent(eventId)}/attempts`,\n );\n }\n\n async retryDelivery(merchantId: string, eventId: string): Promise<EventDetailResponse> {\n return this.request(\n 'POST',\n `/events/${encodeURIComponent(merchantId)}/${encodeURIComponent(eventId)}/retry`,\n );\n }\n\n // --- Profile-scoped listing (Task 4.12) ---\n\n /** List events (profile-scoped). `POST /events/profile/list` */\n async listByProfile(params?: Record<string, unknown>): Promise<EventListResponse> {\n return this.request('POST', '/events/profile/list', { body: params });\n }\n}\n","import type {\n FeeRulePreviewRequest,\n FeeRulePreviewResponse,\n FeeScheduleCreateRequest,\n FeeScheduleResponse,\n FeeScheduleUpdateRequest,\n PlatformFeeRuleInput,\n PlatformFeeRuleRecord,\n PlatformFeeRuleRequest,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Merchant-scoped fee schedules. Each schedule optionally targets a\n * specific shop (via `shop_id`). Merchants can CRUD their own fee\n * overrides; platform-wide fee programs are administered by Delopay and\n * not exposed here.\n *\n * `fees.rules` manages the merchant-owned Euclid fee-rule program, which takes\n * precedence over the flat schedules above. A program is scoped either to one\n * shop (`profile_id`) or merchant-wide; a shop-scoped program wins for that\n * shop, otherwise the merchant-wide one applies. Build the program with the\n * `feeProgram()` helper.\n */\nexport class Fees {\n /** Merchant-owned Euclid fee-rule program (`/merchant-fees/rules`). */\n readonly rules: FeeRulesManager;\n\n constructor(private readonly request: RequestFn) {\n this.rules = new FeeRulesManager(request);\n }\n\n /**\n * Create a merchant-scoped fee schedule (optionally per-shop).\n *\n * @param params - Fee schedule parameters.\n * @param merchantId - The merchant account ID.\n */\n async create(params: FeeScheduleCreateRequest, merchantId: string): Promise<FeeScheduleResponse> {\n return this.request('POST', '/merchant-fees', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * List the merchant's own fee schedules.\n *\n * @param merchantId - The merchant account ID.\n */\n async list(merchantId: string): Promise<FeeScheduleResponse[]> {\n return this.request('GET', '/merchant-fees/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Update a merchant-scoped fee schedule.\n *\n * @param feeId - The fee schedule ID.\n * @param params - Fields to update.\n */\n async update(feeId: string, params: FeeScheduleUpdateRequest): Promise<FeeScheduleResponse> {\n return this.request('PUT', `/merchant-fees/${encodeURIComponent(feeId)}`, { body: params });\n }\n\n /**\n * Delete a merchant-scoped fee schedule.\n *\n * @param feeId - The fee schedule ID.\n */\n async delete(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('DELETE', `/merchant-fees/${encodeURIComponent(feeId)}`);\n }\n}\n\n/**\n * Manages a merchant's Euclid fee-rule programs (merchant-wide or per-shop, one\n * active program per scope). Build the `algorithm` with `feeProgram()`. The SDK\n * injects `fee_owner: 'merchant'`; set `profile_id` on the input to scope a\n * program to a shop.\n */\nexport class FeeRulesManager {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create or replace the merchant's fee-rule program (a new active version;\n * the previous version is deactivated server-side).\n *\n * @param params - The program plus optional name / shop scope / validity window.\n * @param merchantId - The merchant account ID.\n */\n async upsert(params: PlatformFeeRuleInput, merchantId: string): Promise<PlatformFeeRuleRecord> {\n const body: PlatformFeeRuleRequest = { ...params, fee_owner: 'merchant' };\n return this.request('PUT', '/merchant-fees/rules', {\n body,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve the active fee-rule program for a scope, or `null` if none.\n *\n * @param merchantId - The merchant account ID.\n * @param profileId - Optional shop (`profile_id`) scope. Omit for the\n * merchant-wide program; pass a shop id to get that shop's program.\n */\n async retrieve(merchantId: string, profileId?: string): Promise<PlatformFeeRuleRecord | null> {\n return this.request('GET', '/merchant-fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Deactivate a fee-rule program (falls back to the flat fee schedules /\n * volume tier). Idempotent.\n *\n * @param merchantId - The merchant account ID.\n * @param profileId - Optional shop (`profile_id`) scope. Omit to target the\n * merchant-wide program; pass a shop id to delete only that shop's program\n * (other shops' programs are left intact).\n */\n async delete(merchantId: string, profileId?: string): Promise<void> {\n await this.request('DELETE', '/merchant-fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Dry-run a candidate fee-rule program against a sample transaction.\n * Returns the matched rule name, whether it fell through, and the computed fee.\n * Does not persist anything.\n *\n * @param input - Candidate program + sample transaction fields.\n * @param merchantId - The merchant account ID.\n */\n async preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse> {\n return this.request('POST', '/merchant-fees/rules/preview', {\n body: input,\n query: { merchant_id: merchantId },\n });\n }\n}\n","import type { MandateResponse, MandateRevokedResponse, MandateListParams } from '../types';\nimport type { RequestFn } from '../client';\n\n/** View and revoke recurring payment mandates. */\nexport class Mandates {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Retrieve a mandate by its ID.\n *\n * @param mandateId - The unique mandate ID.\n * @returns The mandate.\n */\n async retrieve(mandateId: string): Promise<MandateResponse> {\n return this.request('GET', `/mandates/${encodeURIComponent(mandateId)}`);\n }\n\n /**\n * Revoke an active mandate, preventing future charges.\n *\n * @param mandateId - The mandate ID to revoke.\n * @returns Revocation confirmation.\n */\n async revoke(mandateId: string): Promise<MandateRevokedResponse> {\n return this.request('POST', `/mandates/revoke/${encodeURIComponent(mandateId)}`);\n }\n\n /**\n * List mandates, optionally filtered by customer or status.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Array of mandates.\n */\n async list(params?: MandateListParams): Promise<MandateResponse[]> {\n return this.request('GET', '/mandates/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n}\n","import type {\n MerchantAccountCreateRequest,\n MerchantAccountResponse,\n MerchantAccountUpdateRequest,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class MerchantAccounts {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: MerchantAccountCreateRequest): Promise<MerchantAccountResponse> {\n return this.request('POST', '/accounts', { body: params });\n }\n\n async retrieve(accountId: string): Promise<MerchantAccountResponse> {\n return this.request('GET', `/accounts/${encodeURIComponent(accountId)}`);\n }\n\n async update(\n accountId: string,\n params: MerchantAccountUpdateRequest,\n ): Promise<MerchantAccountResponse> {\n return this.request('POST', `/accounts/${encodeURIComponent(accountId)}`, { body: params });\n }\n\n async delete(accountId: string): Promise<MerchantAccountResponse> {\n return this.request('DELETE', `/accounts/${encodeURIComponent(accountId)}`);\n }\n\n // --- Advanced operations (Task 4.9) ---\n\n /** List all merchant accounts. `GET /accounts/list` */\n async list(): Promise<MerchantAccountResponse[]> {\n return this.request('GET', '/accounts/list');\n }\n\n /** Toggle key-value store for a merchant. `POST /accounts/{accountId}/kv` */\n async toggleKv(accountId: string): Promise<Record<string, unknown>> {\n return this.request('POST', `/accounts/${encodeURIComponent(accountId)}/kv`);\n }\n\n /** Get KV status for a merchant. `GET /accounts/{accountId}/kv` */\n async getKvStatus(accountId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/accounts/${encodeURIComponent(accountId)}/kv`);\n }\n\n /** Transfer keys between merchants. `POST /accounts/transfer` */\n async transferKeys(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/accounts/transfer', { body: params });\n }\n}\n","import type { PaymentLinkResponse, PaymentLinkListParams, PaymentLinkListResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/** Retrieve and list hosted payment links. */\nexport class PaymentLinks {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Retrieve a payment link by its ID.\n *\n * @param linkId - The unique payment link ID.\n * @returns The payment link details.\n */\n async retrieve(linkId: string): Promise<PaymentLinkResponse> {\n return this.request('GET', `/payment-link/${encodeURIComponent(linkId)}`);\n }\n\n /**\n * List payment links, optionally filtered by status or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Paginated list of payment links.\n */\n async list(params?: PaymentLinkListParams): Promise<PaymentLinkListResponse> {\n return this.request('POST', '/payment-link/list', { body: params });\n }\n\n /** Initiate (render) a payment link page. `GET /payment-link/{merchantId}/{paymentId}` */\n async initiate(merchantId: string, paymentId: string): Promise<Record<string, unknown>> {\n return this.request(\n 'GET',\n `/payment-link/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`,\n );\n }\n\n /** Get payment link status. `GET /payment-link/status/{merchantId}/{paymentId}` */\n async status(merchantId: string, paymentId: string): Promise<Record<string, unknown>> {\n return this.request(\n 'GET',\n `/payment-link/status/${encodeURIComponent(merchantId)}/${encodeURIComponent(paymentId)}`,\n );\n }\n}\n","import type {\n PaymentMethodCreateRequest,\n PaymentMethodResponse,\n PaymentMethodUpdateRequest,\n PaymentMethodListParams,\n PaymentMethodListResponse,\n PaymentMethodDeleteResponse,\n CustomerPaymentMethodsListParams,\n CustomerPaymentMethodsListResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage saved payment methods for customers. */\nexport class PaymentMethods {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Save a new payment method (card, bank account, wallet, etc.).\n *\n * @param params - Payment method data including type and card/bank details.\n * @returns The saved payment method.\n *\n * @example\n * ```typescript\n * const pm = await delopay.paymentMethods.create({\n * payment_method: 'card',\n * customer_id: 'cus_123',\n * client_secret: 'cs_...',\n * });\n * ```\n */\n async create(params: PaymentMethodCreateRequest): Promise<PaymentMethodResponse> {\n return this.request('POST', '/payment-methods', { body: params });\n }\n\n /**\n * Retrieve a saved payment method by its ID.\n *\n * @param methodId - The payment method ID.\n * @returns The payment method.\n */\n async retrieve(methodId: string): Promise<PaymentMethodResponse> {\n return this.request('GET', `/payment-methods/${encodeURIComponent(methodId)}`);\n }\n\n /**\n * Update an existing payment method (e.g. update card expiry).\n *\n * @param methodId - The payment method ID to update.\n * @param params - Fields to update (card expiry, holder name, etc.).\n * @returns The updated payment method.\n */\n async update(\n methodId: string,\n params: PaymentMethodUpdateRequest,\n ): Promise<PaymentMethodResponse> {\n return this.request('POST', `/payment-methods/${encodeURIComponent(methodId)}/update`, {\n body: params,\n });\n }\n\n /**\n * Delete a saved payment method.\n *\n * @param methodId - The payment method ID to delete.\n * @returns Deletion confirmation.\n */\n async delete(methodId: string): Promise<PaymentMethodDeleteResponse> {\n return this.request('DELETE', `/payment-methods/${encodeURIComponent(methodId)}`);\n }\n\n /**\n * List the payment methods available for a payment — the discovery endpoint a\n * custom checkout renders its tiles from.\n *\n * Callable with a publishable key plus the payment's `client_secret`, so it\n * runs from the browser. The returned set is already filtered by country,\n * order value and the merchant's availability rules, and each entry carries\n * `display` (name + icon slug) and `amount_limits` (the order values it stays\n * available for) so you do not have to maintain either alongside.\n *\n * This is *not* the customer's saved methods — see {@link listForCustomer}.\n *\n * @param params - `client_secret`, plus optional `country`, `amount` and filters.\n * @returns The methods available for the payment, grouped by payment method.\n *\n * @example\n * ```typescript\n * const { payment_methods } = await delopay.paymentMethods.list({\n * client_secret: 'pay_abc_secret_xyz',\n * country: 'DE',\n * amount: 25000,\n * });\n *\n * for (const group of payment_methods) {\n * for (const method of group.payment_method_types) {\n * // Re-check availability yourself as the cart total changes, instead of\n * // re-listing on every keystroke.\n * const limits = method.amount_limits;\n * const available =\n * !limits ||\n * ((limits.min_amount == null || cartTotal >= limits.min_amount) &&\n * (limits.max_amount == null || cartTotal <= limits.max_amount) &&\n * !limits.excluded_ranges.some(\n * (band) => cartTotal >= band.min_amount && cartTotal <= band.max_amount,\n * ));\n *\n * if (available) render(method.display?.display_name, method.display?.icon_slug);\n * }\n * }\n * ```\n */\n async list(params?: PaymentMethodListParams): Promise<PaymentMethodListResponse> {\n return this.request('GET', '/payment-methods', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /**\n * List all saved payment methods for a customer, optionally filtered.\n *\n * @param customerId - The customer ID.\n * @param params - Optional filters: `client_secret`, `accepted_countries`, `accepted_currencies`,\n * `amount`, `recurring_enabled`, `installment_payment_enabled`, `limit`, `card_networks`.\n * @returns Customer's saved payment methods.\n *\n * @example\n * ```typescript\n * const { customer_payment_methods } = await delopay.paymentMethods.listForCustomer(\n * 'cus_123',\n * { accepted_currencies: ['EUR'], amount: 5000 },\n * );\n * ```\n */\n async listForCustomer(\n customerId: string,\n params?: CustomerPaymentMethodsListParams,\n ): Promise<CustomerPaymentMethodsListResponse> {\n return this.request('GET', `/customers/${encodeURIComponent(customerId)}/payment-methods`, {\n query: params as Record<\n string,\n string | number | boolean | (string | number | boolean)[] | null | undefined\n >,\n });\n }\n\n /**\n * Set a payment method as the default for a customer.\n *\n * @param customerId - The customer ID.\n * @param methodId - The payment method ID to set as default.\n * @returns The updated payment method.\n */\n async setDefault(customerId: string, methodId: string): Promise<PaymentMethodResponse> {\n return this.request(\n 'POST',\n `/customers/${encodeURIComponent(customerId)}/payment-methods/${encodeURIComponent(methodId)}/default`,\n );\n }\n\n // --- Advanced operations (Task 3.3) ---\n\n /** Migrate a payment method. `POST /payment-methods/migrate` */\n async migrate(params: Record<string, unknown>): Promise<PaymentMethodResponse> {\n return this.request('POST', '/payment-methods/migrate', { body: params });\n }\n\n /** Batch migrate payment methods. `POST /payment-methods/migrate-batch` */\n async migrateBatch(params: Record<string, unknown>[]): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/migrate-batch', { body: params });\n }\n\n /** Batch update payment methods. `POST /payment-methods/update-batch` */\n async updateBatch(params: Record<string, unknown>[]): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/update-batch', { body: params });\n }\n\n /** Batch retrieve payment methods. `GET /payment-methods/batch` */\n async batchRetrieve(\n params?: Record<string, string | number | undefined>,\n ): Promise<PaymentMethodResponse[]> {\n return this.request('GET', '/payment-methods/batch', { query: params });\n }\n\n /** Tokenize a card. `POST /payment-methods/tokenize-card` */\n async tokenizeCard(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/tokenize-card', { body: params });\n }\n\n /** Batch tokenize cards. `POST /payment-methods/tokenize-card-batch` */\n async tokenizeCardBatch(params: Record<string, unknown>[]): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/tokenize-card-batch', { body: params });\n }\n\n /** Initiate payment method collect link flow. `POST /payment-methods/collect` */\n async collect(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/collect', { body: params });\n }\n\n /** Save a payment method. `POST /payment-methods/{methodId}/save` */\n async save(methodId: string, params?: Record<string, unknown>): Promise<PaymentMethodResponse> {\n return this.request('POST', `/payment-methods/${encodeURIComponent(methodId)}/save`, {\n body: params,\n });\n }\n\n /** Create payment method auth link token. `POST /payment-methods/auth/link` */\n async createAuthLink(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/auth/link', { body: params });\n }\n\n /** Exchange payment method auth token. `POST /payment-methods/auth/exchange` */\n async exchangeAuthToken(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payment-methods/auth/exchange', { body: params });\n }\n\n /** Tokenize card using existing PM. `POST /payment-methods/{methodId}/tokenize-card` */\n async tokenizeCardForMethod(\n methodId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/payment-methods/${encodeURIComponent(methodId)}/tokenize-card`, {\n body: params,\n });\n }\n}\n","import type {\n PaymentClientContextListResponse,\n PaymentCreateRequest,\n PaymentListFilterConstraints,\n PaymentListFilteredResponse,\n PaymentListResponse,\n PaymentResponse,\n PaymentRetrieveOptions,\n PaymentUpdateRequest,\n PaymentConfirmRequest,\n PaymentCaptureRequest,\n PaymentCancelRequest,\n PaymentListParams,\n PaymentAttemptsListResponse,\n PaymentsDeletePolicyResponse,\n PaymentsDeleteResponse,\n PaymentStatusHistoryResponse,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/** Manage payment intents — create, confirm, capture, cancel, and list payments. */\nexport class Payments {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new payment intent.\n *\n * @param params - Payment creation parameters including amount and currency.\n * @param options - Optional per-call extras: extra `headers` (e.g. an\n * `Idempotency-Key` to make the create safe to retry), a `timeout` override,\n * and an `AbortSignal`.\n * @returns The created payment intent.\n *\n * @example\n * ```typescript\n * const payment = await delopay.payments.create(\n * { amount: 5000, currency: 'EUR', customer_id: 'cus_123' },\n * { headers: { 'Idempotency-Key': 'order_1001' } },\n * );\n * ```\n *\n * @example Send `test_mode` to pick the environment per payment, so a staging\n * deploy cannot charge real cards and a forgotten processor toggle cannot\n * swallow production traffic:\n * ```typescript\n * const payment = await delopay.payments.create({\n * amount: 5000,\n * currency: 'EUR',\n * test_mode: process.env.NODE_ENV !== 'production',\n * });\n * ```\n *\n * A payment that pins one connector through `routing` (the `single` form)\n * is now checked against `test_mode` here rather than at confirm: if that\n * connector has no credentials for the environment asked for, create fails\n * instead of handing back a payment whose checkout the buyer cannot\n * complete. `priority` and `volume_split` name several accounts and are\n * still resolved at confirm.\n */\n async create(params: PaymentCreateRequest, options?: RequestExtras): Promise<PaymentResponse> {\n return this.request('POST', '/payments', { body: params, ...options });\n }\n\n /**\n * Retrieve a payment by its ID.\n *\n * @param paymentId - The unique payment intent ID.\n * @param options - Optional query flags. `force_sync` reconciles the\n * intent's state with the connector before returning (useful to recover\n * a stuck intent when a webhook was lost). `all_keys_required` forces a\n * connector sync even for intents in early states like\n * `requires_payment_method` that would otherwise return the local\n * snapshot. Both flags work with JWT and API-key authentication.\n * @returns The payment intent.\n *\n * @example\n * ```typescript\n * const payment = await delopay.payments.retrieve('pay_abc123');\n * const synced = await delopay.payments.retrieve('pay_abc123', {\n * force_sync: true,\n * all_keys_required: true,\n * });\n * ```\n */\n async retrieve(paymentId: string, options?: PaymentRetrieveOptions): Promise<PaymentResponse> {\n const path = `/payments/${encodeURIComponent(paymentId)}`;\n if (options === undefined) return this.request('GET', path);\n const query: Record<string, boolean> = {};\n if (options.force_sync !== undefined) query['force_sync'] = options.force_sync;\n if (options.all_keys_required !== undefined) {\n query['all_keys_required'] = options.all_keys_required;\n }\n if (Object.keys(query).length === 0) return this.request('GET', path);\n return this.request('GET', path, { query });\n }\n\n /**\n * List every attempt made on a payment, each with its full failure detail\n * (`error_code` / `error_message`, the Delopay-unified `unified_code` and\n * `unified_message`, and structured `error_details`).\n *\n * Useful for surfacing retries across connectors — e.g. \"attempt 1 stripe →\n * insufficient_funds, attempt 2 adyen → success\".\n *\n * `GET /payments/{paymentId}/attempts`\n *\n * @param paymentId - The payment intent ID whose attempts to list.\n * @param options - Optional per-call extras: extra `headers`, a `timeout`\n * override, and an `AbortSignal`.\n * @returns The attempt list — `size` plus a `data` array of attempts.\n * @throws If the payment does not exist or belongs to another merchant (404).\n *\n * @example\n * ```typescript\n * const { size, data } = await delopay.payments.listAttempts('pay_abc123');\n * for (const attempt of data) {\n * console.log(attempt.status, attempt.unified_message ?? attempt.error_message);\n * }\n * ```\n */\n async listAttempts(\n paymentId: string,\n options?: RequestExtras,\n ): Promise<PaymentAttemptsListResponse> {\n return this.request('GET', `/payments/${encodeURIComponent(paymentId)}/attempts`, options);\n }\n\n /**\n * The status timeline of a payment: every recorded creation / status\n * transition of the intent and its attempts, refunds and disputes, oldest\n * first. `complete: false` marks timelines partially reconstructed from\n * current records (payments created before the status log existed).\n *\n * @param paymentId - The payment intent ID.\n * @returns The ordered status-history events.\n *\n * @example\n * ```typescript\n * const { events, complete } = await delopay.payments.listStatusHistory('pay_abc123');\n * for (const event of events) {\n * console.log(event.timestamp, event.entity_type, event.status);\n * }\n * ```\n */\n async listStatusHistory(\n paymentId: string,\n options?: RequestExtras,\n ): Promise<PaymentStatusHistoryResponse> {\n return this.request(\n 'GET',\n `/payments/${encodeURIComponent(paymentId)}/status-history`,\n options,\n );\n }\n\n /**\n * Update an existing payment intent before it is confirmed.\n *\n * @param paymentId - The payment intent ID to update.\n * @param params - Fields to update (amount, currency, metadata, etc.).\n * @returns The updated payment intent.\n */\n async update(paymentId: string, params: PaymentUpdateRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}`, { body: params });\n }\n\n /**\n * Confirm a payment intent, triggering authorisation with the selected gateway.\n *\n * @param paymentId - The payment intent ID to confirm.\n * @param params - Confirmation parameters (payment method data, return URL, etc.).\n * @returns The updated payment intent.\n */\n async confirm(paymentId: string, params: PaymentConfirmRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/confirm`, {\n body: params,\n });\n }\n\n /**\n * Capture a previously authorised payment.\n *\n * @param paymentId - The payment intent ID to capture.\n * @param params - Optional capture parameters (partial capture amount, etc.).\n * @returns The updated payment intent.\n */\n async capture(paymentId: string, params?: PaymentCaptureRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/capture`, {\n body: params,\n });\n }\n\n /**\n * Cancel a payment intent that has not yet been captured.\n *\n * @param paymentId - The payment intent ID to cancel.\n * @param params - Optional cancellation reason.\n * @returns The updated payment intent.\n */\n async cancel(paymentId: string, params?: PaymentCancelRequest): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/cancel`, {\n body: params,\n });\n }\n\n /**\n * List payment intents, optionally filtered by customer or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @param options - Optional per-call extras: extra `headers`, a `timeout`\n * override, and an `AbortSignal` for cancellation.\n * @returns Paginated list of payment intents.\n *\n * @example\n * ```typescript\n * const { data } = await delopay.payments.list({ customer_id: 'cus_123', limit: 25 });\n * ```\n */\n async list(params?: PaymentListParams, options?: RequestExtras): Promise<PaymentListResponse> {\n return this.request('GET', '/payments/list', {\n query: params as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /**\n * The status timeline of client/device observations captured while the\n * buyer interacted with the payment (checkout opens, confirms, redirect\n * legs, reported client signals), oldest first.\n *\n * `GET /payments/{paymentId}/client-context`\n */\n async listClientContext(\n paymentId: string,\n options?: RequestExtras,\n ): Promise<PaymentClientContextListResponse> {\n return this.request(\n 'GET',\n `/payments/${encodeURIComponent(paymentId)}/client-context`,\n options,\n );\n }\n\n /**\n * Soft-delete a payment. Only payments whose status is in the merchant's\n * delete policy (see {@link Payments.getDeletePolicy}) can be deleted;\n * anything else fails with a precondition error.\n *\n * `DELETE /payments/{paymentId}`\n */\n async delete(paymentId: string, options?: RequestExtras): Promise<PaymentsDeleteResponse> {\n return this.request('DELETE', `/payments/${encodeURIComponent(paymentId)}`, options);\n }\n\n /**\n * The effective deletable-status set for the calling merchant — lets a\n * dashboard show the delete action only where it is allowed.\n *\n * `GET /payments/delete-policy`\n */\n async getDeletePolicy(options?: RequestExtras): Promise<PaymentsDeletePolicyResponse> {\n return this.request('GET', '/payments/delete-policy', options);\n }\n\n // --- Advanced operations (Task 3.2) ---\n\n /** Generate session tokens. `POST /payments/session-tokens` */\n async sessionTokens(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/payments/session-tokens', { body: params });\n }\n\n /** Retrieve payment with gateway credentials. `POST /payments/sync` */\n async sync(params: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('POST', '/payments/sync', { body: params });\n }\n\n /** Cancel after partial capture. `POST /payments/{paymentId}/cancel-post-capture` */\n async cancelPostCapture(\n paymentId: string,\n params?: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/cancel-post-capture`, {\n body: params,\n });\n }\n\n /** Incrementally authorize more funds. `POST /payments/{paymentId}/incremental-authorization` */\n async incrementalAuthorization(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request(\n 'POST',\n `/payments/${encodeURIComponent(paymentId)}/incremental-authorization`,\n {\n body: params,\n },\n );\n }\n\n /** Extend authorization window. `POST /payments/{paymentId}/extend-authorization` */\n async extendAuthorization(\n paymentId: string,\n params?: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/extend-authorization`, {\n body: params,\n });\n }\n\n /** Complete authorization. `POST /payments/{paymentId}/complete-authorize` */\n async completeAuthorize(\n paymentId: string,\n params?: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/complete-authorize`, {\n body: params,\n });\n }\n\n /** Dynamic tax calculation. `POST /payments/{paymentId}/calculate-tax` */\n async calculateTax(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/calculate-tax`, {\n body: params,\n });\n }\n\n /** Update payment metadata. `POST /payments/{paymentId}/update-metadata` */\n async updateMetadata(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/update-metadata`, {\n body: params,\n });\n }\n\n /** Retrieve extended card info. `GET /payments/{paymentId}/extended-card-info` */\n async extendedCardInfo(paymentId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/payments/${encodeURIComponent(paymentId)}/extended-card-info`);\n }\n\n // --- OLAP extensions (Task 4.2) ---\n\n /** List payments (profile-scoped). `GET /payments/profile/list` */\n async listByProfile(params?: PaymentListParams): Promise<PaymentListResponse> {\n return this.request('GET', '/payments/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** List payments across all shops. `GET /payments/list-all-shops` */\n async listAllShops(params?: PaymentListParams): Promise<PaymentListResponse> {\n return this.request('GET', '/payments/list-all-shops', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** List payments by filter (POST body). `POST /payments/list` */\n async listByFilter(params: Record<string, unknown>): Promise<PaymentListResponse> {\n return this.request('POST', '/payments/list', { body: params });\n }\n\n /**\n * List payments by filter, scoped to the caller's profile (the shop-user\n * twin of `listByFilter`). The backend narrows to the profile from the\n * auth context, so `profile_id` / `project_id` must not be sent.\n *\n * Not to be confused with {@link Payments.listByProfile}, which is the GET\n * cursor variant and rejects this body.\n *\n * `POST /payments/profile/list`\n */\n async listByProfileFilter(\n params: PaymentListFilterConstraints,\n options?: RequestExtras,\n ): Promise<PaymentListFilteredResponse> {\n return this.request('POST', '/payments/profile/list', { body: params, ...options });\n }\n\n /** Get payment filter options. `GET /payments/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/filter', { query: params });\n }\n\n /**\n * Get payment filter options, scoped to the caller's profile.\n * `GET /payments/profile/filter`\n */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/profile/filter', { query: params });\n }\n\n /** Get payment aggregates. `GET /payments/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/aggregate', { query: params });\n }\n\n /** Get payment aggregates (profile-scoped). `GET /payments/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payments/profile/aggregate', { query: params });\n }\n\n /** Manually update payment status. `PUT /payments/{paymentId}/manual-update` */\n async manualUpdate(paymentId: string, params: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('PUT', `/payments/${encodeURIComponent(paymentId)}/manual-update`, {\n body: params,\n });\n }\n\n /** Approve a payment waiting for review. `POST /payments/{paymentId}/approve` */\n async approve(paymentId: string, params?: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/approve`, {\n body: params,\n });\n }\n\n /** Reject a payment waiting for review. `POST /payments/{paymentId}/reject` */\n async reject(paymentId: string, params?: Record<string, unknown>): Promise<PaymentResponse> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/reject`, {\n body: params,\n });\n }\n\n /** Initiate external 3DS authentication. `POST /payments/{paymentId}/3ds/authentication` */\n async threeDsAuthentication(\n paymentId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/payments/${encodeURIComponent(paymentId)}/3ds/authentication`, {\n body: params,\n });\n }\n}\n","import type {\n PayoutCreateRequest,\n PayoutResponse,\n PayoutUpdateRequest,\n PayoutListParams,\n PayoutListResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage payouts — fund transfers from merchant to a recipient bank account. */\nexport class Payouts {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new payout.\n *\n * @param params - Payout parameters including amount, currency, and destination.\n * @returns The created payout.\n *\n * @example\n * ```typescript\n * const payout = await delopay.payouts.create({\n * amount: 10000,\n * currency: 'EUR',\n * customer_id: 'cus_123',\n * });\n * ```\n */\n async create(params: PayoutCreateRequest): Promise<PayoutResponse> {\n return this.request('POST', '/payouts/create', { body: params });\n }\n\n /**\n * Retrieve a payout by its ID.\n *\n * @param payoutId - The unique payout ID.\n * @returns The payout.\n */\n async retrieve(payoutId: string): Promise<PayoutResponse> {\n return this.request('GET', `/payouts/${encodeURIComponent(payoutId)}`);\n }\n\n /**\n * Update a payout before it is confirmed.\n *\n * @param payoutId - The payout ID to update.\n * @param params - Fields to update.\n * @returns The updated payout.\n */\n async update(payoutId: string, params: PayoutUpdateRequest): Promise<PayoutResponse> {\n return this.request('PUT', `/payouts/${encodeURIComponent(payoutId)}`, { body: params });\n }\n\n /**\n * Confirm a payout, triggering the actual transfer.\n *\n * @param payoutId - The payout ID to confirm.\n * @param params - Optional confirmation parameters.\n * @returns The updated payout.\n */\n async confirm(payoutId: string, params?: PayoutUpdateRequest): Promise<PayoutResponse> {\n return this.request('POST', `/payouts/${encodeURIComponent(payoutId)}/confirm`, {\n body: params,\n });\n }\n\n /**\n * Cancel a payout before it is fulfilled.\n *\n * @param payoutId - The payout ID to cancel.\n * @returns The cancelled payout.\n */\n async cancel(payoutId: string): Promise<PayoutResponse> {\n return this.request('POST', `/payouts/${encodeURIComponent(payoutId)}/cancel`);\n }\n\n /**\n * Mark a payout as fulfilled (manual confirmation of successful transfer).\n *\n * @param payoutId - The payout ID to fulfil.\n * @returns The fulfilled payout.\n */\n async fulfill(payoutId: string): Promise<PayoutResponse> {\n return this.request('POST', `/payouts/${encodeURIComponent(payoutId)}/fulfill`);\n }\n\n /**\n * List payouts, optionally filtered by status or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Paginated list of payouts.\n */\n async list(params?: PayoutListParams): Promise<PayoutListResponse> {\n return this.request('GET', '/payouts/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n // --- OLAP extensions (Task 4.5) ---\n\n /** List payouts (profile-scoped). `GET /payouts/profile/list` */\n async listByProfile(params?: PayoutListParams): Promise<PayoutListResponse> {\n return this.request('GET', '/payouts/profile/list', {\n query: params as Record<string, string | number | undefined>,\n });\n }\n\n /** List payouts by filter (POST body). `POST /payouts/list` */\n async listByFilter(params: Record<string, unknown>): Promise<PayoutListResponse> {\n return this.request('POST', '/payouts/list', { body: params });\n }\n\n /** Get payout filter options. `GET /payouts/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/filter', { query: params });\n }\n\n /** Get payout filters (profile-scoped). `GET /payouts/profile/filter` */\n async getFiltersByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/profile/filter', { query: params });\n }\n\n /** Get payout aggregates. `GET /payouts/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/aggregate', { query: params });\n }\n\n /** Get payout aggregates (profile-scoped). `GET /payouts/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/payouts/profile/aggregate', { query: params });\n }\n\n /** Manually update payout status. `PUT /payouts/{payoutId}/manual-update` */\n async manualUpdate(payoutId: string, params: Record<string, unknown>): Promise<PayoutResponse> {\n return this.request('PUT', `/payouts/${encodeURIComponent(payoutId)}/manual-update`, {\n body: params,\n });\n }\n}\n","import type { PollStatusResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Poll {\n constructor(private readonly request: RequestFn) {}\n\n async getStatus(pollId: string): Promise<PollStatusResponse> {\n return this.request('GET', `/poll/status/${encodeURIComponent(pollId)}`);\n }\n}\n","import type {\n ProfileAcquirerCreateRequest,\n ProfileAcquirerResponse,\n ProfileAcquirerUpdateRequest,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class ProfileAcquirers {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: ProfileAcquirerCreateRequest): Promise<ProfileAcquirerResponse> {\n return this.request('POST', '/profile-acquirer', { body: params });\n }\n\n async update(\n profileId: string,\n profileAcquirerId: string,\n params: ProfileAcquirerUpdateRequest,\n ): Promise<ProfileAcquirerResponse> {\n return this.request(\n 'POST',\n `/profile-acquirer/${encodeURIComponent(profileId)}/${encodeURIComponent(profileAcquirerId)}`,\n {\n body: params,\n },\n );\n }\n}\n","import type { ProfileCreateRequest, ProfileResponse, ProfileUpdateRequest } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Profiles {\n constructor(private readonly request: RequestFn) {}\n\n async create(accountId: string, params: ProfileCreateRequest): Promise<ProfileResponse> {\n return this.request('POST', `/account/${encodeURIComponent(accountId)}/business-profile`, {\n body: params,\n });\n }\n\n async retrieve(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'GET',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}`,\n );\n }\n\n async list(accountId: string): Promise<ProfileResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/business-profile`);\n }\n\n /**\n * List the business profiles the caller can see at profile scope — the\n * `ProfileAccountRead` twin of `list()` (which needs merchant-level read).\n * A shop-scoped user gets exactly their own shop back.\n *\n * `GET /account/{accountId}/profile`\n */\n async listByProfile(accountId: string): Promise<ProfileResponse[]> {\n return this.request('GET', `/account/${encodeURIComponent(accountId)}/profile`);\n }\n\n async update(\n accountId: string,\n profileId: string,\n params: ProfileUpdateRequest,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}`,\n {\n body: params,\n },\n );\n }\n\n async delete(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'DELETE',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}`,\n );\n }\n\n // --- Advanced operations (Task 4.8) ---\n\n /** Toggle extended card info for a profile. `POST /account/{accountId}/business-profile/{profileId}/toggle-extended-card-info` */\n async toggleExtendedCardInfo(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}/toggle-extended-card-info`,\n );\n }\n\n /** Toggle connector agnostic MIT. `POST /account/{accountId}/business-profile/{profileId}/toggle-connector-agnostic-mit` */\n async toggleConnectorAgnosticMit(accountId: string, profileId: string): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/account/${encodeURIComponent(accountId)}/business-profile/${encodeURIComponent(profileId)}/toggle-connector-agnostic-mit`,\n );\n }\n}\n","import type {\n ProjectCreateRequest,\n ProjectResponse,\n ProjectUpdateRequest,\n ProjectStatsResponse,\n MerchantOverviewResponse,\n StatsPeriod,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage projects — optional grouping layers that contain one or more shops. */\nexport class Projects {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a new project under a merchant account.\n *\n * @param params - Project creation parameters (name, description, etc.).\n * @param merchantId - The merchant account ID that owns this project.\n * @returns The created project.\n *\n * @example\n * ```typescript\n * const project = await delopay.projects.create({ name: 'EU Stores' }, 'merch_123');\n * ```\n */\n async create(params: ProjectCreateRequest, merchantId: string): Promise<ProjectResponse> {\n return this.request('POST', '/projects', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve a project by its ID.\n *\n * @param projectId - The unique project ID.\n * @param merchantId - Optional merchant scope. When provided, sent as\n * `?merchant_id=…` — required by dashboards that authenticate with a JWT\n * spanning multiple merchants and need to disambiguate which one this\n * call applies to. API-key callers can omit it.\n * @returns The project.\n */\n async retrieve(projectId: string, merchantId?: string): Promise<ProjectResponse> {\n const path = `/projects/${encodeURIComponent(projectId)}`;\n if (merchantId === undefined) return this.request('GET', path);\n return this.request('GET', path, { query: { merchant_id: merchantId } });\n }\n\n /**\n * Update a project's details.\n *\n * @param projectId - The project ID to update.\n * @param params - Fields to update.\n * @param merchantId - Optional merchant scope. See {@link Projects.retrieve}.\n * @returns The updated project.\n */\n async update(\n projectId: string,\n params: ProjectUpdateRequest,\n merchantId?: string,\n ): Promise<ProjectResponse> {\n const path = `/projects/${encodeURIComponent(projectId)}`;\n if (merchantId === undefined) return this.request('PUT', path, { body: params });\n return this.request('PUT', path, { body: params, query: { merchant_id: merchantId } });\n }\n\n /**\n * Delete a project.\n *\n * @param projectId - The project ID to delete.\n * @param merchantId - Optional merchant scope. See {@link Projects.retrieve}.\n * @returns The deleted project object.\n */\n async delete(projectId: string, merchantId?: string): Promise<ProjectResponse> {\n const path = `/projects/${encodeURIComponent(projectId)}`;\n if (merchantId === undefined) return this.request('DELETE', path);\n return this.request('DELETE', path, { query: { merchant_id: merchantId } });\n }\n\n /**\n * List all projects for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns Array of projects.\n */\n async list(merchantId: string): Promise<ProjectResponse[]> {\n return this.request('GET', '/projects/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Get aggregate payment statistics across all projects for a merchant.\n *\n * The response's flat `shops[]` array holds every shop, including shops that\n * belong to no project — those are absent from `projects[].shops[]`, so look\n * a single shop up in `shops[]`. Requires `MerchantAccountRead`; a\n * shop-scoped user should call {@link Shops.stats} instead.\n *\n * @param merchantId - The merchant account ID.\n * @param period - Window in days, or `'all'` for an all-time total.\n * Omitted means the server default of 30 days.\n * @returns Project statistics.\n *\n * @example\n * ```typescript\n * const stats = await delopay.projects.stats('merch_123', 'all');\n * const shop = stats.shops.find((s) => s.shop_id === 'pro_1');\n * ```\n */\n async stats(merchantId: string, period?: StatsPeriod): Promise<ProjectStatsResponse> {\n const query: Record<string, string> = { merchant_id: merchantId };\n if (period !== undefined) query['period'] = String(period);\n return this.request('GET', '/projects/stats', { query });\n }\n\n /**\n * Get a high-level overview (volume, counts, top connectors) for a merchant.\n *\n * @param merchantId - The merchant account ID.\n * @returns Merchant overview data.\n */\n async overview(merchantId: string): Promise<MerchantOverviewResponse> {\n return this.request('GET', '/projects/overview', {\n query: { merchant_id: merchantId },\n });\n }\n}\n","import type {\n RefundCreateRequest,\n RefundResponse,\n RefundUpdateRequest,\n RefundListParams,\n RefundListResponse,\n RefundAggregateResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/** Create and manage refunds for completed payments. */\nexport class Refunds {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create a refund for a payment.\n *\n * Dashboard-initiated refunds are subject to the caller's operation-limit\n * rule, resolved against the role the request authenticated with. An\n * over-limit refund either fails with `DE_01` (the rule blocks) or with\n * HTTP 409 `DE_06` — the rule requires approval, and `DelopayError.data`\n * carries `PendingApprovalErrorDetails`. No refund exists in either case;\n * `DE_06` names one that a second approver can still let through, via\n * `operationLimits.approve()`.\n *\n * @param params - Refund parameters, including the required `payment_id` and optional amount.\n * @returns The created refund.\n *\n * @example\n * ```typescript\n * const refund = await delopay.refunds.create({\n * payment_id: 'pay_abc123',\n * amount: 2500, // partial refund of 25.00 EUR\n * });\n * ```\n */\n async create(params: RefundCreateRequest): Promise<RefundResponse> {\n return this.request('POST', '/refunds', { body: params });\n }\n\n /**\n * Retrieve a refund by its ID.\n *\n * @param refundId - The unique refund ID.\n * @returns The refund.\n *\n * @example\n * ```typescript\n * const refund = await delopay.refunds.retrieve('ref_abc123');\n * ```\n */\n async retrieve(refundId: string): Promise<RefundResponse> {\n return this.request('GET', `/refunds/${encodeURIComponent(refundId)}`);\n }\n\n /**\n * Update the reason or metadata on an existing refund.\n *\n * @param refundId - The refund ID to update.\n * @param params - Fields to update (reason, metadata).\n * @returns The updated refund.\n */\n async update(refundId: string, params: RefundUpdateRequest): Promise<RefundResponse> {\n return this.request('POST', `/refunds/${encodeURIComponent(refundId)}`, { body: params });\n }\n\n /**\n * List refunds, optionally filtered by payment, status, or date range.\n *\n * @param params - Optional filter and pagination parameters.\n * @returns Paginated list of refunds.\n */\n async list(params?: RefundListParams): Promise<RefundListResponse> {\n return this.request('POST', '/refunds/list', { body: params });\n }\n\n // --- OLAP extensions (Task 4.3) ---\n\n /** List refunds (profile-scoped). `POST /refunds/profile/list` */\n async listByProfile(params?: RefundListParams): Promise<RefundListResponse> {\n return this.request('POST', '/refunds/profile/list', { body: params });\n }\n\n /** Get refund filter options. `GET /refunds/filter` */\n async getFilters(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/refunds/filter', { query: params });\n }\n\n /** Get refund aggregates. `GET /refunds/aggregate` */\n async aggregate(\n params?: Record<string, string | number | undefined>,\n ): Promise<RefundAggregateResponse> {\n return this.request('GET', '/refunds/aggregate', { query: params });\n }\n\n /** Get refund aggregates (profile-scoped). `GET /refunds/profile/aggregate` */\n async aggregateByProfile(\n params?: Record<string, string | number | undefined>,\n ): Promise<RefundAggregateResponse> {\n return this.request('GET', '/refunds/profile/aggregate', { query: params });\n }\n\n /** Manually update refund status. `PUT /refunds/{refundId}/manual-update` */\n async manualUpdate(refundId: string, params: Record<string, unknown>): Promise<RefundResponse> {\n return this.request('PUT', `/refunds/${encodeURIComponent(refundId)}/manual-update`, {\n body: params,\n });\n }\n}\n","import type { RelayRequest, RelayResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Relay {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: RelayRequest): Promise<RelayResponse> {\n return this.request('POST', '/relay', { body: params });\n }\n\n async retrieve(relayId: string): Promise<RelayResponse> {\n return this.request('GET', `/relay/${encodeURIComponent(relayId)}`);\n }\n}\n","import type {\n CheckoutThemeConversionQuery,\n CheckoutThemeConversionResponse,\n CheckoutThemeProgramRequest,\n CheckoutThemeProgramResponse,\n LinkedRoutingConfigRetrieveResponse,\n MerchantRoutingAlgorithm,\n ProfileDefaultRoutingConfig,\n ProfileDeniedConnectorsResponse,\n RoutableConnectorChoice,\n RoutingActivatePayload,\n RoutingConfigCreateRequest,\n RoutingConfigHistoryResponse,\n RoutingConfigUpdateRequest,\n RoutingConnectorCaps,\n RoutingDeactivateRequest,\n RoutingDictionary,\n RoutingDictionaryRecord,\n RoutingHistoryParams,\n SurchargeRuleRequest,\n SurchargeRuleResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Create and manage payment routing algorithms.\n *\n * Routing rules determine which gateway connector handles each payment based on\n * card type, currency, amount, or custom conditions.\n */\nexport class Routing {\n readonly decision: RoutingDecisionManager;\n /** Merchant-friendly, per-payment-method surcharge rules (no Euclid DSL). */\n readonly surchargeRules: SurchargeRules;\n /** Which stored appearance variant a buyer is shown. Decides a look, never a payment. */\n readonly checkoutThemeRules: CheckoutThemeRules;\n /** Rendered-to-paid conversion per appearance variant and segment. */\n readonly checkoutThemeConversion: CheckoutThemeConversion;\n\n constructor(private readonly request: RequestFn) {\n this.decision = new RoutingDecisionManager(request);\n this.surchargeRules = new SurchargeRules(request);\n this.checkoutThemeRules = new CheckoutThemeRules(request);\n this.checkoutThemeConversion = new CheckoutThemeConversion(request);\n }\n\n /**\n * Create a new routing algorithm.\n *\n * @param params - Routing algorithm definition (rule-based, priority, or volume-based).\n * @returns Metadata record for the created routing configuration. The full\n * algorithm body is not echoed back — use `retrieve(id)` if you need it.\n *\n * @example\n * ```typescript\n * const config = await delopay.routing.create({\n * name: 'EU Priority',\n * algorithm: { type: 'priority', data: [{ connector: 'stripe' }] },\n * });\n * ```\n *\n * @example Conditional volume split (advanced): cards → 90% epayouts / 10% stripe.\n * Rules run top-down (first match wins); `defaultSelection` is the fallback.\n * Splits must sum to 100; `amount` conditions are in minor units.\n * ```typescript\n * const config = await delopay.routing.create({\n * name: 'Card split 90/10',\n * profile_id: 'pro_...',\n * algorithm: {\n * type: 'advanced',\n * data: {\n * defaultSelection: { type: 'priority', data: [{ connector: 'stripe' }] },\n * rules: [\n * {\n * name: 'cards',\n * connectorSelection: {\n * type: 'volume_split',\n * data: [\n * { connector: { connector: 'epayouts' }, split: 90 },\n * { connector: { connector: 'stripe' }, split: 10 },\n * ],\n * },\n * statements: [\n * {\n * condition: [\n * {\n * lhs: 'payment_method',\n * comparison: 'equal',\n * value: { type: 'enum_variant', value: 'card' },\n * metadata: {},\n * },\n * ],\n * },\n * ],\n * },\n * ],\n * metadata: {},\n * },\n * },\n * });\n * await delopay.routing.activate(config.id);\n * ```\n */\n async create(params: RoutingConfigCreateRequest): Promise<RoutingDictionaryRecord> {\n return this.request('POST', '/routing', { body: params });\n }\n\n /**\n * Retrieve a routing algorithm by its ID.\n *\n * @param algorithmId - The routing algorithm ID.\n * @returns The full routing configuration including the algorithm body.\n */\n async retrieve(algorithmId: string): Promise<MerchantRoutingAlgorithm> {\n return this.request('GET', `/routing/${encodeURIComponent(algorithmId)}`);\n }\n\n /**\n * Activate a routing algorithm, making it the active routing strategy.\n *\n * Always sends a JSON body (default `{}`) so the request carries the\n * `Content-Type: application/json` header that the server requires.\n *\n * @param algorithmId - The routing algorithm ID to activate.\n * @param params - Optional activation payload (e.g. `transaction_type`).\n */\n async activate(\n algorithmId: string,\n params: RoutingActivatePayload = {},\n ): Promise<RoutingDictionaryRecord> {\n return this.request('POST', `/routing/${encodeURIComponent(algorithmId)}/activate`, {\n body: params,\n });\n }\n\n /**\n * Deactivate the currently active routing algorithm (falls back to default routing).\n *\n * Always sends a JSON body (default `{}`) so the request carries the\n * `Content-Type: application/json` header that the server requires.\n *\n * @param params - Optional deactivation payload.\n */\n async deactivate(params: RoutingDeactivateRequest = {}): Promise<RoutingDictionaryRecord> {\n return this.request('POST', '/routing/deactivate', { body: params });\n }\n\n /**\n * Edit a static routing configuration.\n *\n * Partial: send only the fields to change. `name`/`description` are\n * metadata-only; `algorithm` is a wholesale rule replacement, validated\n * against the shop exactly as at create. `modified_at` is bumped either way.\n *\n * `PUT /routing/{algorithmId}`\n *\n * @param algorithmId - The routing algorithm ID to edit.\n * @param params - The fields to change (at least one required).\n * @returns The updated routing configuration including the algorithm body.\n */\n async update(\n algorithmId: string,\n params: RoutingConfigUpdateRequest,\n ): Promise<MerchantRoutingAlgorithm> {\n return this.request('PUT', `/routing/${encodeURIComponent(algorithmId)}`, { body: params });\n }\n\n /**\n * Every content window a routing configuration has had, oldest first.\n *\n * A configuration's rule can be edited in place, so this is what makes \"which\n * rule decided this payment\" answerable after the fact. Each entry is the rule\n * as it stood between `valid_from` and `valid_until`; the windows of one\n * config abut exactly, with no gap.\n *\n * Paging covers the whole timeline including the live window, so a page never\n * holds more than `limit` entries and the live one — the only entry without a\n * `valid_until` — comes back on exactly one page. Advance `offset` by `limit`;\n * a page past the end is empty, and `total_count` says where that end is\n * without probing for it.\n *\n * `GET /routing/{algorithmId}/history`\n *\n * @param algorithmId - The routing algorithm to read the history of.\n * @param params - Optional paging.\n */\n async history(\n algorithmId: string,\n params: RoutingHistoryParams = {},\n ): Promise<RoutingConfigHistoryResponse> {\n return this.request('GET', `/routing/${encodeURIComponent(algorithmId)}/history`, {\n query: params as Record<string, number | null | undefined>,\n });\n }\n\n /**\n * A shop's lifetime per-connector payment caps, each with how much of it is\n * already spent.\n *\n * `GET /routing/connector-caps/{profileId}`\n */\n async connectorCaps(profileId: string): Promise<RoutingConnectorCaps> {\n return this.request('GET', `/routing/connector-caps/${encodeURIComponent(profileId)}`);\n }\n\n /**\n * Replace a shop's per-connector payment caps.\n *\n * Whole-set replacement, not a patch: the list sent becomes the complete set\n * of capped connectors, and an empty list clears them all — which is how\n * acquirer onboarding finishes, the new account ceasing to be a special case.\n *\n * Every account named must belong to this shop; one that does not is refused.\n *\n * `PUT /routing/connector-caps/{profileId}`\n */\n async setConnectorCaps(\n profileId: string,\n params: RoutingConnectorCaps,\n ): Promise<RoutingConnectorCaps> {\n return this.request('PUT', `/routing/connector-caps/${encodeURIComponent(profileId)}`, {\n body: params,\n });\n }\n\n /**\n * List all routing algorithms for the current merchant.\n *\n * @returns The routing dictionary (records + currently active id).\n */\n async list(): Promise<RoutingDictionary> {\n return this.request('GET', '/routing');\n }\n\n /**\n * Connector names denied at routing for a shop (explicit denies plus\n * whitelist-implied exclusions). Read-only; surfaced in the routing builder.\n *\n * `GET /routing/connector-restrictions/{profileId}`\n */\n async connectorRestrictions(profileId: string): Promise<ProfileDeniedConnectorsResponse> {\n return this.request('GET', `/routing/connector-restrictions/${encodeURIComponent(profileId)}`);\n }\n\n // --- Advanced operations (Task 3.4) ---\n\n /** Get active routing config. `GET /routing/active` */\n async getActive(): Promise<LinkedRoutingConfigRetrieveResponse> {\n return this.request('GET', '/routing/active');\n }\n\n /** Update default routing config. `POST /routing/default` */\n async updateDefault(params: Record<string, unknown>): Promise<RoutableConnectorChoice[]> {\n return this.request('POST', '/routing/default', { body: params });\n }\n\n /** Retrieve default config for profiles. `GET /routing/default/profile` */\n async getDefaultProfile(): Promise<RoutableConnectorChoice[] | ProfileDefaultRoutingConfig[]> {\n return this.request('GET', '/routing/default/profile');\n }\n\n /** Update default config for a profile. `POST /routing/default/profile/{profileId}` */\n async updateDefaultProfile(\n profileId: string,\n params: Record<string, unknown>,\n ): Promise<ProfileDefaultRoutingConfig> {\n return this.request('POST', `/routing/default/profile/${encodeURIComponent(profileId)}`, {\n body: params,\n });\n }\n\n /** List routing configs for profile. `GET /routing/list/profile` */\n async listForProfile(): Promise<RoutingDictionary> {\n return this.request('GET', '/routing/list/profile');\n }\n\n /** Evaluate a routing rule. `POST /routing/rule/evaluate` */\n async evaluateRule(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/rule/evaluate', { body: params });\n }\n\n /** Migrate routing rules for profile. `POST /routing/rule/migrate` */\n async migrateRule(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/rule/migrate', { body: params });\n }\n\n /** Evaluate routing for a payment. `POST /routing/evaluate` */\n async evaluate(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/evaluate', { body: params });\n }\n\n /** Update gateway scores for dynamic routing. `POST /routing/feedback` */\n async feedback(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/routing/feedback', { body: params });\n }\n}\n\nclass RoutingDecisionManager {\n constructor(private readonly request: RequestFn) {}\n\n /** Upsert decision manager config. `PUT /routing/decision` */\n async upsert(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', '/routing/decision', { body: params });\n }\n\n /** Retrieve decision manager config. `GET /routing/decision` */\n async retrieve(): Promise<Record<string, unknown>> {\n return this.request('GET', '/routing/decision');\n }\n\n /** Delete decision manager config. `DELETE /routing/decision` */\n async delete(): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/routing/decision');\n }\n\n /** Upsert surcharge decision config. `PUT /routing/decision/surcharge` */\n async upsertSurcharge(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', '/routing/decision/surcharge', { body: params });\n }\n\n /** Retrieve surcharge decision config. `GET /routing/decision/surcharge` */\n async retrieveSurcharge(): Promise<Record<string, unknown>> {\n return this.request('GET', '/routing/decision/surcharge');\n }\n\n /** Delete surcharge decision config. `DELETE /routing/decision/surcharge` */\n async deleteSurcharge(): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/routing/decision/surcharge');\n }\n}\n\n/**\n * Merchant-friendly surcharge rules: configure a per-payment-method surcharge\n * (fixed or %) added to the amount the buyer pays — without hand-writing the\n * Euclid DSL. Scope to a shop via `profile_id` (omit for merchant-wide).\n *\n * Distinct from the platform fee (a balance deduction): a surcharge changes what\n * the buyer is charged.\n */\nclass SurchargeRules {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create or replace the surcharge program for a scope.\n *\n * `PUT /routing/surcharge/rules`\n *\n * @example\n * ```typescript\n * await delopay.routing.surchargeRules.upsert({\n * surcharges: [\n * { payment_method: 'crypto', surcharge: { rate: { percent: 1.0 } } },\n * { payment_method: 'card', surcharge: { fixed: { amount: 35 } } },\n * ],\n * });\n * ```\n */\n async upsert(params: SurchargeRuleRequest): Promise<SurchargeRuleResponse> {\n return this.request('PUT', '/routing/surcharge/rules', { body: params });\n }\n\n /**\n * Retrieve the active surcharge program for a scope, or `null` when none is set.\n *\n * `GET /routing/surcharge/rules?profile_id={profileId}`\n *\n * @param profileId - Shop scope. Omit for the merchant-wide rule.\n */\n async retrieve(profileId?: string): Promise<SurchargeRuleResponse | null> {\n return this.request('GET', '/routing/surcharge/rules', {\n query: { profile_id: profileId },\n });\n }\n\n /**\n * Deactivate the active surcharge program for a scope.\n *\n * `DELETE /routing/surcharge/rules?profile_id={profileId}`\n *\n * @param profileId - Shop scope. Omit for the merchant-wide rule.\n */\n async delete(profileId?: string): Promise<void> {\n return this.request('DELETE', '/routing/surcharge/rules', {\n query: { profile_id: profileId },\n });\n }\n}\n\n/**\n * Checkout theme programs: which of a shop's stored appearance variants a buyer\n * is shown.\n *\n * Same engine and same wire format as the advanced routing rules above — a\n * Euclid program whose rules run top-down, first match wins, with\n * `defaultSelection` as the fallback — with the output swapped for a variant\n * name. That is deliberate: the dashboard's routing rule builder can author\n * these without learning a second condition language.\n *\n * **A theme program decides a look and nothing else.** It cannot express which\n * payment methods are offered, what is charged, which provider processes the\n * payment, or whether it succeeds. The allowed dimensions are fixed server-side\n * by the output type — see {@link CheckoutThemeDimension} — so that is a\n * property of the API rather than a convention.\n *\n * Naming a variant the shop has not defined is **not** an error: the checkout\n * falls back to the shop default, exactly as it does for an unknown `?theme=`,\n * because a buyer who cannot pay is worse than a buyer who sees the default\n * look. Such names come back in `warnings` instead, recomputed on every read.\n */\nclass CheckoutThemeRules {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create or replace the theme program for a scope.\n *\n * `PUT /routing/checkout-theme/rules`\n *\n * Supersedes rather than overwrites: the previous active version is retired\n * and a new one stored, so the record of which look was live when survives.\n * Pass `active: false` to store a revision **without** retiring the live one —\n * that is where a program drafted against a variant you have not built yet\n * belongs.\n *\n * @example A phone in Germany gets the compact look; everyone else the house style.\n * ```typescript\n * await delopay.routing.checkoutThemeRules.upsert({\n * name: 'Autumn targeting',\n * profile_id: 'pro_...',\n * algorithm: {\n * rules: [\n * {\n * name: 'German phones',\n * connectorSelection: { theme: { variant: 'compact' } },\n * statements: [\n * {\n * condition: [\n * {\n * lhs: 'device_class',\n * comparison: 'equal',\n * value: { type: 'enum_variant', value: 'phone' },\n * metadata: {},\n * },\n * {\n * lhs: 'browser_language',\n * comparison: 'equal',\n * value: { type: 'enum_variant', value: 'de' },\n * metadata: {},\n * },\n * ],\n * },\n * ],\n * },\n * ],\n * defaultSelection: { theme: { variant: 'house' } },\n * metadata: {},\n * },\n * });\n * ```\n */\n async upsert(params: CheckoutThemeProgramRequest): Promise<CheckoutThemeProgramResponse> {\n return this.request('PUT', '/routing/checkout-theme/rules', { body: params });\n }\n\n /**\n * Retrieve the active theme program for a scope, or `null` when none is set.\n *\n * `GET /routing/checkout-theme/rules?profile_id={profileId}`\n *\n * @param profileId - Shop scope. Omit for the merchant-wide program. A\n * shop-scoped caller that omits it gets its own shop's program.\n */\n async retrieve(profileId?: string): Promise<CheckoutThemeProgramResponse | null> {\n return this.request('GET', '/routing/checkout-theme/rules', {\n query: { profile_id: profileId },\n });\n }\n\n /**\n * Deactivate the active theme program for a scope. Idempotent.\n *\n * `DELETE /routing/checkout-theme/rules?profile_id={profileId}`\n *\n * Deactivation, not deletion — the stored row is what says which look was\n * live when, and that history cannot be reconstructed after the fact. Shops\n * go back to their default appearance immediately.\n *\n * @param profileId - Shop scope. Omit for the merchant-wide program.\n */\n async delete(profileId?: string): Promise<void> {\n return this.request('DELETE', '/routing/checkout-theme/rules', {\n query: { profile_id: profileId },\n });\n }\n}\n\n/**\n * Rendered-to-paid conversion, per appearance variant and segment.\n *\n * Answers the one question theme targeting exists for: *does variant B convert\n * better than the house style, on phones, in Germany?*\n *\n * **What a rate here means.** The denominator is backend-observed checkout page\n * opens, deduplicated by device within the hosted checkout's cache window, with\n * automated traffic excluded from both sides. It is narrower than \"paints\", and\n * that is deliberate - counting one buyer's refresh as a second render would\n * understate conversion. The exact basis travels with every response in\n * `denominator`, and the ways it is not the whole truth travel in `caveats`.\n *\n * **The server decides what may be concluded, not you.** Rate, Wilson interval,\n * per-cell `verdict` and the variant-vs-default `separates` test are computed\n * once, server-side, and shipped as values. Do not recompute them: the first\n * client that rounds differently tells a merchant a difference is real when the\n * server says it is not.\n */\nclass CheckoutThemeConversion {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Rendered-to-paid conversion for a shop over a window.\n *\n * `GET /routing/checkout-theme/conversion`\n *\n * Requires `CheckoutBranding` read at profile scope - the same permission\n * that governs seeing how a checkout looks.\n *\n * @param params - Window (RFC3339, `start` inclusive / `end` exclusive), the\n * shop, and the dimension to group by.\n *\n * @example Which variant wins on which device, over the last 30 days.\n * ```typescript\n * const report = await delopay.routing.checkoutThemeConversion.retrieve({\n * profile_id: 'pro_...',\n * start: '2026-07-21T00:00:00Z',\n * end: '2026-08-20T00:00:00Z',\n * segment: 'device',\n * });\n *\n * for (const c of report.comparisons) {\n * if (!c.separates) continue; // \"not shown to differ\" - say nothing\n * console.log(`${c.variant} on ${c.segment}: ${c.higher} converts better`);\n * }\n * ```\n */\n async retrieve(params: CheckoutThemeConversionQuery): Promise<CheckoutThemeConversionResponse> {\n return this.request('GET', '/routing/checkout-theme/conversion', {\n query: {\n profile_id: params.profile_id,\n start: params.start,\n end: params.end,\n segment: params.segment,\n },\n });\n }\n}\n","import type { RequestFn } from '../client';\n\n/** Index discriminator returned for each search result group. */\nexport type SearchIndex =\n | 'payment_attempts'\n | 'payment_intents'\n | 'refunds'\n | 'disputes'\n | 'payouts'\n | 'sessionizer_payment_attempts'\n | 'sessionizer_payment_intents'\n | 'sessionizer_refunds'\n | 'sessionizer_disputes'\n | 'routing_rules'\n | 'webhook_events'\n | 'audit_logs'\n | 'subscriptions';\n\nexport type SearchStatus = 'Success' | 'Failure';\n\n/** One result group (per index) in the response array. */\nexport interface SearchGroupResponse {\n count: number;\n index: SearchIndex;\n hits: Record<string, unknown>[];\n status: SearchStatus;\n}\n\n/**\n * The window a global search covers. The documented wire fields are\n * `start_time` (required) and `end_time` (optional — omit it for \"up to\n * now\"); the server also accepts the camelCase spellings as aliases, which\n * earlier SDK versions sent, so both are declared and either compiles.\n * Prefer the snake_case pair: it is what the operation documents.\n */\nexport type SearchTimeRange =\n | { start_time: string; end_time?: string | null }\n /** @deprecated Use `start_time` / `end_time` — the documented wire names. */\n | { startTime: string; endTime?: string | null };\n\nexport interface GlobalSearchRequest {\n query: string;\n filters?: Record<string, unknown>;\n /** Naive ISO 8601 bounds; `end_time` may be omitted. */\n timeRange?: SearchTimeRange;\n /** Wire alias for `timeRange` — the server reads either. */\n time_range?: SearchTimeRange;\n}\n\n/** Global cross-index search. */\nexport class Search {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Search every supported index for `query`.\n * `POST /analytics/search`\n *\n * @example\n * ```typescript\n * const groups = await delopay.search.global({ query: 'pay_abc' });\n * for (const g of groups) console.log(g.index, g.count);\n * ```\n */\n async global(\n params: GlobalSearchRequest,\n options?: { signal?: AbortSignal },\n ): Promise<SearchGroupResponse[]> {\n return this.request('POST', '/analytics/search', {\n body: params,\n ...(options?.signal ? { signal: options.signal } : {}),\n });\n }\n}\n","import type {\n CheckoutBrandingUpdate,\n ShopCreateRequest,\n ShopResponse,\n ShopUpdateRequest,\n GatewayConnectRequest,\n GatewayResponse,\n ProfileLogoUploadResponse,\n ProfileResponse,\n ShopStatsResponse,\n StatsPeriod,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/** Manage gateway connections for a specific shop. */\nclass ShopGateways {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Connect a payment gateway to a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID.\n * @param params - Gateway connector credentials and configuration.\n * @returns The created gateway connection.\n */\n async connect(\n merchantId: string,\n shopId: string,\n params: GatewayConnectRequest,\n ): Promise<GatewayResponse> {\n return this.request(\n 'POST',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/gateways`,\n { body: params },\n );\n }\n\n /**\n * List all gateway connections for a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID.\n * @returns Array of gateway connections.\n */\n async list(merchantId: string, shopId: string): Promise<GatewayResponse[]> {\n return this.request(\n 'GET',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/gateways`,\n );\n }\n\n /**\n * Disconnect a gateway from a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID.\n * @param gatewayId - The gateway connector ID to remove.\n * @returns The removed gateway connection.\n */\n async disconnect(\n merchantId: string,\n shopId: string,\n gatewayId: string,\n ): Promise<GatewayResponse> {\n return this.request(\n 'DELETE',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/gateways/${encodeURIComponent(gatewayId)}`,\n );\n }\n}\n\n/**\n * Create and manage shops (business profiles) within a merchant account.\n *\n * Each shop can have its own gateway connections, routing rules, and fee schedules.\n */\nexport class Shops {\n /** Gateway connection management for shops. */\n readonly gateways: ShopGateways;\n\n constructor(private readonly request: RequestFn) {\n this.gateways = new ShopGateways(request);\n }\n\n /**\n * Create a new shop under a merchant account.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Shop creation parameters (name, etc.).\n * @returns The created shop.\n *\n * @example\n * ```typescript\n * const shop = await delopay.shops.create('merch_123', { shop_name: 'EU Store' });\n * ```\n */\n async create(merchantId: string, params: ShopCreateRequest): Promise<ShopResponse> {\n return this.request('POST', `/shops/${encodeURIComponent(merchantId)}`, { body: params });\n }\n\n /**\n * Retrieve a shop by its ID.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID.\n * @returns The shop.\n */\n async retrieve(merchantId: string, shopId: string): Promise<ShopResponse> {\n return this.request(\n 'GET',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}`,\n );\n }\n\n /**\n * Update a shop's configuration.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID to update.\n * @param params - Fields to update.\n * @returns The updated shop.\n */\n async update(\n merchantId: string,\n shopId: string,\n params: ShopUpdateRequest,\n ): Promise<ShopResponse> {\n return this.request(\n 'PUT',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}`,\n { body: params },\n );\n }\n\n /**\n * Delete a shop.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop ID to delete.\n * @returns The deleted shop object.\n */\n async delete(merchantId: string, shopId: string): Promise<ShopResponse> {\n return this.request(\n 'DELETE',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}`,\n );\n }\n\n /**\n * List all shops under a merchant account.\n *\n * @param merchantId - The merchant account ID.\n * @returns Array of shops.\n */\n async list(merchantId: string): Promise<ShopResponse[]> {\n return this.request('GET', `/shops/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Successful-order count and revenue for one shop.\n *\n * Unlike `projects.stats()` this needs only `ProfileAccountRead`, so a\n * shop-scoped user can load it for their own shop; merchant-level users can\n * load any shop of their merchant.\n *\n * Revenue comes back FX-converted as `revenue_usd` (USD major units) plus a\n * `revenue_by_currency` breakdown. The legacy `revenue` field is a raw\n * cross-currency minor-unit sum and should not be displayed.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID.\n * @param period - Window in days, or `'all'` for an all-time total.\n * Omitted means the server default of 30 days.\n * @returns The shop's stats over the requested window.\n *\n * @example\n * ```typescript\n * const stats = await delopay.shops.stats('merch_123', 'pro_1', 'all');\n * console.log(stats.orders, stats.revenue_usd);\n * ```\n */\n async stats(\n merchantId: string,\n shopId: string,\n period?: StatsPeriod,\n ): Promise<ShopStatsResponse> {\n const path = `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/stats`;\n if (period === undefined) return this.request('GET', path);\n return this.request('GET', path, { query: { period: String(period) } });\n }\n\n /**\n * Upload a logo file for a shop. The file is stored in Delopay's configured\n * object store and a public HTTPS URL is returned. This method does NOT write\n * the URL into the shop's `payment_link_config.logo` — call\n * `shops.update` afterwards with the returned `logo_url` to persist the change.\n *\n * Accepts PNG, JPEG, WebP or SVG. The file must be ≤ 1 MiB.\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID.\n * @param file - The logo file (Blob / File in browsers).\n * @returns The publicly-reachable URL of the uploaded logo.\n *\n * @example\n * ```typescript\n * const { logo_url } = await delopay.shops.uploadLogo('merch_1', 'pro_1', file);\n * await delopay.shops.update('merch_1', 'pro_1', {\n * payment_link_config: { logo: logo_url },\n * });\n * ```\n */\n async uploadLogo(\n merchantId: string,\n shopId: string,\n file: Blob,\n ): Promise<ProfileLogoUploadResponse> {\n const form = new FormData();\n form.append('file', file);\n return this.request(\n 'POST',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/logo`,\n { body: form },\n );\n }\n\n /**\n * Update only the checkout appearance (the `payment_link_config` blob:\n * theme, logo, colours, seller name, SDK layout/rules, DeloPay-branding\n * toggle) of a shop. Applied as a whole-object replace of\n * `payment_link_config`, mirroring the shop-update semantics.\n *\n * Gated on the dedicated `CheckoutBranding` permission, so \"may restyle\n * the checkout\" can be granted without full account/shop write.\n *\n * `POST /shops/{merchantId}/{shopId}/checkout-branding`\n *\n * @param merchantId - The merchant account ID.\n * @param shopId - The shop (business profile) ID to restyle.\n * @param params - The new `payment_link_config` blob (full replacement).\n * @returns The updated business profile.\n */\n async updateCheckoutBranding(\n merchantId: string,\n shopId: string,\n params: CheckoutBrandingUpdate,\n options?: RequestExtras,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/shops/${encodeURIComponent(merchantId)}/${encodeURIComponent(shopId)}/checkout-branding`,\n { body: params, ...options },\n );\n }\n}\n","import type {\n StripeConnectAccountRequest,\n StripeConnectAccountResponse,\n StripeConnectLinkRequest,\n StripeConnectLinkResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class StripeConnect {\n constructor(private readonly request: RequestFn) {}\n\n async createAccount(params: StripeConnectAccountRequest): Promise<StripeConnectAccountResponse> {\n return this.request('POST', '/connector-onboarding/stripe/accounts', { body: params });\n }\n\n async createAccountLink(params: StripeConnectLinkRequest): Promise<StripeConnectLinkResponse> {\n return this.request('POST', '/connector-onboarding/stripe/account-links', { body: params });\n }\n\n // --- Generic connector onboarding (Task 4.11) ---\n\n /** Get onboarding action URL. `POST /connector-onboarding/action-url` */\n async getActionUrl(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/connector-onboarding/action-url', { body: params });\n }\n\n /** Sync onboarding status. `POST /connector-onboarding/sync` */\n async syncOnboarding(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/connector-onboarding/sync', { body: params });\n }\n\n /** Reset tracking ID. `POST /connector-onboarding/reset-tracking-id` */\n async resetTrackingId(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/connector-onboarding/reset-tracking-id', { body: params });\n }\n}\n","import type { ThreeDsRuleExecuteRequest, ThreeDsRuleResponse } from '../types';\nimport type { RequestFn } from '../client';\n\nexport class ThreeDsRules {\n constructor(private readonly request: RequestFn) {}\n\n async execute(params: ThreeDsRuleExecuteRequest): Promise<ThreeDsRuleResponse> {\n return this.request('POST', '/three-ds-decision/execute', { body: params });\n }\n}\n","import type {\n SignUpRequest,\n SignUpWithMerchantRequest,\n SignInRequest,\n AuthResponse,\n UserResponse,\n ChangePasswordRequest,\n DeleteAccountRequest,\n ForgotPasswordRequest,\n ResetPasswordRequest,\n SwitchMerchantRequest,\n SwitchProfileRequest,\n ImpersonateEmployeeRequest,\n InviteUsersRequest,\n InviteUsersResponse,\n AddUserRequest,\n AddUserResponse,\n UpdateUserRoleRequest,\n DeleteUserRoleRequest,\n TotpResponse,\n RecoveryCodesResponse,\n PhoneOtpRequest,\n PhoneOtpResponse,\n PhoneOtpVerifyRequest,\n PhoneOtpVerifyResponse,\n UpdateMetadataRequest,\n UpdateUserDetailsRequest,\n FromEmailRequest,\n TokenResponse,\n VerifyTotpRequest,\n Terminate2faQueryParams,\n ListInvitableRolesParams,\n ListUsersInLineageParams,\n UserInLineage,\n LoginHistoryParams,\n LoginHistoryResponse,\n UserSessionListResponse,\n UserSessionRevokeResponse,\n ParentGroupInfo,\n RoleConnectorGrant,\n UpdateRoleConnectorGrantParams,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Users {\n constructor(private readonly request: RequestFn) {}\n\n async signUp(params: SignUpRequest | SignUpWithMerchantRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/signup', { body: params });\n }\n\n async signIn(params: SignInRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/signin', { body: params });\n }\n\n async signOut(): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/signout');\n }\n\n /**\n * Sliding-session refresh: exchange the current (still-valid) login JWT\n * for a fresh one with the same claims and a full lifetime. The backend\n * keeps the session's identity (`jti`), slides `user_session.expires_at`\n * forward and re-sets the `login_token` cookie.\n *\n * Requires a token backed by a revocable session (a `jti` claim). Signin\n * and switch-merchant/-profile tokens have one; **session-less tokens do\n * not and are rejected with 400** — team-impersonation tokens are the\n * case in practice, and they are deliberately tab-scoped and\n * time-bounded rather than renewable. A 400 here is not a dead session:\n * the token remains valid for ordinary calls, it simply cannot slide.\n *\n * Rejected (401) for expired, blacklisted or revoked tokens — refresh can\n * only extend a session that is still alive. Rate-limited server-side\n * (429) to one mint per session per minute; treat a 429 as \"still fresh\n * enough\", not as an error.\n *\n * The returned token is NOT applied to this client automatically — pass\n * it to `setJwtToken()`, or use {@link Delopay.refreshSession} which does\n * both.\n *\n * `POST /user/token/refresh`. Requires a logged-in JWT.\n */\n async refreshToken(): Promise<TokenResponse> {\n return this.request('POST', '/user/token/refresh');\n }\n\n /**\n * Paginated login history for the authenticated user -- IP, User-Agent,\n * country / city / lat-lon (when GeoIP is enabled), success and failure\n * events with their reasons. Strictly scoped to the JWT subject; a user\n * can only see their own activity.\n *\n * `GET /user/me/login-activity`. Requires a logged-in JWT.\n *\n * Returns an empty page when a Delopay admin is impersonating a merchant,\n * so the admin's metadata is not exposed inside the merchant dashboard.\n */\n async listLoginActivity(params?: LoginHistoryParams): Promise<LoginHistoryResponse> {\n if (params === undefined) {\n return this.request('GET', '/user/me/login-activity');\n }\n return this.request('GET', '/user/me/login-activity', {\n query: params as Record<string, number | undefined>,\n });\n }\n\n /**\n * List the authenticated user's currently-active dashboard sessions\n * (one row per minted login JWT that hasn't been revoked or expired).\n *\n * The row matching the JWT making this call has `is_current: true`,\n * which is what lets the dashboard render a \"This device\" tag.\n *\n * `GET /user/me/sessions`. Requires a logged-in JWT. Returns an empty\n * list when a Delopay admin is impersonating a non-admin merchant\n * (same guard as `listLoginActivity`).\n */\n async listActiveSessions(): Promise<UserSessionListResponse> {\n return this.request('GET', '/user/me/sessions');\n }\n\n /**\n * Disconnect one of the authenticated user's sessions. The matching\n * JWT is rejected on its next request — fast-path via Redis, fall back\n * to the persistent `revoked_at` column.\n *\n * Idempotent: revoking an already-revoked or unknown id returns 404,\n * which the caller can treat as success for retry purposes. Revoking\n * a session id that belongs to a different user also returns 404 —\n * the response intentionally doesn't leak whether the id exists.\n *\n * `POST /user/me/sessions/{sessionId}/revoke`.\n */\n async revokeSession(sessionId: string): Promise<UserSessionRevokeResponse> {\n return this.request('POST', `/user/me/sessions/${encodeURIComponent(sessionId)}/revoke`);\n }\n\n async getDetails(): Promise<UserResponse> {\n return this.request('GET', '/user');\n }\n\n async update(params: UpdateUserDetailsRequest): Promise<UserResponse> {\n return this.request('POST', '/user/update', { body: params });\n }\n\n /**\n * RFC 7396 merge-patch the caller's own user-scoped metadata bucket.\n * Returns the full user details, so callers can refresh their context\n * without a second fetch.\n *\n * `PATCH /user/metadata`\n */\n async updateMetadata(params: UpdateMetadataRequest): Promise<UserResponse> {\n return this.request('PATCH', '/user/metadata', { body: params });\n }\n\n /**\n * RFC 7396 merge-patch the merchant-scoped metadata bucket shared by\n * every dashboard user of the merchant. Same response contract as\n * {@link Users.updateMetadata}.\n *\n * `PATCH /user/merchant/metadata`\n */\n async updateMerchantMetadata(params: UpdateMetadataRequest): Promise<UserResponse> {\n return this.request('PATCH', '/user/merchant/metadata', { body: params });\n }\n\n /**\n * Permanently delete the caller's account. Requires a fresh password\n * (and a current 6-digit TOTP code if the user has TOTP enrolled). On\n * success all role assignments are removed, the user record is\n * deactivated, and all in-flight sessions are invalidated. The caller\n * should clear local credentials and route to the login page.\n *\n * Returns `InvalidDeleteOperation` when the caller is the sole\n * owner-level admin of an org / merchant / profile -- they must\n * transfer ownership first.\n */\n async deleteAccount(params: DeleteAccountRequest): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/user/account', { body: params });\n }\n\n async changePassword(params: ChangePasswordRequest): Promise<UserResponse> {\n return this.request('POST', '/user/change-password', { body: params });\n }\n\n async rotatePassword(params: ResetPasswordRequest): Promise<UserResponse> {\n return this.request('POST', '/user/rotate-password', { body: params });\n }\n\n async forgotPassword(params: ForgotPasswordRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/forgot-password', { body: params });\n }\n\n /**\n * Commit a password reset.\n *\n * The caller is responsible for obtaining a `SinglePurposeToken` with\n * `purpose: reset_password` via the email-token exchange + TOTP flow\n * (see `fromEmail`, `beginTotp`, `updateTotp`/`verifyTotp`,\n * `generateRecoveryCodes`, `terminate2fa`) and setting it on the client\n * via `setJwtToken` before calling this method. `body.token` must still\n * be the original `EmailToken` from the reset-link URL — the handler\n * decodes it a second time to find the user.\n */\n async resetPassword(params: ResetPasswordRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/reset-password', { body: params });\n }\n\n /**\n * Exchange an email-link token (`EmailToken`) for a single-purpose JWT\n * that drives the next step of the flow (TOTP, verify email, accept\n * invitation, etc.). No authentication required.\n *\n * The `token_type` in the response tells you which step to run next.\n */\n async fromEmail(params: FromEmailRequest): Promise<TokenResponse> {\n return this.request('POST', '/user/from-email', { body: params });\n }\n\n async verifyEmail(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/verify-email', { body: params });\n }\n\n async sendVerificationEmail(params: ForgotPasswordRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/verify-email-request', { body: params });\n }\n\n async createMerchant(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/create-merchant', { body: params });\n }\n\n async switchMerchant(params: SwitchMerchantRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/switch/merchant', { body: params });\n }\n\n async switchProfile(params: SwitchProfileRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/switch/profile', { body: params });\n }\n\n async listMerchants(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/list/merchant');\n }\n\n async listProfiles(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/list/profile');\n }\n\n async inviteUsers(params: InviteUsersRequest[]): Promise<InviteUsersResponse[]> {\n return this.request('POST', '/user/employees/invite', { body: params });\n }\n\n /**\n * Add a team member directly, without sending an invite email.\n * `POST /user/employees/add`\n *\n * Unlike `inviteUsers`, the account is active immediately and you hand over\n * the credentials yourself. Omit `password` to have the server generate one\n * and return it once in `password` on the response; supply your own and it is\n * not echoed back. Either way the member must change it on first sign-in.\n *\n * Same role rules as invite: you cannot grant a role above your own, and a\n * shop-scoped caller can only target their own shop.\n */\n async addUser(params: AddUserRequest): Promise<AddUserResponse> {\n return this.request('POST', '/user/employees/add', { body: params });\n }\n\n /**\n * Impersonate one of your own team members — `POST /user/employees/impersonate`.\n *\n * Mints a session token **as** the given member, so the dashboard renders\n * exactly what they see (useful for support and role verification). The\n * caller needs the *Impersonation* permission, and the member's role must\n * rank **strictly below** the caller's (`Profile < Merchant < Organization`);\n * the server rejects self-impersonation, cross-merchant targets, and\n * equal/higher roles.\n *\n * The returned token is tab-scoped by design: open it in a fresh tab (e.g.\n * `/auth/impersonate?token=…`) rather than replacing the caller's own\n * session. No auth cookie is set on the response.\n */\n async impersonateEmployee(params: ImpersonateEmployeeRequest): Promise<TokenResponse> {\n return this.request('POST', '/user/employees/impersonate', { body: params });\n }\n\n async acceptInvitation(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/employees/invite/accept', { body: params });\n }\n\n /**\n * Accept an invitation via the email-link flow.\n *\n * Caller must already hold a `SinglePurposeToken` with\n * `purpose: accept_invitation_from_email` (obtained via `fromEmail` + any\n * required TOTP step) and have set it on the client via `setJwtToken`.\n * `body.token` must still be the original `EmailToken` from the\n * invite-link URL — the handler decodes it a second time to find the\n * invitee and the entity lineage.\n */\n async acceptInviteFromEmail(params: FromEmailRequest): Promise<AuthResponse> {\n return this.request('POST', '/user/accept-invite-from-email', { body: params });\n }\n\n /**\n * Start TOTP setup (or no-op if already set).\n *\n * Returns the QR-code payload when the user has no TOTP configured yet;\n * returns `{ secret: null }` when the user is already set up (caller\n * should then prompt for a 6-digit code and call `verifyTotp`).\n *\n * Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async beginTotp(): Promise<TotpResponse> {\n return this.request('GET', '/user/2fa/totp/begin');\n }\n\n /**\n * Verify a 6-digit TOTP code for a user whose TOTP is already set up.\n * Marks the code as used in Redis so subsequent flow steps can advance.\n *\n * Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async verifyTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/2fa/totp/verify', { body: params });\n }\n\n async resetTotp(): Promise<Record<string, unknown>> {\n return this.request('GET', '/user/2fa/totp/reset');\n }\n\n async generateRecoveryCodes(): Promise<RecoveryCodesResponse> {\n return this.request('GET', '/user/2fa/recovery-code/generate');\n }\n\n async verifyRecoveryCode(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/2fa/recovery-code/verify', { body: params });\n }\n\n async sendPhoneOtp(params: PhoneOtpRequest): Promise<PhoneOtpResponse> {\n return this.request('POST', '/user/phone/send-otp', { body: params });\n }\n\n async verifyPhoneOtp(params: PhoneOtpVerifyRequest): Promise<PhoneOtpVerifyResponse> {\n return this.request('POST', '/user/phone/verify-otp', { body: params });\n }\n\n /**\n * List all roles visible to the caller (predefined + custom).\n *\n * `GET /user/role/list`. With `groups: true` the response is the\n * parent-groups shape: `[{role_id, role_name, entity_type, role_scope,\n * parent_groups: [{name, description, scopes}]}]`; without it, the\n * deprecated flat `groups` shape.\n */\n async listRoles(params?: {\n groups?: boolean;\n entity_type?: string;\n }): Promise<Record<string, unknown>[]> {\n if (params === undefined) {\n return this.request('GET', '/user/role/list');\n }\n return this.request('GET', '/user/role/list', {\n query: { groups: params.groups, entity_type: params.entity_type },\n });\n }\n\n async listUserRoles(params?: Record<string, unknown>): Promise<Record<string, unknown>[]> {\n return this.request('POST', '/user/employees', { body: params });\n }\n\n /**\n * Change a team member's role. `POST /user/employees/update-role`\n *\n * Pass `profile_id` to name the shop when managing a shop's team as a\n * merchant-scoped admin — see {@link UpdateUserRoleRequest.profile_id}.\n */\n async updateUserRole(params: UpdateUserRoleRequest): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/employees/update-role', { body: params });\n }\n\n /**\n * Remove a team member. `DELETE /user/employees/delete`\n *\n * Pass `profile_id` to name the shop when managing a shop's team as a\n * merchant-scoped admin — see {@link DeleteUserRoleRequest.profile_id}.\n */\n async deleteUserRole(params: DeleteUserRoleRequest): Promise<Record<string, unknown>> {\n return this.request('DELETE', '/user/employees/delete', { body: params });\n }\n\n /** Sign in via OIDC. `POST /user/oidc` */\n async signInOidc(params: Record<string, unknown>): Promise<AuthResponse> {\n return this.request('POST', '/user/oidc', { body: params });\n }\n\n /** Transfer key. `POST /user/key/transfer` */\n async transferKey(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/key/transfer', { body: params });\n }\n\n /** List invitations. `GET /user/list/invitation` */\n async listInvitations(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/list/invitation');\n }\n\n /** Check 2FA status. `GET /user/2fa` */\n async check2faStatus(): Promise<Record<string, unknown>> {\n return this.request('GET', '/user/2fa');\n }\n\n /**\n * Finish first-time TOTP setup: commit the secret generated by `beginTotp`\n * against a 6-digit code from the user's authenticator app.\n *\n * `PUT /user/2fa/totp/verify`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async updateTotp(params: VerifyTotpRequest): Promise<Record<string, unknown>> {\n return this.request('PUT', '/user/2fa/totp/verify', { body: params });\n }\n\n /**\n * Complete the TOTP step and advance to the next flow stage (e.g.\n * `reset_password`). Returns a fresh single-purpose token with the\n * next `token_type`.\n *\n * `GET /user/2fa/terminate`. Requires `Authorization: Bearer <SPT{purpose:totp}>`.\n */\n async terminate2fa(query?: Terminate2faQueryParams): Promise<TokenResponse> {\n if (query === undefined) {\n return this.request('GET', '/user/2fa/terminate');\n }\n return this.request('GET', '/user/2fa/terminate', {\n query: query as Record<string, boolean | undefined>,\n });\n }\n\n /** Create auth method. `POST /user/auth` */\n async createAuthMethod(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/auth', { body: params });\n }\n\n /** Update auth method. `PUT /user/auth` */\n async updateAuthMethod(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', '/user/auth', { body: params });\n }\n\n /** List auth methods. `GET /user/auth/list` */\n async listAuthMethods(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/auth/list');\n }\n\n /** Get auth URL. `GET /user/auth/url` */\n async getAuthUrl(): Promise<Record<string, unknown>> {\n return this.request('GET', '/user/auth/url');\n }\n\n /** Select auth method. `POST /user/auth/select` */\n async selectAuth(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/auth/select', { body: params });\n }\n\n /**\n * List users in lineage.\n *\n * Needs the Users *view* grant now — the response carries colleagues' email\n * addresses, so a role without it is refused rather than handed a roster.\n * A shop-scoped role keeps reading its own shop's members.\n *\n * `GET /user/employees/list`\n */\n async listUsersInLineage(params?: ListUsersInLineageParams): Promise<UserInLineage[]> {\n return this.request('GET', '/user/employees/list', {\n query: params as Record<string, string | undefined> | undefined,\n });\n }\n\n /** Resend invite. `POST /user/resend-invite` */\n async resendInvite(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/resend-invite', { body: params });\n }\n\n /**\n * Get the caller's parent permission groups + scopes.\n *\n * `GET /user/role`\n */\n async getRolePermissions(): Promise<ParentGroupInfo[]> {\n return this.request('GET', '/user/role');\n }\n\n /**\n * List invitable roles. `GET /user/role/list/invite`\n *\n * @param params - Optional query. `entity_type` scopes the role list to a\n * particular entity (e.g. `'merchant'` to list only merchant-scoped roles\n * when inviting employees from the merchant dashboard).\n */\n async listInvitableRoles(params?: ListInvitableRolesParams): Promise<Record<string, unknown>[]> {\n if (params === undefined || params.entity_type === undefined) {\n return this.request('GET', '/user/role/list/invite');\n }\n return this.request('GET', '/user/role/list/invite', {\n query: { entity_type: params.entity_type },\n });\n }\n\n /** List updatable roles. `GET /user/role/list/update` */\n async listUpdatableRoles(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/role/list/update');\n }\n\n /** Get parent list. `GET /user/parent/list` */\n async getParentList(): Promise<Record<string, unknown>[]> {\n return this.request('GET', '/user/parent/list');\n }\n\n /** Create a role. `POST /user/role` */\n async createRole(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/user/role', { body: params });\n }\n\n /** Get role by ID. `GET /user/role/{roleId}` */\n async getRoleById(roleId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/user/role/${encodeURIComponent(roleId)}`);\n }\n\n /** Update role by ID. `PUT /user/role/{roleId}` */\n async updateRole(\n roleId: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('PUT', `/user/role/${encodeURIComponent(roleId)}`, { body: params });\n }\n\n /**\n * Delete a custom role. Predefined roles and roles still assigned to\n * team members are rejected by the backend with a 400.\n *\n * `DELETE /user/role/{roleId}`\n */\n async deleteRole(roleId: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/user/role/${encodeURIComponent(roleId)}`);\n }\n\n /**\n * Read which individual connector accounts a role may see.\n *\n * `GET /user/role/{roleId}/connectors`\n *\n * **Check `restricted` before reading `connectors`.** An empty list is\n * ambiguous by itself, so the backend states which case it is: `false` means\n * the role holds no grant and sees whatever its entity and profile scope\n * already allowed. Rendering an empty `connectors` array as \"this role sees\n * nothing\" inverts the meaning.\n *\n * Requires the permission that *edits a role*, not a connector permission.\n */\n async getRoleConnectors(roleId: string): Promise<RoleConnectorGrant> {\n return this.request('GET', `/user/role/${encodeURIComponent(roleId)}/connectors`);\n }\n\n /**\n * Replace the set of connector accounts a role may see.\n *\n * `PUT /user/role/{roleId}/connectors`\n *\n * The call **replaces** the whole set rather than adding to it, so send the\n * complete list every time. An empty `merchant_connector_ids` clears the\n * grant and returns the role to unrestricted.\n *\n * The backend refuses an id that is not a connector account of the caller's\n * own merchant, an `Organization`-scoped role (a connector account belongs to\n * exactly one merchant, so an org-spanning role cannot hold one coherently),\n * and any predefined role (one static entry shared by every tenant).\n *\n * Editing a grant invalidates the role cache and blacklists tokens minted\n * before the edit, so **users holding this role must sign in again**. Worth\n * saying in the UI before the save, not after.\n */\n async updateRoleConnectors(\n roleId: string,\n params: UpdateRoleConnectorGrantParams,\n ): Promise<RoleConnectorGrant> {\n return this.request('PUT', `/user/role/${encodeURIComponent(roleId)}/connectors`, {\n body: params,\n });\n }\n}\n","import type {\n ApplePayVerificationRequest,\n ApplePayVerificationResponse,\n ApplePayVerifiedDomainsResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\nexport class Verification {\n constructor(private readonly request: RequestFn) {}\n\n async registerApplePayDomains(\n merchantId: string,\n params: ApplePayVerificationRequest,\n ): Promise<ApplePayVerificationResponse> {\n return this.request('POST', `/verify/apple-pay/${encodeURIComponent(merchantId)}`, {\n body: params,\n });\n }\n\n async getApplePayVerifiedDomains(\n params: Record<string, string>,\n ): Promise<ApplePayVerifiedDomainsResponse> {\n return this.request('GET', '/verify/applepay-verified-domains', {\n query: params,\n });\n }\n}\n","import type {\n EventType,\n PaymentResponse,\n RefundResponse,\n DisputeResponse,\n MandateResponse,\n PayoutResponse,\n ConfirmSubscriptionResponse,\n} from '../types';\n\n/**\n * The payload of a webhook event, tagged by kind.\n *\n * Mirrors the backend's `{ \"type\": …, \"object\": … }` envelope: `type` names the\n * payload shape and `object` carries it. Narrow on `content.type` to get a\n * fully-typed `object`:\n *\n * ```typescript\n * if (event.content.type === 'payment_details') {\n * event.content.object.payment_id; // typed as PaymentResponse\n * }\n * ```\n */\nexport type WebhookContent =\n | { type: 'payment_details'; object: PaymentResponse }\n | { type: 'refund_details'; object: RefundResponse }\n | { type: 'dispute_details'; object: DisputeResponse }\n | { type: 'mandate_details'; object: MandateResponse }\n | { type: 'payout_details'; object: PayoutResponse }\n | { type: 'subscription_details'; object: ConfirmSubscriptionResponse };\n\n/**\n * A parsed and verified Delopay webhook event.\n *\n * Matches the signed wire body exactly:\n * `{ merchant_id, event_id, event_type, content: { type, object }, timestamp }`.\n *\n * - `event_type` identifies the event, e.g. `'payment_succeeded'`.\n * - `content.type` tags the payload kind, e.g. `'payment_details'`.\n * - `content.object` is the payload; narrow on `content.type` to type it.\n */\nexport interface WebhookEvent {\n /** ID of the merchant that owns this event. */\n merchant_id: string;\n /** Unique ID for this event (stable across delivery retries). */\n event_id: string;\n /** Event type identifier, e.g. `'payment_succeeded'` or `'refund_succeeded'`. */\n event_type: EventType;\n /** The event payload, tagged by kind. Narrow on `content.type` to type `object`. */\n content: WebhookContent;\n /** ISO 8601 timestamp at which the webhook was sent. */\n timestamp: string;\n}\n\nfunction hexToBytes(hex: string): Uint8Array | null {\n if (hex.length === 0 || hex.length % 2 !== 0) return null;\n const bytes = new Uint8Array(hex.length / 2);\n for (let i = 0; i < hex.length; i += 2) {\n const byte = Number.parseInt(hex.slice(i, i + 2), 16);\n if (Number.isNaN(byte)) return null;\n bytes[i / 2] = byte;\n }\n return bytes;\n}\n\nexport const Webhooks = {\n /**\n * Verify the signature of an incoming Delopay webhook and return the parsed event.\n *\n * Delopay signs each outgoing webhook with HMAC-SHA512 over the raw request body,\n * using your shop's webhook secret (the *payment response hash key* configured on\n * the shop). The hex-encoded digest is delivered in the `X-Webhook-Signature-512`\n * HTTP header.\n *\n * Uses the Web Crypto API (`globalThis.crypto.subtle`), so it runs unchanged in\n * Node 18+, modern browsers, Deno, Bun, and edge runtimes (Cloudflare Workers, Vercel Edge).\n *\n * Available as a static property on the `Delopay` class\n * (`Delopay.webhooks.verify`) and does not require a client instance.\n *\n * @param rawBody - The raw request body. Pass the original bytes (`Uint8Array` /\n * `Buffer`) when possible; if you pass a string, it must be the unmodified UTF-8\n * text of the request body. Do **not** parse it before passing.\n * @param signatureHeader - The value of the `X-Webhook-Signature-512` HTTP header.\n * @param secret - Your shop's webhook signing secret.\n * @returns Promise that resolves to the parsed webhook event.\n * @throws {Error} When the signature header is malformed or does not match the body.\n *\n * @example\n * ```typescript\n * // Express example\n * app.post('/webhook', express.raw({ type: 'application/json' }), async (req, res) => {\n * try {\n * const event = await Delopay.webhooks.verify(\n * req.body, // Buffer from express.raw()\n * req.header('x-webhook-signature-512') ?? '',\n * process.env.DELOPAY_WEBHOOK_SECRET!,\n * );\n * console.log(event.event_type, event.content.object);\n * res.sendStatus(200);\n * } catch {\n * res.status(400).send('Invalid signature');\n * }\n * });\n * ```\n */\n async verify(\n rawBody: string | Uint8Array,\n signatureHeader: string,\n secret: string,\n ): Promise<WebhookEvent> {\n const subtle = globalThis.crypto?.subtle;\n if (!subtle) {\n throw new Error(\n 'Web Crypto unavailable: Delopay.webhooks.verify requires globalThis.crypto.subtle (Node 18+, modern browsers, Workers, Deno)',\n );\n }\n\n const signatureBytes = hexToBytes(signatureHeader.trim());\n if (!signatureBytes) {\n throw new Error('Invalid webhook signature format');\n }\n\n const encoder = new TextEncoder();\n const bodyBytes = typeof rawBody === 'string' ? encoder.encode(rawBody) : rawBody;\n\n // `TextEncoder.encode` returns `Uint8Array<ArrayBufferLike>` in current lib.dom.d.ts,\n // but `crypto.subtle.*` wants `BufferSource` (backed by `ArrayBuffer`). At runtime the\n // underlying buffer is always an `ArrayBuffer` — cast to quiet the type checker.\n const asBufferSource = (bytes: Uint8Array): BufferSource => bytes as unknown as BufferSource;\n const key = await subtle.importKey(\n 'raw',\n asBufferSource(encoder.encode(secret)),\n { name: 'HMAC', hash: 'SHA-512' },\n false,\n ['verify'],\n );\n\n const valid = await subtle.verify(\n 'HMAC',\n key,\n asBufferSource(signatureBytes),\n asBufferSource(bodyBytes),\n );\n\n if (!valid) {\n throw new Error('Invalid webhook signature');\n }\n\n const bodyText =\n typeof rawBody === 'string' ? rawBody : new TextDecoder('utf-8').decode(rawBody);\n return JSON.parse(bodyText) as WebhookEvent;\n },\n};\n","import type { RequestFn } from '../client';\nimport type {\n AnalyticsScopeRequest,\n AnalyticsScopeResponse,\n ClientAnalyticsRequest,\n DevicesAnalyticsResponse,\n GeoAnalyticsResponse,\n DeviceDrillRequest,\n GeoDrillRequest,\n DrillResponse,\n SubscriptionAnalyticsRequest,\n SubscriptionAnalyticsResponse,\n SubscriptionDrillRequest,\n} from '../types';\n\nexport class Analytics {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Scoped, drill-level analytics dashboard for the authenticated merchant\n * (the same engine as the admin portal, pinned server-side to your own\n * merchant). The server ignores `merchant_id` — it always scopes to your\n * merchant, and to your single shop for profile-scoped users — so pass only\n * `project_id` / `shop_id` to drill and the window / `sections` fields.\n * Returns one drill level: the scope's daily series + previous window,\n * processor mix and direct children. `GET /analytics/scope`\n */\n async scope(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/analytics/scope', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Device analytics over the canonical client-context observation per\n * payment (browser/platform families, device classes and models, checkout\n * channel mix, time-to-pay), pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`. Gated on the\n * client-context optimisation-use switch: when it is off the server answers\n * 200 with `enabled: false` and a caveat naming the switch.\n * `GET /analytics/devices`\n */\n async devices(params?: ClientAnalyticsRequest): Promise<DevicesAnalyticsResponse> {\n return this.request('GET', '/analytics/devices', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Geo analytics over the canonical client-context observation per payment:\n * country totals, city bubbles (IP mode), buyer languages, buyer-local\n * purchase hours and the IP-vs-billing mismatch share. `mode` selects the\n * location claim (`ip` default, `billing`); the two are never coalesced.\n * Same drill, window and gating contract as `devices`.\n * `GET /analytics/geo`\n */\n async geo(params?: ClientAnalyticsRequest): Promise<GeoAnalyticsResponse> {\n return this.request('GET', '/analytics/geo', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked geo target: a map country (in the\n * active claim mode), optionally narrowed to an IP-resolved city, or one\n * buyer-local heatmap cell (`dow` + `hour`, paid sessions only). Same\n * window/scope/filter and gating contract as `geo`; capped at 50 rows,\n * newest first, with the full match count alongside.\n * `GET /analytics/geo/transactions`\n */\n async geoTransactions(params: GeoDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/geo/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked device target: exactly one of a\n * browser family, a platform family, an identified device-model label, or\n * a device class. Family/model targets are resolved server-side with the\n * same classifiers the cards use. Same window/scope/filter and gating\n * contract as `devices`; 50 rows per page (`offset` for the next page),\n * newest first, with the full match count alongside.\n * `GET /analytics/devices/transactions`\n */\n async deviceTransactions(params: DeviceDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/devices/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Subscription analytics over `subscription` and `invoice`: estimated\n * recurring volume, the invoice funnel, movement (new / expansion /\n * contraction / churn), both processor axes, plan mix and the breakdown one\n * level below the scope. Pinned server-side to your own merchant and\n * drillable via `project_id` / `shop_id` exactly like `scope`.\n *\n * Half the figures are **stocks** — a snapshot at the window's end rather\n * than a sum over it — so `est_monthly_volume_usd` and `active` can match\n * across a 7-day and a 30-day window while `billed_volume_usd` does not.\n * Day granularity only. `GET /analytics/subscriptions`\n */\n async subscriptions(\n params?: SubscriptionAnalyticsRequest,\n ): Promise<SubscriptionAnalyticsResponse> {\n return this.request('GET', '/analytics/subscriptions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The billing cycles behind one clicked element of the subscription\n * dashboard: an invoice outcome, a processor slice on either axis, a plan\n * row, a subscription status, a movement component, a series bucket or a\n * breakdown row. Same window/scope/filter contract as `subscriptions`; 50\n * rows per page (`offset` for the next), newest first, with the full match\n * count alongside.\n *\n * A cycle that never reached a payment is listed too — that is what \"still\n * unpaid\" means — and carries its invoice id as `payment_id` with\n * `invoice_id` set to the same value, so you can always tell which you got.\n * `GET /analytics/subscriptions/list`\n */\n async subscriptionsList(params: SubscriptionDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/analytics/subscriptions/list', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point, and the query builder\n // only ever reads own enumerable keys.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /** Global search. `POST /analytics/search` */\n async search(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/search', { body: params });\n }\n\n /** Domain-specific search. `POST /analytics/search/{domain}` */\n async searchDomain(\n domain: string,\n params: Record<string, unknown>,\n ): Promise<Record<string, unknown>> {\n return this.request('POST', `/analytics/search/${encodeURIComponent(domain)}`, {\n body: params,\n });\n }\n\n /** Get analytics info. `GET /analytics/{domain}/info` */\n async getInfo(domain: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/analytics/${encodeURIComponent(domain)}/info`);\n }\n\n /** Get API event logs. `GET /analytics/api-event-logs` */\n async apiEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/api-event-logs', { query: params });\n }\n\n /** Get SDK event logs. `POST /analytics/sdk-event-logs` */\n async sdkEventLogs(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics/sdk-event-logs', { body: params });\n }\n\n /** Get connector event logs. `GET /analytics/connector-event-logs` */\n async connectorEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/connector-event-logs', { query: params });\n }\n\n /** Get routing event logs. `GET /analytics/routing-event-logs` */\n async routingEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/routing-event-logs', { query: params });\n }\n\n /** Get outgoing webhook event logs. `GET /analytics/outgoing-webhook-event-logs` */\n async outgoingWebhookEventLogs(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics/outgoing-webhook-event-logs', { query: params });\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class AnalyticsDashboard {\n constructor(private readonly request: RequestFn) {}\n\n /** Get analytics dashboard data. `GET /analytics-dashboard` */\n async retrieve(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/analytics-dashboard', { query: params });\n }\n\n /** Generate analytics dashboard report. `POST /analytics-dashboard` */\n async generate(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/analytics-dashboard', { body: params });\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Cards {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a card. `POST /cards/create` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/cards/create', { body: params });\n }\n\n /** Update a card. `POST /cards/update` */\n async update(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/cards/update', { body: params });\n }\n\n /** Retrieve card info by BIN. `GET /cards/{bin}` */\n async retrieve(bin: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/cards/${encodeURIComponent(bin)}`);\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Export {\n constructor(private readonly request: RequestFn) {}\n\n /** Export transactions. `POST /export/transactions` */\n async transactions(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/export/transactions', { body: params });\n }\n}\n","import type { FeatureMatrixResponse } from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * What each connector can do: payment methods, capture methods, webhook\n * flows, and whether an unverified webhook is acted on.\n */\nexport class FeatureMatrix {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve the feature matrix. `GET /feature-matrix` */\n async retrieve(): Promise<FeatureMatrixResponse> {\n return this.request('GET', '/feature-matrix');\n }\n\n /**\n * Retrieve the feature matrix scoped to a merchant. Beta connectors\n * are filtered against the merchant's allowlist so the dashboard only\n * surfaces connectors the merchant can actually attach.\n * `GET /feature-matrix/{merchantId}`\n */\n async retrieveForMerchant(merchantId: string): Promise<FeatureMatrixResponse> {\n return this.request('GET', `/feature-matrix/${encodeURIComponent(merchantId)}`);\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Files {\n constructor(private readonly request: RequestFn) {}\n\n /** Upload a file. `POST /files` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/files', { body: params });\n }\n\n /** Retrieve/download a file. `GET /files/{fileId}` */\n async retrieve(fileId: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/files/${encodeURIComponent(fileId)}`);\n }\n\n /** Delete a file. `DELETE /files/{fileId}` */\n async delete(fileId: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/files/${encodeURIComponent(fileId)}`);\n }\n}\n","import type { RequestFn } from '../client';\n\nexport class Forex {\n constructor(private readonly request: RequestFn) {}\n\n /** Retrieve forex rates. `GET /forex/rates` */\n async getRates(\n params?: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/rates', { query: params });\n }\n\n /** Convert from minor currency. `GET /forex/convert-from-minor` */\n async convertFromMinor(\n params: Record<string, string | number | undefined>,\n ): Promise<Record<string, unknown>> {\n return this.request('GET', '/forex/convert-from-minor', { query: params });\n }\n}\n","import type {\n RegionCreateRequest,\n RegionUpdateRequest,\n RegionResponse,\n RegionSetCountriesRequest,\n RegionCountriesResponse,\n BuiltInRegionGroupResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Custom regions (named country groups) scoped to a shop/profile, used by the\n * geo-aware payment-method availability overrides. Every endpoint is scoped by\n * `profileId`. Admin (`sk_*`) access required.\n */\nexport class Regions {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a region. `POST /regions?profile_id=` */\n async create(profileId: string, params: RegionCreateRequest): Promise<RegionResponse> {\n return this.request('POST', '/regions', {\n body: params,\n query: { profile_id: profileId },\n });\n }\n\n /** List all regions for a profile. `GET /regions/list?profile_id=` */\n async list(profileId: string): Promise<RegionResponse[]> {\n return this.request('GET', '/regions/list', { query: { profile_id: profileId } });\n }\n\n /** List the built-in (global) region groups (EU/EEA/SEPA/LATAM/APAC). `GET /regions/groups` */\n async groups(): Promise<BuiltInRegionGroupResponse[]> {\n return this.request('GET', '/regions/groups');\n }\n\n /** Retrieve a region by id. `GET /regions/{regionId}?profile_id=` */\n async retrieve(regionId: string, profileId: string): Promise<RegionResponse> {\n return this.request('GET', `/regions/${encodeURIComponent(regionId)}`, {\n query: { profile_id: profileId },\n });\n }\n\n /** Update a region. `PUT /regions/{regionId}?profile_id=` */\n async update(\n regionId: string,\n profileId: string,\n params: RegionUpdateRequest,\n ): Promise<RegionResponse> {\n return this.request('PUT', `/regions/${encodeURIComponent(regionId)}`, {\n body: params,\n query: { profile_id: profileId },\n });\n }\n\n /** Delete a region. `DELETE /regions/{regionId}?profile_id=` */\n async delete(regionId: string, profileId: string): Promise<boolean> {\n return this.request('DELETE', `/regions/${encodeURIComponent(regionId)}`, {\n query: { profile_id: profileId },\n });\n }\n\n /** Get the countries that belong to a region. `GET /regions/{regionId}/countries?profile_id=` */\n async getCountries(regionId: string, profileId: string): Promise<RegionCountriesResponse> {\n return this.request('GET', `/regions/${encodeURIComponent(regionId)}/countries`, {\n query: { profile_id: profileId },\n });\n }\n\n /** Replace the full country membership of a region. `PUT /regions/{regionId}/countries?profile_id=` */\n async setCountries(\n regionId: string,\n profileId: string,\n params: RegionSetCountriesRequest,\n ): Promise<RegionCountriesResponse> {\n return this.request('PUT', `/regions/${encodeURIComponent(regionId)}/countries`, {\n body: params,\n query: { profile_id: profileId },\n });\n }\n}\n","import type {\n AvailabilityOverrideCreateRequest,\n AvailabilityOverrideResponse,\n AvailabilityPreviewParams,\n AvailabilityPreviewResponse,\n} from '../types';\nimport type { RequestFn } from '../client';\n\n/**\n * Merchant payment-method availability overrides. Force-show or force-hide a\n * payment method per country/region at global, project, or shop scope, on top\n * of the curated country defaults. Admin (`sk_*`) access required.\n */\nexport class AvailabilityOverrides {\n constructor(private readonly request: RequestFn) {}\n\n /** Create an availability override. `POST /availability-overrides` */\n async create(params: AvailabilityOverrideCreateRequest): Promise<AvailabilityOverrideResponse> {\n return this.request('POST', '/availability-overrides', { body: params });\n }\n\n /** List a merchant's availability overrides. `GET /availability-overrides` */\n async list(merchantId: string): Promise<AvailabilityOverrideResponse[]> {\n return this.request('GET', '/availability-overrides', {\n query: { merchant_id: merchantId },\n });\n }\n\n /** Delete an availability override by id. `DELETE /availability-overrides/{id}` */\n async delete(id: string): Promise<boolean> {\n return this.request('DELETE', `/availability-overrides/${encodeURIComponent(id)}`);\n }\n\n /**\n * Preview the methods a customer in `country` would be shown for a shop —\n * the connector ceiling narrowed by the smart country defaults and the\n * merchant overrides, without an active payment. Pass `amount` + `currency`\n * to also evaluate order-value rules.\n * `GET /availability-overrides/preview`\n */\n async preview(params: AvailabilityPreviewParams): Promise<AvailabilityPreviewResponse> {\n return this.request('GET', '/availability-overrides/preview', {\n query: {\n merchant_id: params.merchant_id,\n profile_id: params.profile_id,\n ...(params.country ? { country: params.country } : {}),\n // `0` is a legitimate order value, so test for presence, not truthiness.\n ...(params.amount !== undefined ? { amount: params.amount } : {}),\n ...(params.currency ? { currency: params.currency } : {}),\n },\n });\n }\n}\n","import type {\n CreateSubscriptionRequest,\n CreateAndConfirmSubscriptionRequest,\n ConfirmSubscriptionRequest,\n UpdateSubscriptionRequest,\n PauseSubscriptionRequest,\n ResumeSubscriptionRequest,\n CancelSubscriptionRequest,\n SubscriptionResponse,\n ConfirmSubscriptionResponse,\n PauseSubscriptionResponse,\n ResumeSubscriptionResponse,\n CancelSubscriptionResponse,\n GetSubscriptionItemsResponse,\n GetSubscriptionItemsParams,\n SubscriptionEstimateResponse,\n SubscriptionEstimateParams,\n SubscriptionListParams,\n SubscriptionPaymentLookupRequest,\n SubscriptionPaymentLookupResponse,\n SubscriptionInvoiceListParams,\n SubscriptionInvoiceListResponse,\n SubscriptionBillingProcessorResponse,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Subscription endpoints are profile-scoped: the backend requires an\n * `X-Profile-Id` header to resolve the shop / billing processor (`IR_04`\n * otherwise). Pass it through the per-call `options.headers`, e.g.\n * `subscriptions.list(params, { headers: { 'X-Profile-Id': profileId } })`.\n */\nexport class Subscriptions {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create and immediately confirm a subscription. `POST /subscriptions`\n *\n * For billing processors that require buyer approval (e.g. PayPal), the\n * response carries a `redirect_url` the customer must be sent to.\n */\n async createAndConfirm(\n params: CreateAndConfirmSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.request('POST', '/subscriptions', { body: params, ...options });\n }\n\n /** Create a subscription without confirming it. `POST /subscriptions/create` */\n async create(\n params: CreateSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse> {\n return this.request('POST', '/subscriptions/create', { body: params, ...options });\n }\n\n /** Retrieve a subscription by ID. `GET /subscriptions/{subscriptionId}` */\n async retrieve(subscriptionId: string, options?: RequestExtras): Promise<SubscriptionResponse> {\n return this.request('GET', `/subscriptions/${encodeURIComponent(subscriptionId)}`, {\n ...options,\n });\n }\n\n /**\n * Confirm a previously created subscription. `POST /subscriptions/{subscriptionId}/confirm`\n *\n * Like {@link createAndConfirm}, the response may carry a `redirect_url` for\n * processors that require buyer approval.\n */\n async confirm(\n subscriptionId: string,\n params: ConfirmSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/confirm`, {\n body: params,\n ...options,\n });\n }\n\n /** Update a subscription's plan/price. `PUT /subscriptions/{subscriptionId}/update` */\n async update(\n subscriptionId: string,\n params: UpdateSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse> {\n return this.request('PUT', `/subscriptions/${encodeURIComponent(subscriptionId)}/update`, {\n body: params,\n ...options,\n });\n }\n\n /** List subscriptions for the profile. `GET /subscriptions/list` */\n async list(\n params?: SubscriptionListParams,\n options?: RequestExtras,\n ): Promise<SubscriptionResponse[]> {\n return this.request('GET', '/subscriptions/list', {\n query: params as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /** Estimate the cost of a subscription before creating it. `GET /subscriptions/estimate` */\n async getEstimate(\n params: SubscriptionEstimateParams,\n options?: RequestExtras,\n ): Promise<SubscriptionEstimateResponse> {\n return this.request('GET', '/subscriptions/estimate', {\n query: params as unknown as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /** List purchasable subscription items (plans/addons). `GET /subscriptions/items` */\n async getItems(\n params: GetSubscriptionItemsParams,\n options?: RequestExtras,\n ): Promise<GetSubscriptionItemsResponse[]> {\n return this.request('GET', '/subscriptions/items', {\n query: params as unknown as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /**\n * Pause a subscription. `POST /subscriptions/{subscriptionId}/pause`\n *\n * The body defaults to `{}` so the request still carries\n * `Content-Type: application/json` even when no params are passed — the\n * backend rejects the POST otherwise (\"Unsupported content type\").\n */\n async pause(\n subscriptionId: string,\n params?: PauseSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<PauseSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/pause`, {\n body: params ?? {},\n ...options,\n });\n }\n\n /** Resume a paused subscription. `POST /subscriptions/{subscriptionId}/resume` */\n async resume(\n subscriptionId: string,\n params?: ResumeSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<ResumeSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/resume`, {\n body: params ?? {},\n ...options,\n });\n }\n\n /** Cancel a subscription. `POST /subscriptions/{subscriptionId}/cancel` */\n async cancel(\n subscriptionId: string,\n params?: CancelSubscriptionRequest,\n options?: RequestExtras,\n ): Promise<CancelSubscriptionResponse> {\n return this.request('POST', `/subscriptions/${encodeURIComponent(subscriptionId)}/cancel`, {\n body: params ?? {},\n ...options,\n });\n }\n\n /**\n * Resolve which of the given payments were raised by a subscription.\n * `POST /subscriptions/payments/lookup`\n *\n * The linkage exists in one direction only — an invoice points at the payment\n * it settled, and nothing is stamped on the payment — so this is the only way\n * to tell a subscription charge from a one-off one when you are holding a\n * page of payments. In particular, do not use `off_session` or the presence\n * of a mandate: an ordinary saved-card charge sets those identically.\n *\n * Ids that belong to no subscription are **absent** from `links` rather than\n * returned as an error, so match on presence:\n *\n * ```ts\n * const { links } = await subscriptions.lookupPayments(\n * { payment_ids: page.map((p) => p.payment_id) },\n * { headers: { 'X-Profile-Id': profileId } },\n * );\n * const bySubscription = new Map(links.map((l) => [l.payment_id, l]));\n * ```\n *\n * Profile-scoped like every other subscription route, and that matters more\n * here than elsewhere: a `payment_id` is merchant-supplied and only unique\n * within a merchant, so the shop is part of the question, not an\n * optimisation. Pass the profile that owns **the payments** — for a list\n * spanning several shops, group the ids by shop and call once per group.\n *\n * At most 200 ids per call.\n */\n async lookupPayments(\n params: SubscriptionPaymentLookupRequest,\n options?: RequestExtras,\n ): Promise<SubscriptionPaymentLookupResponse> {\n return this.request('POST', '/subscriptions/payments/lookup', { body: params, ...options });\n }\n\n /**\n * One subscription's billing history, newest cycle first.\n * `GET /subscriptions/{subscriptionId}/invoices`\n *\n * {@link retrieve} carries only the *latest* invoice, which is the current\n * cycle — a subscription that has renewed monthly for a year has one of those\n * and twelve of these. Use this wherever a merchant needs to see what a\n * subscription has actually billed, in particular on self-charging processors\n * (Creem, PayPal) where each renewal is charged by the processor and mirrored\n * here rather than raised as a DeloPay payment.\n *\n * Two things to render honestly, both decided rather than incidental:\n *\n * - `amount` is **gross** and `refunded_amount` sits beside it. Do not net\n * them: the difference between the two is not a smaller charge.\n * - A `refunded_amount` of `null` is \"not reported\" and must not render as\n * `0`. Likewise a processor-hosted origination records a bootstrap invoice\n * at `0` before the buyer has paid anything, so a zero amount on such a\n * subscription is a placeholder rather than a free cycle.\n *\n * Profile-scoped like every other subscription route.\n */\n async listInvoices(\n subscriptionId: string,\n params?: SubscriptionInvoiceListParams,\n options?: RequestExtras,\n ): Promise<SubscriptionInvoiceListResponse> {\n return this.request('GET', `/subscriptions/${encodeURIComponent(subscriptionId)}/invoices`, {\n query: params as Record<string, string | number | undefined>,\n ...options,\n });\n }\n\n /**\n * Which billing processor this shop's subscriptions run on.\n * `GET /subscriptions/billing_processor`\n *\n * The same mapping is derivable from the connector inventory\n * (`GET /account/{merchant_id}/connectors`), but that route is gated by a\n * connector-read permission granted independently of subscriptions — so a\n * role authorised to create subscriptions could be unable to learn which\n * processor it was creating them on. This answers under the same\n * authorization as the rest of the subscription API.\n *\n * Reach for it when the client must branch on the processor *before* calling\n * — origination differs by processor, and guessing is destructive. Resolve\n * the shop's `billing_processor_id` first: a shop that runs no subscriptions\n * has none assigned, and this route has no identity to report for it.\n */\n async getBillingProcessor(\n options?: RequestExtras,\n ): Promise<SubscriptionBillingProcessorResponse> {\n return this.request('GET', '/subscriptions/billing_processor', { ...options });\n }\n}\n","import type {\n FeeStatementDetail,\n SettlementBackfillRequest,\n SettlementBackfillResponse,\n SettlementCostParams,\n SettlementCostResponse,\n SettlementCurrentParams,\n SettlementCurrentResponse,\n SettlementLineListParams,\n SettlementLineListResponse,\n SettlementOverviewParams,\n SettlementOverviewResponse,\n SettlementStatementListParams,\n SettlementStatementListResponse,\n ShopFeeConfigParams,\n ShopFeeConfigResponse,\n ShopVisibilityResponse,\n ShopVisibilityUpdateRequest,\n StatementAdjustment,\n StatementAdjustmentCreateRequest,\n StatementAdjustmentListResponse,\n StatementGenerateRequest,\n StatementPayoutUpdateRequest,\n StatementPdfParams,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Hosted-shop settlement: monthly statements, the live current-period\n * rollup, per-line detail, fee schedules and backfills.\n *\n * Every read takes an explicit `test_mode` — test and live figures must\n * never blend, so the environment lives in the signature rather than in a\n * default. `false` is transmitted, not dropped.\n *\n * Shop-owner responses are redacted server-side: absent platform-fee fields\n * are a permission boundary, not a gap — never re-derive them client-side.\n */\nexport class Settlement {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Per-shop settlement rollup for the host merchant: unpaid totals and the\n * running current period, one row per shop.\n *\n * `GET /settlement/overview`\n */\n async overview(\n params: SettlementOverviewParams,\n options?: RequestExtras,\n ): Promise<SettlementOverviewResponse> {\n return this.request('GET', '/settlement/overview', {\n query: { test_mode: params.test_mode },\n ...options,\n });\n }\n\n /**\n * Live rollup of the current (not yet statemented) period.\n *\n * `GET /settlement/current`\n */\n async current(\n params: SettlementCurrentParams,\n options?: RequestExtras,\n ): Promise<SettlementCurrentResponse> {\n return this.request('GET', '/settlement/current', {\n query: { test_mode: params.test_mode, profile_id: params.profile_id },\n ...options,\n });\n }\n\n /**\n * What a period's payments cost, and what was left over: gross, the\n * platform fee, hosting fees, what the rails took, and the margin, with a\n * per-connector breakdown.\n *\n * Send `year` and `month` together to report one UTC calendar month, or\n * neither for the running month so far.\n *\n * **Host-only.** The response is the host's cost base, which a shop owner\n * must never see, so a profile-scoped caller is refused with a 403 rather\n * than given a redacted shell. Gate the surface on the caller's scope\n * instead of calling it and handling the failure.\n *\n * Two things not to flatten when rendering the result:\n * `margin_usd` is absent — not zero — whenever `margin_quality` is\n * `'unknown'`, and `unlined_captured_attempt_count` (cost definitely\n * missing) means something different from `unlined_unresolved_attempt_count`\n * (mostly ordinary abandonment).\n *\n * `GET /settlement/cost`\n *\n * @example\n * ```typescript\n * const cost = await delopay.settlement.cost({ test_mode: false, year: 2026, month: 7 });\n * if (cost.margin_quality === 'unknown') {\n * // cost.margin_usd is absent — say so, do not render 0.00\n * }\n * ```\n */\n async cost(\n params?: SettlementCostParams,\n options?: RequestExtras,\n ): Promise<SettlementCostResponse> {\n return this.request('GET', '/settlement/cost', {\n query: {\n profile_id: params?.profile_id,\n test_mode: params?.test_mode,\n year: params?.year,\n month: params?.month,\n },\n ...options,\n });\n }\n\n /**\n * List generated settlement statements, newest first.\n *\n * `GET /settlement/statements`\n */\n async listStatements(\n params: SettlementStatementListParams,\n options?: RequestExtras,\n ): Promise<SettlementStatementListResponse> {\n return this.request('GET', '/settlement/statements', {\n query: {\n test_mode: params.test_mode,\n profile_id: params.profile_id,\n limit: params.limit,\n offset: params.offset,\n },\n ...options,\n });\n }\n\n /**\n * One statement with its per-connector/currency breakdown.\n *\n * `GET /settlement/statements/{statementId}`\n */\n async retrieveStatement(\n statementId: string,\n options?: RequestExtras,\n ): Promise<FeeStatementDetail> {\n return this.request(\n 'GET',\n `/settlement/statements/${encodeURIComponent(statementId)}`,\n options,\n );\n }\n\n /**\n * Generate (or regenerate) the statement for one shop and calendar month.\n *\n * `POST /settlement/statements/generate`\n */\n async generateStatement(\n params: StatementGenerateRequest,\n options?: RequestExtras,\n ): Promise<FeeStatementDetail> {\n return this.request('POST', '/settlement/statements/generate', {\n body: params,\n ...options,\n });\n }\n\n /**\n * Record payout progress on a statement (`unpaid` / `partial` / `paid`).\n *\n * Subject to the caller's `settlement_payout` operation limit, which can\n * only be a per-operation ceiling: an over-limit call fails with `DE_01`\n * and nothing is recorded. There is no approval route out of it — four-eyes\n * needs an executor that can run the operation once somebody says yes, and\n * only refunds have one, so a settlement rule can only block.\n *\n * `POST /settlement/statements/{statementId}/payout`\n */\n async updateStatementPayout(\n statementId: string,\n params: StatementPayoutUpdateRequest,\n options?: RequestExtras,\n ): Promise<FeeStatementDetail> {\n return this.request(\n 'POST',\n `/settlement/statements/${encodeURIComponent(statementId)}/payout`,\n { body: params, ...options },\n );\n }\n\n /**\n * Export a statement as PDF. Returns the raw PDF bytes as a `Blob`, with\n * the same auth, retries and error handling as every other call — persist\n * or object-URL it caller-side.\n *\n * `GET /settlement/statements/{statementId}/pdf`\n *\n * @example\n * ```typescript\n * const pdf = await delopay.settlement.downloadStatementPdf('stmt_1', {\n * currency: 'EUR',\n * include_transactions: true,\n * });\n * const url = URL.createObjectURL(pdf);\n * ```\n */\n async downloadStatementPdf(\n statementId: string,\n params?: StatementPdfParams,\n options?: RequestExtras,\n ): Promise<Blob> {\n return this.request('GET', `/settlement/statements/${encodeURIComponent(statementId)}/pdf`, {\n query: {\n currency: params?.currency,\n include_transactions: params?.include_transactions,\n },\n responseType: 'blob',\n ...options,\n });\n }\n\n /**\n * The individual settled attempts of one shop's calendar month.\n *\n * `GET /settlement/lines`\n */\n async listLines(\n params: SettlementLineListParams,\n options?: RequestExtras,\n ): Promise<SettlementLineListResponse> {\n return this.request('GET', '/settlement/lines', {\n query: {\n profile_id: params.profile_id,\n year: params.year,\n month: params.month,\n test_mode: params.test_mode,\n limit: params.limit,\n offset: params.offset,\n },\n ...options,\n });\n }\n\n /**\n * The fee schedules that currently apply to a shop.\n *\n * `GET /settlement/fee-config`\n */\n async feeConfig(\n params: ShopFeeConfigParams,\n options?: RequestExtras,\n ): Promise<ShopFeeConfigResponse> {\n return this.request('GET', '/settlement/fee-config', {\n query: { profile_id: params.profile_id },\n ...options,\n });\n }\n\n /**\n * Enqueue a settlement-line backfill over historical attempts. Attempts\n * already covered by a line are always skipped.\n *\n * `POST /settlement/backfill`\n */\n async backfill(\n params?: SettlementBackfillRequest,\n options?: RequestExtras,\n ): Promise<SettlementBackfillResponse> {\n return this.request('POST', '/settlement/backfill', { body: params, ...options });\n }\n\n /**\n * Toggle whether a shop's owner can see their own settlement figures.\n *\n * `POST /settlement/shops/visibility`\n */\n async setShopVisibility(\n params: ShopVisibilityUpdateRequest,\n options?: RequestExtras,\n ): Promise<ShopVisibilityResponse> {\n return this.request('POST', '/settlement/shops/visibility', {\n body: params,\n ...options,\n });\n }\n\n /**\n * Manual adjustments recorded on a statement.\n *\n * `GET /settlement/statements/{statementId}/adjustments`\n */\n async listStatementAdjustments(\n statementId: string,\n options?: RequestExtras,\n ): Promise<StatementAdjustmentListResponse> {\n return this.request(\n 'GET',\n `/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,\n options,\n );\n }\n\n /**\n * Add a manual adjustment to a statement. Positive `amount_usd` charges\n * the shop (reducing their payout); negative credits them.\n *\n * Subject to the caller's `settlement_adjustment` operation limit (amount\n * dimensions only): an over-limit call fails with `DE_01` and no adjustment\n * is added. A settlement rule can only block — approval is refund-only, for\n * the reason given on `updateStatementPayout()`.\n *\n * `POST /settlement/statements/{statementId}/adjustments`\n */\n async createStatementAdjustment(\n statementId: string,\n params: StatementAdjustmentCreateRequest,\n options?: RequestExtras,\n ): Promise<StatementAdjustment> {\n return this.request(\n 'POST',\n `/settlement/statements/${encodeURIComponent(statementId)}/adjustments`,\n { body: params, ...options },\n );\n }\n\n /**\n * Remove a manual adjustment from a statement.\n *\n * `DELETE /settlement/statements/{statementId}/adjustments/{adjustmentId}`\n */\n async deleteStatementAdjustment(\n statementId: string,\n adjustmentId: string,\n options?: RequestExtras,\n ): Promise<void> {\n return this.request(\n 'DELETE',\n `/settlement/statements/${encodeURIComponent(statementId)}/adjustments/${encodeURIComponent(adjustmentId)}`,\n options,\n );\n }\n}\n","import type {\n DecidePendingOperationRequest,\n OperationLimitRule,\n OperationLimitRuleDeleteResponse,\n OperationLimitRuleListParams,\n OperationLimitSettings,\n PendingOperation,\n PendingOperationListParams,\n PendingOperationListResponse,\n UpdateOperationLimitSettingsRequest,\n UpsertOperationLimitRuleRequest,\n} from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Per-operation spending limits: rules scoped to the merchant, a role or a\n * user, the merchant-level enforcement settings, and the approvals inbox.\n * Enforcement resolves the most specific rule: user > role > merchant.\n *\n * A rule set to `require_approval` does not refuse an over-limit operation —\n * it parks it. The original call fails with HTTP 409 `DE_06` carrying\n * `PendingApprovalErrorDetails`, and the operation runs only once a second\n * person approves the request through this inbox.\n *\n * **Refunds only.** Approval needs an executor that can run the operation\n * after the decision, and only refunds have one; the settlement operations\n * take `block` alone, which the request type enforces. So every request in\n * this inbox is a refund, and `DE_06` never comes back from a settlement\n * call — an over-limit settlement adjustment or payout fails with `DE_01`.\n */\nexport class OperationLimits {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * List the merchant's limit rules, optionally for one operation.\n *\n * `GET /operation-limits/rules`\n */\n async listRules(\n params?: OperationLimitRuleListParams,\n options?: RequestExtras,\n ): Promise<OperationLimitRule[]> {\n return this.request('GET', '/operation-limits/rules', {\n query: { operation: params?.operation },\n ...options,\n });\n }\n\n /**\n * Create or replace the limit rule for one target. Full-replace upsert:\n * absent limit fields clear that dimension.\n *\n * `PUT /operation-limits/rules`\n */\n async upsertRule(\n params: UpsertOperationLimitRuleRequest,\n options?: RequestExtras,\n ): Promise<OperationLimitRule> {\n return this.request('PUT', '/operation-limits/rules', { body: params, ...options });\n }\n\n /**\n * Delete a limit rule.\n *\n * `DELETE /operation-limits/rules/{ruleId}`\n */\n async deleteRule(\n ruleId: string,\n options?: RequestExtras,\n ): Promise<OperationLimitRuleDeleteResponse> {\n return this.request('DELETE', `/operation-limits/rules/${encodeURIComponent(ruleId)}`, options);\n }\n\n /**\n * The merchant-level enforcement settings. An untouched merchant gets the\n * defaults: rolling window, admins not exempt.\n *\n * `GET /operation-limits/settings`\n */\n async retrieveSettings(options?: RequestExtras): Promise<OperationLimitSettings> {\n return this.request('GET', '/operation-limits/settings', options);\n }\n\n /**\n * Update the enforcement settings. Only provided fields change.\n *\n * `PUT /operation-limits/settings`\n */\n async updateSettings(\n params: UpdateOperationLimitSettingsRequest,\n options?: RequestExtras,\n ): Promise<OperationLimitSettings> {\n return this.request('PUT', '/operation-limits/settings', { body: params, ...options });\n }\n\n /**\n * The approvals inbox: over-limit operations waiting on a second person.\n *\n * Both filters default rather than widen. With no `status` the list holds\n * **pending requests only** — approved, rejected and expired ones are\n * reachable only by asking for that status, so a history view must pass one\n * per status. With no `operation` it lists **refunds only**; the list is one\n * operation at a time. `limit` defaults to 100 and is clamped to 1–500.\n *\n * Requests past their `expires_at` are expired before the list is read, so\n * nothing here is shown as actionable when it is not.\n *\n * `GET /operation-limits/approvals`\n */\n async listApprovals(\n params?: PendingOperationListParams,\n options?: RequestExtras,\n ): Promise<PendingOperationListResponse> {\n return this.request('GET', '/operation-limits/approvals', {\n query: {\n operation: params?.operation,\n status: params?.status,\n limit: params?.limit,\n },\n ...options,\n });\n }\n\n /**\n * Approve a parked operation and execute it.\n *\n * Refused for the user who requested it, and for an approver whose own\n * limit would not have covered the operation — the permission is necessary\n * and not sufficient.\n *\n * Approval and execution are two facts. A request that was approved but\n * whose operation then failed comes back `approved` with `execution_error`\n * set and no `result_entity_id`; that is a real outcome, not a partial read.\n *\n * `POST /operation-limits/approvals/{id}/approve`\n */\n async approve(\n id: string,\n params: DecidePendingOperationRequest = {},\n options?: RequestExtras,\n ): Promise<PendingOperation> {\n return this.request('POST', `/operation-limits/approvals/${encodeURIComponent(id)}/approve`, {\n body: params,\n ...options,\n });\n }\n\n /**\n * Reject a parked operation. Nothing is executed and the request is closed.\n *\n * `POST /operation-limits/approvals/{id}/reject`\n */\n async reject(\n id: string,\n params: DecidePendingOperationRequest = {},\n options?: RequestExtras,\n ): Promise<PendingOperation> {\n return this.request('POST', `/operation-limits/approvals/${encodeURIComponent(id)}/reject`, {\n body: params,\n ...options,\n });\n }\n}\n","import type { MerchantRisk, ShopRisk } from '../types';\nimport type { RequestExtras, RequestFn } from '../client';\n\n/**\n * Stored shop risk indexes, per connector.\n *\n * Both reads return snapshots and never score on demand, so `computed_at` is\n * the age of the answer rather than the time of the call.\n *\n * The caller's own scope is what bounds the answer, and it is enforced\n * server-side: a profile-scoped role, or an API key pinned to one shop, gets\n * that shop from both endpoints and cannot read or enumerate a sibling's.\n */\nexport class Risk {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Every shop's stored risk for the caller's merchant, with the worst band\n * across them.\n *\n * `GET /risk`\n */\n async retrieve(options?: RequestExtras): Promise<MerchantRisk> {\n return this.request('GET', '/risk', options);\n }\n\n /**\n * One shop's stored risk index per connector.\n *\n * `GET /risk/shops/{profileId}`\n */\n async retrieveShop(profileId: string, options?: RequestExtras): Promise<ShopRisk> {\n return this.request('GET', `/risk/shops/${encodeURIComponent(profileId)}`, options);\n }\n}\n","import { DelopayError, DelopayAuthenticationError } from './error';\nimport { ApiKeys } from './resources/apiKeys';\nimport { Authentication } from './resources/authentication';\nimport { Billing } from './resources/billing';\nimport { Blocklist } from './resources/blocklist';\nimport { Connectors } from './resources/connectors';\nimport { Customers } from './resources/customers';\nimport { Disputes } from './resources/disputes';\nimport { EphemeralKeys } from './resources/ephemeralKeys';\nimport { Events } from './resources/events';\nimport { Fees } from './resources/fees';\nimport { Mandates } from './resources/mandates';\nimport { MerchantAccounts } from './resources/merchantAccounts';\nimport { PaymentLinks } from './resources/paymentLinks';\nimport { PaymentMethods } from './resources/paymentMethods';\nimport { Payments } from './resources/payments';\nimport { Payouts } from './resources/payouts';\nimport { Poll } from './resources/poll';\nimport { ProfileAcquirers } from './resources/profileAcquirers';\nimport { Profiles } from './resources/profiles';\nimport { Projects } from './resources/projects';\nimport { Refunds } from './resources/refunds';\nimport { Relay } from './resources/relay';\nimport { Routing } from './resources/routing';\nimport { Search } from './resources/search';\nimport { Shops } from './resources/shops';\nimport { StripeConnect } from './resources/stripeConnect';\nimport { ThreeDsRules } from './resources/threeDsRules';\nimport { Users } from './resources/users';\nimport { Verification } from './resources/verification';\nimport { Webhooks } from './resources/webhooks';\nimport type { TokenResponse } from './types';\nimport { Analytics } from './resources/analytics';\nimport { AnalyticsDashboard } from './resources/analyticsDashboard';\nimport { Cards } from './resources/cards';\nimport { Export } from './resources/export';\nimport { FeatureMatrix } from './resources/featureMatrix';\nimport { Files } from './resources/files';\nimport { Forex } from './resources/forex';\nimport { Regions } from './resources/regions';\nimport { AvailabilityOverrides } from './resources/availabilityOverrides';\nimport { Subscriptions } from './resources/subscriptions';\nimport { Settlement } from './resources/settlement';\nimport { OperationLimits } from './resources/operationLimits';\nimport { Risk } from './resources/risk';\n\nconst PRODUCTION_URL = 'https://api.delopay.net';\nconst SANDBOX_URL = 'https://sandbox.delopay.net';\n\nconst MAX_RAW_BODY_BYTES = 2048;\nconst MAX_RETRY_AFTER_MS = 30_000;\n\nfunction parseRetryAfter(header: string | null): number | null {\n if (!header) return null;\n const trimmed = header.trim();\n const seconds = Number(trimmed);\n if (Number.isFinite(seconds) && seconds >= 0) {\n return Math.min(seconds * 1000, MAX_RETRY_AFTER_MS);\n }\n const date = Date.parse(trimmed);\n if (Number.isFinite(date)) {\n const delta = date - Date.now();\n return delta > 0 ? Math.min(delta, MAX_RETRY_AFTER_MS) : 0;\n }\n return null;\n}\n\nfunction truncateRawBody(raw: string): string | undefined {\n if (!raw) return undefined;\n return raw.length > MAX_RAW_BODY_BYTES ? raw.slice(0, MAX_RAW_BODY_BYTES) + '…' : raw;\n}\n\nfunction findIdempotencyKey(headers: Record<string, string>): string | undefined {\n for (const [k, v] of Object.entries(headers)) {\n if (k.toLowerCase() === 'idempotency-key') return v;\n }\n return undefined;\n}\n\ninterface CombinedSignal {\n signal: AbortSignal;\n dispose: () => void;\n}\n\nfunction noop(): void {\n // Intentionally empty: no listeners registered, nothing to clean up.\n}\n\nfunction combineSignals(signals: AbortSignal[]): CombinedSignal {\n const controller = new AbortController();\n const listeners: { signal: AbortSignal; handler: () => void }[] = [];\n const dispose = () => {\n for (const { signal, handler } of listeners) {\n signal.removeEventListener('abort', handler);\n }\n listeners.length = 0;\n };\n for (const signal of signals) {\n if (signal.aborted) {\n controller.abort(signal.reason);\n dispose();\n return { signal: controller.signal, dispose: noop };\n }\n const handler = () => {\n controller.abort(signal.reason);\n dispose();\n };\n signal.addEventListener('abort', handler, { once: true });\n listeners.push({ signal, handler });\n }\n return { signal: controller.signal, dispose };\n}\n\n/**\n * Events emitted by the debug logger.\n * - `request` — about to send a request (`method`, `url`, `path`)\n * - `response` — response received (`status`, `method`, `path`, `requestId?`)\n * - `retry` — about to retry after a transient failure (`attempt`, `maxRetries`, `method`, `path`)\n */\nexport type DelopayLogger = (\n event: 'request' | 'response' | 'retry',\n data: Record<string, unknown>,\n) => void;\n\n/**\n * Configuration options for the Delopay client.\n */\nexport interface DelopayOptions {\n /** Use the sandbox environment (`https://sandbox.delopay.net`). Defaults to `false` (production). */\n sandbox?: boolean;\n /** Override the base URL entirely. Takes precedence over `sandbox`. */\n baseUrl?: string;\n /** Request timeout in milliseconds. Defaults to `30000` (30 seconds). */\n timeout?: number;\n /**\n * Maximum number of automatic retries for transient failures (5xx, timeout, network errors).\n * Retries use exponential backoff. Set to `0` to disable. Defaults to `2`.\n * Only idempotent-safe requests (GET, DELETE, and requests with an `Idempotency-Key` header) are retried.\n */\n maxRetries?: number;\n /** Enable debug logging of requests and responses. Defaults to `false`. */\n debug?: boolean;\n /**\n * Custom logger for debug events (`request`, `response`, `retry`). When omitted,\n * debug output is written to `console.log`. Has no effect unless `debug` is `true`.\n * Useful for routing SDK logs through pino, winston, or similar structured loggers.\n */\n logger?: DelopayLogger;\n}\n\nconst SENSITIVE_QUERY_KEYS = new Set([\n 'client_secret',\n 'ephemeral_key',\n 'api_key',\n 'publishable_key',\n]);\n\n/**\n * Return a copy of `url` with the values of known-sensitive query parameters\n * replaced by `REDACTED`, leaving the rest of the query string intact.\n * Used only to sanitize URLs before they hit debug logs.\n */\nfunction redactUrlForLogging(url: string): string {\n const qIdx = url.indexOf('?');\n if (qIdx === -1) return url;\n const base = url.slice(0, qIdx);\n const query = url.slice(qIdx + 1);\n const parts = query.split('&').map((pair) => {\n const eqIdx = pair.indexOf('=');\n if (eqIdx === -1) return pair;\n const key = pair.slice(0, eqIdx);\n if (SENSITIVE_QUERY_KEYS.has(decodeURIComponent(key).toLowerCase())) {\n return `${key}=REDACTED`;\n }\n return pair;\n });\n return `${base}?${parts.join('&')}`;\n}\n\n/**\n * Low-level options forwarded to a single HTTP request.\n */\nexport interface RequestOptions {\n /** Request body, serialised as JSON. */\n body?: unknown;\n /**\n * Query-string parameters. `undefined` and `null` values are omitted.\n * Array values are emitted as repeated keys (`?tag=a&tag=b`) — not comma-joined.\n */\n query?: Record<\n string,\n string | number | boolean | null | undefined | (string | number | boolean)[]\n >;\n /** Additional HTTP headers merged with the default `api-key` header. */\n headers?: Record<string, string>;\n /** Override the client-level timeout for this request, in milliseconds. */\n timeout?: number;\n /**\n * Caller-provided `AbortSignal`. Aborting it cancels the in-flight request and rejects\n * with a `DelopayError` carrying code `'ABORTED'`. Combined with the per-request timeout.\n */\n signal?: AbortSignal;\n /**\n * How to decode a 2xx response body. `'json'` (the default) parses JSON;\n * `'blob'` / `'arraybuffer'` return the raw bytes for binary endpoints\n * such as PDF exports. Error responses are always decoded as JSON and\n * thrown as `DelopayError` regardless of this setting.\n */\n responseType?: 'json' | 'blob' | 'arraybuffer';\n /**\n * Pass `keepalive: true` to let the request outlive its page — e.g.\n * telemetry sent while the document is navigating away. Browsers cap\n * keepalive request bodies at ~64 KiB and reject larger ones.\n */\n keepalive?: boolean;\n}\n\nexport type RequestFn = <T>(method: string, path: string, options?: RequestOptions) => Promise<T>;\n\n/**\n * Per-call options that resource methods accept as an optional final argument:\n * extra HTTP headers (e.g. `Idempotency-Key`), a per-request timeout override,\n * and an `AbortSignal` for cancellation.\n */\nexport type RequestExtras = Pick<RequestOptions, 'headers' | 'timeout' | 'signal'>;\n\n/**\n * Delopay API client.\n *\n * Instantiate once with your API key and reuse across your application.\n * All resource sub-clients (payments, refunds, customers, …) are exposed\n * as properties on the instance.\n *\n * @example\n * ```typescript\n * const delopay = new Delopay('prd_...', { sandbox: false });\n * const payment = await delopay.payments.create({ amount: 5000, currency: 'EUR' });\n * ```\n */\nexport class Delopay {\n /** Utility for verifying incoming webhook signatures (static, no instance needed). */\n static webhooks = Webhooks;\n\n /** The resolved base URL used for all API requests. */\n readonly baseUrl: string;\n private readonly apiKey: string;\n private readonly timeout: number;\n private readonly maxRetries: number;\n private readonly debug: boolean;\n private readonly logger?: DelopayLogger;\n private jwtToken?: string;\n\n // Merchant-facing\n readonly payments: Payments;\n readonly refunds: Refunds;\n readonly customers: Customers;\n readonly paymentMethods: PaymentMethods;\n readonly paymentLinks: PaymentLinks;\n readonly mandates: Mandates;\n readonly disputes: Disputes;\n readonly payouts: Payouts;\n readonly ephemeralKeys: EphemeralKeys;\n readonly events: Events;\n readonly poll: Poll;\n\n // Connector / routing\n readonly connectors: Connectors;\n readonly routing: Routing;\n readonly profiles: Profiles;\n readonly shops: Shops;\n readonly profileAcquirers: ProfileAcquirers;\n\n // Authentication & verification\n readonly authentication: Authentication;\n readonly verification: Verification;\n\n // Dashboard / internal\n readonly users: Users;\n readonly apiKeys: ApiKeys;\n readonly billing: Billing;\n readonly blocklist: Blocklist;\n readonly fees: Fees;\n readonly merchantAccounts: MerchantAccounts;\n readonly projects: Projects;\n readonly relay: Relay;\n readonly stripeConnect: StripeConnect;\n readonly threeDsRules: ThreeDsRules;\n readonly settlement: Settlement;\n readonly operationLimits: OperationLimits;\n readonly risk: Risk;\n\n // New resources (Phases 3-4)\n readonly subscriptions: Subscriptions;\n readonly files: Files;\n readonly export: Export;\n readonly forex: Forex;\n readonly regions: Regions;\n readonly availabilityOverrides: AvailabilityOverrides;\n readonly analytics: Analytics;\n readonly analyticsDashboard: AnalyticsDashboard;\n readonly featureMatrix: FeatureMatrix;\n readonly cards: Cards;\n readonly search: Search;\n\n /**\n * Create a new Delopay client.\n *\n * @param apiKey - Your Delopay API key (e.g. `prd_...` or `snd_...`).\n * Pass an empty string or omit for JWT-only usage (e.g. dashboard apps).\n * @param options - Optional configuration (sandbox mode, base URL override, timeout).\n */\n constructor(apiKey?: string, options?: DelopayOptions) {\n this.apiKey = apiKey ?? '';\n this.timeout = options?.timeout ?? 30_000;\n this.maxRetries = options?.maxRetries ?? 2;\n this.debug = options?.debug ?? false;\n if (options?.logger !== undefined) this.logger = options.logger;\n\n if (options?.baseUrl !== undefined) {\n this.baseUrl = options.baseUrl;\n } else if (options?.sandbox) {\n this.baseUrl = SANDBOX_URL;\n } else {\n this.baseUrl = PRODUCTION_URL;\n }\n\n const request = this.request.bind(this) as RequestFn;\n\n // JWT auth methods are defined below (setJwtToken / clearJwtToken)\n\n // Merchant-facing\n this.payments = new Payments(request);\n this.refunds = new Refunds(request);\n this.customers = new Customers(request);\n this.paymentMethods = new PaymentMethods(request);\n this.paymentLinks = new PaymentLinks(request);\n this.mandates = new Mandates(request);\n this.disputes = new Disputes(request);\n this.payouts = new Payouts(request);\n this.ephemeralKeys = new EphemeralKeys(request);\n this.events = new Events(request);\n this.poll = new Poll(request);\n\n // Connector / routing\n this.connectors = new Connectors(request);\n this.routing = new Routing(request);\n this.profiles = new Profiles(request);\n this.shops = new Shops(request);\n this.profileAcquirers = new ProfileAcquirers(request);\n\n // Authentication & verification\n this.authentication = new Authentication(request);\n this.verification = new Verification(request);\n\n // Dashboard / internal\n this.users = new Users(request);\n this.apiKeys = new ApiKeys(request);\n this.billing = new Billing(request);\n this.blocklist = new Blocklist(request);\n this.fees = new Fees(request);\n this.merchantAccounts = new MerchantAccounts(request);\n this.projects = new Projects(request);\n this.relay = new Relay(request);\n this.stripeConnect = new StripeConnect(request);\n this.threeDsRules = new ThreeDsRules(request);\n this.settlement = new Settlement(request);\n this.operationLimits = new OperationLimits(request);\n this.risk = new Risk(request);\n\n // New resources (Phases 3-4)\n this.subscriptions = new Subscriptions(request);\n this.files = new Files(request);\n this.export = new Export(request);\n this.forex = new Forex(request);\n this.regions = new Regions(request);\n this.availabilityOverrides = new AvailabilityOverrides(request);\n this.analytics = new Analytics(request);\n this.analyticsDashboard = new AnalyticsDashboard(request);\n this.featureMatrix = new FeatureMatrix(request);\n this.cards = new Cards(request);\n this.search = new Search(request);\n }\n\n /**\n * Set a JWT token for subsequent requests.\n * When set, requests use `Authorization: Bearer <token>` instead of `api-key`.\n * Useful after `users.signIn()` returns a JWT for dashboard operations.\n */\n setJwtToken(token: string): void {\n this.jwtToken = token;\n }\n\n /**\n * Clear the JWT token, reverting to API key authentication.\n */\n clearJwtToken(): void {\n this.jwtToken = undefined;\n }\n\n /**\n * Refresh the current login JWT (see {@link Users.refreshToken}) and\n * apply the fresh token to this client, so subsequent requests use it.\n * Returns the fresh token for the caller to persist (e.g. session\n * storage) — the backend has already re-set the `login_token` cookie.\n *\n * If the client's auth state changes while the refresh is pending —\n * `clearJwtToken()` on sign-out, or `setJwtToken()` switching to another\n * session — the stale completion is discarded and this rejects with a\n * `session_changed` `DelopayError` (status 0), so the explicit change\n * wins and the caller never persists a token for a session that is gone.\n *\n * Otherwise throws like any other request; in particular a 401 means the\n * session is dead (expired/blacklisted/revoked), a 429 means a refresh\n * was already minted for this session within the last minute, and a 400\n * means this token has no revocable session to slide (no `jti` — team\n * impersonation is the case in practice) and can never be refreshed,\n * though it stays valid for ordinary calls.\n */\n async refreshSession(): Promise<TokenResponse> {\n const originatingToken = this.jwtToken;\n const response = await this.users.refreshToken();\n if (this.jwtToken !== originatingToken) {\n throw new DelopayError(\n 'Auth state changed while the refresh was pending; refreshed token discarded',\n {\n status: 0,\n code: 'session_changed',\n type: 'session_changed',\n },\n );\n }\n this.setJwtToken(response.token);\n return response;\n }\n\n /**\n * Make a raw HTTP request to the Delopay API.\n *\n * You rarely need to call this directly — prefer the typed resource methods.\n * Use it only for endpoints not yet covered by a resource class.\n *\n * @param method - HTTP method (`GET`, `POST`, `PUT`, `PATCH`, `DELETE`).\n * @param path - API path starting with `/` (e.g. `/payments`).\n * @param options - Optional body, query parameters, and headers.\n * @returns Parsed JSON response body typed as `T`.\n * @throws {DelopayAuthenticationError} On 401 responses.\n * @throws {DelopayError} On all other non-2xx responses, timeouts, and network errors.\n */\n async request<T>(method: string, path: string, options?: RequestOptions): Promise<T> {\n let url = `${this.baseUrl}${path}`;\n\n if (options?.query) {\n const params = new URLSearchParams();\n for (const [key, value] of Object.entries(options.query)) {\n if (value === undefined || value === null) continue;\n if (Array.isArray(value)) {\n for (const v of value) {\n if (v !== undefined && v !== null) params.append(key, String(v));\n }\n } else {\n params.set(key, String(value));\n }\n }\n const qs = params.toString();\n if (qs) {\n url += `?${qs}`;\n }\n }\n\n const headers: Record<string, string> = {\n ...(this.jwtToken\n ? { Authorization: `Bearer ${this.jwtToken}` }\n : this.apiKey\n ? { 'api-key': this.apiKey }\n : {}),\n ...options?.headers,\n };\n\n // FormData / Blob / ArrayBuffer / URLSearchParams pass through unchanged so callers\n // can send multipart uploads. The runtime (browser or Node 18+ fetch) sets the\n // appropriate Content-Type including the multipart boundary, so we don't touch it.\n const isRawBody =\n options?.body !== undefined &&\n options?.body !== null &&\n (options.body instanceof FormData ||\n options.body instanceof Blob ||\n options.body instanceof ArrayBuffer ||\n options.body instanceof URLSearchParams);\n\n if (options?.body && !isRawBody) {\n headers['Content-Type'] = 'application/json';\n }\n\n const idempotencyKey = findIdempotencyKey(headers)?.trim();\n const isRetryable =\n method === 'GET' ||\n method === 'DELETE' ||\n (idempotencyKey !== undefined && idempotencyKey !== '');\n\n // Serialize body once so circular-reference errors surface immediately and big payloads\n // aren't re-stringified on every retry attempt. Raw bodies pass through untouched.\n let serializedBody: BodyInit | undefined;\n if (isRawBody) {\n serializedBody = options?.body as BodyInit;\n } else if (options?.body) {\n serializedBody = JSON.stringify(options.body);\n }\n\n const callerSignal = options?.signal;\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n\n const timeoutMs = options?.timeout ?? this.timeout;\n\n let lastError: unknown;\n let retryAfterOverrideMs: number | null = null;\n\n const safeUrl = () => redactUrlForLogging(url);\n const emit = (event: 'request' | 'response' | 'retry', data: Record<string, unknown>) => {\n if (!this.debug) return;\n if (this.logger) {\n this.logger(event, data);\n return;\n }\n if (event === 'request')\n console.log(`[delopay] ${data.method as string} ${data.url as string}`);\n else if (event === 'response')\n console.log(\n `[delopay] ${data.status as number} ${data.method as string} ${data.path as string}`,\n );\n else\n console.log(\n `[delopay] retry ${data.attempt as number}/${data.maxRetries as number} ${data.method as string} ${data.path as string}`,\n );\n };\n\n for (let attempt = 0; attempt <= this.maxRetries; attempt++) {\n if (attempt > 0) {\n const base = Math.min(500 * 2 ** (attempt - 1), 5000);\n // Full jitter: pick uniformly in [0, base) to avoid synchronized retry storms.\n const jittered = Math.random() * base;\n const delay = Math.max(retryAfterOverrideMs ?? 0, jittered);\n retryAfterOverrideMs = null;\n await new Promise((resolve) => setTimeout(resolve, delay));\n emit('retry', { attempt, maxRetries: this.maxRetries, method, path });\n }\n\n const timeoutCtrl = new AbortController();\n const timeoutId = setTimeout(() => timeoutCtrl.abort(), timeoutMs);\n const combined = combineSignals(\n callerSignal ? [timeoutCtrl.signal, callerSignal] : [timeoutCtrl.signal],\n );\n\n try {\n emit('request', { method, url: safeUrl(), path });\n\n const response = await fetch(url, {\n method,\n headers,\n body: serializedBody,\n signal: combined.signal,\n ...(options?.keepalive !== undefined ? { keepalive: options.keepalive } : {}),\n });\n\n const requestId =\n response.headers?.get('x-request-id') ?? response.headers?.get('x-trace-id') ?? undefined;\n\n emit('response', { status: response.status, method, path, requestId });\n\n if (!response.ok) {\n const rawBody = await response.text().catch(() => '');\n let parsed: Record<string, unknown> = {};\n if (rawBody) {\n try {\n parsed = JSON.parse(rawBody) as Record<string, unknown>;\n } catch {\n // non-JSON error body (HTML from a proxy, truncated stream, etc.) — keep raw\n }\n }\n // API wraps errors as { error: { message, code, type, data? } } — unwrap if present\n const err = (parsed.error as Record<string, unknown>) ?? parsed;\n const message =\n (err.message as string) ?? `Request failed with status ${response.status}`;\n const code = (err.code as string) ?? '';\n const type = (err.error_type as string) ?? (err.type as string) ?? '';\n const data =\n err.data && typeof err.data === 'object' && !Array.isArray(err.data)\n ? (err.data as Record<string, unknown>)\n : undefined;\n const truncatedRaw = truncateRawBody(rawBody);\n\n // A 401 usually means OUR credential (API key / JWT) was rejected —\n // but connector-passthrough errors (`CE_*` / type \"connector\", e.g.\n // a PSP rejecting the merchant's stored Stripe key) propagate the\n // upstream status and are NOT a Delopay authentication failure, so\n // they stay a plain DelopayError instead of triggering the\n // \"re-authenticate\" handling dashboards attach to auth errors.\n const isConnectorPassthrough = type === 'connector' || code.startsWith('CE_');\n if (response.status === 401 && !isConnectorPassthrough) {\n throw new DelopayAuthenticationError(message, {\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n }\n\n const error = new DelopayError(message, {\n status: response.status,\n code,\n type,\n requestId,\n rawBody: truncatedRaw,\n data,\n });\n\n // Retry on 5xx and 429 (rate limit). 4xx other than 429 are not transient.\n const isTransientStatus = response.status >= 500 || response.status === 429;\n if (isTransientStatus && isRetryable && attempt < this.maxRetries) {\n if (response.status === 429) {\n retryAfterOverrideMs = parseRetryAfter(response.headers?.get('retry-after') ?? null);\n }\n lastError = error;\n continue;\n }\n\n throw error;\n }\n\n if (options?.responseType === 'blob') {\n return (await response.blob()) as T;\n }\n if (options?.responseType === 'arraybuffer') {\n return (await response.arrayBuffer()) as T;\n }\n const text = await response.text();\n return (text ? JSON.parse(text) : undefined) as T;\n } catch (err) {\n if (err instanceof DelopayError || err instanceof DelopayAuthenticationError) {\n throw err;\n }\n if (err instanceof Error && err.name === 'AbortError') {\n if (callerSignal?.aborted) {\n throw new DelopayError('Request aborted', {\n status: 0,\n code: 'ABORTED',\n type: 'abort_error',\n });\n }\n lastError = new DelopayError('Request timed out', {\n status: 0,\n code: 'TIMEOUT',\n type: 'timeout_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n if (err instanceof TypeError) {\n lastError = new DelopayError(`Network error: ${err.message}`, {\n status: 0,\n code: 'NETWORK',\n type: 'network_error',\n });\n if (isRetryable && attempt < this.maxRetries) continue;\n throw lastError;\n }\n throw err;\n } finally {\n clearTimeout(timeoutId);\n combined.dispose();\n }\n }\n\n throw lastError;\n }\n\n /**\n * Auto-paginate a list endpoint. Yields items one by one, fetching\n * the next page automatically when the current one is exhausted.\n *\n * Delopay list endpoints use one of two pagination styles, so this helper\n * supports both:\n * - **Offset** (default) — for endpoints like `customers.list` that accept\n * `offset`/`limit`. Each page advances `offset` by the number of items returned.\n * - **Cursor** — for endpoints like `payments.list` and `payouts.list` that page\n * with `starting_after`/`limit` (they ignore `offset`). Pass a `cursor` extractor\n * that returns the id of an item; the next page is requested with\n * `starting_after` set to the last item's id.\n *\n * @param listFn - A function that takes the paging params and returns `{ data: T[] }` or `T[]`.\n * @param params - Additional parameters to pass to every page request.\n * @param options - Page size (number) for offset mode, or `{ pageSize?, cursor? }`.\n * Provide `cursor` to switch to cursor pagination.\n *\n * @example\n * ```typescript\n * // Offset endpoint (customers):\n * for await (const c of delopay.paginate((p) => delopay.customers.list(p))) {\n * console.log(c.customer_id);\n * }\n *\n * // Cursor endpoint (payments): extract the id used as the next cursor.\n * for await (const payment of delopay.paginate(\n * (p) => delopay.payments.list(p),\n * undefined,\n * { cursor: (p) => p.payment_id },\n * )) {\n * console.log(payment.payment_id);\n * }\n * ```\n */\n async *paginate<T, P extends Record<string, unknown>>(\n listFn: (\n params: P & { limit: number; offset?: number; starting_after?: string },\n ) => Promise<{ data: T[] } | T[]>,\n params?: P,\n options?: number | { pageSize?: number; cursor?: (item: T) => string | undefined },\n ): AsyncGenerator<T> {\n const pageSize = typeof options === 'number' ? options : (options?.pageSize ?? 50);\n const cursorOf = typeof options === 'object' ? options.cursor : undefined;\n let offset = 0;\n let after: string | undefined;\n while (true) {\n const page = { ...((params ?? {}) as P), limit: pageSize } as P & {\n limit: number;\n offset?: number;\n starting_after?: string;\n };\n if (cursorOf) {\n if (after !== undefined) page.starting_after = after;\n } else {\n page.offset = offset;\n }\n const result = await listFn(page);\n const items = Array.isArray(result) ? result : result.data;\n if (items.length === 0) break;\n for (const item of items) {\n yield item;\n }\n if (items.length < pageSize) break;\n if (cursorOf) {\n const last = items[items.length - 1];\n if (last === undefined) break;\n after = cursorOf(last);\n if (after === undefined) break;\n } else {\n offset += items.length;\n }\n }\n }\n}\n","import type {\n Connector,\n Currency,\n EuclidComparison,\n EuclidComparisonType,\n EuclidIfStatement,\n EuclidValue,\n PaymentMethod,\n PlatformFeeKind,\n PlatformFeeOutput,\n PlatformFeeProgram,\n PlatformFeeRule,\n} from './types';\n\n/** A single condition leaf in the builder's condition tree. */\nexport interface LeafNode {\n kind: 'leaf';\n lhs: string;\n comparison: EuclidComparisonType;\n value: EuclidValue;\n}\n\n/** An AND (`all`) or OR (`any`) group of condition nodes. */\nexport interface GroupNode {\n kind: 'all' | 'any';\n children: ConditionNode[];\n}\n\nexport type ConditionNode = LeafNode | GroupNode;\n\n/**\n * A condition leaf. Numeric values (amount, merchant_volume) tag as `number`;\n * string values (payment_method, connector, currency, card_network) tag as\n * `enum_variant`.\n */\nexport function leaf(\n lhs: string,\n comparison: EuclidComparisonType,\n value: string | number,\n): LeafNode {\n const tagged: EuclidValue =\n typeof value === 'number' ? { type: 'number', value } : { type: 'enum_variant', value };\n return { kind: 'leaf', lhs, comparison, value: tagged };\n}\n\n/** AND group — all children must match. */\nexport function allOf(...children: ConditionNode[]): GroupNode {\n return { kind: 'all', children };\n}\n\n/** OR group — any child matching is enough. */\nexport function anyOf(...children: ConditionNode[]): GroupNode {\n return { kind: 'any', children };\n}\n\n/**\n * How a rule (or the default) prices a transaction. `fee_type` is inferred:\n * percentage-only → `percentage`, flat-only → `flat`, both → `combined`.\n */\nexport interface FeeSpecInput {\n /** Percentage fee, e.g. `2.5` means 2.5%. */\n percentage?: number;\n /** Flat fee in minor units. */\n flat?: number;\n /** ISO 4217 currency for the flat fee. */\n flatCurrency?: string;\n /** Clamp floor in minor units. */\n min?: number;\n /** Clamp ceiling in minor units. */\n max?: number;\n}\n\n/**\n * Friendly conditions for a rule. Every provided key becomes one condition and\n * they are ANDed together. For dimensions not covered here (payment-method-type\n * keys like `crypto`/`wallet`, metadata, value arrays) use `rawConditions`.\n */\nexport interface FeeRuleConditions {\n paymentMethod?: PaymentMethod;\n connector?: Connector;\n currency?: Currency;\n cardNetwork?: string;\n /**\n * Customer billing-address country. Must be the exact backend `Country` enum\n * variant (PascalCase full name, e.g. `Germany`/`UnitedStatesOfAmerica`), not\n * an ISO code — the engine lowers `billing_country` via case-sensitive\n * `from_str`.\n */\n billingCountry?: string;\n /** `amount == n` (minor units). */\n amountEquals?: number;\n /** `amount > n` (minor units). */\n amountGreaterThan?: number;\n /** `amount < n` (minor units). */\n amountLessThan?: number;\n /**\n * `merchant_volume == n` — the merchant's previous-month volume snapshot\n * (USD minor units). Combine with any other condition, e.g.\n * `{ paymentMethod: 'crypto', merchantVolumeGreaterThan: 1_000_000 }`.\n */\n merchantVolumeEquals?: number;\n /** `merchant_volume > n` (USD minor units). */\n merchantVolumeGreaterThan?: number;\n /** `merchant_volume < n` (USD minor units). */\n merchantVolumeLessThan?: number;\n}\n\nexport interface FeeRuleInput {\n name: string;\n /** Friendly conditions (ANDed). Omit for an always-matching rule (prefer `otherwise`). */\n when?: FeeRuleConditions;\n /** Extra raw conditions ANDed in, for dimensions `when` does not cover. */\n rawConditions?: EuclidComparison[];\n /** Nested AND/OR condition tree. Mutually exclusive with `when`/`rawConditions`. */\n match?: ConditionNode;\n fee: FeeSpecInput;\n}\n\nfunction toFeeOutput(spec: FeeSpecInput): PlatformFeeOutput {\n const hasPct = spec.percentage != null;\n const hasFlat = spec.flat != null;\n const feeType: PlatformFeeKind = hasPct && hasFlat ? 'combined' : hasFlat ? 'flat' : 'percentage';\n return {\n fee_type: feeType,\n percentage_fee: spec.percentage ?? null,\n flat_fee_amount: spec.flat ?? null,\n flat_fee_currency: spec.flatCurrency ?? null,\n min_fee_amount: spec.min ?? null,\n max_fee_amount: spec.max ?? null,\n };\n}\n\nfunction enumCondition(lhs: string, value: string): EuclidComparison {\n return { lhs, comparison: 'equal', value: { type: 'enum_variant', value }, metadata: {} };\n}\n\nfunction numberCondition(\n lhs: string,\n comparison: EuclidComparisonType,\n value: number,\n): EuclidComparison {\n return { lhs, comparison, value: { type: 'number', value }, metadata: {} };\n}\n\nfunction buildConditions(\n when: FeeRuleConditions = {},\n raw: EuclidComparison[] = [],\n): EuclidComparison[] {\n const out: EuclidComparison[] = [];\n if (when.paymentMethod != null) out.push(enumCondition('payment_method', when.paymentMethod));\n if (when.connector != null) out.push(enumCondition('connector', when.connector));\n if (when.currency != null) out.push(enumCondition('currency', when.currency));\n if (when.cardNetwork != null) out.push(enumCondition('card_network', when.cardNetwork));\n if (when.billingCountry != null) out.push(enumCondition('billing_country', when.billingCountry));\n if (when.amountEquals != null) out.push(numberCondition('amount', 'equal', when.amountEquals));\n if (when.amountGreaterThan != null) {\n out.push(numberCondition('amount', 'greater_than', when.amountGreaterThan));\n }\n if (when.amountLessThan != null) {\n out.push(numberCondition('amount', 'less_than', when.amountLessThan));\n }\n if (when.merchantVolumeEquals != null) {\n out.push(numberCondition('merchant_volume', 'equal', when.merchantVolumeEquals));\n }\n if (when.merchantVolumeGreaterThan != null) {\n out.push(numberCondition('merchant_volume', 'greater_than', when.merchantVolumeGreaterThan));\n }\n if (when.merchantVolumeLessThan != null) {\n out.push(numberCondition('merchant_volume', 'less_than', when.merchantVolumeLessThan));\n }\n out.push(...raw);\n return out;\n}\n\nfunction leafToComparison(node: LeafNode): EuclidComparison {\n return { lhs: node.lhs, comparison: node.comparison, value: node.value, metadata: {} };\n}\n\n/**\n * Flatten associativity (nested all-in-all / any-in-any) and collapse\n * single-child groups, so every group child of an `all` is an `any`.\n * @internal\n */\nexport function normalizeNode(node: ConditionNode): ConditionNode {\n if (node.kind === 'leaf') return node;\n const children = node.children.map(normalizeNode);\n const flat: ConditionNode[] = [];\n for (const c of children) {\n if (c.kind === node.kind) flat.push(...c.children);\n else flat.push(c);\n }\n if (flat.length === 1) return flat[0];\n return { kind: node.kind, children: flat };\n}\n\nfunction toStatement(node: ConditionNode): EuclidIfStatement {\n if (node.kind === 'leaf') return { condition: [leafToComparison(node)], nested: null };\n // Unreachable via current callers (encodeStatements strips top-level any); kept for totality.\n if (node.kind === 'any') {\n return { condition: [], nested: node.children.map(toStatement) };\n }\n // 'all': after normalize, group children are all 'any'.\n const leaves = node.children.filter((c): c is LeafNode => c.kind === 'leaf');\n const groups = node.children.filter((c): c is GroupNode => c.kind !== 'leaf');\n const condition = leaves.map(leafToComparison);\n if (groups.length === 0) return { condition, nested: null };\n const [first, ...rest] = groups;\n // `first` is an OR; AND each of its branches with the remaining OR groups.\n const nested = first.children.map((branch) => toStatement(normalizeNode(allOf(branch, ...rest))));\n return { condition, nested };\n}\n\nfunction assertNoEmptyAnyOf(node: ConditionNode): void {\n if (node.kind === 'leaf') return;\n if (node.kind === 'any' && node.children.length === 0) {\n throw new Error('feeProgram: an anyOf() group must have at least one condition');\n }\n node.children.forEach(assertNoEmptyAnyOf);\n}\n\n/**\n * Encode a rule's match (a condition tree) into the engine's `statements[]`.\n * A top-level OR spreads across statements; anything else is a single statement.\n * @internal\n */\nexport function encodeStatements(match: ConditionNode): EuclidIfStatement[] {\n const m = normalizeNode(match);\n if (m.kind === 'any') return m.children.map(toStatement);\n return [toStatement(m)];\n}\n\nfunction comparisonToLeaf(c: EuclidComparison): LeafNode {\n return { kind: 'leaf', lhs: c.lhs, comparison: c.comparison, value: c.value };\n}\n\nfunction statementToNode(stmt: EuclidIfStatement): ConditionNode {\n const leaves = stmt.condition.map(comparisonToLeaf);\n if (stmt.nested && stmt.nested.length > 0) {\n const orNode = anyOf(...stmt.nested.map(statementToNode));\n if (leaves.length === 0) return orNode;\n return allOf(...leaves, orNode);\n }\n return leaves.length === 1 ? leaves[0] : allOf(...leaves);\n}\n\n/**\n * Decode a rule's `statements[]` back into a condition tree.\n *\n * Returns a tree that is **logically equivalent** to the source. It is\n * deep-equal to `normalizeNode(input)` only when no `all` group contains two\n * or more `any` groups; where the encoder distributed AND over OR, the decoded\n * shape differs (still equivalent).\n */\nexport function ruleMatchToTree(statements: EuclidIfStatement[]): ConditionNode {\n if (statements.length === 1) return normalizeNode(statementToNode(statements[0]));\n return normalizeNode(anyOf(...statements.map(statementToNode)));\n}\n\n/**\n * Decode a stored program into the builder's editable model.\n *\n * Returns a tree that is **logically equivalent** to the source. It is\n * deep-equal to `normalizeNode(input)` only when no `all` group contains two\n * or more `any` groups; where the encoder distributed AND over OR, the decoded\n * shape differs (still equivalent).\n */\nexport function programToTree(program: PlatformFeeProgram): {\n rules: { name: string; match: ConditionNode; fee: PlatformFeeOutput | null }[];\n otherwise: PlatformFeeOutput | null;\n} {\n return {\n rules: program.rules.map((r) => ({\n name: r.name,\n match: ruleMatchToTree(r.statements),\n fee: r.connectorSelection.fee ?? null,\n })),\n otherwise: program.defaultSelection.fee ?? null,\n };\n}\n\n/**\n * Fluent builder for a platform fee-rule program. Emits the exact Euclid wire\n * shape (camelCase tree, tagged values, `metadata: {}` everywhere) so callers\n * never hand-write the AST. Rules are evaluated in order; the first match wins,\n * else `otherwise` (the default selection).\n *\n * @example\n * ```ts\n * const algorithm = feeProgram()\n * .rule({ name: 'crypto', when: { paymentMethod: 'crypto' }, fee: { percentage: 1.0 } })\n * .rule({\n * name: 'card_on_cryptomus',\n * when: { paymentMethod: 'card', connector: 'cryptomus' },\n * fee: { percentage: 2.0 },\n * })\n * .otherwise({ percentage: 3.0 })\n * .build();\n *\n * await delopay.fees.rules.upsert({ algorithm }, merchantId);\n * ```\n */\nexport class FeeProgramBuilder {\n private readonly rules: PlatformFeeRule[] = [];\n private defaultFee: PlatformFeeOutput | null = null;\n\n /** Append a rule. Provided `when`/`rawConditions` are ANDed. */\n rule(input: FeeRuleInput): this {\n if (input.match) assertNoEmptyAnyOf(input.match);\n const statements: PlatformFeeRule['statements'] = input.match\n ? encodeStatements(input.match)\n : [{ condition: buildConditions(input.when, input.rawConditions) }];\n this.rules.push({\n name: input.name,\n connectorSelection: { fee: toFeeOutput(input.fee) },\n statements,\n });\n return this;\n }\n\n /** Set the default selection (applied when no rule matches). */\n otherwise(fee: FeeSpecInput): this {\n this.defaultFee = toFeeOutput(fee);\n return this;\n }\n\n /** Produce the wire-ready program. */\n build(): PlatformFeeProgram {\n return {\n defaultSelection: { fee: this.defaultFee },\n rules: this.rules,\n metadata: {},\n };\n }\n}\n\n/** Start building a platform fee-rule program. See {@link FeeProgramBuilder}. */\nexport function feeProgram(): FeeProgramBuilder {\n return new FeeProgramBuilder();\n}\n","// Checkout branding — typed shape, design tokens, palettes, persistence\n// codec, CSS sanitizer, and DOM helpers for `--dp-*` CSS variables.\n//\n// Both delopay-checkout and delopay-control-center consume this module.\n//\n// Persistence: top-level fields own the \"loud\" tokens (logo, theme,\n// payment_button_*, background_colour, etc.). Everything else lives in\n// `sdk_ui_rules.branding` as a nested string-keyed map — booleans and\n// numbers round-trip as strings, the trust-badge list is JSON-stringified.\n\n// --- Types --------------------------------------------------------------\n\nexport type CornerRadius = 'square' | 'small' | 'medium' | 'large' | 'pill';\n\n// Surfaces and inputs never make sense pill-shaped (a pill input ends up with\n// half-circle ends crammed against text). The form picker only exposes these\n// four; if a stale 'pill' value lands here from older saved data, decode\n// drops it back to 'medium'. Buttons and badges still allow 'pill'.\nexport type NonPillRadius = Exclude<CornerRadius, 'pill'>;\n\n// Spacing scales — split apart so the merchant can independently tune\n// surface padding, vertical rhythm, input height and pay-button height. Used\n// to live as a single `density` enum but that conflated four dimensions.\nexport type SpacingScale = 'compact' | 'comfortable' | 'spacious';\nexport type SizeScale = 'sm' | 'md' | 'lg';\nexport type SurfaceStyle = 'flat' | 'outlined' | 'elevated';\n\nexport type FontFamily =\n | 'inter'\n | 'system'\n | 'serif'\n | 'mono'\n | 'roboto'\n | 'poppins'\n | 'manrope'\n | 'dm-sans'\n | 'space-grotesk'\n | 'plex-sans'\n | 'work-sans'\n | 'open-sans'\n | 'lora'\n | 'playfair'\n | 'plex-mono'\n | 'jetbrains-mono';\n\nexport type FontWeight = 'regular' | 'medium' | 'semibold' | 'bold';\nexport type LayoutStyle = 'compact' | 'split';\nexport type SummaryPosition = 'left' | 'right';\n\n// Stripe Elements only supports two label modes (\"above\" or hidden via the\n// .Label-collapse hack); a \"floating\" label is not a Stripe concept and\n// would only render in our own mock — preview was lying about it. Persisted\n// `'floating'` is silently decoded to `'above'` for back-compat.\nexport type LabelStyle = 'above' | 'hidden';\n\n// Stripe Elements layout. Honored inside the StripeCardPane only — other\n// connector panes stack vertically regardless of this setting.\nexport type PaymentLayout = 'tabs' | 'accordion' | 'spaced_accordion';\n\nexport type LogoShape = 'square' | 'rounded' | 'circle';\nexport type LogoSize = 'sm' | 'md' | 'lg';\n\nexport interface TrustBadge {\n id: string;\n label: string;\n textColor: string;\n backgroundColor: string;\n borderColor: string | null;\n}\n\n// Merchant-defined checkout inputs. Rendered by the buyer-facing checkout\n// above the payment surface; submitted values land in the payment's\n// `metadata` under each field's `key`. Persisted JSON-stringified under\n// `sdk_ui_rules.branding.customFields` (same transport as trustBadges).\n// `checkbox` is a single opt-in box (terms acceptance, marketing consent),\n// not a multi-select. Its submitted value is always the string `'true'` or\n// `'false'` — never absent — so a merchant can tell \"declined\" from \"never\n// asked\" in the payment's metadata, which is what makes it usable as a\n// consent record. See `CHECKBOX_CHECKED` / `isCheckboxChecked`.\nexport type CustomFieldType = 'text' | 'textarea' | 'password' | 'email' | 'select' | 'checkbox';\n\n// Per-locale overrides ('de', 'en', …). Missing locale falls back to the\n// default-language string on the field itself — see `customFieldText`.\nexport type CustomFieldTranslations = Record<string, string>;\n\nexport interface CustomFieldOption {\n value: string;\n label: string;\n labelTranslations: CustomFieldTranslations;\n}\n\n// --- Conditional visibility ---------------------------------------------\n//\n// A field can be gated on facts the payment already carries when the\n// checkout renders: the intent's `metadata` (which a shop integration fills\n// per product/category — see the WordPress plugin's product metadata), its\n// `currency`, or its `amount`. This is what lets one profile serve a\n// \"Windows key\" order (no fields) and a \"Spotify account\" order (login\n// fields) without two shops.\n//\n// Evaluation is authoritative on the **backend**: `form_payment_link_data`\n// drops non-matching fields from the payload the buyer's browser receives,\n// so merchant metadata never leaves the server and the rules can't be\n// tampered with client-side. The implementation here is the shared\n// specification (and drives the control-center's builder); the Rust mirror\n// in `crates/router/src/core/payment_link/custom_fields.rs` must stay\n// behaviorally identical.\nexport type CustomFieldConditionSource = 'metadata' | 'currency' | 'amount';\n\n// String operators apply to metadata + currency; numeric ones (`gt`…`lte`)\n// apply to amount and to metadata values that parse as numbers.\nexport type CustomFieldOperator =\n | 'equals'\n | 'not_equals'\n | 'contains'\n | 'not_contains'\n | 'starts_with'\n | 'ends_with'\n | 'in'\n | 'not_in'\n | 'exists'\n | 'not_exists'\n | 'gt'\n | 'gte'\n | 'lt'\n | 'lte';\n\nexport interface CustomFieldCondition {\n // Stable identity for editor list operations (reorder/remove). Not part\n // of the semantics.\n id: string;\n source: CustomFieldConditionSource;\n // Metadata key to read. Ignored (and persisted empty) for currency/amount.\n key: string;\n operator: CustomFieldOperator;\n // Right-hand operand. `in`/`not_in` read it as a comma-separated list;\n // `exists`/`not_exists` ignore it; amount comparisons parse it as an\n // integer in the currency's minor unit (1000 = 10.00).\n value: string;\n}\n\nexport interface CustomFieldVisibility {\n // `always` — unconditional (the default, and what every pre-feature field\n // decodes to). `match` — evaluate `conditions`.\n mode: 'always' | 'match';\n // How to combine multiple conditions.\n match: 'all' | 'any';\n conditions: CustomFieldCondition[];\n}\n\nexport interface CheckoutCustomField {\n // Stable identity for editor list operations (reorder/remove).\n id: string;\n // Metadata key the submitted value is stored under. Must be unique per\n // profile; the editor enforces `CUSTOM_FIELD_KEY_PATTERN`.\n key: string;\n type: CustomFieldType;\n // Default-language copy; `*Translations` maps override per locale.\n label: string;\n labelTranslations: CustomFieldTranslations;\n placeholder: string;\n placeholderTranslations: CustomFieldTranslations;\n helpText: string;\n helpTextTranslations: CustomFieldTranslations;\n required: boolean;\n // Disabled fields stay configured but are neither rendered nor submitted.\n enabled: boolean;\n // Length bounds apply to text/textarea/password/email; null = unbounded.\n minLength: number | null;\n maxLength: number | null;\n // Prefill for text-like fields; for selects, the option `value` selected\n // initially (empty = placeholder \"choose\" state).\n defaultValue: string;\n // Select choices; ignored for other types.\n options: CustomFieldOption[];\n // Conditional display. Always populated by the decoder — fields without a\n // persisted rule decode to `{ mode: 'always', … }`.\n visibility: CustomFieldVisibility;\n}\n\nexport interface CheckoutBranding {\n // Brand identity\n displayName: string;\n logoUrl: string;\n tagline: string;\n showLogo: boolean;\n logoShape: LogoShape;\n logoSize: LogoSize;\n\n // Color tokens\n primary: string;\n background: string;\n surface: string;\n text: string;\n heading: string;\n muted: string;\n border: string;\n accentText: string;\n buttonBackground: string;\n buttonText: string;\n\n // Typography\n fontFamily: FontFamily;\n headingWeight: FontWeight;\n\n // Shape — granular per-element. Surfaces & inputs use a narrower union\n // (no pill) because pill cards/inputs are always wrong; button and badge\n // keep the full `CornerRadius` since pill is a legitimate look there.\n radiusSurface: NonPillRadius;\n radiusInput: NonPillRadius;\n radiusButton: CornerRadius;\n radiusBadge: CornerRadius;\n surfaceStyle: SurfaceStyle;\n\n // Spacing — four independent dimensions.\n surfacePadding: SpacingScale;\n verticalGap: SpacingScale;\n inputSize: SizeScale;\n buttonSize: SizeScale;\n\n // Layout\n layout: LayoutStyle;\n summaryPosition: SummaryPosition;\n showOrderSummary: boolean;\n summaryGradient: boolean;\n showTotal: boolean;\n totalLabel: string;\n showCurrencyCode: boolean;\n showOrderItems: boolean;\n\n // Trust badges (fully customizable; empty = hide row).\n trustBadges: TrustBadge[];\n\n // Merchant-defined checkout inputs (empty = no custom fields section).\n customFields: CheckoutCustomField[];\n\n // Copy. All of these are optional in the persisted form: empty string\n // means \"unset\" and consumers should fall back (e.g. payButtonLabel falls\n // back to a localized \"Pay $X\" string).\n headerText: string;\n payButtonLabel: string;\n cardTermsMessage: string;\n footerText: string;\n supportEmail: string;\n\n // Stripe Elements behavior. `paymentLayout` only affects what's painted\n // inside Stripe's iframe; non-Stripe connector panes stack vertically\n // regardless. `labelStyle` is also Stripe-iframe scope.\n paymentLayout: PaymentLayout;\n labelStyle: LabelStyle;\n\n // Footer\n showPoweredBy: boolean;\n\n // Advanced — raw CSS appended after brand-token CSS variables are\n // applied, so its declarations win cascade order. Sanitized at render\n // time (see `sanitizeCustomCss`); persisted as-typed under\n // `sdk_ui_rules.branding.customCss`.\n customCss: string;\n}\n\n// --- Token maps ---------------------------------------------------------\n\n// Self-hostable font stacks. The buyer-facing checkout bundles these via\n// @fontsource* packages; the variable-font names ('Inter Variable', …) are\n// listed first so the smaller variable file is preferred when bundled.\nconst FONT_STACKS: Record<FontFamily, string> = {\n inter: \"'Inter Variable', 'Inter', system-ui, -apple-system, sans-serif\",\n system:\n \"system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif\",\n serif: \"Georgia, 'Times New Roman', serif\",\n mono: 'ui-monospace, SFMono-Regular, Menlo, Consolas, monospace',\n roboto: \"'Roboto', system-ui, sans-serif\",\n poppins: \"'Poppins', system-ui, sans-serif\",\n manrope: \"'Manrope Variable', 'Manrope', system-ui, sans-serif\",\n 'dm-sans': \"'DM Sans Variable', 'DM Sans', system-ui, sans-serif\",\n 'space-grotesk': \"'Space Grotesk Variable', 'Space Grotesk', system-ui, sans-serif\",\n 'plex-sans': \"'IBM Plex Sans', system-ui, sans-serif\",\n 'work-sans': \"'Work Sans Variable', 'Work Sans', system-ui, sans-serif\",\n 'open-sans': \"'Open Sans Variable', 'Open Sans', system-ui, sans-serif\",\n lora: \"'Lora Variable', 'Lora', Georgia, serif\",\n playfair: \"'Playfair Display Variable', 'Playfair Display', Georgia, serif\",\n 'plex-mono': \"'IBM Plex Mono', ui-monospace, monospace\",\n 'jetbrains-mono': \"'JetBrains Mono Variable', 'JetBrains Mono', ui-monospace, monospace\",\n};\n\nconst RADIUS_PX: Record<CornerRadius, string> = {\n square: '0px',\n small: '6px',\n medium: '12px',\n large: '20px',\n pill: '999px',\n};\n\nconst FONT_WEIGHT_NUMERIC: Record<FontWeight, string> = {\n regular: '400',\n medium: '500',\n semibold: '600',\n bold: '700',\n};\n\nconst SURFACE_PAD: Record<SpacingScale, string> = {\n compact: '1rem',\n comfortable: '1.5rem',\n spacious: '2rem',\n};\n\nconst VERTICAL_GAP: Record<SpacingScale, string> = {\n compact: '0.75rem',\n comfortable: '1rem',\n spacious: '1.5rem',\n};\n\nconst INPUT_PAD: Record<SizeScale, string> = {\n sm: '0.5rem 0.75rem',\n md: '0.625rem 0.75rem',\n lg: '0.875rem 0.875rem',\n};\n\nconst BUTTON_PAD: Record<SizeScale, string> = {\n sm: '0.625rem 1rem',\n md: '0.875rem 1.25rem',\n lg: '1.125rem 1.5rem',\n};\n\nexport function fontStack(family: FontFamily): string {\n return FONT_STACKS[family] ?? FONT_STACKS.inter;\n}\n\nexport function radiusValue(radius: CornerRadius): string {\n return RADIUS_PX[radius] ?? RADIUS_PX.medium;\n}\n\nexport function fontWeightValue(weight: FontWeight): string {\n return FONT_WEIGHT_NUMERIC[weight] ?? '600';\n}\n\nexport function surfacePadValue(scale: SpacingScale): string {\n return SURFACE_PAD[scale] ?? SURFACE_PAD.comfortable;\n}\n\nexport function verticalGapValue(scale: SpacingScale): string {\n return VERTICAL_GAP[scale] ?? VERTICAL_GAP.comfortable;\n}\n\nexport function inputPadValue(size: SizeScale): string {\n return INPUT_PAD[size] ?? INPUT_PAD.md;\n}\n\nexport function buttonPadValue(size: SizeScale): string {\n return BUTTON_PAD[size] ?? BUTTON_PAD.md;\n}\n\nexport function logoDimensions(size: LogoSize): { px: number; radius: number } {\n switch (size) {\n case 'sm':\n return { px: 36, radius: 8 };\n case 'lg':\n return { px: 64, radius: 16 };\n case 'md':\n default:\n return { px: 48, radius: 12 };\n }\n}\n\nconst HEX_RE = /^#[0-9a-fA-F]{3}([0-9a-fA-F]{3})?$/;\n\nexport function isHexColor(value: string): boolean {\n return HEX_RE.test(value.trim());\n}\n\n// Crude perceived-luminance check — picks the right Stripe Elements preset\n// (`'night'` vs `'stripe'`) when the merchant has a dark surface. Inputs we\n// don't recognize as a 6-/3-digit hex fall through to \"light\" since that's\n// the safer assumption for the default palette.\nexport function isDarkSurface(color: string): boolean {\n const m = color.replace('#', '').trim();\n if (m.length !== 3 && m.length !== 6) return false;\n const full =\n m.length === 3\n ? m\n .split('')\n .map((c) => c + c)\n .join('')\n : m;\n const r = parseInt(full.slice(0, 2), 16);\n const g = parseInt(full.slice(2, 4), 16);\n const b = parseInt(full.slice(4, 6), 16);\n if ([r, g, b].some(Number.isNaN)) return false;\n const luma = (r * 299 + g * 587 + b * 114) / 1000;\n return luma < 128;\n}\n\n// --- Defaults -----------------------------------------------------------\n\n// Light-mode DeloPay-branded baseline. Hex values come straight from\n// `design-guidelines/colors.md`:\n// - #1E4FEB is `--color-dp-blue`, the wordmark/icon brand blue\n// - #0A1130 is `--color-dp-blue-dark`, the wordmark navy\n// - the rest are slate-50 / slate-200 / slate-500 / slate-800 from the\n// design system's neutral ramp.\n// Picked for: high contrast, neutral surroundings, brand-blue accents,\n// confident navy CTA. Reads \"fintech\" without feeling cold.\nconst LIGHT_PALETTE = {\n primary: '#1E4FEB',\n background: '#f8fafc',\n surface: '#ffffff',\n text: '#1e293b',\n heading: '#0A1130',\n muted: '#64748b',\n border: '#e2e8f0',\n accentText: '#1E4FEB',\n buttonBackground: '#0A1130',\n buttonText: '#ffffff',\n} as const;\n\nexport const DEFAULT_BADGES: TrustBadge[] = [\n {\n id: 'secure',\n label: 'Secure',\n textColor: '#047857',\n backgroundColor: '#ecfdf5',\n borderColor: '#a7f3d0',\n },\n {\n id: 'ssl',\n label: '256-bit SSL',\n textColor: '#1E4FEB',\n backgroundColor: '#eff6ff',\n borderColor: '#bfdbfe',\n },\n];\n\n// Dark-mode equivalents of DEFAULT_BADGES. Dark trust chips need solid hex\n// (the form's color picker only accepts hex), so we pick the design system's\n// success-900 / info-900 backdrops paired with their *-400 foreground tokens.\nexport const DEFAULT_BADGES_DARK: TrustBadge[] = [\n {\n id: 'secure',\n label: 'Secure',\n textColor: '#34d399',\n backgroundColor: '#064e3b',\n borderColor: '#065f46',\n },\n {\n id: 'ssl',\n label: '256-bit SSL',\n textColor: '#60a5fa',\n backgroundColor: '#172554',\n borderColor: '#1e40af',\n },\n];\n\nconst DEFAULT_BRANDING_BASE: Omit<\n CheckoutBranding,\n keyof typeof LIGHT_PALETTE | 'trustBadges' | 'customFields'\n> = {\n displayName: '',\n logoUrl: '',\n tagline: '',\n // Logo + summary gradient OFF by default — an unconfigured DeloPay\n // checkout reads cleaner without a placeholder logo block, and the\n // gradient implies a primary tint the merchant hasn't yet picked.\n showLogo: false,\n logoShape: 'rounded',\n logoSize: 'md',\n\n fontFamily: 'inter',\n headingWeight: 'semibold',\n\n radiusSurface: 'medium',\n radiusInput: 'medium',\n radiusButton: 'medium',\n radiusBadge: 'pill',\n surfaceStyle: 'elevated',\n surfacePadding: 'comfortable',\n verticalGap: 'comfortable',\n inputSize: 'md',\n buttonSize: 'md',\n\n layout: 'split',\n summaryPosition: 'left',\n showOrderSummary: true,\n summaryGradient: false,\n showTotal: true,\n totalLabel: 'Total',\n showCurrencyCode: false,\n showOrderItems: true,\n\n headerText: '',\n payButtonLabel: '',\n cardTermsMessage: '',\n footerText: '',\n supportEmail: '',\n\n paymentLayout: 'tabs',\n labelStyle: 'above',\n showPoweredBy: true,\n\n customCss: '',\n};\n\nexport const DEFAULT_BRANDING: CheckoutBranding = {\n ...DEFAULT_BRANDING_BASE,\n ...LIGHT_PALETTE,\n trustBadges: DEFAULT_BADGES.map((b) => ({ ...b })),\n customFields: [],\n};\n\n// Dark counterpart to DEFAULT_BRANDING. Same form-only fields stay empty\n// (logo / display name / tagline / copy) — only visual tokens diverge.\n// Palette mirrors the design-guidelines dark ramp:\n// - background = slate-950, surface = slate-900 → soft contrast.\n// - text = slate-200, heading = slate-50 → AA+ contrast on the surface.\n// - muted = slate-400, border = slate-800 → chrome that fades into the bg.\n// - accentText = primary-400, button bg = brand blue → brand pops on dark\n// where the light theme's near-black navy CTA would disappear.\n// - surfaceStyle = 'flat' because soft drop-shadows don't read on dark\n// surfaces; the existing 'elevated' shadow tokens are tuned for light.\nexport const DEFAULT_BRANDING_DARK: CheckoutBranding = {\n ...DEFAULT_BRANDING_BASE,\n primary: '#1E4FEB',\n background: '#020617',\n surface: '#0f172a',\n text: '#e2e8f0',\n heading: '#f8fafc',\n muted: '#94a3b8',\n border: '#1e293b',\n accentText: '#60a5fa',\n buttonBackground: '#1E4FEB',\n buttonText: '#ffffff',\n surfaceStyle: 'flat',\n trustBadges: DEFAULT_BADGES_DARK.map((b) => ({ ...b })),\n customFields: [],\n};\n\n// Back-compat alias. Prefer `DEFAULT_BRANDING` directly.\nexport function defaultBranding(): CheckoutBranding {\n return cloneBranding(DEFAULT_BRANDING);\n}\n\n// Deep-ish clone — needed because the form mutates state reactively and we\n// don't want shared TrustBadge / CheckoutCustomField object refs across the\n// loaded/edit/default snapshots. Spread is shallow; array elements would\n// otherwise be shared between snapshots, breaking reset.\nexport function cloneBranding(b: CheckoutBranding): CheckoutBranding {\n return {\n ...b,\n trustBadges: b.trustBadges.map((badge) => ({ ...badge })),\n customFields: b.customFields.map(cloneCustomField),\n };\n}\n\nexport function cloneCustomField(f: CheckoutCustomField): CheckoutCustomField {\n return {\n ...f,\n labelTranslations: { ...f.labelTranslations },\n placeholderTranslations: { ...f.placeholderTranslations },\n helpTextTranslations: { ...f.helpTextTranslations },\n options: f.options.map((o) => ({ ...o, labelTranslations: { ...o.labelTranslations } })),\n visibility: {\n ...f.visibility,\n conditions: f.visibility.conditions.map((c) => ({ ...c })),\n },\n };\n}\n\n// --- Sanitizer ----------------------------------------------------------\n\n// Hard cap on the persisted custom CSS payload. Mirrors the editor's\n// validation; oversized input is dropped to null rather than truncated,\n// since a half-truncated rule is worse than no rule.\nexport const CUSTOM_CSS_MAX_LENGTH = 50_000;\n\n// Strip CSS tokens that turn a stylesheet into a delivery vector before\n// handing the merchant's input to the renderer. The list isn't exhaustive\n// — it's the everyday surface area:\n//\n// - `</style` would let injected text break out of the <style> block and\n// parse as HTML/JS. Replaced with a benign token (not removed) so\n// `</styled-tag` (unlikely but possible inside a content: string)\n// doesn't silently merge into surrounding text.\n// - `@import` would let the merchant pull in a remote stylesheet on\n// every buyer page-load (analytics by side-channel; possible buyer-IP\n// leak).\n// - `expression(…)` was a legacy IE construct that ran JS from CSS.\n// - `behavior:` and `-moz-binding:` ditto for IE/old-Gecko.\n// - `javascript:` URLs in url(...) execute on resource load in some\n// browsers/contexts.\n//\n// Anything else passes through. The merchant can still write whatever\n// declarations they like (background images, gradients, transforms,\n// keyframes, container queries, …).\nexport function sanitizeCustomCss(raw: string | null | undefined): string | null {\n if (typeof raw !== 'string') return null;\n const trimmed = raw.trim();\n if (trimmed.length === 0) return null;\n if (trimmed.length > CUSTOM_CSS_MAX_LENGTH) return null;\n\n let out = trimmed;\n out = out.replace(/<\\/style/gi, '<\\\\/style');\n out = out.replace(/@import\\b[^;]*;?/gi, '');\n out = out.replace(/expression\\s*\\(/gi, '/* expression( */');\n out = out.replace(/(^|[^a-z-])behavior\\s*:/gi, '$1/* behavior: */');\n out = out.replace(/-moz-binding\\s*:/gi, '/* -moz-binding: */');\n out = out.replace(/url\\s*\\(\\s*[\"']?\\s*javascript:/gi, 'url(invalid:');\n return out;\n}\n\n// --- Codec --------------------------------------------------------------\n\n// Structural shape the decoder reads. Both `CheckoutDetails` (public buyer\n// payload) and `BusinessPaymentLinkConfig` (merchant config request shape)\n// satisfy this via duck typing — they each fill some of these and leave the\n// rest undefined. `merchant_*` and `seller_*`/`logo` are aliases for the\n// same API field, surfaced under different names by the two payloads.\nexport interface BrandingSource {\n // Identity (one or the other, depending on payload shape)\n merchant_name?: string | null;\n seller_name?: string | null;\n merchant_logo?: string | null;\n logo?: string | null;\n merchant_description?: string | null;\n\n // Visual\n theme?: string | null;\n background_colour?: string | null;\n payment_button_colour?: string | null;\n payment_button_text_colour?: string | null;\n\n // Copy\n payment_form_header_text?: string | null;\n payment_button_text?: string | null;\n custom_message_for_card_terms?: string | null;\n\n // Footer\n branding_visibility?: boolean | null;\n\n // Stripe\n sdk_layout?: string | null;\n payment_form_label_type?: string | null;\n\n // The bag for everything else\n sdk_ui_rules?: Record<string, Record<string, string> | null | undefined> | null;\n}\n\nconst BRANDING_GROUP_KEY = 'branding';\n\nconst ALL_FONT_FAMILIES: readonly FontFamily[] = [\n 'inter',\n 'system',\n 'serif',\n 'mono',\n 'roboto',\n 'poppins',\n 'manrope',\n 'dm-sans',\n 'space-grotesk',\n 'plex-sans',\n 'work-sans',\n 'open-sans',\n 'lora',\n 'playfair',\n 'plex-mono',\n 'jetbrains-mono',\n];\n\nconst ALL_RADII: readonly CornerRadius[] = ['square', 'small', 'medium', 'large', 'pill'];\nconst NON_PILL_RADII: readonly NonPillRadius[] = ['square', 'small', 'medium', 'large'];\n\nfunction pickEnum<T extends string>(value: unknown, allowed: readonly T[], fallback: T): T {\n if (typeof value !== 'string') return fallback;\n return (allowed as readonly string[]).includes(value) ? (value as T) : fallback;\n}\n\nfunction parseBool(value: unknown, fallback: boolean): boolean {\n if (typeof value === 'boolean') return value;\n if (value === 'true') return true;\n if (value === 'false') return false;\n return fallback;\n}\n\nfunction s(value: string | null | undefined): string {\n return typeof value === 'string' ? value : '';\n}\n\n// Decode the JSON-encoded trust badges stored under\n// `sdk_ui_rules.branding.trustBadges`. Tolerant: a malformed payload,\n// missing fields, or wrong types fall through to null so the caller can\n// substitute the default badge set. An explicit empty array means \"no\n// badges\" (we honor it — merchants who hide the row need a way to express\n// that).\nexport function decodeBadges(raw: string | undefined): TrustBadge[] | null {\n if (raw === undefined) return null;\n try {\n const parsed: unknown = JSON.parse(raw);\n if (!Array.isArray(parsed)) return null;\n return parsed\n .filter((b): b is Record<string, unknown> => !!b && typeof b === 'object')\n .map((b, i) => ({\n id: typeof b['id'] === 'string' && b['id'] ? (b['id'] as string) : `badge-${i}`,\n label: typeof b['label'] === 'string' ? (b['label'] as string) : '',\n textColor: typeof b['textColor'] === 'string' ? (b['textColor'] as string) : '#0f172a',\n backgroundColor:\n typeof b['backgroundColor'] === 'string' ? (b['backgroundColor'] as string) : '#f1f5f9',\n borderColor:\n typeof b['borderColor'] === 'string' && b['borderColor']\n ? (b['borderColor'] as string)\n : null,\n }))\n .filter((b) => b.label.length > 0);\n } catch {\n return null;\n }\n}\n\nexport function encodeBadges(badges: TrustBadge[]): string {\n return JSON.stringify(\n badges.map((b) => ({\n id: b.id,\n label: b.label,\n textColor: b.textColor,\n backgroundColor: b.backgroundColor,\n ...(b.borderColor ? { borderColor: b.borderColor } : {}),\n })),\n );\n}\n\n// --- Custom checkout fields codec ---------------------------------------\n\nexport const CUSTOM_FIELDS_MAX = 20;\n// Metadata keys: start with a letter, then letters/digits/underscore/dash.\n// Keeps keys safe for every downstream metadata consumer (dashboards,\n// exports, PSP forwarding).\nexport const CUSTOM_FIELD_KEY_PATTERN = /^[A-Za-z][A-Za-z0-9_-]{0,39}$/;\n\nexport const ALL_CUSTOM_FIELD_TYPES: readonly CustomFieldType[] = [\n 'text',\n 'textarea',\n 'password',\n 'email',\n 'select',\n 'checkbox',\n];\n\n// The two values a checkbox field ever submits. Kept as strings because the\n// whole metadata bag is `Record<string, string>` on the wire.\nexport const CHECKBOX_CHECKED = 'true';\nexport const CHECKBOX_UNCHECKED = 'false';\n\n/** Whether a stored/submitted checkbox value counts as ticked. Tolerant of\n * case and padding so a value round-tripped through a shop integration\n * ('True', ' true ') still reads correctly. */\nexport function isCheckboxChecked(value: string | null | undefined): boolean {\n return typeof value === 'string' && value.trim().toLowerCase() === CHECKBOX_CHECKED;\n}\n\n/** Types whose value is free text, so length bounds and a placeholder apply.\n * `select` and `checkbox` are choice controls and have neither. */\nexport function customFieldIsTextLike(type: CustomFieldType): boolean {\n return type !== 'select' && type !== 'checkbox';\n}\n\n// Rule-builder vocabulary. Kept next to the codec so the editor, the\n// evaluator and the Rust mirror all read from one list.\nexport const CUSTOM_FIELD_CONDITIONS_MAX = 10;\n\nexport const ALL_CUSTOM_FIELD_CONDITION_SOURCES: readonly CustomFieldConditionSource[] = [\n 'metadata',\n 'currency',\n 'amount',\n];\n\nexport const ALL_CUSTOM_FIELD_OPERATORS: readonly CustomFieldOperator[] = [\n 'equals',\n 'not_equals',\n 'contains',\n 'not_contains',\n 'starts_with',\n 'ends_with',\n 'in',\n 'not_in',\n 'exists',\n 'not_exists',\n 'gt',\n 'gte',\n 'lt',\n 'lte',\n];\n\n// Which operators make sense per source. Currency is a closed 3-letter set,\n// so substring/numeric operators would only ever confuse; amount is numeric,\n// so string operators don't apply. Metadata is free-form and gets all of them.\nexport const CUSTOM_FIELD_OPERATORS_BY_SOURCE: Record<\n CustomFieldConditionSource,\n readonly CustomFieldOperator[]\n> = {\n metadata: ALL_CUSTOM_FIELD_OPERATORS,\n currency: ['equals', 'not_equals', 'in', 'not_in'],\n amount: ['equals', 'not_equals', 'gt', 'gte', 'lt', 'lte'],\n};\n\n// Operators that ignore the right-hand operand — the editor hides the value\n// input for these, and validation must not demand a value.\nexport const CUSTOM_FIELD_VALUELESS_OPERATORS: readonly CustomFieldOperator[] = [\n 'exists',\n 'not_exists',\n];\n\nexport function customFieldOperatorTakesValue(operator: CustomFieldOperator): boolean {\n return !CUSTOM_FIELD_VALUELESS_OPERATORS.includes(operator);\n}\n\n// The operator a condition falls back to when its source changes and the\n// current operator isn't valid for the new source.\nexport function defaultOperatorForSource(source: CustomFieldConditionSource): CustomFieldOperator {\n return CUSTOM_FIELD_OPERATORS_BY_SOURCE[source][0] ?? 'equals';\n}\n\nexport function defaultCustomFieldVisibility(): CustomFieldVisibility {\n return { mode: 'always', match: 'all', conditions: [] };\n}\n\nfunction parseTranslations(raw: unknown): CustomFieldTranslations {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return {};\n const out: CustomFieldTranslations = {};\n for (const [k, v] of Object.entries(raw as Record<string, unknown>)) {\n if (typeof v === 'string' && v.length > 0) out[k] = v;\n }\n return out;\n}\n\n// Normalize one persisted condition. Total: an unusable source/operator\n// falls back rather than dropping the row, so a rule authored by a newer\n// control-center never silently becomes \"always visible\" on an older\n// decoder — it becomes a stricter, still-evaluable rule.\nfunction normalizeCondition(raw: unknown, index: number): CustomFieldCondition | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;\n const c = raw as Record<string, unknown>;\n const source = pickEnum<CustomFieldConditionSource>(\n c['source'],\n ALL_CUSTOM_FIELD_CONDITION_SOURCES,\n 'metadata',\n );\n const allowed = CUSTOM_FIELD_OPERATORS_BY_SOURCE[source];\n const operator = pickEnum<CustomFieldOperator>(\n c['operator'],\n allowed,\n defaultOperatorForSource(source),\n );\n const rawValue = c['value'];\n return {\n id: typeof c['id'] === 'string' && c['id'] ? (c['id'] as string) : `cond-${index}`,\n source,\n // Only metadata conditions carry a key; drop anything else so the\n // encoded form stays canonical.\n key: source === 'metadata' && typeof c['key'] === 'string' ? c['key'].trim() : '',\n operator,\n value:\n typeof rawValue === 'string'\n ? rawValue\n : typeof rawValue === 'number' || typeof rawValue === 'boolean'\n ? String(rawValue)\n : '',\n };\n}\n\nfunction normalizeVisibility(raw: unknown): CustomFieldVisibility {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return defaultCustomFieldVisibility();\n const v = raw as Record<string, unknown>;\n const conditions: CustomFieldCondition[] = Array.isArray(v['conditions'])\n ? (v['conditions'] as unknown[])\n .slice(0, CUSTOM_FIELD_CONDITIONS_MAX)\n .map(normalizeCondition)\n .filter((c): c is CustomFieldCondition => c !== null)\n : [];\n return {\n mode: pickEnum<'always' | 'match'>(v['mode'], ['always', 'match'], 'always'),\n match: pickEnum<'all' | 'any'>(v['match'], ['all', 'any'], 'all'),\n conditions,\n };\n}\n\nfunction parseBoundedInt(raw: unknown): number | null {\n const n = typeof raw === 'number' ? raw : typeof raw === 'string' ? Number(raw) : NaN;\n if (!Number.isInteger(n) || n < 0) return null;\n return Math.min(n, 5000);\n}\n\n// Normalize one persisted/imported field object. Total: anything malformed\n// falls back per-property; returns null only when there is no usable key.\nfunction normalizeCustomField(raw: unknown, index: number): CheckoutCustomField | null {\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return null;\n const f = raw as Record<string, unknown>;\n const key = typeof f['key'] === 'string' ? f['key'].trim() : '';\n if (!CUSTOM_FIELD_KEY_PATTERN.test(key)) return null;\n\n const type = pickEnum<CustomFieldType>(f['type'], ALL_CUSTOM_FIELD_TYPES, 'text');\n\n const options: CustomFieldOption[] =\n type === 'select' && Array.isArray(f['options'])\n ? (f['options'] as unknown[])\n .filter((o): o is Record<string, unknown> => !!o && typeof o === 'object')\n .map((o) => {\n const value = typeof o['value'] === 'string' ? o['value'] : '';\n return {\n value,\n label: typeof o['label'] === 'string' && o['label'] ? (o['label'] as string) : value,\n labelTranslations: parseTranslations(o['labelTranslations']),\n };\n })\n .filter((o) => o.value.length > 0)\n : [];\n\n // Length bounds are meaningless for choice controls; drop them at decode\n // so a field switched to checkbox/select can't carry stale bounds that\n // would then be validated against 'true'/'false'.\n const textLike = customFieldIsTextLike(type);\n const minLength = textLike ? parseBoundedInt(f['minLength']) : null;\n const maxLength = textLike ? parseBoundedInt(f['maxLength']) : null;\n\n // A checkbox default is a tick state, not free text: anything that isn't\n // truthy normalizes to unchecked, so the control can never start in a\n // third state.\n const rawDefault = typeof f['defaultValue'] === 'string' ? f['defaultValue'] : '';\n const defaultValue =\n type === 'checkbox'\n ? isCheckboxChecked(rawDefault)\n ? CHECKBOX_CHECKED\n : CHECKBOX_UNCHECKED\n : rawDefault;\n\n return {\n id: typeof f['id'] === 'string' && f['id'] ? (f['id'] as string) : `field-${index}`,\n key,\n type,\n label: typeof f['label'] === 'string' && f['label'] ? (f['label'] as string) : key,\n labelTranslations: parseTranslations(f['labelTranslations']),\n placeholder: typeof f['placeholder'] === 'string' ? (f['placeholder'] as string) : '',\n placeholderTranslations: parseTranslations(f['placeholderTranslations']),\n helpText: typeof f['helpText'] === 'string' ? (f['helpText'] as string) : '',\n helpTextTranslations: parseTranslations(f['helpTextTranslations']),\n required: parseBool(f['required'], false),\n enabled: parseBool(f['enabled'], true),\n minLength,\n // Guard inverted bounds at decode so consumers never see min > max.\n maxLength: maxLength !== null && minLength !== null && maxLength < minLength ? null : maxLength,\n defaultValue,\n options,\n visibility: normalizeVisibility(f['visibility']),\n };\n}\n\n// Parse an array of field objects (already JSON-parsed). Null when the\n// input isn't an array — callers fall back to \"no custom fields\". Duplicate\n// keys keep the first occurrence; the list is capped at CUSTOM_FIELDS_MAX.\nexport function parseCustomFieldsLoose(raw: unknown): CheckoutCustomField[] | null {\n if (!Array.isArray(raw)) return null;\n const seen = new Set<string>();\n const out: CheckoutCustomField[] = [];\n for (let i = 0; i < raw.length && out.length < CUSTOM_FIELDS_MAX; i++) {\n const field = normalizeCustomField(raw[i], i);\n if (!field || seen.has(field.key)) continue;\n seen.add(field.key);\n out.push(field);\n }\n return out;\n}\n\n// Decode the JSON-encoded custom fields stored under\n// `sdk_ui_rules.branding.customFields`. Tolerant like `decodeBadges`:\n// malformed payloads fall through to null.\nexport function decodeCustomFields(raw: string | undefined): CheckoutCustomField[] | null {\n if (raw === undefined) return null;\n try {\n return parseCustomFieldsLoose(JSON.parse(raw));\n } catch {\n return null;\n }\n}\n\nexport function encodeCustomFields(fields: CheckoutCustomField[]): string {\n const nonEmpty = (m: CustomFieldTranslations): CustomFieldTranslations | undefined => {\n const entries = Object.entries(m).filter(([, v]) => v.trim().length > 0);\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n };\n return JSON.stringify(\n fields.map((f) => ({\n id: f.id,\n key: f.key,\n type: f.type,\n label: f.label,\n ...(nonEmpty(f.labelTranslations)\n ? { labelTranslations: nonEmpty(f.labelTranslations) }\n : {}),\n ...(f.placeholder ? { placeholder: f.placeholder } : {}),\n ...(nonEmpty(f.placeholderTranslations)\n ? { placeholderTranslations: nonEmpty(f.placeholderTranslations) }\n : {}),\n ...(f.helpText ? { helpText: f.helpText } : {}),\n ...(nonEmpty(f.helpTextTranslations)\n ? { helpTextTranslations: nonEmpty(f.helpTextTranslations) }\n : {}),\n ...(f.required ? { required: true } : {}),\n ...(f.enabled ? {} : { enabled: false }),\n // Length bounds only exist for free-text types; a choice control that\n // still carries them is stale state the decoder would drop anyway.\n ...(customFieldIsTextLike(f.type) && f.minLength !== null ? { minLength: f.minLength } : {}),\n ...(customFieldIsTextLike(f.type) && f.maxLength !== null ? { maxLength: f.maxLength } : {}),\n // A checkbox persists only \"starts ticked\"; unticked is the decoder's\n // default, so writing 'false' would be noise on every such field.\n ...(f.type === 'checkbox'\n ? isCheckboxChecked(f.defaultValue)\n ? { defaultValue: CHECKBOX_CHECKED }\n : {}\n : f.defaultValue\n ? { defaultValue: f.defaultValue }\n : {}),\n ...(f.type === 'select' ? { options: f.options } : {}),\n // Omitted for unconditional fields so the stored blob (and every\n // pre-feature payload) stays byte-identical to what it was.\n ...(f.visibility.mode === 'match' ? { visibility: encodeVisibility(f.visibility) } : {}),\n })),\n );\n}\n\nfunction encodeVisibility(v: CustomFieldVisibility): Record<string, unknown> {\n return {\n mode: v.mode,\n match: v.match,\n conditions: v.conditions.map((c) => ({\n id: c.id,\n source: c.source,\n ...(c.source === 'metadata' && c.key ? { key: c.key } : {}),\n operator: c.operator,\n ...(customFieldOperatorTakesValue(c.operator) && c.value ? { value: c.value } : {}),\n })),\n };\n}\n\n// --- Conditional-visibility evaluator -----------------------------------\n\n/** Facts a rule can read. `amount` is in the currency's minor unit (what\n * the payment intent stores); `metadata` values are already flattened to\n * strings by `customFieldContextFromMetadata`. */\nexport interface CustomFieldContext {\n amount: number;\n currency: string;\n metadata: Record<string, string>;\n}\n\n/** Flatten a payment's raw `metadata` object into the string map a rule\n * compares against. Arrays join on `,` so a list-shaped value stays usable\n * with `contains` / `in`; objects fall back to JSON. Mirrors the Rust\n * side's `flatten_metadata`. */\nexport function customFieldContextFromMetadata(raw: unknown): Record<string, string> {\n const out: Record<string, string> = {};\n if (!raw || typeof raw !== 'object' || Array.isArray(raw)) return out;\n for (const [key, value] of Object.entries(raw as Record<string, unknown>)) {\n const flat = flattenMetadataValue(value);\n if (flat !== null) out[key] = flat;\n }\n return out;\n}\n\nfunction flattenMetadataValue(value: unknown): string | null {\n if (typeof value === 'string') return value;\n if (typeof value === 'number' || typeof value === 'boolean') return String(value);\n if (value === null || value === undefined) return null;\n if (Array.isArray(value)) {\n return value\n .map((v) => flattenMetadataValue(v))\n .filter((v): v is string => v !== null)\n .join(',');\n }\n try {\n return JSON.stringify(value);\n } catch {\n return null;\n }\n}\n\n// Case- and whitespace-insensitive: merchants type `Windows` in the builder\n// and the shop sends `windows`. Exact-case matching would be a support\n// ticket generator.\nfunction norm(value: string): string {\n return value.trim().toLowerCase();\n}\n\n// Decimal-float grammar, deliberately narrower than `Number()`.\n//\n// `Number()` accepts radix-prefixed literals — `Number('0x10') === 16` — while\n// the router's Rust mirror uses `f64::from_str`, which rejects them. Left\n// unconstrained, a metadata value of `0x10` would satisfy `gte 5` in the\n// control-center's builder and fail it on the backend: the merchant sees one\n// rule, buyers get another. This regex is `f64::from_str`'s number grammar\n// (sign, digits with optional point, optional exponent); `inf`/`nan` are\n// excluded here rather than by the finiteness check below, which matches\n// Rust filtering them out too.\nconst DECIMAL_NUMBER_PATTERN = /^[+-]?(?:\\d+\\.?\\d*|\\.\\d+)(?:[eE][+-]?\\d+)?$/;\n\n// Both implementations compare as f64, so they round identically. Payment\n// amounts in minor units are far below 2^53, where that is lossless.\nfunction numeric(value: string): number | null {\n const trimmed = value.trim();\n if (!DECIMAL_NUMBER_PATTERN.test(trimmed)) return null;\n const n = Number(trimmed);\n return Number.isFinite(n) ? n : null;\n}\n\nfunction splitList(value: string): string[] {\n return value\n .split(',')\n .map((part) => norm(part))\n .filter((part) => part.length > 0);\n}\n\n/** Resolve the left-hand operand. `undefined` means \"the metadata key is\n * absent\" — which only `exists`/`not_exists` distinguish from empty. */\nfunction operandFor(condition: CustomFieldCondition, ctx: CustomFieldContext): string | undefined {\n switch (condition.source) {\n case 'currency':\n return ctx.currency;\n case 'amount':\n return String(ctx.amount);\n case 'metadata':\n return Object.prototype.hasOwnProperty.call(ctx.metadata, condition.key)\n ? ctx.metadata[condition.key]\n : undefined;\n }\n}\n\nexport function evaluateCustomFieldCondition(\n condition: CustomFieldCondition,\n ctx: CustomFieldContext,\n): boolean {\n const raw = operandFor(condition, ctx);\n const actual = raw ?? '';\n const expected = condition.value;\n\n switch (condition.operator) {\n case 'exists':\n return raw !== undefined && raw.trim().length > 0;\n case 'not_exists':\n return raw === undefined || raw.trim().length === 0;\n case 'equals':\n return norm(actual) === norm(expected);\n case 'not_equals':\n return norm(actual) !== norm(expected);\n case 'contains':\n return norm(actual).includes(norm(expected));\n case 'not_contains':\n return !norm(actual).includes(norm(expected));\n case 'starts_with':\n return norm(actual).startsWith(norm(expected));\n case 'ends_with':\n return norm(actual).endsWith(norm(expected));\n case 'in':\n return splitList(expected).includes(norm(actual));\n case 'not_in':\n return !splitList(expected).includes(norm(actual));\n case 'gt':\n case 'gte':\n case 'lt':\n case 'lte': {\n // Both sides must be numbers. A non-numeric metadata value never\n // matches a numeric comparison (rather than coercing to 0).\n const a = numeric(actual);\n const b = numeric(expected);\n if (a === null || b === null) return false;\n if (condition.operator === 'gt') return a > b;\n if (condition.operator === 'gte') return a >= b;\n if (condition.operator === 'lt') return a < b;\n return a <= b;\n }\n }\n}\n\n/**\n * Whether a field's rule matches the payment.\n *\n * Fail-open in two spots, deliberately: `mode: 'always'` and a `match` rule\n * with no conditions both resolve to visible. A half-authored rule should\n * never silently swallow a field the merchant needs collected — the\n * control-center flags the empty rule as a validation issue instead.\n */\nexport function evaluateCustomFieldVisibility(\n field: CheckoutCustomField,\n ctx: CustomFieldContext,\n): boolean {\n const { mode, match, conditions } = field.visibility;\n if (mode !== 'match' || conditions.length === 0) return true;\n return match === 'any'\n ? conditions.some((c) => evaluateCustomFieldCondition(c, ctx))\n : conditions.every((c) => evaluateCustomFieldCondition(c, ctx));\n}\n\n/** Filter a field list to what the buyer should see for this payment.\n * Disabled fields are dropped here too — the two reasons a field doesn't\n * render are the same to every consumer. */\nexport function visibleCustomFields(\n fields: CheckoutCustomField[],\n ctx: CustomFieldContext,\n): CheckoutCustomField[] {\n return fields.filter((f) => f.enabled && evaluateCustomFieldVisibility(f, ctx));\n}\n\n// Exact-locale-then-base-language lookup. Own-property + string checks so\n// a hostile or odd locale string ('constructor', '__proto__') can never\n// surface a prototype-chain member as a \"translation\".\nfunction translationFor(map: CustomFieldTranslations, locale?: string): string | null {\n if (!locale) return null;\n const own = (k: string): string | null => {\n const v = Object.prototype.hasOwnProperty.call(map, k) ? map[k] : undefined;\n return typeof v === 'string' && v.length > 0 ? v : null;\n };\n const exact = own(locale);\n if (exact) return exact;\n const base = locale.split('-')[0];\n return base && base !== locale ? own(base) : null;\n}\n\n// Resolve the display string for a field part in a buyer locale.\n// Exact locale wins ('de-AT'), then its base language ('de'), then the\n// field's default-language string; labels finally fall back to the key so\n// a field is never rendered nameless.\nexport function customFieldText(\n field: CheckoutCustomField,\n part: 'label' | 'placeholder' | 'helpText',\n locale?: string,\n): string {\n const map =\n part === 'label'\n ? field.labelTranslations\n : part === 'placeholder'\n ? field.placeholderTranslations\n : field.helpTextTranslations;\n const translated = translationFor(map, locale);\n if (translated) return translated;\n const fallback = field[part];\n if (fallback) return fallback;\n return part === 'label' ? field.key : '';\n}\n\nexport function customFieldOptionLabel(option: CustomFieldOption, locale?: string): string {\n return translationFor(option.labelTranslations, locale) ?? (option.label || option.value);\n}\n\n// Read a branding source into a fully-resolved CheckoutBranding.\n// Flat fields are authoritative when set; the bag fills in everything not\n// reachable via flat columns. Persisted `labelStyle: 'floating'` (legacy\n// \"floating\" mock) decodes to `'above'`.\nexport function decodeBranding(source: BrandingSource | null | undefined): CheckoutBranding {\n if (!source) return cloneBranding(DEFAULT_BRANDING);\n\n const extras: Record<string, string> = (source.sdk_ui_rules?.[BRANDING_GROUP_KEY] ??\n {}) as Record<string, string>;\n\n const decodedBadges = decodeBadges(extras['trustBadges']);\n const decodedCustomFields = decodeCustomFields(extras['customFields']);\n\n // Identity name: public payloads call it `merchant_name`, request payloads\n // call it `seller_name`. Same API field; pick whichever is present.\n const displayName = s(source.merchant_name) || s(source.seller_name);\n const logoUrl = s(source.merchant_logo) || s(source.logo);\n\n // Tagline lives in the bag, but `merchant_description` is its public\n // surface. Either may fill it; bag wins if both are set.\n const tagline = s(extras['tagline']) || s(source.merchant_description);\n\n // Stripe label style: the bag's `labelStyle` is the new source of truth;\n // the legacy flat `payment_form_label_type` is consulted only when the\n // bag is empty. `'floating'` (a legacy preview-only value that Stripe\n // Elements never honored) decodes to `'above'`. `'never'` (legacy API\n // wording) decodes to `'hidden'`.\n const labelStyle: LabelStyle = (() => {\n const fromBag = extras['labelStyle'];\n if (fromBag === 'above' || fromBag === 'hidden') return fromBag;\n if (fromBag === 'floating') return 'above';\n const legacy = source.payment_form_label_type;\n if (legacy === 'above' || legacy === 'floating') return 'above';\n if (legacy === 'hidden' || legacy === 'never') return 'hidden';\n return DEFAULT_BRANDING.labelStyle;\n })();\n\n return {\n displayName,\n logoUrl,\n tagline,\n showLogo: parseBool(extras['showLogo'], DEFAULT_BRANDING.showLogo),\n logoShape: pickEnum<LogoShape>(\n extras['logoShape'],\n ['square', 'rounded', 'circle'],\n DEFAULT_BRANDING.logoShape,\n ),\n logoSize: pickEnum<LogoSize>(extras['logoSize'], ['sm', 'md', 'lg'], DEFAULT_BRANDING.logoSize),\n\n primary: s(source.theme) || DEFAULT_BRANDING.primary,\n background: s(source.background_colour) || DEFAULT_BRANDING.background,\n surface: s(extras['surface']) || DEFAULT_BRANDING.surface,\n text: s(extras['text']) || DEFAULT_BRANDING.text,\n heading: s(extras['heading']) || s(extras['text']) || DEFAULT_BRANDING.heading,\n muted: s(extras['muted']) || DEFAULT_BRANDING.muted,\n border: s(extras['border']) || DEFAULT_BRANDING.border,\n accentText: s(extras['accentText']) || s(source.theme) || DEFAULT_BRANDING.accentText,\n buttonBackground:\n s(source.payment_button_colour) || s(source.theme) || DEFAULT_BRANDING.buttonBackground,\n buttonText: s(source.payment_button_text_colour) || DEFAULT_BRANDING.buttonText,\n\n fontFamily: pickEnum<FontFamily>(\n extras['fontFamily'],\n ALL_FONT_FAMILIES,\n DEFAULT_BRANDING.fontFamily,\n ),\n headingWeight: pickEnum<FontWeight>(\n extras['headingWeight'],\n ['regular', 'medium', 'semibold', 'bold'],\n DEFAULT_BRANDING.headingWeight,\n ),\n\n radiusSurface: pickEnum<NonPillRadius>(\n extras['radiusSurface'],\n NON_PILL_RADII,\n DEFAULT_BRANDING.radiusSurface,\n ),\n radiusInput: pickEnum<NonPillRadius>(\n extras['radiusInput'],\n NON_PILL_RADII,\n DEFAULT_BRANDING.radiusInput,\n ),\n radiusButton: pickEnum<CornerRadius>(\n extras['radiusButton'],\n ALL_RADII,\n DEFAULT_BRANDING.radiusButton,\n ),\n radiusBadge: pickEnum<CornerRadius>(\n extras['radiusBadge'],\n ALL_RADII,\n DEFAULT_BRANDING.radiusBadge,\n ),\n surfaceStyle: pickEnum<SurfaceStyle>(\n extras['surfaceStyle'],\n ['flat', 'outlined', 'elevated'],\n DEFAULT_BRANDING.surfaceStyle,\n ),\n surfacePadding: pickEnum<SpacingScale>(\n extras['surfacePadding'],\n ['compact', 'comfortable', 'spacious'],\n DEFAULT_BRANDING.surfacePadding,\n ),\n verticalGap: pickEnum<SpacingScale>(\n extras['verticalGap'],\n ['compact', 'comfortable', 'spacious'],\n DEFAULT_BRANDING.verticalGap,\n ),\n inputSize: pickEnum<SizeScale>(\n extras['inputSize'],\n ['sm', 'md', 'lg'],\n DEFAULT_BRANDING.inputSize,\n ),\n buttonSize: pickEnum<SizeScale>(\n extras['buttonSize'],\n ['sm', 'md', 'lg'],\n DEFAULT_BRANDING.buttonSize,\n ),\n\n layout: pickEnum<LayoutStyle>(extras['layout'], ['compact', 'split'], DEFAULT_BRANDING.layout),\n summaryPosition: pickEnum<SummaryPosition>(\n extras['summaryPosition'],\n ['left', 'right'],\n DEFAULT_BRANDING.summaryPosition,\n ),\n showOrderSummary: parseBool(extras['showOrderSummary'], DEFAULT_BRANDING.showOrderSummary),\n summaryGradient: parseBool(extras['summaryGradient'], DEFAULT_BRANDING.summaryGradient),\n showTotal: parseBool(extras['showTotal'], DEFAULT_BRANDING.showTotal),\n totalLabel: s(extras['totalLabel']) || DEFAULT_BRANDING.totalLabel,\n showCurrencyCode: parseBool(extras['showCurrencyCode'], DEFAULT_BRANDING.showCurrencyCode),\n showOrderItems: parseBool(extras['showOrderItems'], DEFAULT_BRANDING.showOrderItems),\n\n trustBadges: decodedBadges ?? DEFAULT_BRANDING.trustBadges.map((b) => ({ ...b })),\n customFields: decodedCustomFields ?? [],\n\n headerText: s(source.payment_form_header_text),\n payButtonLabel: s(source.payment_button_text),\n cardTermsMessage: s(source.custom_message_for_card_terms),\n footerText: s(extras['footerText']),\n supportEmail: s(extras['supportEmail']),\n\n paymentLayout: pickEnum<PaymentLayout>(\n source.sdk_layout,\n ['tabs', 'accordion', 'spaced_accordion'],\n DEFAULT_BRANDING.paymentLayout,\n ),\n labelStyle,\n showPoweredBy: source.branding_visibility !== false,\n\n customCss: s(extras['customCss']),\n };\n}\n\n// Encoded request shape — the union of fields the encoder fills. Compatible\n// with `BusinessPaymentLinkConfig` / `PaymentLinkConfigRequest` via\n// structural typing on the consumer side.\nexport interface EncodedBranding {\n theme: string;\n logo: string | null;\n seller_name: string | null;\n sdk_layout: PaymentLayout;\n payment_button_text: string | null;\n payment_button_colour: string;\n payment_button_text_colour: string;\n background_colour: string;\n payment_form_header_text: string | null;\n payment_form_label_type: 'above' | 'never';\n custom_message_for_card_terms: string | null;\n sdk_ui_rules: Record<string, Record<string, string>>;\n branding_visibility: boolean;\n}\n\n// Encode a CheckoutBranding into the API request shape. `base` is the\n// existing config (if any) -- preserves bag entries the form doesn't surface\n// (other sdk_ui_rules groups, business_specific_configs, etc.) by spreading\n// it through.\n//\n// `TBase` is constrained to `object | null | undefined` (not\n// `Record<string, unknown>`) so consumers can pass interface-typed values\n// directly. TS interfaces don't get an implicit string index signature, so\n// they don't structurally satisfy `Record<string, unknown>` even when their\n// property values would all unify to `unknown` — `object` admits them\n// without forcing a cast at every call site. We only spread the value, so\n// no index-signature semantics are needed at runtime.\nexport function encodeBranding<TBase extends object | null | undefined>(\n branding: CheckoutBranding,\n base?: TBase,\n): EncodedBranding & (TBase extends object ? TBase : Record<string, never>) {\n const trim = (v: string): string | null => {\n const t = v.trim();\n return t.length > 0 ? t : null;\n };\n\n // We only read one property off `base` and structural typing on `object`\n // doesn't permit index access, so go through `unknown` here.\n const existingRules = ((base as unknown as Record<string, unknown> | undefined)?.[\n 'sdk_ui_rules'\n ] ?? {}) as Record<string, Record<string, string>>;\n const extras: Record<string, string> = {\n surface: branding.surface,\n text: branding.text,\n heading: branding.heading,\n muted: branding.muted,\n border: branding.border,\n accentText: branding.accentText,\n fontFamily: branding.fontFamily,\n headingWeight: branding.headingWeight,\n radiusSurface: branding.radiusSurface,\n radiusInput: branding.radiusInput,\n radiusButton: branding.radiusButton,\n radiusBadge: branding.radiusBadge,\n surfaceStyle: branding.surfaceStyle,\n surfacePadding: branding.surfacePadding,\n verticalGap: branding.verticalGap,\n inputSize: branding.inputSize,\n buttonSize: branding.buttonSize,\n layout: branding.layout,\n summaryPosition: branding.summaryPosition,\n showOrderSummary: String(branding.showOrderSummary),\n summaryGradient: String(branding.summaryGradient),\n showTotal: String(branding.showTotal),\n totalLabel: branding.totalLabel,\n showCurrencyCode: String(branding.showCurrencyCode),\n showOrderItems: String(branding.showOrderItems),\n showLogo: String(branding.showLogo),\n logoShape: branding.logoShape,\n logoSize: branding.logoSize,\n labelStyle: branding.labelStyle,\n trustBadges: encodeBadges(branding.trustBadges),\n };\n // Omit the key entirely when there are no fields — decode treats a\n // missing entry the same as an empty list, and the bag stays clean for\n // merchants who never touch the feature.\n if (branding.customFields.length > 0) {\n extras['customFields'] = encodeCustomFields(branding.customFields);\n }\n const tagline = trim(branding.tagline);\n if (tagline) extras['tagline'] = tagline;\n const footer = trim(branding.footerText);\n if (footer) extras['footerText'] = footer;\n const support = trim(branding.supportEmail);\n if (support) extras['supportEmail'] = support;\n // Persist raw — sanitization runs at render time so we keep the merchant's\n // input as-typed (preserves comments, whitespace) and let the checkout\n // strip dangerous tokens consistently across all readers.\n const css = trim(branding.customCss);\n if (css) extras['customCss'] = css;\n\n const nextRules: Record<string, Record<string, string>> = {\n ...existingRules,\n [BRANDING_GROUP_KEY]: extras,\n };\n\n // Map `hidden` back to the legacy `never` token the API's label type\n // enum understands. `floating` no longer exists.\n const legacyLabel: 'above' | 'never' = branding.labelStyle === 'hidden' ? 'never' : 'above';\n\n const flatFields: EncodedBranding = {\n theme: branding.primary,\n logo: trim(branding.logoUrl),\n seller_name: trim(branding.displayName),\n sdk_layout: branding.paymentLayout,\n payment_button_text: trim(branding.payButtonLabel),\n payment_button_colour: branding.buttonBackground,\n payment_button_text_colour: branding.buttonText,\n background_colour: branding.background,\n payment_form_header_text: trim(branding.headerText),\n payment_form_label_type: legacyLabel,\n custom_message_for_card_terms: trim(branding.cardTermsMessage),\n sdk_ui_rules: nextRules,\n branding_visibility: branding.showPoweredBy,\n };\n\n // Spread `base` first to preserve fields the encoder doesn't surface\n // (show_card_terms, show_card_form_by_default, hide_card_nickname_field,\n // enable_button_only_on_form_ready, skip_status_screen,\n // transaction_details, background_image, details_layout,\n // custom_message_for_payment_method_types, payment_link_ui_rules,\n // color_icon_card_cvc_error, is_setup_mandate_flow,\n // enabled_saved_payment_method, display_sdk_only,\n // business_specific_configs, domain_name, allowed_domains).\n return {\n ...base,\n ...flatFields,\n } as EncodedBranding & (TBase extends object ? TBase : Record<string, never>);\n}\n\n// --- Import / Export envelope ------------------------------------------\n\n// Versioned envelope used by the merchant control-center's \"Import /\n// Export\" buttons. Bumping `version` is informational; the importer is\n// graceful and accepts any version (or no envelope at all).\nexport const BRANDING_EXPORT_FORMAT = 'delopay-checkout-branding';\nexport const BRANDING_EXPORT_VERSION = 1;\n\nexport interface BrandingExport {\n format: typeof BRANDING_EXPORT_FORMAT;\n version: number;\n exported_at: string;\n branding: CheckoutBranding;\n}\n\nexport function buildBrandingExport(branding: CheckoutBranding): BrandingExport {\n return {\n format: BRANDING_EXPORT_FORMAT,\n version: BRANDING_EXPORT_VERSION,\n exported_at: new Date().toISOString(),\n branding: cloneBranding(branding),\n };\n}\n\n// Resolve arbitrary JSON into a fully-typed CheckoutBranding. Designed to\n// never throw — every field is independently validated against its type\n// and silently falls back to the light-mode default if missing or\n// malformed:\n// - extra fields the form doesn't know about are ignored,\n// - missing fields inherit defaults,\n// - hex colors that fail the regex stay at the default,\n// - enums outside the allowed set fall back,\n// - a payload with no recognizable shape produces DEFAULT_BRANDING.\n//\n// Accepts either a bare CheckoutBranding object or an envelope produced by\n// `buildBrandingExport()`. The caller (the import handler) only needs to\n// catch JSON.parse errors; everything past that point is total.\nexport function parseImportedBranding(raw: unknown): CheckoutBranding {\n // Unwrap the envelope if present. Don't gate on version — bumping it is\n // informational; this function is the migration layer.\n const root: Record<string, unknown> | null =\n isObject(raw) && isObject(raw['branding'])\n ? (raw['branding'] as Record<string, unknown>)\n : isObject(raw)\n ? raw\n : null;\n\n if (!root) return cloneBranding(DEFAULT_BRANDING);\n\n const dflt = DEFAULT_BRANDING;\n const sStr = (v: unknown, fallback: string): string => (typeof v === 'string' ? v : fallback);\n const sHex = (v: unknown, fallback: string): string =>\n typeof v === 'string' && isHexColor(v) ? v : fallback;\n\n const trustBadges =\n parseTrustBadgesLoose(root['trustBadges']) ?? dflt.trustBadges.map((b) => ({ ...b }));\n const customFields = parseCustomFieldsLoose(root['customFields']) ?? [];\n\n // `floating` from older exports normalizes to `above`; see decodeBranding.\n const labelStyle: LabelStyle = (() => {\n const v = root['labelStyle'];\n if (v === 'above' || v === 'hidden') return v;\n return dflt.labelStyle;\n })();\n\n return {\n displayName: sStr(root['displayName'], dflt.displayName),\n logoUrl: sStr(root['logoUrl'], dflt.logoUrl),\n tagline: sStr(root['tagline'], dflt.tagline),\n showLogo: parseBool(root['showLogo'], dflt.showLogo),\n logoShape: pickEnum<LogoShape>(\n root['logoShape'],\n ['square', 'rounded', 'circle'],\n dflt.logoShape,\n ),\n logoSize: pickEnum<LogoSize>(root['logoSize'], ['sm', 'md', 'lg'], dflt.logoSize),\n\n primary: sHex(root['primary'], dflt.primary),\n background: sHex(root['background'], dflt.background),\n surface: sHex(root['surface'], dflt.surface),\n text: sHex(root['text'], dflt.text),\n heading: sHex(root['heading'], dflt.heading),\n muted: sHex(root['muted'], dflt.muted),\n border: sHex(root['border'], dflt.border),\n accentText: sHex(root['accentText'], dflt.accentText),\n buttonBackground: sHex(root['buttonBackground'], dflt.buttonBackground),\n buttonText: sHex(root['buttonText'], dflt.buttonText),\n\n fontFamily: pickEnum<FontFamily>(root['fontFamily'], ALL_FONT_FAMILIES, dflt.fontFamily),\n headingWeight: pickEnum<FontWeight>(\n root['headingWeight'],\n ['regular', 'medium', 'semibold', 'bold'],\n dflt.headingWeight,\n ),\n\n radiusSurface: pickEnum<NonPillRadius>(\n root['radiusSurface'],\n NON_PILL_RADII,\n dflt.radiusSurface,\n ),\n radiusInput: pickEnum<NonPillRadius>(root['radiusInput'], NON_PILL_RADII, dflt.radiusInput),\n radiusButton: pickEnum<CornerRadius>(root['radiusButton'], ALL_RADII, dflt.radiusButton),\n radiusBadge: pickEnum<CornerRadius>(root['radiusBadge'], ALL_RADII, dflt.radiusBadge),\n surfaceStyle: pickEnum<SurfaceStyle>(\n root['surfaceStyle'],\n ['flat', 'outlined', 'elevated'],\n dflt.surfaceStyle,\n ),\n surfacePadding: pickEnum<SpacingScale>(\n root['surfacePadding'],\n ['compact', 'comfortable', 'spacious'],\n dflt.surfacePadding,\n ),\n verticalGap: pickEnum<SpacingScale>(\n root['verticalGap'],\n ['compact', 'comfortable', 'spacious'],\n dflt.verticalGap,\n ),\n inputSize: pickEnum<SizeScale>(root['inputSize'], ['sm', 'md', 'lg'], dflt.inputSize),\n buttonSize: pickEnum<SizeScale>(root['buttonSize'], ['sm', 'md', 'lg'], dflt.buttonSize),\n\n layout: pickEnum<LayoutStyle>(root['layout'], ['compact', 'split'], dflt.layout),\n summaryPosition: pickEnum<SummaryPosition>(\n root['summaryPosition'],\n ['left', 'right'],\n dflt.summaryPosition,\n ),\n showOrderSummary: parseBool(root['showOrderSummary'], dflt.showOrderSummary),\n summaryGradient: parseBool(root['summaryGradient'], dflt.summaryGradient),\n showTotal: parseBool(root['showTotal'], dflt.showTotal),\n totalLabel: sStr(root['totalLabel'], dflt.totalLabel),\n showCurrencyCode: parseBool(root['showCurrencyCode'], dflt.showCurrencyCode),\n showOrderItems: parseBool(root['showOrderItems'], dflt.showOrderItems),\n\n trustBadges,\n customFields,\n\n headerText: sStr(root['headerText'], dflt.headerText),\n payButtonLabel: sStr(root['payButtonLabel'], dflt.payButtonLabel),\n cardTermsMessage: sStr(root['cardTermsMessage'], dflt.cardTermsMessage),\n footerText: sStr(root['footerText'], dflt.footerText),\n supportEmail: sStr(root['supportEmail'], dflt.supportEmail),\n\n paymentLayout: pickEnum<PaymentLayout>(\n root['paymentLayout'],\n ['tabs', 'accordion', 'spaced_accordion'],\n dflt.paymentLayout,\n ),\n labelStyle,\n showPoweredBy: parseBool(root['showPoweredBy'], dflt.showPoweredBy),\n\n customCss: sStr(root['customCss'], dflt.customCss).slice(0, CUSTOM_CSS_MAX_LENGTH),\n };\n}\n\nfunction isObject(v: unknown): v is Record<string, unknown> {\n return typeof v === 'object' && v !== null && !Array.isArray(v);\n}\n\n// Loose trust-badge parser used by the importer. Unlike `decodeBadges`\n// (which reads the JSON-stringified API bag), this accepts an array of\n// objects directly. Returns null when the input isn't an array — the\n// caller falls back to the default badge set; an explicit empty array is\n// honored.\nfunction parseTrustBadgesLoose(raw: unknown): TrustBadge[] | null {\n if (!Array.isArray(raw)) return null;\n return raw\n .filter(isObject)\n .map((b, i) => ({\n id: typeof b['id'] === 'string' && b['id'] ? (b['id'] as string) : `badge-${i}`,\n label: typeof b['label'] === 'string' ? (b['label'] as string) : '',\n textColor:\n typeof b['textColor'] === 'string' && isHexColor(b['textColor'] as string)\n ? (b['textColor'] as string)\n : '#0f172a',\n backgroundColor:\n typeof b['backgroundColor'] === 'string' && isHexColor(b['backgroundColor'] as string)\n ? (b['backgroundColor'] as string)\n : '#f1f5f9',\n borderColor:\n typeof b['borderColor'] === 'string' && isHexColor(b['borderColor'] as string)\n ? (b['borderColor'] as string)\n : null,\n }))\n .filter((b) => b.label.length > 0);\n}\n\n// --- DOM helpers --------------------------------------------------------\n\n// Write branding tokens onto a target element as CSS custom properties.\n// The buyer-facing checkout sets these on `<html>` so every component sees\n// the same set, including Stripe Elements (indirectly via\n// appearance.variables). The merchant control-center's preview component\n// uses an analogous `--p-*` set with `var(--dp-*, fallback)` indirection so\n// a custom-CSS rule like `:root{--dp-primary:red}` overrides the preview\n// without re-typing the whole brand.\nexport function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void {\n const set = (k: string, v: string) => {\n el.style.setProperty(k, v);\n };\n\n set('--dp-primary', b.primary);\n set('--dp-bg', b.background);\n set('--dp-surface', b.surface);\n set('--dp-text', b.text);\n set('--dp-heading', b.heading);\n set('--dp-muted', b.muted);\n set('--dp-border', b.border);\n set('--dp-accent-text', b.accentText);\n set('--dp-btn-bg', b.buttonBackground);\n set('--dp-btn-fg', b.buttonText);\n\n set('--dp-radius-surface', radiusValue(b.radiusSurface));\n set('--dp-radius-input', radiusValue(b.radiusInput));\n set('--dp-radius-button', radiusValue(b.radiusButton));\n set('--dp-radius-badge', radiusValue(b.radiusBadge));\n\n set('--dp-font', fontStack(b.fontFamily));\n set('--dp-heading-weight', fontWeightValue(b.headingWeight));\n\n set('--dp-pad-surface', SURFACE_PAD[b.surfacePadding]);\n set('--dp-gap-vertical', VERTICAL_GAP[b.verticalGap]);\n set('--dp-input-pad', INPUT_PAD[b.inputSize]);\n set('--dp-button-pad', BUTTON_PAD[b.buttonSize]);\n\n set('--dp-shadow', shadowFor(b.surfaceStyle));\n set(\n '--dp-surface-border',\n b.surfaceStyle === 'outlined' ? `1px solid ${b.border}` : '1px solid transparent',\n );\n}\n\nexport function shadowFor(style: SurfaceStyle): string {\n switch (style) {\n case 'elevated':\n return '0 1px 2px rgba(15, 23, 42, 0.04), 0 8px 32px -12px rgba(15, 23, 42, 0.08)';\n case 'outlined':\n case 'flat':\n default:\n return 'none';\n }\n}\n","import { Delopay } from './client';\nimport type { DelopayLogger, RequestExtras } from './client';\nimport { DelopayError } from './error';\nimport type {\n ConfirmSubscriptionRequest,\n ConfirmSubscriptionResponse,\n EpayoutsMethodsResponse,\n PaymentConfirmRequest,\n PaymentMethodListResponse,\n PaymentResponse,\n PaymentUpdateRequest,\n PayseproMethodsResponse,\n RecordCheckoutEventRequest,\n RecordCheckoutEventResponse,\n VaultCollectSessionResponse,\n VaultPaymentMethodRequest,\n VaultPaymentMethodResponse,\n} from './types';\n\n/**\n * A publishable (browser-safe) API key. The template type rejects secret\n * keys (`prd_…` / `snd_…`) at compile time, so a checkout cannot be handed\n * a credential that would reach secret-key routes.\n */\nexport type PublishableKey = `pk_${string}`;\n\n/**\n * Drop any caller-supplied credential headers (case-insensitively), so a\n * route can only ever carry the one credential its family requires — the\n * class's isolation guarantee must hold against per-call `headers` too.\n * Non-credential extras (`Idempotency-Key`, `X-Dp-*`, …) pass through.\n */\nfunction withoutCredentialHeaders(extra?: Record<string, string>): Record<string, string> {\n if (!extra) return {};\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(extra)) {\n const lower = key.toLowerCase();\n if (lower === 'api-key' || lower === 'authorization') continue;\n out[key] = value;\n }\n return out;\n}\n\n/** Drop one header (case-insensitively) from a caller-supplied extras map. */\nfunction withoutHeader(headers: Record<string, string>, name: string): Record<string, string> {\n const out: Record<string, string> = {};\n for (const [key, value] of Object.entries(headers)) {\n if (key.toLowerCase() === name) continue;\n out[key] = value;\n }\n return out;\n}\n\n/** Configuration for a {@link CheckoutSession}. */\nexport interface CheckoutSessionOptions {\n /** The merchant the payment belongs to. */\n merchantId: string;\n /** The payment this session is about. */\n paymentId: string;\n /**\n * The merchant's publishable key (`pk_prd_…` / `pk_snd_…`), from the\n * checkout payload's `pub_key`. Required for the `/payments/*` and\n * `/payment-methods` calls.\n */\n publishableKey?: PublishableKey;\n /**\n * The payment's client secret, from the checkout payload. Required for\n * every `/payment-link/*` call, and rides along on the payment calls.\n */\n clientSecret?: string;\n /** Override the API base URL (e.g. `/api` behind a same-origin proxy). */\n baseUrl?: string;\n /** Use the sandbox environment. Ignored when `baseUrl` is set. */\n sandbox?: boolean;\n /** Per-request timeout in milliseconds. */\n timeout?: number;\n /** Maximum automatic retries for retryable requests. */\n maxRetries?: number;\n debug?: boolean;\n logger?: DelopayLogger;\n}\n\n/**\n * Buyer-side client for a single hosted-checkout payment.\n *\n * Binds the two browser-safe credentials once — the merchant's publishable\n * key and the payment's client secret — and sends each request with exactly\n * the credential its route expects:\n *\n * - `/payment-link/*` side-channel routes authenticate with\n * `Authorization: Bearer <client_secret>`.\n * - `/payments/*` and `/payment-methods` authenticate with the publishable\n * key in the `api-key` header, with the client secret as query parameter\n * or body field.\n *\n * Neither credential can reach a secret-key route: the publishable key is\n * typed to the `pk_` prefix and the client secret only ever leaves as a\n * bearer token / parameter, never as an `api-key`.\n *\n * @example\n * ```typescript\n * const session = new CheckoutSession({\n * merchantId: checkout.merchant_id,\n * paymentId: checkout.payment_id,\n * publishableKey: checkout.pub_key,\n * clientSecret: checkout.client_secret,\n * });\n * const catalog = await session.payseproMethods('de');\n * ```\n */\nexport class CheckoutSession {\n private readonly client: Delopay;\n private readonly merchantId: string;\n private readonly paymentId: string;\n private readonly publishableKey?: PublishableKey;\n private readonly clientSecret?: string;\n\n constructor(options: CheckoutSessionOptions) {\n this.merchantId = options.merchantId;\n this.paymentId = options.paymentId;\n this.publishableKey = options.publishableKey;\n this.clientSecret = options.clientSecret;\n // Constructed WITHOUT a key: every call attaches its own credential\n // explicitly, so a bearer-authenticated route never carries an api-key\n // header and vice versa.\n this.client = new Delopay('', {\n baseUrl: options.baseUrl,\n sandbox: options.sandbox,\n timeout: options.timeout,\n maxRetries: options.maxRetries,\n debug: options.debug,\n logger: options.logger,\n });\n }\n\n private get linkBase(): string {\n return `/payment-link/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`;\n }\n\n /** Headers for the client-secret bearer routes (`/payment-link/*`). */\n private bearerHeaders(extra?: Record<string, string>): Record<string, string> {\n return {\n ...withoutCredentialHeaders(extra),\n Authorization: `Bearer ${this.requireClientSecret()}`,\n };\n }\n\n /** Headers for the publishable-key routes (`/payments/*`, `/payment-methods`). */\n private pkHeaders(extra?: Record<string, string>): Record<string, string> {\n if (!this.publishableKey) {\n throw new DelopayError('This call requires the publishable key', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return { ...withoutCredentialHeaders(extra), 'api-key': this.publishableKey };\n }\n\n private requireClientSecret(): string {\n if (!this.clientSecret) {\n throw new DelopayError('This call requires the payment client secret', {\n status: 0,\n code: 'MISSING_CREDENTIAL',\n type: 'invalid_request',\n });\n }\n return this.clientSecret;\n }\n\n /**\n * The hosted checkout's bootstrap payload for a one-time payment —\n * `CheckoutDetails` while payable, a status view once settled.\n *\n * Deliberately unauthenticated: a `pay_` link bootstraps before any\n * credential exists, so no credential header is ever attached (caller\n * extras are still stripped of credentials). The response is a large\n * discriminated union owned by the consuming checkout, which keeps its\n * own types and runtime gates — hence the loose return type.\n *\n * `theme` is the route's one declared query parameter (a named checkout\n * variant). `locale` travels as `Accept-Language` — the only\n * channel the backend's locale resolution reads; a `?locale=` query is\n * silently ignored by this route.\n *\n * `GET /payment-link/data/{merchantId}/{paymentId}`\n */\n async fetchCheckoutData(\n params?: { locale?: string; theme?: string },\n options?: RequestExtras,\n ): Promise<Record<string, unknown>> {\n return this.client.request(\n 'GET',\n `/payment-link/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n query: { theme: params?.theme },\n ...options,\n headers: {\n ...(params?.locale\n ? {\n ...withoutHeader(withoutCredentialHeaders(options?.headers), 'accept-language'),\n 'Accept-Language': params.locale,\n }\n : withoutCredentialHeaders(options?.headers)),\n },\n },\n );\n }\n\n /**\n * The subscription twin of {@link CheckoutSession.fetchCheckoutData}: the\n * bootstrap payload for a `sub_` checkout. Authenticated with the\n * subscription's client secret (construct the session with the `sub_…` id\n * in the `paymentId` slot). `locale` travels as `Accept-Language`, same\n * as {@link CheckoutSession.fetchCheckoutData}.\n *\n * `GET /subscriptions/data/{merchantId}/{subscriptionId}`\n */\n async fetchSubscriptionData(\n params?: { locale?: string },\n options?: RequestExtras,\n ): Promise<Record<string, unknown>> {\n return this.client.request(\n 'GET',\n `/subscriptions/data/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n ...options,\n headers: {\n ...(params?.locale\n ? {\n ...withoutHeader(this.bearerHeaders(options?.headers), 'accept-language'),\n 'Accept-Language': params.locale,\n }\n : this.bearerHeaders(options?.headers)),\n },\n },\n );\n }\n\n /**\n * Report buyer/device signals for rails that never reach\n * `/payments/{id}/confirm` (the Stripe SAQ-A rail: raw cards, Apple Pay,\n * Google Pay). Same telemetry contract as\n * {@link CheckoutSession.recordEvent}: sent with `keepalive: true`, and\n * failures resolve instead of rejecting — signals must never block or\n * break a checkout. Unauthenticated by design.\n *\n * `POST /payment-link/client-signals/{merchantId}/{paymentId}`\n */\n async reportClientSignals(\n params: {\n browser_info?: Record<string, unknown>;\n signals: Record<string, unknown>;\n },\n options?: RequestExtras,\n ): Promise<void> {\n try {\n await this.client.request(\n 'POST',\n `/payment-link/client-signals/${encodeURIComponent(this.merchantId)}/${encodeURIComponent(this.paymentId)}`,\n {\n body: params,\n keepalive: true,\n ...options,\n headers: withoutCredentialHeaders(options?.headers),\n },\n );\n } catch {\n // Telemetry: swallowing is the contract, not an oversight.\n }\n }\n\n /**\n * Confirm a subscription (PayPal approval rail). The client secret is\n * attached automatically; the shop's profile id travels as the\n * `X-Profile-Id` header the subscription routes require.\n *\n * `POST /subscriptions/{subscriptionId}/confirm` (publishable key)\n */\n async confirmSubscription(\n subscriptionId: string,\n profileId: string,\n params: Omit<ConfirmSubscriptionRequest, 'client_secret'>,\n options?: RequestExtras,\n ): Promise<ConfirmSubscriptionResponse> {\n return this.client.request(\n 'POST',\n `/subscriptions/${encodeURIComponent(subscriptionId)}/confirm`,\n {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n // Strip any caller-supplied x-profile-id first (case-insensitively):\n // Fetch folds duplicate headers into `caller, pro_x`, and the\n // subscription routes must see exactly one profile scope.\n headers: {\n ...withoutHeader(this.pkHeaders(options?.headers), 'x-profile-id'),\n 'X-Profile-Id': profileId,\n },\n },\n );\n }\n\n /**\n * The Paysepro rail catalog for the buyer's country.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/paysepro/methods`\n *\n * @param country - Lowercase ISO 3166-1 alpha-2 country code.\n */\n async payseproMethods(\n country: string,\n options?: RequestExtras,\n ): Promise<PayseproMethodsResponse> {\n return this.client.request('GET', `${this.linkBase}/paysepro/methods`, {\n query: { cc: country },\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The e-Payouts rail catalog for the buyer's country, plus the set of\n * countries that have at least one vendor.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/epayouts/methods`\n *\n * @param country - Lowercase ISO 3166-1 alpha-2 country code.\n */\n async epayoutsMethods(\n country: string,\n options?: RequestExtras,\n ): Promise<EpayoutsMethodsResponse> {\n return this.client.request('GET', `${this.linkBase}/epayouts/methods`, {\n query: { cc: country },\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Record a buyer-side checkout event on the payment's status timeline.\n *\n * Telemetry semantics, built in so callers can genuinely fire-and-forget:\n * the request is sent with `keepalive: true` (it survives the document\n * navigating away, e.g. right before a `window.open`), and transport or\n * server failures resolve to `undefined` instead of rejecting — telemetry\n * must never break a checkout or surface an unhandled rejection. Do not\n * `await` this in a click handler that must stay synchronous.\n *\n * A missing client secret still throws `MISSING_CREDENTIAL`: that is a\n * wiring bug, not a telemetry failure.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/checkout-events`\n */\n async recordEvent(\n params: RecordCheckoutEventRequest,\n options?: RequestExtras,\n ): Promise<RecordCheckoutEventResponse | undefined> {\n const headers = this.bearerHeaders(options?.headers);\n try {\n return await this.client.request('POST', `${this.linkBase}/checkout-events`, {\n body: params,\n keepalive: true,\n ...options,\n headers,\n });\n } catch {\n return undefined;\n }\n }\n\n /**\n * A short-lived VGS Collect session for browser-side card capture.\n *\n * **Exactly one refusal means \"this shop has no vault\": a 400 carrying\n * `IR_19`.** Every other refusal means a vault exists and could not be used,\n * and answering it by falling back to the processor's own card pane sends an\n * unprotected card number to the very processor the shop pays to hide it\n * from — the bug this endpoint's error contract exists to prevent.\n *\n * A **404 is not benign.** The router answers it when the shop's vault\n * account cannot be found — the state a shop is left in when its vault\n * connector is deleted while the profile keeps naming the id: it still\n * reports the vault as enabled and still expects its cards cloaked. The same\n * status also covers a payment that does not exist.\n *\n * `GET /payment-link/{merchantId}/{paymentId}/vault/collect-session`\n */\n async vaultCollectSession(options?: RequestExtras): Promise<VaultCollectSessionResponse> {\n return this.client.request('GET', `${this.linkBase}/vault/collect-session`, {\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * Register the aliased card as a payment method and mint the one-shot\n * `payment_token` the confirm call spends.\n *\n * `POST /payment-link/{merchantId}/{paymentId}/vault/payment-method`\n */\n async registerVaultPaymentMethod(\n params: VaultPaymentMethodRequest,\n options?: RequestExtras,\n ): Promise<VaultPaymentMethodResponse> {\n return this.client.request('POST', `${this.linkBase}/vault/payment-method`, {\n body: params,\n ...options,\n headers: this.bearerHeaders(options?.headers),\n });\n }\n\n /**\n * The payment's current state — status polling for redirect/popup rails.\n *\n * `GET /payments/{paymentId}` (publishable key + client secret)\n */\n async retrievePayment(options?: RequestExtras): Promise<PaymentResponse> {\n return this.client.request('GET', `/payments/${encodeURIComponent(this.paymentId)}`, {\n query: { client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Update the payment before confirmation (e.g. persist custom-field\n * answers as `metadata` on rails that never hit `/confirm`). The client\n * secret is attached automatically.\n *\n * `POST /payments/{paymentId}` (publishable key)\n */\n async updatePayment(\n params: PaymentUpdateRequest,\n options?: RequestExtras,\n ): Promise<PaymentResponse> {\n return this.client.request('POST', `/payments/${encodeURIComponent(this.paymentId)}`, {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Confirm the payment. The client secret is attached automatically; pass\n * an `Idempotency-Key` header via `options` to make retries safe.\n *\n * `POST /payments/{paymentId}/confirm` (publishable key)\n */\n async confirmPayment(\n params: PaymentConfirmRequest,\n options?: RequestExtras,\n ): Promise<PaymentResponse> {\n return this.client.request('POST', `/payments/${encodeURIComponent(this.paymentId)}/confirm`, {\n body: { ...params, client_secret: this.requireClientSecret() },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n\n /**\n * Payment methods available for this payment.\n *\n * `GET /payment-methods` (publishable key + client secret)\n *\n * @param params - Optional filters; `country` is the highest-precedence\n * geo hint, ahead of billing address and IP geolocation.\n */\n async listPaymentMethods(\n params?: { country?: string },\n options?: RequestExtras,\n ): Promise<PaymentMethodListResponse> {\n return this.client.request('GET', '/payment-methods', {\n query: { client_secret: this.requireClientSecret(), country: params?.country },\n ...options,\n headers: this.pkHeaders(options?.headers),\n });\n }\n}\n","// Stripe **native panes** — merchant-configured payment methods that render as\n// DeloPay-drawn tiles in the embedded checkout instead of inside Stripe's\n// Payment Element.\n//\n// Why they exist: Stripe only offers Apple Pay / Google Pay / Link when the\n// *top-level* document's domain is registered as a payment method domain on the\n// merchant's Stripe account. In an embedded iframe that domain is the\n// merchant's shop, not the DeloPay checkout — so the wallet silently\n// disappears. A native pane replaces it with our own tile that opens the DeloPay\n// hosted checkout at the top level, in a focused single-method view.\n//\n// Nothing here is Apple-Pay-specific: the feature is \"which Stripe payment\n// methods render as a native pane, and how they look\".\n//\n// This module serves SDK consumers: merchants configuring\n// `metadata.native_panes` on a Stripe connector account programmatically\n// (codec), reading the resolved `native_panes` off a checkout payload\n// (`NativePaneView`), or building the focused single-method link that goes\n// behind their own button (`focusedCheckoutUrl()`).\n//\n// It is a **mirror**, not the source of truth. The catalog and wire shapes are\n// owned by the router (delopay-backend\n// `crates/router/src/core/payment_link/native_panes.rs`). Four independent\n// copies exist, none importing another — change the router and all four in the\n// same change, or a merchant configures a pane the router silently drops:\n//\n// 1. this module\n// 2. delopay-control-center `src/app/core/services/native-panes.model.ts`\n// (the connector-page editor)\n// 3. delopay-java `src/main/java/net/delopay/sdk/nativepanes/NativePanes.java`\n// 4. delopay-rust-sdk `src/core/native_panes.rs`\n//\n// delopay-checkout (`src/lib/types.ts`) holds the resolved wire type only, not\n// the catalog, but its field names move with the router too.\n\n// --- Wire types ---------------------------------------------------------\n\n/**\n * How the focused external checkout charges a paned method. Decided\n * server-side; the browser never picks.\n *\n * - `wallet` — the method rides inside Stripe's `card` rail (Apple Pay, Google\n * Pay, Link). The focused view charges the **same** PaymentIntent the\n * embedded checkout already holds, so no second intent is ever created.\n * - `redirect` — the method has its own `payment_method_types[]` entry. The\n * focused view confirms through the standard `/payments/{id}/confirm` rail\n * and follows `next_action.redirect_to_url`.\n */\nexport type NativePaneRail = 'wallet' | 'redirect';\n\n/**\n * Where a pane's tile is offered. Wallet rail only — a redirect pane is\n * suppressed server-side, before any render knows whether it is framed, so\n * `embedded_only` there would leave the method unpayable at top level and the\n * router forces it back to `always`.\n */\nexport type NativePaneVisibility = 'always' | 'embedded_only';\n\n/**\n * How the embedded checkout opens a pane's focused view: a new browser tab\n * (`tab`, the historical behaviour) or a centred popup window (`popup`).\n * Only meaningful when the checkout renders inside an iframe — a top-level\n * render always navigates in place. Browsers that refuse popup windows fall\n * back to a tab on their own.\n */\nexport type NativePaneOpenTarget = 'tab' | 'popup';\n\n/**\n * One native pane exactly as the merchant configures it. Persisted (JSON) under\n * `metadata.native_panes` on the Stripe merchant connector account.\n *\n * Field names are the wire contract — renaming one is a migration. The router\n * decodes strictly row by row: a row that fails strict decoding (e.g. a\n * wrong-typed field like `display_order: \"3\"`) is dropped whole with a server\n * log, and the remaining rows still render. This SDK's\n * {@link decodeNativePanes} is additionally per-property tolerant — including\n * clamping `display_order` into the router's `i32` range — so a decode→encode\n * round-trip through the SDK repairs a blob the router would partially drop.\n */\nexport interface StripeNativePane {\n /** Catalog key of the promoted method — see {@link STRIPE_NATIVE_PANE_METHODS}. */\n method: string;\n /** Disabled rows keep their tuning but never reach a buyer. */\n enabled: boolean;\n /** Default-language tile label. Empty falls back to the catalog name. */\n label: string;\n /** Per-locale overrides of `label`, keyed by checkout locale (`de`, `de-AT`). */\n labelTranslations: Record<string, string>;\n /**\n * Secondary line under the label. `null` means \"use the catalog default\";\n * an empty string means the merchant deliberately hid the line. That\n * distinction is the whole reason this is nullable and `label` is not.\n */\n sublabel: string | null;\n /** Per-locale overrides of `sublabel`. */\n sublabelTranslations: Record<string, string>;\n /** Section the tile groups under. Empty falls back to the catalog category. */\n category: string;\n /** Built-in icon key — see {@link NATIVE_PANE_ICON_KEYS}. */\n icon: string;\n /** Custom inline SVG. Sanitized server-side before it reaches a buyer; a\n * rejected payload falls back to the built-in `icon`. */\n iconSvg: string;\n /** Lower renders first; ties break on catalog order. */\n displayOrder: number;\n /** `embedded_only` keeps the wallet inside Stripe's form at top level. */\n visibility: NativePaneVisibility;\n /** How the embedded checkout opens the focused view — see {@link NativePaneOpenTarget}. */\n openIn: NativePaneOpenTarget;\n}\n\n/**\n * One resolved native pane as the buyer-facing checkout receives it on the\n * payment-link payload (`native_panes`). Labels are already localized for the\n * render's locale and icons already sanitized — snake_case because this is the\n * API wire shape, not the editor's.\n */\nexport interface NativePaneView {\n method: string;\n rail: NativePaneRail;\n label: string;\n sublabel: string;\n category: string;\n icon?: string | null;\n icon_svg?: string | null;\n display_order: number;\n /** Redirect rail only — echo verbatim on confirm, never derive. */\n payment_method?: string | null;\n /** Redirect rail only — echo verbatim on confirm, never derive. */\n payment_method_type?: string | null;\n /** Redirect rail only — echo verbatim on confirm, never derive. */\n payment_method_data?: Record<string, unknown> | null;\n /**\n * The confirm body needs the buyer's country: merged into\n * `billing.address.country` and echoed into the single `payment_method_data`\n * variant's `billing_country`.\n */\n requires_billing_country?: boolean;\n /** `true` when the tile is only offered inside an iframe. Wallet rail only. */\n embedded_only?: boolean;\n /**\n * How the embedded checkout opens this tile's focused view. Absent on\n * payloads from older backends — treat as `tab`.\n */\n open_in?: NativePaneOpenTarget;\n}\n\n// --- Catalog ------------------------------------------------------------\n\n/**\n * Methods that may be promoted to a native pane.\n *\n * **The router owns this list** — `core::payment_link::native_panes::CATALOG` in\n * delopay-backend. This is a mirror so SDK consumers can validate or offer the\n * promotable methods without a round-trip; keep it in sync when the router's\n * catalog changes (the control-center keeps its own copy in\n * `native-panes.model.ts`). Drift is safe in one direction only: the backend\n * silently drops a key it does not know, so a stale entry here produces a row\n * that never renders rather than a broken checkout.\n */\nexport interface NativePaneMethodInfo {\n key: string;\n rail: NativePaneRail;\n /** Catalog default label, shown as the editor's placeholder. */\n defaultLabel: string;\n /** Catalog default sub-text. */\n defaultSublabel: string;\n /** Catalog default section. */\n defaultCategory: string;\n /** Catalog default icon key. */\n defaultIcon: string;\n}\n\nexport const STRIPE_NATIVE_PANE_METHODS: readonly NativePaneMethodInfo[] = [\n {\n key: 'apple_pay',\n rail: 'wallet',\n defaultLabel: 'Apple Pay',\n defaultSublabel: 'Pay with Apple Pay',\n defaultCategory: 'wallet',\n defaultIcon: 'apple',\n },\n {\n key: 'google_pay',\n rail: 'wallet',\n defaultLabel: 'Google Pay',\n defaultSublabel: 'Pay with Google Pay',\n defaultCategory: 'wallet',\n defaultIcon: 'google',\n },\n {\n key: 'link',\n rail: 'wallet',\n defaultLabel: 'Link',\n defaultSublabel: 'Pay with saved details',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n {\n key: 'klarna',\n rail: 'redirect',\n defaultLabel: 'Klarna',\n defaultSublabel: 'Pay later or in instalments',\n defaultCategory: 'bnpl',\n defaultIcon: 'bnpl',\n },\n {\n key: 'affirm',\n rail: 'redirect',\n defaultLabel: 'Affirm',\n defaultSublabel: 'Pay over time',\n defaultCategory: 'bnpl',\n defaultIcon: 'bnpl',\n },\n {\n key: 'ideal',\n rail: 'redirect',\n defaultLabel: 'iDEAL',\n defaultSublabel: 'Pay from your bank',\n defaultCategory: 'bank_redirect',\n defaultIcon: 'bank',\n },\n // eps / p24 / bancontact were removed from the router catalog: Stripe\n // hard-requires billing fields the focused checkout never collects (full\n // name for EPS/Bancontact, email for Przelewy24), so their tiles could\n // never succeed. They may return behind billing-aware gating.\n {\n key: 'alipay',\n rail: 'redirect',\n defaultLabel: 'Alipay',\n defaultSublabel: 'Pay with Alipay',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n {\n key: 'revolut_pay',\n rail: 'redirect',\n defaultLabel: 'Revolut Pay',\n defaultSublabel: 'Pay with Revolut',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n {\n key: 'amazon_pay',\n rail: 'redirect',\n defaultLabel: 'Amazon Pay',\n defaultSublabel: 'Pay with Amazon',\n defaultCategory: 'wallet',\n defaultIcon: 'wallet',\n },\n];\n\n/** Built-in tile icon keys the buyer-facing checkout ships a glyph for. */\nexport const NATIVE_PANE_ICON_KEYS: readonly string[] = [\n 'wallet',\n 'card',\n 'bank',\n 'apple',\n 'google',\n 'bnpl',\n 'cash',\n];\n\n/** Section keys the checkout knows a translated header for. */\nexport const NATIVE_PANE_CATEGORY_KEYS: readonly string[] = [\n 'wallet',\n 'card',\n 'bnpl',\n 'bank_redirect',\n 'bank_transfer',\n 'cash',\n];\n\n/**\n * Mirror of the router's per-connector cap. Counted differently on each side:\n * {@link decodeNativePanes} stops after 12 *decoded* rows (entries with a\n * usable, non-duplicate `method` — junk and duplicate entries don't consume a\n * slot), while the router caps *accepted* panes (enabled, known,\n * deduplicated) at 12 — so an oversized hand-written blob may render a pane\n * this decoder drops. Blobs the SDK itself encodes never exceed the cap.\n */\nexport const NATIVE_PANES_MAX = 12;\n\nexport function nativePaneMethodInfo(method: string): NativePaneMethodInfo | undefined {\n return STRIPE_NATIVE_PANE_METHODS.find((m) => m.key === method);\n}\n\n// --- Codec --------------------------------------------------------------\n\nexport function defaultNativePane(method: string): StripeNativePane {\n const info = nativePaneMethodInfo(method);\n return {\n method,\n enabled: true,\n label: '',\n labelTranslations: {},\n sublabel: null,\n sublabelTranslations: {},\n category: '',\n icon: info?.defaultIcon ?? '',\n iconSvg: '',\n displayOrder: 0,\n visibility: 'always',\n openIn: 'tab',\n };\n}\n\nexport function cloneNativePane(pane: StripeNativePane): StripeNativePane {\n return {\n ...pane,\n labelTranslations: { ...pane.labelTranslations },\n sublabelTranslations: { ...pane.sublabelTranslations },\n };\n}\n\nfunction isObject(value: unknown): value is Record<string, unknown> {\n return typeof value === 'object' && value !== null && !Array.isArray(value);\n}\n\nfunction parseTranslations(raw: unknown): Record<string, string> {\n if (!isObject(raw)) return {};\n const out: Record<string, string> = {};\n for (const [locale, value] of Object.entries(raw)) {\n if (typeof value === 'string' && value.length > 0) out[locale] = value;\n }\n return out;\n}\n\nfunction str(raw: unknown): string {\n return typeof raw === 'string' ? raw : '';\n}\n\n// The router's wire type is an `i32` (`api_models` `display_order`), and a\n// fractional or out-of-range value fails its strict row decode — dropping the\n// whole row server-side while an SDK round-trip would keep the blob looking\n// healthy. Clamped on BOTH decode and encode so this codec never emits a\n// value the router rejects, regardless of where the number came from.\nconst DISPLAY_ORDER_MIN = -2147483648;\nconst DISPLAY_ORDER_MAX = 2147483647;\n\nfunction clampDisplayOrder(raw: number): number {\n if (!Number.isFinite(raw)) return 0;\n return Math.min(DISPLAY_ORDER_MAX, Math.max(DISPLAY_ORDER_MIN, Math.trunc(raw)));\n}\n\n/**\n * Decode the stored `metadata.native_panes` blob into editor rows.\n *\n * Tolerant like the branding codecs: anything malformed falls back per\n * property, rows without a usable `method` are dropped, duplicates keep the\n * first occurrence — except that an enabled row wins over an earlier disabled\n * one for the same method, because that is the row the router renders — and\n * decoding stops after {@link NATIVE_PANES_MAX} decoded\n * rows (dropped junk/duplicate entries don't consume a slot). That is more\n * forgiving than the router, which drops a strict-decode-failing row whole\n * (keeping the rest) and caps accepted panes rather than decoded rows — see\n * {@link StripeNativePane} and {@link NATIVE_PANES_MAX}. Returns `null` when\n * the input is not an array so the caller can distinguish \"never configured\"\n * from \"cleared\".\n */\nexport function decodeNativePanes(raw: unknown): StripeNativePane[] | null {\n if (!Array.isArray(raw)) return null;\n const decodeRow = (entry: Record<string, unknown>, method: string): StripeNativePane => ({\n method,\n enabled: entry['enabled'] !== false,\n label: str(entry['label']),\n labelTranslations: parseTranslations(entry['label_translations']),\n sublabel: typeof entry['sublabel'] === 'string' ? entry['sublabel'] : null,\n sublabelTranslations: parseTranslations(entry['sublabel_translations']),\n category: str(entry['category']),\n icon: str(entry['icon']),\n iconSvg: str(entry['icon_svg']),\n displayOrder: clampDisplayOrder(Number(entry['display_order'])),\n // Anything unrecognised degrades to `always` rather than dropping the row.\n visibility: entry['visibility'] === 'embedded_only' ? 'embedded_only' : 'always',\n // Same tolerance: an unknown value degrades to the default `tab`.\n openIn: entry['open_in'] === 'popup' ? 'popup' : 'tab',\n });\n\n const indexByMethod = new Map<string, number>();\n const out: StripeNativePane[] = [];\n for (const entry of raw) {\n if (out.length >= NATIVE_PANES_MAX) break;\n if (!isObject(entry)) continue;\n const method = str(entry['method']).trim();\n if (!method) continue;\n const kept = indexByMethod.get(method);\n if (kept !== undefined) {\n // Duplicate method. Keep the row the ROUTER would render: it skips\n // disabled rows BEFORE deduping (`native_panes.rs`), so where a blob\n // holds both a disabled and an enabled row for one method, buyers see\n // the enabled one. Keeping the disabled row here would show the merchant\n // a pane that is off while it is live, and persist that on the next save.\n const enabled = entry['enabled'] !== false;\n const existing = out[kept];\n if (enabled && existing && !existing.enabled) out[kept] = decodeRow(entry, method);\n continue;\n }\n indexByMethod.set(method, out.length);\n out.push(decodeRow(entry, method));\n }\n return out;\n}\n\n/**\n * Encode editor rows back into the snake_case blob the connector account\n * stores. Empty optional strings are omitted so the metadata stays small and a\n * merchant who typed nothing round-trips as \"use the catalog default\" rather\n * than as an explicit empty override.\n *\n * `sublabel` is the exception: an explicitly-empty value is preserved (as `\"\"`)\n * because that is how a merchant hides the second line.\n */\nexport function encodeNativePanes(panes: StripeNativePane[]): Record<string, unknown>[] {\n const nonEmpty = (map: Record<string, string>): Record<string, string> | undefined => {\n const entries = Object.entries(map).filter(([, v]) => v.trim().length > 0);\n return entries.length > 0 ? Object.fromEntries(entries) : undefined;\n };\n return panes.slice(0, NATIVE_PANES_MAX).map((pane) => {\n const labelTranslations = nonEmpty(pane.labelTranslations);\n const sublabelTranslations = nonEmpty(pane.sublabelTranslations);\n return {\n method: pane.method,\n enabled: pane.enabled,\n ...(pane.label.trim() ? { label: pane.label.trim() } : {}),\n ...(labelTranslations ? { label_translations: labelTranslations } : {}),\n // `null` omits the key entirely (catalog default wins); `''` is sent\n // as-is because that is how the merchant hides the second line.\n ...(pane.sublabel !== null ? { sublabel: pane.sublabel } : {}),\n ...(sublabelTranslations ? { sublabel_translations: sublabelTranslations } : {}),\n ...(pane.category.trim() ? { category: pane.category.trim() } : {}),\n ...(pane.icon.trim() ? { icon: pane.icon.trim() } : {}),\n ...(pane.iconSvg.trim() ? { icon_svg: pane.iconSvg.trim() } : {}),\n // Clamped on encode too, not only decode: the router's strict i32 row\n // decode drops a row whole for a fractional or out-of-range value, so\n // writing e.g. 3.5 or Date.now() verbatim would silently delete the\n // pane at render while every read surface shows it healthy.\n display_order: clampDisplayOrder(pane.displayOrder),\n visibility: pane.visibility,\n open_in: pane.openIn,\n };\n });\n}\n\n// --- Focused checkout URL ----------------------------------------------\n\nexport interface FocusedCheckoutUrlParams {\n /** Base URL of the DeloPay hosted checkout, e.g. `https://checkout.delopay.net`. */\n checkoutBaseUrl: string;\n merchantId: string;\n paymentId: string;\n /** Native-pane method key to focus on (`apple_pay`, `klarna`, …). */\n method: string;\n /** Optional buyer locale, forwarded as `?locale=`. */\n locale?: string;\n /**\n * Set when the merchant's checkout-custom-field answers are already\n * persisted on the payment — forwarded as `cf=1` so the focused view skips\n * asking a second time. Purely a UI hint: the values live on the intent\n * either way, and the backend only accepts the merchant's configured field\n * keys from a client, so a wrongly-set flag can at worst skip an\n * informational prompt. This is the same hint the embedded pane sets when\n * it opens the focused view.\n */\n customFieldsCollected?: boolean;\n}\n\n/**\n * Build the link to the **focused single-method checkout**: the DeloPay hosted\n * checkout rendered with one payment method, one button, no picker.\n *\n * Two callers:\n * - the embedded checkout, which opens this in a new tab when a buyer clicks\n * a native pane tile, and\n * - a merchant running their own checkout, who puts it behind their own\n * button — the same mechanism without an iframe.\n *\n * `method` is not limited to configured native panes. A configured Stripe\n * native pane gets the focused one-button view; `card`, `paypal`,\n * `crypto_currency` and the local-methods catalogs (by method key or vendor\n * code) open the checkout pinned to that method. Methods that exist only as a\n * tab inside Stripe's Payment Element — iDEAL, Bancontact, P24 and the like,\n * unless promoted to a native pane — cannot be isolated, because Stripe owns\n * that surface. An unknown or unavailable method is never a dead end: the\n * checkout shows a notice with a visible \"show all payment methods\" action.\n *\n * Open it **at the top level** (a new tab or a full-page navigation). The whole\n * point is that the top-level domain is the registered payment method domain;\n * rendering it in an iframe puts you back where you started.\n *\n * If you open it with `window.open`, call that **synchronously inside the click\n * handler** or the popup blocker will eat it, and make sure any iframe you\n * render DeloPay in permits popups (`allow-popups`, plus\n * `allow-popups-to-escape-sandbox` under a restrictive `sandbox`).\n */\nexport function focusedCheckoutUrl(params: FocusedCheckoutUrlParams): string {\n const base = params.checkoutBaseUrl.replace(/\\/+$/, '');\n const path = `${base}/pay/${encodeURIComponent(params.merchantId)}/${encodeURIComponent(\n params.paymentId,\n )}`;\n const query = new URLSearchParams({ pane: params.method });\n if (params.locale) query.set('locale', params.locale);\n if (params.customFieldsCollected) query.set('cf', '1');\n return `${path}?${query.toString()}`;\n}\n\n// --- Buyer-side checkout events ----------------------------------------\n\n/**\n * The closed vocabulary of buyer-side checkout events recorded on the payment's\n * status timeline. Written through\n * `POST /payment-link/{merchant_id}/{payment_id}/checkout-events`, authorized\n * with the payment's `client_secret` as a bearer token.\n */\nexport const CHECKOUT_EVENT_KINDS = [\n 'native_pane_selected',\n 'native_pane_tab_opened',\n 'native_pane_tab_blocked',\n 'native_pane_abandoned',\n 'native_pane_returned',\n] as const;\n\nexport type CheckoutEventKind = (typeof CHECKOUT_EVENT_KINDS)[number];\n","import type { AuthResponse, SignUpWithMerchantIdRequest } from '../../types';\nimport type {\n AdminSignInRequest,\n AuthorizeResponse,\n CreateInternalUserRequest,\n CreateTenantUserRequest,\n OnboardMerchantRequest,\n OnboardMerchantResponse,\n SignupToggleRequest,\n SignupToggleResponse,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class Admin {\n constructor(private readonly request: RequestFn) {}\n\n async signIn(params: AdminSignInRequest): Promise<AuthResponse> {\n return this.request('POST', '/admin/signin', { body: params });\n }\n\n async createInternalUser(params: CreateInternalUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/internal-signup', { body: params });\n }\n\n async createTenant(params: CreateTenantUserRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/tenant-signup', { body: params });\n }\n\n /**\n * Create a new merchant admin user and merchant account atomically.\n *\n * This is the correct endpoint for bootstrapping the first admin user in a\n * fresh deployment — `internal-signup`/`tenant-signup` both require\n * pre-existing merchant records that don't exist on a clean database.\n *\n * `POST /admin/signup-with-merchant-id`\n */\n async signupWithMerchantId(params: SignUpWithMerchantIdRequest): Promise<AuthorizeResponse> {\n return this.request('POST', '/admin/signup-with-merchant-id', { body: params });\n }\n\n /** Toggle public signup on/off. `POST /admin/settings/signup` */\n async setSignupSettings(params: SignupToggleRequest): Promise<SignupToggleResponse> {\n return this.request('POST', '/admin/settings/signup', { body: params });\n }\n\n /** Read current public-signup status. `GET /admin/settings/signup` */\n async getSignupSettings(): Promise<SignupToggleResponse> {\n return this.request('GET', '/admin/settings/signup');\n }\n\n /** Full merchant bootstrap — user + merchant + project + profile + keys. `POST /admin/onboard-merchant` */\n async onboardMerchant(params: OnboardMerchantRequest): Promise<OnboardMerchantResponse> {\n return this.request('POST', '/admin/onboard-merchant', { body: params });\n }\n}\n","import type {\n FeeStatementDetail,\n MerchantAccountResponse,\n MerchantAccountUpdateRequest,\n PaymentAttemptsListResponse,\n PaymentClientContextListResponse,\n PaymentResponse,\n PaymentsDeleteResponse,\n PaymentStatusHistoryResponse,\n ProfileResponse,\n RefundListResponse,\n SettlementCurrentParams,\n SettlementCurrentResponse,\n SettlementOverviewParams,\n SettlementOverviewResponse,\n SettlementStatementListParams,\n SettlementStatementListResponse,\n StatementPdfParams,\n SubscriptionAnalyticsRequest,\n SubscriptionAnalyticsResponse,\n SubscriptionDrillRequest,\n} from '../../types';\nimport type {\n AdminAttachVaultRequest,\n AdminAttachVaultResponse,\n AdminVaultStateResponse,\n AdminCustomerListParams,\n AdminCustomerListResponse,\n AdminCustomerDetail,\n AdminTransactionListParams,\n AdminTransactionListResponse,\n AdminAnalyticsRequest,\n PlatformAnalyticsResponse,\n OverviewStatsResponse,\n PaymentAnalyticsRequest,\n PaymentAnalyticsResponse,\n AnalyticsScopeRequest,\n ClientAnalyticsRequest,\n DeviceDrillRequest,\n GeoDrillRequest,\n DrillResponse,\n DevicesAnalyticsResponse,\n GeoAnalyticsResponse,\n AnalyticsScopeResponse,\n AdminLedgerAnalyticsRequest,\n AdminLedgerAnalyticsResponse,\n AdminCreateUserForMerchantRequest,\n AdminUpdateUserRequest,\n AdminUserResponse,\n PaymentAutoCloseConfigResponse,\n PaymentAutoCloseOverrideResponse,\n PromoConfigResponse,\n TransactionDeleteConfigResponse,\n TransactionDeleteOverrideResponse,\n UpdatePaymentAutoCloseConfigRequest,\n UpdatePaymentAutoCloseOverrideRequest,\n UpdatePromoConfigRequest,\n UpdateTransactionDeleteConfigRequest,\n UpdateTransactionDeleteOverrideRequest,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class AdminPortal {\n constructor(private readonly request: RequestFn) {}\n\n async listCustomers(params?: AdminCustomerListParams): Promise<AdminCustomerListResponse> {\n return this.request('GET', '/admin-portal/customers', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n async getCustomer(customerId: string): Promise<AdminCustomerDetail> {\n return this.request('GET', `/admin-portal/customers/${encodeURIComponent(customerId)}`);\n }\n\n async listTransactions(\n params?: AdminTransactionListParams,\n ): Promise<AdminTransactionListResponse> {\n return this.request('GET', '/admin-portal/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Full detail for a single transaction of ANY merchant — the same\n * `PaymentResponse` the merchant `payments.retrieve` returns. Admin-scoped:\n * the JWT (or admin API key) does not need to belong to the payment's\n * merchant; the backend resolves the owning merchant and reads it read-only\n * (no connector sync).\n */\n async getTransaction(paymentId: string): Promise<PaymentResponse> {\n return this.request('GET', `/admin-portal/transactions/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * Per-attempt history (retries across connectors, decline reasons) for a\n * single transaction of ANY merchant.\n */\n async getTransactionAttempts(paymentId: string): Promise<PaymentAttemptsListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/attempts`,\n );\n }\n\n /**\n * Status timeline (intent / attempt / refund / dispute transitions) for a\n * single transaction of ANY merchant. `complete: false` marks timelines\n * partially reconstructed from current records.\n */\n async getTransactionStatusHistory(paymentId: string): Promise<PaymentStatusHistoryResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/status-history`,\n );\n }\n\n /**\n * Refunds for a single transaction of ANY merchant.\n */\n async getTransactionRefunds(paymentId: string): Promise<RefundListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/refunds`,\n );\n }\n\n async analytics(params: AdminAnalyticsRequest): Promise<PlatformAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n async overviewStats(): Promise<OverviewStatsResponse> {\n return this.request('GET', '/admin-portal/overview-stats');\n }\n\n async paymentAnalytics(params: PaymentAnalyticsRequest): Promise<PaymentAnalyticsResponse> {\n return this.request('GET', '/admin-portal/payment-analytics', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * One drill level of the analytics dashboard: the scope's daily series +\n * processor mix and its direct children's series. Range / metric / donut\n * toggles apply client-side; only a drill (passing merchant_id / project_id\n * / shop_id) fetches the next level.\n */\n async analyticsScope(params?: AnalyticsScopeRequest): Promise<AnalyticsScopeResponse> {\n return this.request('GET', '/admin-portal/analytics/scope', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Device analytics over the canonical client-context observation per\n * payment, rooted at all merchants and drillable via `merchant_id` /\n * `project_id` / `shop_id` like `analyticsScope`. Answers 200 with\n * `enabled: false` when the client-context optimisation-use switch is off.\n */\n async analyticsDevices(params?: ClientAnalyticsRequest): Promise<DevicesAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics/devices', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Geo analytics over the canonical client-context observation per payment,\n * rooted at all merchants. `mode` selects the location claim (`ip` default,\n * `billing`).\n */\n async analyticsGeo(params?: ClientAnalyticsRequest): Promise<GeoAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics/geo', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked geo target (map country/city or\n * local-hours heatmap cell), rooted at all merchants. Capped at 50 rows,\n * newest first, with the full match count alongside.\n */\n async analyticsGeoTransactions(params: GeoDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/admin-portal/analytics/geo/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The recent payments behind one clicked device target (browser/platform\n * family, device-model label or device class), rooted at all merchants.\n * 50 rows per page (`offset` for the next page), newest first.\n */\n async analyticsDeviceTransactions(params: DeviceDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/admin-portal/analytics/devices/transactions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Subscription analytics over `subscription` and `invoice`, rooted at all\n * merchants and drillable via `merchant_id` / `project_id` / `shop_id` like\n * `analyticsScope`. The `children` block at the root is the merchant\n * breakdown — there is no separate endpoint for it.\n *\n * Half the figures are **stocks** (a snapshot at the window's end, not a sum\n * over it), so `est_monthly_volume_usd` and `active` can match across a\n * 7-day and a 30-day window while `billed_volume_usd` does not. Day\n * granularity only.\n */\n async analyticsSubscriptions(\n params?: SubscriptionAnalyticsRequest,\n ): Promise<SubscriptionAnalyticsResponse> {\n return this.request('GET', '/admin-portal/analytics/subscriptions', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * The billing cycles behind one clicked element of the admin subscription\n * dashboard: an invoice outcome, a processor slice on either axis, a plan\n * row, a subscription status, a movement component, a series bucket or a\n * breakdown row. 50 rows per page (`offset` for the next), newest first,\n * with the full match count alongside.\n *\n * A cycle that never reached a payment is listed too — that is what \"still\n * unpaid\" means — and carries its invoice id as `payment_id` with\n * `invoice_id` set to the same value.\n */\n async analyticsSubscriptionsList(params: SubscriptionDrillRequest): Promise<DrillResponse> {\n return this.request('GET', '/admin-portal/analytics/subscriptions/list', {\n // A discriminated union carries no index signature, so the widening\n // goes via `unknown` — the union is the point, and the query builder\n // only ever reads own enumerable keys.\n query: params as unknown as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Platform billing dashboard: total balance across all ledger accounts (+\n * the net change), top-ups, fees collected, and the day-by-day ledger flow.\n * All amounts are in USD minor units.\n */\n async ledgerAnalytics(\n params?: AdminLedgerAnalyticsRequest,\n ): Promise<AdminLedgerAnalyticsResponse> {\n return this.request('GET', '/admin-portal/ledger-analytics', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n /**\n * Retrieve a merchant account via the admin portal. Unlike\n * `merchantAccounts.retrieve`, this route accepts an admin JWT (or admin API\n * key) and does not require the JWT to be scoped to the target merchant.\n */\n async retrieveAccount(merchantId: string): Promise<MerchantAccountResponse> {\n return this.request('GET', `/admin-portal/accounts/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Update a merchant account via the admin portal. Authenticated via admin JWT\n * or admin API key.\n */\n async updateAccount(\n merchantId: string,\n params: MerchantAccountUpdateRequest,\n ): Promise<MerchantAccountResponse> {\n return this.request('POST', `/admin-portal/accounts/${encodeURIComponent(merchantId)}`, {\n body: params,\n });\n }\n\n /**\n * Delete a merchant account via the admin portal. Authenticated via admin JWT\n * or admin API key.\n */\n async deleteAccount(merchantId: string): Promise<MerchantAccountResponse> {\n return this.request('DELETE', `/admin-portal/accounts/${encodeURIComponent(merchantId)}`);\n }\n\n /**\n * Create a brand-new user attached to the given merchant. The user is\n * marked `is_verified = true` so the admin can hand off credentials\n * immediately — no email round-trip is sent.\n */\n async createUserForMerchant(\n customerId: string,\n body: AdminCreateUserForMerchantRequest,\n ): Promise<AdminUserResponse> {\n return this.request('POST', `/admin-portal/customers/${encodeURIComponent(customerId)}/users`, {\n body,\n });\n }\n\n /**\n * Edit a user record. Any subset of fields may be supplied. `role_id`\n * requires `merchant_id`. `password` triggers a password reset (validated\n * against signup policy + JWT blacklist). `reset_2fa` clears TOTP state\n * so the user re-enrolls on next login. `is_active` supports both\n * directions: false soft-disables, true reactivates a soft-disabled user.\n */\n async updateUser(userId: string, body: AdminUpdateUserRequest): Promise<AdminUserResponse> {\n return this.request('PATCH', `/admin-portal/users/${encodeURIComponent(userId)}`, { body });\n }\n\n /**\n * Soft-delete a user globally: deactivates the row, blacklists existing\n * JWTs, and wipes credentials. Distinct from `deleteUserRole`, which\n * removes a single role binding while leaving the user signed-in elsewhere.\n */\n async deleteUser(userId: string): Promise<void> {\n return this.request('DELETE', `/admin-portal/users/${encodeURIComponent(userId)}`);\n }\n\n /**\n * Set a target merchant's shop iframe-allowed origins. Internal-admin\n * route — accepts an admin JWT or admin API key without requiring the\n * caller to be scoped to the target merchant. Pass `null` (or an empty\n * array) to clear the allowlist back to same-origin only.\n *\n * Server validates each origin: full origin (scheme + host[:port]),\n * no path/query/fragment, no wildcards.\n */\n async updateShopIframeOrigins(\n merchantId: string,\n profileId: string,\n origins: string[] | null,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/business_profile/${encodeURIComponent(profileId)}/iframe-origins`,\n { body: { iframe_allowed_origins: origins } },\n );\n }\n\n /**\n * Set (or clear) a target merchant shop's home country — the geo\n * dashboard's cross-border baseline. Internal-admin route. Pass `null` to\n * clear back to \"international / no home country\" (the default).\n *\n * `POST /admin-portal/accounts/{merchantId}/business-profile/{profileId}/home-country`\n */\n async updateShopHomeCountry(\n merchantId: string,\n profileId: string,\n homeCountry: string | null,\n ): Promise<ProfileResponse> {\n return this.request(\n 'POST',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/business-profile/${encodeURIComponent(profileId)}/home-country`,\n { body: { home_country: homeCountry } },\n );\n }\n\n /**\n * Soft-delete a transaction of ANY merchant. Only payments whose status\n * is in the admin delete policy can be deleted; the action is audited.\n *\n * `DELETE /admin-portal/transactions/{paymentId}`\n */\n async deleteTransaction(paymentId: string): Promise<PaymentsDeleteResponse> {\n return this.request('DELETE', `/admin-portal/transactions/${encodeURIComponent(paymentId)}`);\n }\n\n /**\n * Recover (undelete) a soft-deleted transaction. Audited.\n *\n * `POST /admin-portal/transactions/{paymentId}/recover`\n */\n async recoverTransaction(paymentId: string): Promise<PaymentsDeleteResponse> {\n return this.request(\n 'POST',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/recover`,\n );\n }\n\n /**\n * Client/device observations captured while the buyer interacted with a\n * transaction of ANY merchant, oldest first.\n *\n * `GET /admin-portal/transactions/{paymentId}/client-context`\n */\n async getTransactionClientContext(paymentId: string): Promise<PaymentClientContextListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/transactions/${encodeURIComponent(paymentId)}/client-context`,\n );\n }\n\n /**\n * The global payment auto-close policy.\n * `GET /admin-portal/auto-close-config`\n */\n async getAutoCloseConfig(): Promise<PaymentAutoCloseConfigResponse> {\n return this.request('GET', '/admin-portal/auto-close-config');\n }\n\n /**\n * Update the global payment auto-close policy. PATCH semantics — omitted\n * fields are left unchanged.\n *\n * `PUT /admin-portal/auto-close-config`\n */\n async updateAutoCloseConfig(\n params: UpdatePaymentAutoCloseConfigRequest,\n ): Promise<PaymentAutoCloseConfigResponse> {\n return this.request('PUT', '/admin-portal/auto-close-config', { body: params });\n }\n\n /**\n * One merchant's auto-close override plus the effective values.\n * `GET /admin-portal/accounts/{merchantId}/auto-close-config`\n */\n async getMerchantAutoCloseConfig(merchantId: string): Promise<PaymentAutoCloseOverrideResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/auto-close-config`,\n );\n }\n\n /**\n * Replace one merchant's auto-close override. REPLACE semantics — sending\n * both fields as `null` removes the override entirely.\n *\n * `PUT /admin-portal/accounts/{merchantId}/auto-close-config`\n */\n async updateMerchantAutoCloseConfig(\n merchantId: string,\n params: UpdatePaymentAutoCloseOverrideRequest,\n ): Promise<PaymentAutoCloseOverrideResponse> {\n return this.request(\n 'PUT',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/auto-close-config`,\n { body: params },\n );\n }\n\n /**\n * The global transaction soft-delete policy (statuses admins may delete,\n * plus the deploy-time env ceiling).\n *\n * `GET /admin-portal/transaction-delete-config`\n */\n async getTransactionDeleteConfig(): Promise<TransactionDeleteConfigResponse> {\n return this.request('GET', '/admin-portal/transaction-delete-config');\n }\n\n /**\n * Replace the global deletable-status set. Must be a subset of the env\n * ceiling.\n *\n * `PUT /admin-portal/transaction-delete-config`\n */\n async updateTransactionDeleteConfig(\n params: UpdateTransactionDeleteConfigRequest,\n ): Promise<TransactionDeleteConfigResponse> {\n return this.request('PUT', '/admin-portal/transaction-delete-config', { body: params });\n }\n\n /**\n * One merchant's deletable-status override plus the effective set.\n * `GET /admin-portal/accounts/{merchantId}/transaction-delete-config`\n */\n async getMerchantTransactionDeleteConfig(\n merchantId: string,\n ): Promise<TransactionDeleteOverrideResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/transaction-delete-config`,\n );\n }\n\n /**\n * Replace one merchant's deletable-status override. `statuses: null`\n * removes the override; an empty list forbids deletion entirely.\n *\n * `PUT /admin-portal/accounts/{merchantId}/transaction-delete-config`\n */\n async updateMerchantTransactionDeleteConfig(\n merchantId: string,\n params: UpdateTransactionDeleteOverrideRequest,\n ): Promise<TransactionDeleteOverrideResponse> {\n return this.request(\n 'PUT',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/transaction-delete-config`,\n { body: params },\n );\n }\n\n /**\n * A merchant's settlement statements. Same shapes as the merchant-facing\n * `settlement` resource, admin-authenticated.\n *\n * `GET /admin-portal/accounts/{merchantId}/settlement/statements`\n */\n async listSettlementStatements(\n merchantId: string,\n params: SettlementStatementListParams,\n ): Promise<SettlementStatementListResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/statements`,\n {\n query: {\n test_mode: params.test_mode,\n profile_id: params.profile_id,\n limit: params.limit,\n offset: params.offset,\n },\n },\n );\n }\n\n /**\n * One settlement statement with its breakdown.\n * `GET /admin-portal/accounts/{merchantId}/settlement/statements/{statementId}`\n */\n async getSettlementStatement(\n merchantId: string,\n statementId: string,\n ): Promise<FeeStatementDetail> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/statements/${encodeURIComponent(statementId)}`,\n );\n }\n\n /**\n * Export a settlement statement as PDF. Returns the raw bytes as a `Blob`\n * with the same auth and error handling as every other call.\n *\n * `GET /admin-portal/accounts/{merchantId}/settlement/statements/{statementId}/pdf`\n */\n async downloadSettlementStatementPdf(\n merchantId: string,\n statementId: string,\n params?: StatementPdfParams,\n ): Promise<Blob> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/statements/${encodeURIComponent(statementId)}/pdf`,\n {\n query: {\n currency: params?.currency,\n include_transactions: params?.include_transactions,\n },\n responseType: 'blob',\n },\n );\n }\n\n /**\n * A merchant's per-shop settlement overview.\n * `GET /admin-portal/accounts/{merchantId}/settlement/overview`\n */\n async settlementOverview(\n merchantId: string,\n params: SettlementOverviewParams,\n ): Promise<SettlementOverviewResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/overview`,\n { query: { test_mode: params.test_mode } },\n );\n }\n\n /**\n * A merchant's live current-period settlement rollup.\n * `GET /admin-portal/accounts/{merchantId}/settlement/current`\n */\n async settlementCurrent(\n merchantId: string,\n params: SettlementCurrentParams,\n ): Promise<SettlementCurrentResponse> {\n return this.request(\n 'GET',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/settlement/current`,\n { query: { test_mode: params.test_mode, profile_id: params.profile_id } },\n );\n }\n\n /**\n * A merchant's vault state: the attach entitlement, and the vault\n * configuration of every shop.\n *\n * `GET /admin-portal/accounts/{merchantId}/vault`\n */\n async getVaultState(merchantId: string): Promise<AdminVaultStateResponse> {\n return this.request('GET', `/admin-portal/accounts/${encodeURIComponent(merchantId)}/vault`);\n }\n\n /**\n * Attach a vault to one of a merchant's shops — creates the vault\n * connector account and points the profile at it in one request. The\n * Collect credentials are verified write-only before anything is stored.\n *\n * `POST /admin-portal/accounts/{merchantId}/vault/attach`\n */\n async attachVault(\n merchantId: string,\n params: AdminAttachVaultRequest,\n ): Promise<AdminAttachVaultResponse> {\n return this.request(\n 'POST',\n `/admin-portal/accounts/${encodeURIComponent(merchantId)}/vault/attach`,\n { body: params },\n );\n }\n\n /**\n * Fetch the global welcome promotional-credit config (amount + message)\n * granted to newly created billing profiles. Internal-admin route.\n */\n async getPromoConfig(): Promise<PromoConfigResponse> {\n return this.request('GET', '/admin-portal/promo-config');\n }\n\n /**\n * Update the global welcome promotional-credit config. Any subset of\n * `amount` (minor units) / `message` may be supplied; omitted fields are\n * left unchanged. Returns the resulting config. Internal-admin route.\n */\n async updatePromoConfig(params: UpdatePromoConfigRequest): Promise<PromoConfigResponse> {\n return this.request('PUT', '/admin-portal/promo-config', { body: params });\n }\n}\n","import type { AuditLogListParams, AuditLogListResponse, AuditLogResponse } from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class AuditLogs {\n constructor(private readonly request: RequestFn) {}\n\n async list(params?: AuditLogListParams): Promise<AuditLogListResponse> {\n return this.request('GET', '/admin-portal/audit', {\n query: params as Record<string, string | number | boolean | undefined>,\n });\n }\n\n async retrieve(logId: string): Promise<AuditLogResponse> {\n return this.request('GET', `/admin-portal/audit/${encodeURIComponent(logId)}`);\n }\n}\n","import type { RequestFn } from '../../client';\n\nexport class Cache {\n constructor(private readonly request: RequestFn) {}\n\n /** Invalidate a cache entry by key. `POST /cache/invalidate/{key}` */\n async invalidate(key: string): Promise<Record<string, unknown>> {\n return this.request('POST', `/cache/invalidate/${encodeURIComponent(key)}`);\n }\n}\n","import type {\n CardIssuerCreateRequest,\n CardIssuerResponse,\n CardIssuerUpdateRequest,\n CardIssuerListResponse,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class CardIssuers {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: CardIssuerCreateRequest): Promise<CardIssuerResponse> {\n return this.request('POST', '/card-issuers', { body: params });\n }\n\n async update(issuerId: string, params: CardIssuerUpdateRequest): Promise<CardIssuerResponse> {\n return this.request('PUT', `/card-issuers/${encodeURIComponent(issuerId)}`, { body: params });\n }\n\n async list(): Promise<CardIssuerListResponse> {\n return this.request('GET', '/card-issuers');\n }\n}\n","import type { RequestFn } from '../../client';\n\nexport class Configs {\n constructor(private readonly request: RequestFn) {}\n\n /** Create a config. `POST /configs` */\n async create(params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('POST', '/configs', { body: params });\n }\n\n /** Retrieve a config by key. `GET /configs/{key}` */\n async retrieve(key: string): Promise<Record<string, unknown>> {\n return this.request('GET', `/configs/${encodeURIComponent(key)}`);\n }\n\n /** Update a config. `PUT /configs/{key}` */\n async update(key: string, params: Record<string, unknown>): Promise<Record<string, unknown>> {\n return this.request('PUT', `/configs/${encodeURIComponent(key)}`, { body: params });\n }\n\n /** Delete a config. `DELETE /configs/{key}` */\n async delete(key: string): Promise<Record<string, unknown>> {\n return this.request('DELETE', `/configs/${encodeURIComponent(key)}`);\n }\n}\n","import type {\n ConnectorRestrictionRuleResponse,\n CreateConnectorRestrictionRuleRequest,\n ListConnectorRestrictionRulesQuery,\n UpdateConnectorRestrictionRuleRequest,\n} from '../types';\nimport type { RequestFn } from '../../client';\n\nconst BASE = '/admin/connector-restriction-rules';\n\n/**\n * Per-shop / per-project connector restriction rules.\n *\n * Distinct from `connectorRestrictions` (the merchant-tier attach gate):\n * these rules allow/deny a connector for one shop (`scope: 'profile'`) or\n * project (`scope: 'project'`) at routing time. A `deny` is never routed even\n * when the connector is attached and enabled; once a scope has any `allow` it\n * becomes a whitelist, and the project scope takes precedence over the shop\n * scope. Admin-only, under `/admin/connector-restriction-rules`; exposed only\n * via `'@delopay/sdk/internal'`.\n */\nexport class ConnectorRestrictionRules {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Create one allow/deny rule. A duplicate\n * `(merchant_id, scope, scope_id, connector)` is rejected — update or delete\n * the existing rule instead.\n */\n async create(\n body: CreateConnectorRestrictionRuleRequest,\n ): Promise<ConnectorRestrictionRuleResponse> {\n return this.request('POST', BASE, { body });\n }\n\n /**\n * List rules for one scope (`scope` + `scope_id`) or a whole merchant\n * (`merchant_id`). Pass exactly one selector.\n */\n async list(\n query: ListConnectorRestrictionRulesQuery,\n ): Promise<ConnectorRestrictionRuleResponse[]> {\n // Spread into a fresh object literal so the typed query satisfies the\n // request layer's `Record<string, …>` index signature. `undefined` values\n // are dropped by `request()`.\n return this.request('GET', BASE, { query: { ...query } });\n }\n\n /** Retrieve a single rule by ID. */\n async retrieve(id: string): Promise<ConnectorRestrictionRuleResponse> {\n return this.request('GET', `${BASE}/${encodeURIComponent(id)}`);\n }\n\n /** Update a rule's action and/or reason. */\n async update(\n id: string,\n body: UpdateConnectorRestrictionRuleRequest,\n ): Promise<ConnectorRestrictionRuleResponse> {\n return this.request('PATCH', `${BASE}/${encodeURIComponent(id)}`, { body });\n }\n\n /** Delete a rule by ID. */\n async delete(id: string): Promise<{ id: string; deleted: boolean }> {\n return this.request('DELETE', `${BASE}/${encodeURIComponent(id)}`);\n }\n}\n","import type { ConnectorRestrictionResponse, UpsertConnectorRestrictionRequest } from '../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Admin-only allowlist for phased connector rollouts.\n *\n * Default-open semantics: a connector with no restriction row is\n * usable by every merchant (current behavior). A connector with a\n * row is gated — only merchants in `allowed_merchant_ids` can attach\n * a connector account. Enforced server-side at MCA-create time.\n */\nexport class ConnectorRestrictions {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Idempotent upsert. If a row exists for `connector_name`, its\n * allowlist + reason are replaced. To open the connector to\n * everyone again, call `delete()`.\n */\n async upsert(body: UpsertConnectorRestrictionRequest): Promise<ConnectorRestrictionResponse> {\n return this.request('POST', '/admin/connector-restrictions', { body });\n }\n\n async list(): Promise<ConnectorRestrictionResponse[]> {\n return this.request('GET', '/admin/connector-restrictions');\n }\n\n async retrieve(connectorName: string): Promise<ConnectorRestrictionResponse> {\n return this.request(\n 'GET',\n `/admin/connector-restrictions/${encodeURIComponent(connectorName)}`,\n );\n }\n\n /** Removing the row makes the connector public again. */\n async delete(connectorName: string): Promise<{ connector_name: string; deleted: boolean }> {\n return this.request(\n 'DELETE',\n `/admin/connector-restrictions/${encodeURIComponent(connectorName)}`,\n );\n }\n}\n","import type { GsmRuleCreateRequest, GsmRuleResponse, GsmRuleUpdateRequest } from '../types';\nimport type { RequestFn } from '../../client';\n\nexport class Gsm {\n constructor(private readonly request: RequestFn) {}\n\n async create(params: GsmRuleCreateRequest): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm', { body: params });\n }\n\n async retrieve(params: Record<string, unknown>): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm/get', { body: params });\n }\n\n async update(params: GsmRuleUpdateRequest): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm/update', { body: params });\n }\n\n async delete(params: Record<string, unknown>): Promise<GsmRuleResponse> {\n return this.request('POST', '/gsm/delete', { body: params });\n }\n}\n","import type {\n AdminAdjustmentRequest,\n AdminAdjustmentResponse,\n AdminSuspendRequest,\n AdminUnsuspendRequest,\n AdminSetTrustedRequest,\n UpdateLedgerEntryRequest,\n} from '../types';\nimport type { BillingProfileResponse } from '../../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Platform-level ledger adjustments on a merchant's balance. Admin-only\n * routes under `/billing/{merchantId}/admin/credit|debit`. Exposed only\n * via `'@delopay/sdk/internal'` so the public merchant SDK doesn't\n * advertise the admin adjustment path in autocomplete.\n */\nexport class PlatformBilling {\n constructor(private readonly request: RequestFn) {}\n\n /**\n * Manually credit a merchant's balance (e.g. promotional credit,\n * dispute reversal, manual correction).\n *\n * @param merchantId - The merchant account ID.\n * @param params - Credit amount and reason.\n */\n async credit(\n merchantId: string,\n params: AdminAdjustmentRequest,\n ): Promise<AdminAdjustmentResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/credit`, {\n body: params,\n });\n }\n\n /**\n * Manually debit a merchant's balance.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Debit amount and reason.\n */\n async debit(\n merchantId: string,\n params: AdminAdjustmentRequest,\n ): Promise<AdminAdjustmentResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/debit`, {\n body: params,\n });\n }\n\n /**\n * Edit a single ledger entry (amount and/or description), keeping the\n * merchant balance consistent: when `amount` changes, the balance is\n * atomically adjusted by the difference. Returns the entry id and new\n * balance.\n *\n * @param merchantId - The merchant account ID.\n * @param ledgerId - The ledger entry id to edit.\n * @param params - New amount / description (either optional).\n */\n async editLedgerEntry(\n merchantId: string,\n ledgerId: string,\n params: UpdateLedgerEntryRequest,\n ): Promise<AdminAdjustmentResponse> {\n return this.request(\n 'PATCH',\n `/billing/${encodeURIComponent(merchantId)}/admin/ledger/${encodeURIComponent(ledgerId)}`,\n { body: params },\n );\n }\n\n /**\n * Delete a single ledger entry, reversing its amount from the merchant\n * balance. Returns the deleted entry id and the new balance.\n *\n * @param merchantId - The merchant account ID.\n * @param ledgerId - The ledger entry id to delete.\n */\n async deleteLedgerEntry(merchantId: string, ledgerId: string): Promise<AdminAdjustmentResponse> {\n return this.request(\n 'DELETE',\n `/billing/${encodeURIComponent(merchantId)}/admin/ledger/${encodeURIComponent(ledgerId)}`,\n );\n }\n\n /**\n * Manually suspend a merchant (e.g. confirmed fraud or ToS violation),\n * independent of balance. A `reason` is required for audit. Throws 412 if\n * the merchant is trusted (clear the flag first) or already suspended.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Suspension reason.\n * @returns The updated billing profile.\n */\n async suspend(merchantId: string, params: AdminSuspendRequest): Promise<BillingProfileResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/suspend`, {\n body: params,\n });\n }\n\n /**\n * Lift a suspension. Restores the merchant to `active` (or `delinquent` if\n * the balance is at/below the hard floor) and resets the recharge-failure\n * counter. Throws 412 if the merchant is not suspended.\n *\n * @param merchantId - The merchant account ID.\n * @param params - Optional audit note.\n * @returns The updated billing profile.\n */\n async unsuspend(\n merchantId: string,\n params: AdminUnsuspendRequest = {},\n ): Promise<BillingProfileResponse> {\n return this.request('POST', `/billing/${encodeURIComponent(merchantId)}/admin/unsuspend`, {\n body: params,\n });\n }\n\n /**\n * Set or clear the trusted (suspension-exempt) flag. Trusted merchants\n * cannot be suspended automatically or manually. Does not lift an existing\n * suspension — use {@link PlatformBilling.unsuspend} for that.\n *\n * @param merchantId - The merchant account ID.\n * @param params - The desired trusted state.\n * @returns The updated billing profile.\n */\n async setTrusted(\n merchantId: string,\n params: AdminSetTrustedRequest,\n ): Promise<BillingProfileResponse> {\n return this.request('PATCH', `/billing/${encodeURIComponent(merchantId)}/admin/trusted`, {\n body: params,\n });\n }\n}\n","import type {\n FeeRulePreviewRequest,\n FeeRulePreviewResponse,\n FeeScheduleCreateRequest,\n FeeScheduleResponse,\n FeeScheduleUpdateRequest,\n PlatformFeeRuleInput,\n PlatformFeeRuleRecord,\n PlatformFeeRuleRequest,\n} from '../../types';\nimport type { RequestFn } from '../../client';\n\n/**\n * Platform-wide fee schedule management. Admin-only routes under\n * `/admin/fees/*`. Exposed only via `'@delopay/sdk/internal'`.\n *\n * `platformFees.rules` manages the platform-owned Euclid fee-rule program per\n * merchant, which takes precedence over the flat platform schedules. Build the\n * program with `feeProgram()`.\n */\nexport class PlatformFees {\n /** Platform-owned Euclid fee-rule program (`/admin/fees/rules`). */\n readonly rules: PlatformFeeRulesManager;\n\n constructor(private readonly request: RequestFn) {\n this.rules = new PlatformFeeRulesManager(request);\n }\n\n /** Create a platform fee schedule for a specific merchant. */\n async create(params: FeeScheduleCreateRequest, merchantId: string): Promise<FeeScheduleResponse> {\n return this.request('POST', '/admin/fees', {\n body: params,\n query: { merchant_id: merchantId },\n });\n }\n\n /** List every platform fee schedule assigned to a merchant. */\n async list(merchantId: string): Promise<FeeScheduleResponse[]> {\n return this.request('GET', '/admin/fees/list', {\n query: { merchant_id: merchantId },\n });\n }\n\n /** Retrieve a single platform fee schedule by ID. */\n async retrieve(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('GET', `/admin/fees/${encodeURIComponent(feeId)}`);\n }\n\n /** Update a platform fee schedule. */\n async update(feeId: string, params: FeeScheduleUpdateRequest): Promise<FeeScheduleResponse> {\n return this.request('PUT', `/admin/fees/${encodeURIComponent(feeId)}`, { body: params });\n }\n\n /** Delete a platform fee schedule. */\n async delete(feeId: string): Promise<FeeScheduleResponse> {\n return this.request('DELETE', `/admin/fees/${encodeURIComponent(feeId)}`);\n }\n}\n\n/**\n * Manages a merchant's platform-owned Euclid fee-rule programs (admin surface),\n * merchant-wide or per-shop (one active program per scope; a shop-scoped\n * program wins for its shop, else the merchant-wide one applies). Build the\n * `algorithm` with `feeProgram()`. The SDK injects `fee_owner: 'platform'`; set\n * `profile_id` on the input to scope a program to a shop.\n */\nexport class PlatformFeeRulesManager {\n constructor(private readonly request: RequestFn) {}\n\n /** Create or replace the platform fee-rule program for a merchant. */\n async upsert(params: PlatformFeeRuleInput, merchantId: string): Promise<PlatformFeeRuleRecord> {\n const body: PlatformFeeRuleRequest = { ...params, fee_owner: 'platform' };\n return this.request('PUT', '/admin/fees/rules', {\n body,\n query: { merchant_id: merchantId },\n });\n }\n\n /**\n * Retrieve the active platform fee-rule program for a scope, or `null`.\n * `profileId` omitted = merchant-wide program; set = that shop's program.\n */\n async retrieve(merchantId: string, profileId?: string): Promise<PlatformFeeRuleRecord | null> {\n return this.request('GET', '/admin/fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Deactivate a platform fee-rule program. Idempotent. `profileId` omitted\n * targets the merchant-wide program; set targets only that shop's program.\n */\n async delete(merchantId: string, profileId?: string): Promise<void> {\n await this.request('DELETE', '/admin/fees/rules', {\n query: { merchant_id: merchantId, profile_id: profileId },\n });\n }\n\n /**\n * Dry-run a candidate fee-rule program against a sample transaction.\n * Returns the matched rule name, whether it fell through, and the computed fee.\n * Does not persist anything.\n */\n async preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse> {\n return this.request('POST', '/admin/fees/rules/preview', {\n body: input,\n query: { merchant_id: merchantId },\n });\n }\n}\n","import type { RequestFn } from '../client';\nimport { Delopay } from '../client';\nimport { Admin } from './resources/admin';\nimport { AdminPortal } from './resources/adminPortal';\nimport { AuditLogs } from './resources/auditLogs';\nimport { Cache } from './resources/cache';\nimport { CardIssuers } from './resources/cardIssuers';\nimport { Configs } from './resources/configs';\nimport { ConnectorRestrictionRules } from './resources/connectorRestrictionRules';\nimport { ConnectorRestrictions } from './resources/connectorRestrictions';\nimport { Gsm } from './resources/gsm';\nimport { PlatformBilling } from './resources/platformBilling';\nimport { PlatformFees } from './resources/platformFees';\n\n/**\n * Internal-only Delopay client for DeloPay staff tooling (the admin\n * control-center, audit UIs, etc.). Extends the public `Delopay` surface\n * with admin-plane resources that must **not** be discoverable from the\n * merchant-facing package entry.\n *\n * Import path: `import { DelopayInternal } from '@delopay/sdk/internal'`.\n * The merchant-facing `import { Delopay } from '@delopay/sdk'` never\n * surfaces these.\n */\nexport class DelopayInternal extends Delopay {\n /** Bootstrap admin endpoints — signup, signin, onboarding. */\n readonly admin: Admin;\n /** Platform-wide customer, transaction, analytics, merchant-account ops. */\n readonly adminPortal: AdminPortal;\n /** Audit log reads. */\n readonly auditLogs: AuditLogs;\n /** Backend cache invalidation. */\n readonly cache: Cache;\n /** Platform card-issuer program management. */\n readonly cardIssuers: CardIssuers;\n /** Generic platform config store. */\n readonly configs: Configs;\n /** Per-merchant connector allowlist for phased rollouts. */\n readonly connectorRestrictions: ConnectorRestrictions;\n /** Per-shop / per-project connector allow-deny rules (routing-time). */\n readonly connectorRestrictionRules: ConnectorRestrictionRules;\n /** GSM (Gateway Status Mapping) routing rules. */\n readonly gsm: Gsm;\n /** Admin-only ledger credits/debits against a merchant's balance. */\n readonly platformBilling: PlatformBilling;\n /** Platform-wide fee schedules assigned to merchants. */\n readonly platformFees: PlatformFees;\n\n constructor(...args: ConstructorParameters<typeof Delopay>) {\n super(...args);\n const request = this.request.bind(this) as RequestFn;\n this.admin = new Admin(request);\n this.adminPortal = new AdminPortal(request);\n this.auditLogs = new AuditLogs(request);\n this.cache = new Cache(request);\n this.cardIssuers = new CardIssuers(request);\n this.configs = new Configs(request);\n this.connectorRestrictions = new ConnectorRestrictions(request);\n this.connectorRestrictionRules = new ConnectorRestrictionRules(request);\n this.gsm = new Gsm(request);\n this.platformBilling = new PlatformBilling(request);\n this.platformFees = new PlatformFees(request);\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACeO,IAAM,eAAN,cAA2B,MAAM;AAAA,EAsBtC,YACE,SACA,SAQA;AACA,UAAM,OAAO;AACb,WAAO,eAAe,MAAM,WAAW,SAAS;AAChD,SAAK,OAAO;AACZ,SAAK,SAAS,QAAQ;AACtB,SAAK,OAAO,QAAQ;AACpB,SAAK,OAAO,QAAQ;A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