@delopay/sdk 0.47.0 → 0.49.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/index.d.cts CHANGED
@@ -1142,6 +1142,27 @@ interface PlatformFeeRuleRecord {
1142
1142
  created_at: number;
1143
1143
  modified_at: number;
1144
1144
  }
1145
+ /** Sample transaction + candidate program for `POST /admin/fees/rules/preview`. */
1146
+ interface FeeRulePreviewRequest {
1147
+ algorithm: PlatformFeeProgram;
1148
+ /** Amount in minor units. */
1149
+ amount: number;
1150
+ currency: Currency;
1151
+ payment_method?: PaymentMethod | null;
1152
+ connector?: Connector | null;
1153
+ card_network?: string | null;
1154
+ /** USD minor units (previous-month volume snapshot). */
1155
+ merchant_volume?: number | null;
1156
+ }
1157
+ interface FeeRulePreviewResponse {
1158
+ /** Matched rule name, or null when only the default selection matched. */
1159
+ matched_rule: string | null;
1160
+ /** True when the matched branch sets no concrete fee (engine falls through to the legacy schedule/tier chain). */
1161
+ fell_through: boolean;
1162
+ /** Computed fee in minor units, or null when fell_through. */
1163
+ fee_amount: number | null;
1164
+ fee_currency: string | null;
1165
+ }
1145
1166
  interface ProjectCreateRequest {
1146
1167
  project_name: string;
1147
1168
  description?: string | null;
@@ -3026,6 +3047,15 @@ declare class FeeRulesManager {
3026
3047
  * (other shops' programs are left intact).
3027
3048
  */
3028
3049
  delete(merchantId: string, profileId?: string): Promise<void>;
3050
+ /**
3051
+ * Dry-run a candidate fee-rule program against a sample transaction.
3052
+ * Returns the matched rule name, whether it fell through, and the computed fee.
3053
+ * Does not persist anything.
3054
+ *
3055
+ * @param input - Candidate program + sample transaction fields.
3056
+ * @param merchantId - The merchant account ID.
3057
+ */
3058
+ preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse>;
3029
3059
  }
3030
3060
 
3031
3061
  /** View and revoke recurring payment mandates. */
@@ -4591,6 +4621,29 @@ declare const Webhooks: {
4591
4621
  verify(rawBody: string | Uint8Array, signatureHeader: string, secret: string): Promise<WebhookEvent>;
4592
4622
  };
4593
4623
 
4624
+ /** A single condition leaf in the builder's condition tree. */
4625
+ interface LeafNode {
4626
+ kind: 'leaf';
4627
+ lhs: string;
4628
+ comparison: EuclidComparisonType;
4629
+ value: EuclidValue;
4630
+ }
4631
+ /** An AND (`all`) or OR (`any`) group of condition nodes. */
4632
+ interface GroupNode {
4633
+ kind: 'all' | 'any';
4634
+ children: ConditionNode[];
4635
+ }
4636
+ type ConditionNode = LeafNode | GroupNode;
4637
+ /**
4638
+ * A condition leaf. Numeric values (amount, merchant_volume) tag as `number`;
4639
+ * string values (payment_method, connector, currency, card_network) tag as
4640
+ * `enum_variant`.
4641
+ */
4642
+ declare function leaf(lhs: string, comparison: EuclidComparisonType, value: string | number): LeafNode;
4643
+ /** AND group — all children must match. */
4644
+ declare function allOf(...children: ConditionNode[]): GroupNode;
4645
+ /** OR group — any child matching is enough. */
4646
+ declare function anyOf(...children: ConditionNode[]): GroupNode;
4594
4647
  /**
4595
4648
  * How a rule (or the default) prices a transaction. `fee_type` is inferred:
4596
4649
  * percentage-only → `percentage`, flat-only → `flat`, both → `combined`.
@@ -4617,12 +4670,29 @@ interface FeeRuleConditions {
4617
4670
  connector?: Connector;
4618
4671
  currency?: Currency;
4619
4672
  cardNetwork?: string;
4673
+ /**
4674
+ * Customer billing-address country. Must be the exact backend `Country` enum
4675
+ * variant (PascalCase full name, e.g. `Germany`/`UnitedStatesOfAmerica`), not
4676
+ * an ISO code — the engine lowers `billing_country` via case-sensitive
4677
+ * `from_str`.
4678
+ */
4679
+ billingCountry?: string;
4620
4680
  /** `amount == n` (minor units). */
4621
4681
  amountEquals?: number;
4622
4682
  /** `amount > n` (minor units). */
4623
4683
  amountGreaterThan?: number;
4624
4684
  /** `amount < n` (minor units). */
4625
4685
  amountLessThan?: number;
4686
+ /**
4687
+ * `merchant_volume == n` — the merchant's previous-month volume snapshot
4688
+ * (USD minor units). Combine with any other condition, e.g.
4689
+ * `{ paymentMethod: 'crypto', merchantVolumeGreaterThan: 1_000_000 }`.
4690
+ */
4691
+ merchantVolumeEquals?: number;
4692
+ /** `merchant_volume > n` (USD minor units). */
4693
+ merchantVolumeGreaterThan?: number;
4694
+ /** `merchant_volume < n` (USD minor units). */
4695
+ merchantVolumeLessThan?: number;
4626
4696
  }
4627
4697
  interface FeeRuleInput {
4628
4698
  name: string;
@@ -4630,8 +4700,35 @@ interface FeeRuleInput {
4630
4700
  when?: FeeRuleConditions;
4631
4701
  /** Extra raw conditions ANDed in, for dimensions `when` does not cover. */
4632
4702
  rawConditions?: EuclidComparison[];
4703
+ /** Nested AND/OR condition tree. Mutually exclusive with `when`/`rawConditions`. */
4704
+ match?: ConditionNode;
4633
4705
  fee: FeeSpecInput;
4634
4706
  }
4707
+ /**
4708
+ * Decode a rule's `statements[]` back into a condition tree.
4709
+ *
4710
+ * Returns a tree that is **logically equivalent** to the source. It is
4711
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4712
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4713
+ * shape differs (still equivalent).
4714
+ */
4715
+ declare function ruleMatchToTree(statements: EuclidIfStatement[]): ConditionNode;
4716
+ /**
4717
+ * Decode a stored program into the builder's editable model.
4718
+ *
4719
+ * Returns a tree that is **logically equivalent** to the source. It is
4720
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4721
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4722
+ * shape differs (still equivalent).
4723
+ */
4724
+ declare function programToTree(program: PlatformFeeProgram): {
4725
+ rules: {
4726
+ name: string;
4727
+ match: ConditionNode;
4728
+ fee: PlatformFeeOutput | null;
4729
+ }[];
4730
+ otherwise: PlatformFeeOutput | null;
4731
+ };
4635
4732
  /**
4636
4733
  * Fluent builder for a platform fee-rule program. Emits the exact Euclid wire
4637
4734
  * shape (camelCase tree, tagged values, `metadata: {}` everywhere) so callers
@@ -4804,4 +4901,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
4804
4901
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
4805
4902
  declare function shadowFor(style: SurfaceStyle): string;
4806
4903
 
4807
- export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
4904
+ export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
package/dist/index.d.ts CHANGED
@@ -1142,6 +1142,27 @@ interface PlatformFeeRuleRecord {
1142
1142
  created_at: number;
1143
1143
  modified_at: number;
1144
1144
  }
1145
+ /** Sample transaction + candidate program for `POST /admin/fees/rules/preview`. */
1146
+ interface FeeRulePreviewRequest {
1147
+ algorithm: PlatformFeeProgram;
1148
+ /** Amount in minor units. */
1149
+ amount: number;
1150
+ currency: Currency;
1151
+ payment_method?: PaymentMethod | null;
1152
+ connector?: Connector | null;
1153
+ card_network?: string | null;
1154
+ /** USD minor units (previous-month volume snapshot). */
1155
+ merchant_volume?: number | null;
1156
+ }
1157
+ interface FeeRulePreviewResponse {
1158
+ /** Matched rule name, or null when only the default selection matched. */
1159
+ matched_rule: string | null;
1160
+ /** True when the matched branch sets no concrete fee (engine falls through to the legacy schedule/tier chain). */
1161
+ fell_through: boolean;
1162
+ /** Computed fee in minor units, or null when fell_through. */
1163
+ fee_amount: number | null;
1164
+ fee_currency: string | null;
1165
+ }
1145
1166
  interface ProjectCreateRequest {
1146
1167
  project_name: string;
1147
1168
  description?: string | null;
@@ -3026,6 +3047,15 @@ declare class FeeRulesManager {
3026
3047
  * (other shops' programs are left intact).
3027
3048
  */
3028
3049
  delete(merchantId: string, profileId?: string): Promise<void>;
3050
+ /**
3051
+ * Dry-run a candidate fee-rule program against a sample transaction.
3052
+ * Returns the matched rule name, whether it fell through, and the computed fee.
3053
+ * Does not persist anything.
3054
+ *
3055
+ * @param input - Candidate program + sample transaction fields.
3056
+ * @param merchantId - The merchant account ID.
3057
+ */
3058
+ preview(input: FeeRulePreviewRequest, merchantId: string): Promise<FeeRulePreviewResponse>;
3029
3059
  }
3030
3060
 
3031
3061
  /** View and revoke recurring payment mandates. */
@@ -4591,6 +4621,29 @@ declare const Webhooks: {
4591
4621
  verify(rawBody: string | Uint8Array, signatureHeader: string, secret: string): Promise<WebhookEvent>;
4592
4622
  };
4593
4623
 
4624
+ /** A single condition leaf in the builder's condition tree. */
4625
+ interface LeafNode {
4626
+ kind: 'leaf';
4627
+ lhs: string;
4628
+ comparison: EuclidComparisonType;
4629
+ value: EuclidValue;
4630
+ }
4631
+ /** An AND (`all`) or OR (`any`) group of condition nodes. */
4632
+ interface GroupNode {
4633
+ kind: 'all' | 'any';
4634
+ children: ConditionNode[];
4635
+ }
4636
+ type ConditionNode = LeafNode | GroupNode;
4637
+ /**
4638
+ * A condition leaf. Numeric values (amount, merchant_volume) tag as `number`;
4639
+ * string values (payment_method, connector, currency, card_network) tag as
4640
+ * `enum_variant`.
4641
+ */
4642
+ declare function leaf(lhs: string, comparison: EuclidComparisonType, value: string | number): LeafNode;
4643
+ /** AND group — all children must match. */
4644
+ declare function allOf(...children: ConditionNode[]): GroupNode;
4645
+ /** OR group — any child matching is enough. */
4646
+ declare function anyOf(...children: ConditionNode[]): GroupNode;
4594
4647
  /**
4595
4648
  * How a rule (or the default) prices a transaction. `fee_type` is inferred:
4596
4649
  * percentage-only → `percentage`, flat-only → `flat`, both → `combined`.
@@ -4617,12 +4670,29 @@ interface FeeRuleConditions {
4617
4670
  connector?: Connector;
4618
4671
  currency?: Currency;
4619
4672
  cardNetwork?: string;
4673
+ /**
4674
+ * Customer billing-address country. Must be the exact backend `Country` enum
4675
+ * variant (PascalCase full name, e.g. `Germany`/`UnitedStatesOfAmerica`), not
4676
+ * an ISO code — the engine lowers `billing_country` via case-sensitive
4677
+ * `from_str`.
4678
+ */
4679
+ billingCountry?: string;
4620
4680
  /** `amount == n` (minor units). */
4621
4681
  amountEquals?: number;
4622
4682
  /** `amount > n` (minor units). */
4623
4683
  amountGreaterThan?: number;
4624
4684
  /** `amount < n` (minor units). */
4625
4685
  amountLessThan?: number;
4686
+ /**
4687
+ * `merchant_volume == n` — the merchant's previous-month volume snapshot
4688
+ * (USD minor units). Combine with any other condition, e.g.
4689
+ * `{ paymentMethod: 'crypto', merchantVolumeGreaterThan: 1_000_000 }`.
4690
+ */
4691
+ merchantVolumeEquals?: number;
4692
+ /** `merchant_volume > n` (USD minor units). */
4693
+ merchantVolumeGreaterThan?: number;
4694
+ /** `merchant_volume < n` (USD minor units). */
4695
+ merchantVolumeLessThan?: number;
4626
4696
  }
4627
4697
  interface FeeRuleInput {
4628
4698
  name: string;
@@ -4630,8 +4700,35 @@ interface FeeRuleInput {
4630
4700
  when?: FeeRuleConditions;
4631
4701
  /** Extra raw conditions ANDed in, for dimensions `when` does not cover. */
4632
4702
  rawConditions?: EuclidComparison[];
4703
+ /** Nested AND/OR condition tree. Mutually exclusive with `when`/`rawConditions`. */
4704
+ match?: ConditionNode;
4633
4705
  fee: FeeSpecInput;
4634
4706
  }
4707
+ /**
4708
+ * Decode a rule's `statements[]` back into a condition tree.
4709
+ *
4710
+ * Returns a tree that is **logically equivalent** to the source. It is
4711
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4712
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4713
+ * shape differs (still equivalent).
4714
+ */
4715
+ declare function ruleMatchToTree(statements: EuclidIfStatement[]): ConditionNode;
4716
+ /**
4717
+ * Decode a stored program into the builder's editable model.
4718
+ *
4719
+ * Returns a tree that is **logically equivalent** to the source. It is
4720
+ * deep-equal to `normalizeNode(input)` only when no `all` group contains two
4721
+ * or more `any` groups; where the encoder distributed AND over OR, the decoded
4722
+ * shape differs (still equivalent).
4723
+ */
4724
+ declare function programToTree(program: PlatformFeeProgram): {
4725
+ rules: {
4726
+ name: string;
4727
+ match: ConditionNode;
4728
+ fee: PlatformFeeOutput | null;
4729
+ }[];
4730
+ otherwise: PlatformFeeOutput | null;
4731
+ };
4635
4732
  /**
4636
4733
  * Fluent builder for a platform fee-rule program. Emits the exact Euclid wire
4637
4734
  * shape (camelCase tree, tagged values, `metadata: {}` everywhere) so callers
@@ -4804,4 +4901,4 @@ declare function parseImportedBranding(raw: unknown): CheckoutBranding;
4804
4901
  declare function applyBrandingVariables(el: HTMLElement, b: CheckoutBranding): void;
4805
4902
  declare function shadowFor(style: SurfaceStyle): string;
4806
4903
 
4807
- export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, logoDimensions, parseImportedBranding, radiusValue, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
4904
+ export { type Address, type AddressDetails, type AllocationListResponse, type AllocationResponse, type AllocationTransferRequest, type AllocationTransferResponse, Analytics, type AnalyticsChild, type AnalyticsConnectorDay, type AnalyticsConnectorSeries, AnalyticsDashboard, type AnalyticsDayBucket, type AnalyticsScopeRequest, type AnalyticsScopeResponse, type ApiKeyCreateRequest, type ApiKeyCreateResponse, type ApiKeyExpiration, type ApiKeyResponse, type ApiKeyRevokeResponse, type ApiKeyUpdateRequest, type ApplePayVerificationRequest, type ApplePayVerificationResponse, type ApplePayVerifiedDomainsResponse, type AuthResponse, type AuthenticationCreateRequest, type AuthenticationResponse, type AuthenticationStatus, type AuthenticationType, type AutoRechargeConfig, type AutoRechargeUpdateRequest, type AvailabilityOverrideCreateRequest, type AvailabilityOverrideResponse, AvailabilityOverrides, type AvailabilityPreviewMethod, type AvailabilityPreviewParams, type AvailabilityPreviewResponse, BRANDING_EXPORT_FORMAT, BRANDING_EXPORT_VERSION, type BillingCompleteSetupRequest, type BillingProfileResponse, type BillingSetupRequest, type BillingSetupResponse, type BlockedAttempt, type BlockedAttemptListParams, type BlockedAttemptListResponse, type BlocklistAddRequest, type BlocklistDataKind, type BlocklistResponse, type BrandingExport, type BrandingSource, type BuiltInRegionGroupResponse, type BusinessPaymentLinkConfig, CUSTOM_CSS_MAX_LENGTH, type CancelSubscriptionRequest, type CancelSubscriptionResponse, type CaptureMethod, type CardDetail, type CardDetailFromLocker, Cards, type ChangePasswordRequest, type CheckoutBranding, type ConditionNode, type ConfirmSubscriptionPaymentDetails, type ConfirmSubscriptionRequest, type ConfirmSubscriptionResponse, type Connector, type ConnectorCreateRequest, type ConnectorListResponse, type ConnectorResponse, type ConnectorType, type ConnectorUpdateRequest, type ConnectorVolumeSplit, type ConnectorWebhookEntry, type ConnectorWebhookEventType, type ConnectorWebhookListResponse, type ConnectorWebhookRegisterRequest, type ConnectorWebhookRegisterResponse, type CornerRadius, type CreateAndConfirmSubscriptionRequest, type CreateSubscriptionPaymentDetails, type CreateSubscriptionRequest, type Currency, type CustomerCreateRequest, type CustomerListParams, type CustomerPaymentMethodsListParams, type CustomerPaymentMethodsListResponse, type CustomerResponse, type CustomerUpdateRequest, DEFAULT_BADGES, DEFAULT_BADGES_DARK, DEFAULT_BRANDING, DEFAULT_BRANDING_DARK, type DeleteAccountRequest, Delopay, DelopayAuthenticationError, DelopayError, type DelopayLogger, type DelopayOptions, type DisputeEvidenceRequest, type DisputeListParams, type DisputeResponse, type DisputeStage, type DisputeStatus, type EncodedBranding, type EphemeralKeyCreateRequest, type EphemeralKeyCreateResponse, type EuclidComparison, type EuclidComparisonType, type EuclidIfStatement, type EuclidValue, type EventClass, type EventDeliveryAttemptResponse, type EventDetailResponse, type EventListParams, type EventListResponse, type EventResponse, type EventType, Export, FeatureMatrix, type FeeOwner, FeeProgramBuilder, type FeeRuleConditions, type FeeRuleInput, type FeeRulePreviewRequest, type FeeRulePreviewResponse, type FeeScheduleCreateRequest, type FeeScheduleResponse, type FeeScheduleUpdateRequest, type FeeSpecInput, type FeeType, Files, type FontFamily, type FontWeight, Forex, type ForgotPasswordRequest, type FromEmailRequest, type FutureUsage, type GatewayConnectRequest, type GatewayResponse, type GetSubscriptionItemsParams, type GetSubscriptionItemsResponse, type GlobalSearchRequest, type GroupNode, type IntentStatus, type InviteUsersRequest, type InviteUsersResponse, type InvoiceStatus, type LabelStyle, type LayoutStyle, type LeafNode, type LedgerEntry, type LedgerListParams, type LedgerResponse, type LinkedRoutingConfigRetrieveResponse, type ListInvitableRolesParams, type LoginHistoryEntry, type LoginHistoryParams, type LoginHistoryResponse, type LogoShape, type LogoSize, type MandateListParams, type MandateResponse, type MandateRevokedResponse, type MandateStatus, type MandateType, type MerchantAccountCreateRequest, type MerchantAccountResponse, type MerchantAccountType, type MerchantAccountUpdateRequest, type MerchantOverviewResponse, type MerchantOverviewStat, type MerchantRoutingAlgorithm, type MethodSurcharge, type NonPillRadius, type OverrideAction, type OverrideScope, type ParentGroup, type ParentGroupInfo, type PauseSubscriptionRequest, type PauseSubscriptionResponse, type PaymentCancelRequest, type PaymentCaptureRequest, type PaymentConfirmRequest, type PaymentCreateRequest, type PaymentLayout, type PaymentLinkBackgroundImageConfig, type PaymentLinkConfigRequest, type PaymentLinkListParams, type PaymentLinkListResponse, type PaymentLinkResponse, type PaymentLinkTransactionDetails, type PaymentListParams, type PaymentListResponse, type PaymentMethod, type PaymentMethodCreateRequest, type PaymentMethodDeleteResponse, type PaymentMethodListParams, type PaymentMethodResponse, type PaymentMethodType, type PaymentMethodUpdateRequest, type PaymentResponse, type PaymentRetrieveOptions, type PaymentUpdateRequest, type PayoutCreateRequest, type PayoutListParams, type PayoutListResponse, type PayoutResponse, type PayoutStatus, type PayoutType, type PayoutUpdateRequest, type PerMethodSurchargeItem, type PermissionScope, type PhoneDetails, type PhoneOtpRequest, type PhoneOtpResponse, type PhoneOtpVerifyRequest, type PhoneOtpVerifyResponse, type PlatformFeeKind, type PlatformFeeOutput, type PlatformFeeProgram, type PlatformFeeRule, type PlatformFeeRuleInput, type PlatformFeeRuleOutput, type PlatformFeeRuleRecord, type PlatformFeeRuleRequest, type PollStatus, type PollStatusResponse, type ProfileAcquirerCreateRequest, type ProfileAcquirerResponse, type ProfileAcquirerUpdateRequest, type ProfileCreateRequest, type ProfileDefaultRoutingConfig, type ProfileDeniedConnectorsResponse, type ProfileLogoUploadResponse, type ProfileResponse, type ProfileUpdateRequest, type ProjectCreateRequest, type ProjectResponse, type ProjectStats, type ProjectStatsResponse, type ProjectUpdateRequest, type RecoveryCodesResponse, type RefundCreateRequest, type RefundListParams, type RefundListResponse, type RefundResponse, type RefundStatus, type RefundType, type RefundUpdateRequest, type RegionCountriesResponse, type RegionCreateRequest, type RegionResponse, type RegionSetCountriesRequest, type RegionUpdateRequest, Regions, type RelayRequest, type RelayResponse, type RelayStatus, type RelayType, type RequestExtras, type RequestFn, type RequestOptions, type ResetPasswordRequest, type ResumeSubscriptionRequest, type ResumeSubscriptionResponse, type RoutableConnectorChoice, type RoutingActivatePayload, type RoutingConfigCreateRequest, type RoutingConfigResponse, type RoutingDeactivateRequest, type RoutingDictionary, type RoutingDictionaryRecord, Search, type SearchGroupResponse, type SearchIndex, type SearchStatus, type ShopCreateRequest, type ShopResponse, type ShopStats, type ShopUpdateRequest, type SignInRequest, type SignUpRequest, type SignUpWithMerchantIdRequest, type SignUpWithMerchantRequest, type SizeScale, type SpacingScale, type StaticRoutingAlgorithm, type StripeConnectAccountRequest, type StripeConnectAccountResponse, type StripeConnectLinkRequest, type StripeConnectLinkResponse, type SubscriptionEstimateParams, type SubscriptionEstimateResponse, type SubscriptionInvoice, type SubscriptionItem, type SubscriptionItemPrice, type SubscriptionItemType, type SubscriptionLineItem, type SubscriptionListParams, type SubscriptionPaymentData, type SubscriptionPaymentDetails, type SubscriptionPeriodUnit, type SubscriptionResponse, type SubscriptionStatus, Subscriptions, type SummaryPosition, type SurchargeRuleRequest, type SurchargeRuleResponse, type SurfaceStyle, type SwitchMerchantRequest, type SwitchProfileRequest, type Terminate2faQueryParams, type ThreeDSDecision, type ThreeDsRuleExecuteRequest, type ThreeDsRuleResponse, type TierSummary, type TokenPurpose, type TokenResponse, type TopupRequest, type TopupResponse, type TotpResponse, type TransactionType, type TrustBadge, type UpdateSubscriptionRequest, type UpdateUserDetailsRequest, type UserResponse, type UserSessionEntry, type UserSessionListResponse, type UserSessionRevokeResponse, type VerifyTotpRequest, type WebhookDeliveryAttempt, type WebhookEvent, Webhooks, allOf, anyOf, applyBrandingVariables, buildBrandingExport, buttonPadValue, cloneBranding, decodeBadges, decodeBranding, defaultBranding, encodeBadges, encodeBranding, feeProgram, fontStack, fontWeightValue, inputPadValue, isDarkSurface, isHexColor, leaf, logoDimensions, parseImportedBranding, programToTree, radiusValue, ruleMatchToTree, sanitizeCustomCss, shadowFor, surfacePadValue, verticalGapValue };
package/dist/index.js CHANGED
@@ -22,6 +22,8 @@ import {
22
22
  Search,
23
23
  Subscriptions,
24
24
  Webhooks,
25
+ allOf,
26
+ anyOf,
25
27
  applyBrandingVariables,
26
28
  buildBrandingExport,
27
29
  buttonPadValue,
@@ -37,14 +39,17 @@ import {
37
39
  inputPadValue,
38
40
  isDarkSurface,
39
41
  isHexColor,
42
+ leaf,
40
43
  logoDimensions,
41
44
  parseImportedBranding,
45
+ programToTree,
42
46
  radiusValue,
47
+ ruleMatchToTree,
43
48
  sanitizeCustomCss,
44
49
  shadowFor,
45
50
  surfacePadValue,
46
51
  verticalGapValue
47
- } from "./chunk-NNSPBDYP.js";
52
+ } from "./chunk-ABYAZHZC.js";
48
53
  export {
49
54
  Analytics,
50
55
  AnalyticsDashboard,
@@ -69,6 +74,8 @@ export {
69
74
  Search,
70
75
  Subscriptions,
71
76
  Webhooks,
77
+ allOf,
78
+ anyOf,
72
79
  applyBrandingVariables,
73
80
  buildBrandingExport,
74
81
  buttonPadValue,
@@ -84,9 +91,12 @@ export {
84
91
  inputPadValue,
85
92
  isDarkSurface,
86
93
  isHexColor,
94
+ leaf,
87
95
  logoDimensions,
88
96
  parseImportedBranding,
97
+ programToTree,
89
98
  radiusValue,
99
+ ruleMatchToTree,
90
100
  sanitizeCustomCss,
91
101
  shadowFor,
92
102
  surfacePadValue,
package/dist/internal.cjs CHANGED
@@ -55,6 +55,8 @@ __export(internal_exports, {
55
55
  Search: () => Search,
56
56
  Subscriptions: () => Subscriptions,
57
57
  Webhooks: () => Webhooks,
58
+ allOf: () => allOf,
59
+ anyOf: () => anyOf,
58
60
  applyBrandingVariables: () => applyBrandingVariables,
59
61
  buildBrandingExport: () => buildBrandingExport,
60
62
  buttonPadValue: () => buttonPadValue,
@@ -70,9 +72,12 @@ __export(internal_exports, {
70
72
  inputPadValue: () => inputPadValue,
71
73
  isDarkSurface: () => isDarkSurface,
72
74
  isHexColor: () => isHexColor,
75
+ leaf: () => leaf,
73
76
  logoDimensions: () => logoDimensions,
74
77
  parseImportedBranding: () => parseImportedBranding,
78
+ programToTree: () => programToTree,
75
79
  radiusValue: () => radiusValue,
80
+ ruleMatchToTree: () => ruleMatchToTree,
76
81
  sanitizeCustomCss: () => sanitizeCustomCss,
77
82
  shadowFor: () => shadowFor,
78
83
  surfacePadValue: () => surfacePadValue,
@@ -809,6 +814,20 @@ var FeeRulesManager = class {
809
814
  query: { merchant_id: merchantId, profile_id: profileId }
810
815
  });
811
816
  }
817
+ /**
818
+ * Dry-run a candidate fee-rule program against a sample transaction.
819
+ * Returns the matched rule name, whether it fell through, and the computed fee.
820
+ * Does not persist anything.
821
+ *
822
+ * @param input - Candidate program + sample transaction fields.
823
+ * @param merchantId - The merchant account ID.
824
+ */
825
+ async preview(input, merchantId) {
826
+ return this.request("POST", "/merchant-fees/rules/preview", {
827
+ body: input,
828
+ query: { merchant_id: merchantId }
829
+ });
830
+ }
812
831
  };
813
832
 
814
833
  // src/resources/mandates.ts
@@ -3255,6 +3274,16 @@ var Delopay = class {
3255
3274
  Delopay.webhooks = Webhooks;
3256
3275
 
3257
3276
  // src/feeProgram.ts
3277
+ function leaf(lhs, comparison, value) {
3278
+ const tagged = typeof value === "number" ? { type: "number", value } : { type: "enum_variant", value };
3279
+ return { kind: "leaf", lhs, comparison, value: tagged };
3280
+ }
3281
+ function allOf(...children) {
3282
+ return { kind: "all", children };
3283
+ }
3284
+ function anyOf(...children) {
3285
+ return { kind: "any", children };
3286
+ }
3258
3287
  function toFeeOutput(spec) {
3259
3288
  const hasPct = spec.percentage != null;
3260
3289
  const hasFlat = spec.flat != null;
@@ -3280,6 +3309,7 @@ function buildConditions(when = {}, raw = []) {
3280
3309
  if (when.connector != null) out.push(enumCondition("connector", when.connector));
3281
3310
  if (when.currency != null) out.push(enumCondition("currency", when.currency));
3282
3311
  if (when.cardNetwork != null) out.push(enumCondition("card_network", when.cardNetwork));
3312
+ if (when.billingCountry != null) out.push(enumCondition("billing_country", when.billingCountry));
3283
3313
  if (when.amountEquals != null) out.push(numberCondition("amount", "equal", when.amountEquals));
3284
3314
  if (when.amountGreaterThan != null) {
3285
3315
  out.push(numberCondition("amount", "greater_than", when.amountGreaterThan));
@@ -3287,9 +3317,83 @@ function buildConditions(when = {}, raw = []) {
3287
3317
  if (when.amountLessThan != null) {
3288
3318
  out.push(numberCondition("amount", "less_than", when.amountLessThan));
3289
3319
  }
3320
+ if (when.merchantVolumeEquals != null) {
3321
+ out.push(numberCondition("merchant_volume", "equal", when.merchantVolumeEquals));
3322
+ }
3323
+ if (when.merchantVolumeGreaterThan != null) {
3324
+ out.push(numberCondition("merchant_volume", "greater_than", when.merchantVolumeGreaterThan));
3325
+ }
3326
+ if (when.merchantVolumeLessThan != null) {
3327
+ out.push(numberCondition("merchant_volume", "less_than", when.merchantVolumeLessThan));
3328
+ }
3290
3329
  out.push(...raw);
3291
3330
  return out;
3292
3331
  }
3332
+ function leafToComparison(node) {
3333
+ return { lhs: node.lhs, comparison: node.comparison, value: node.value, metadata: {} };
3334
+ }
3335
+ function normalizeNode(node) {
3336
+ if (node.kind === "leaf") return node;
3337
+ const children = node.children.map(normalizeNode);
3338
+ const flat = [];
3339
+ for (const c of children) {
3340
+ if (c.kind === node.kind) flat.push(...c.children);
3341
+ else flat.push(c);
3342
+ }
3343
+ if (flat.length === 1) return flat[0];
3344
+ return { kind: node.kind, children: flat };
3345
+ }
3346
+ function toStatement(node) {
3347
+ if (node.kind === "leaf") return { condition: [leafToComparison(node)], nested: null };
3348
+ if (node.kind === "any") {
3349
+ return { condition: [], nested: node.children.map(toStatement) };
3350
+ }
3351
+ const leaves = node.children.filter((c) => c.kind === "leaf");
3352
+ const groups = node.children.filter((c) => c.kind !== "leaf");
3353
+ const condition = leaves.map(leafToComparison);
3354
+ if (groups.length === 0) return { condition, nested: null };
3355
+ const [first, ...rest] = groups;
3356
+ const nested = first.children.map((branch) => toStatement(normalizeNode(allOf(branch, ...rest))));
3357
+ return { condition, nested };
3358
+ }
3359
+ function assertNoEmptyAnyOf(node) {
3360
+ if (node.kind === "leaf") return;
3361
+ if (node.kind === "any" && node.children.length === 0) {
3362
+ throw new Error("feeProgram: an anyOf() group must have at least one condition");
3363
+ }
3364
+ node.children.forEach(assertNoEmptyAnyOf);
3365
+ }
3366
+ function encodeStatements(match) {
3367
+ const m = normalizeNode(match);
3368
+ if (m.kind === "any") return m.children.map(toStatement);
3369
+ return [toStatement(m)];
3370
+ }
3371
+ function comparisonToLeaf(c) {
3372
+ return { kind: "leaf", lhs: c.lhs, comparison: c.comparison, value: c.value };
3373
+ }
3374
+ function statementToNode(stmt) {
3375
+ const leaves = stmt.condition.map(comparisonToLeaf);
3376
+ if (stmt.nested && stmt.nested.length > 0) {
3377
+ const orNode = anyOf(...stmt.nested.map(statementToNode));
3378
+ if (leaves.length === 0) return orNode;
3379
+ return allOf(...leaves, orNode);
3380
+ }
3381
+ return leaves.length === 1 ? leaves[0] : allOf(...leaves);
3382
+ }
3383
+ function ruleMatchToTree(statements) {
3384
+ if (statements.length === 1) return normalizeNode(statementToNode(statements[0]));
3385
+ return normalizeNode(anyOf(...statements.map(statementToNode)));
3386
+ }
3387
+ function programToTree(program) {
3388
+ return {
3389
+ rules: program.rules.map((r) => ({
3390
+ name: r.name,
3391
+ match: ruleMatchToTree(r.statements),
3392
+ fee: r.connectorSelection.fee ?? null
3393
+ })),
3394
+ otherwise: program.defaultSelection.fee ?? null
3395
+ };
3396
+ }
3293
3397
  var FeeProgramBuilder = class {
3294
3398
  constructor() {
3295
3399
  this.rules = [];
@@ -3297,10 +3401,12 @@ var FeeProgramBuilder = class {
3297
3401
  }
3298
3402
  /** Append a rule. Provided `when`/`rawConditions` are ANDed. */
3299
3403
  rule(input) {
3404
+ if (input.match) assertNoEmptyAnyOf(input.match);
3405
+ const statements = input.match ? encodeStatements(input.match) : [{ condition: buildConditions(input.when, input.rawConditions) }];
3300
3406
  this.rules.push({
3301
3407
  name: input.name,
3302
3408
  connectorSelection: { fee: toFeeOutput(input.fee) },
3303
- statements: [{ condition: buildConditions(input.when, input.rawConditions) }]
3409
+ statements
3304
3410
  });
3305
3411
  return this;
3306
3412
  }
@@ -4399,6 +4505,17 @@ var PlatformFeeRulesManager = class {
4399
4505
  query: { merchant_id: merchantId, profile_id: profileId }
4400
4506
  });
4401
4507
  }
4508
+ /**
4509
+ * Dry-run a candidate fee-rule program against a sample transaction.
4510
+ * Returns the matched rule name, whether it fell through, and the computed fee.
4511
+ * Does not persist anything.
4512
+ */
4513
+ async preview(input, merchantId) {
4514
+ return this.request("POST", "/admin/fees/rules/preview", {
4515
+ body: input,
4516
+ query: { merchant_id: merchantId }
4517
+ });
4518
+ }
4402
4519
  };
4403
4520
 
4404
4521
  // src/internal/client.ts
@@ -4456,6 +4573,8 @@ var DelopayInternal = class extends Delopay {
4456
4573
  Search,
4457
4574
  Subscriptions,
4458
4575
  Webhooks,
4576
+ allOf,
4577
+ anyOf,
4459
4578
  applyBrandingVariables,
4460
4579
  buildBrandingExport,
4461
4580
  buttonPadValue,
@@ -4471,9 +4590,12 @@ var DelopayInternal = class extends Delopay {
4471
4590
  inputPadValue,
4472
4591
  isDarkSurface,
4473
4592
  isHexColor,
4593
+ leaf,
4474
4594
  logoDimensions,
4475
4595
  parseImportedBranding,
4596
+ programToTree,
4476
4597
  radiusValue,
4598
+ ruleMatchToTree,
4477
4599
  sanitizeCustomCss,
4478
4600
  shadowFor,
4479
4601
  surfacePadValue,